@@ -30,6 +30,7 @@ import {
3030 MagicDropCloneFactoryAbis ,
3131 MagicDropTokenImplRegistryAbis ,
3232 NEW_CONTRACT_INITIALIZED_EVENT_ABI ,
33+ SET_MINT_FEE_ABI ,
3334 SET_TRANSFER_VALIDATOR_ABI ,
3435 SUPPORTS_INTERFACE_ABI ,
3536} from '../abis' ;
@@ -99,6 +100,67 @@ export class ContractManager {
99100 }
100101 }
101102
103+ public async getMintFee (
104+ registryAddress : Hex ,
105+ standardId : number ,
106+ implId : number ,
107+ ) : Promise < bigint > {
108+ try {
109+ const data = encodeFunctionData ( {
110+ abi : [ MagicDropTokenImplRegistryAbis . getMintFee ] ,
111+ functionName : MagicDropTokenImplRegistryAbis . getMintFee . name ,
112+ args : [ standardId , implId ] ,
113+ } ) ;
114+
115+ const result = await this . client . call ( {
116+ to : registryAddress ,
117+ data,
118+ } ) ;
119+
120+ showText ( 'Fetching mint fee...' , '' , false , false ) ;
121+
122+ if ( ! result . data ) return BigInt ( 0 ) ;
123+
124+ const decodedResult = decodeFunctionResult ( {
125+ abi : [ MagicDropTokenImplRegistryAbis . getMintFee ] ,
126+ functionName : MagicDropTokenImplRegistryAbis . getMintFee . name ,
127+ data : result . data ,
128+ } ) ;
129+
130+ return decodedResult ;
131+ } catch ( error : any ) {
132+ console . error ( 'Error fetching deployment fee:' , error . message ) ;
133+ throw new Error ( 'Failed to fetch deployment fee.' ) ;
134+ }
135+ }
136+
137+ public async setMintFee (
138+ contractAddress : Hex ,
139+ mintFee : bigint ,
140+ ) : Promise < TransactionReceipt > {
141+ try {
142+ const data = encodeFunctionData ( {
143+ abi : [ SET_MINT_FEE_ABI ] ,
144+ functionName : SET_MINT_FEE_ABI . name ,
145+ args : [ mintFee ] ,
146+ } ) ;
147+
148+ showText ( 'Setting mint fee... this will take a moment' , '' , false , false ) ;
149+
150+ const txHash = await this . sendTransaction ( {
151+ to : contractAddress ,
152+ data,
153+ } ) ;
154+
155+ const receipt = await this . waitForTransactionReceipt ( txHash ) ;
156+
157+ return receipt ;
158+ } catch ( error : any ) {
159+ console . error ( 'Error setting mint fee:' , error . message ) ;
160+ throw new Error ( 'Failed to set mint fee.' ) ;
161+ }
162+ }
163+
102164 /**
103165 * Sends a transaction using METurnkeyServiceClient for signing.
104166 */
0 commit comments