@@ -6,7 +6,7 @@ import { Psp22ContractApi } from './contracts/psp22';
66import * as flipper from './contracts/flipper_v5.json' ;
77// @ts -ignore
88import * as psp22 from './contracts/psp22.json' ;
9- import { ContractDeployer , parseRawMetadata } from 'dedot/contracts' ;
9+ import { Contract , ContractDeployer , parseRawMetadata } from 'dedot/contracts' ;
1010import { assert , deferred } from 'dedot/utils' ;
1111import { cryptoWaitReady } from '@polkadot/util-crypto' ;
1212import { KeyringPair } from '@polkadot/keyring/types' ;
@@ -145,6 +145,29 @@ export const deployPsp22Contract = async (salt?: string): Promise<string> => {
145145 return defer . promise ;
146146} ;
147147
148+ export const mintPSP22Balance = async ( psp22Address : string , pair : KeyringPair , amount : bigint ) : Promise < void > => {
149+ console . log ( '[mintPSP22Balance]' , psp22Address , pair . address , amount ) ;
150+
151+ const contract = new Contract < Psp22ContractApi > ( client , psp22Metadata , psp22Address , { defaultCaller : pair . address } ) ;
152+
153+ const {
154+ raw : { gasRequired } ,
155+ } = await contract . query . psp22MintableMint ( amount ) ;
156+
157+ const defer = deferred < void > ( ) ;
158+ await contract . tx
159+ . psp22MintableMint ( amount , { gasLimit : gasRequired } ) // prettier-end-here
160+ . signAndSend ( pair , ( { status } ) => {
161+ console . log ( 'Transaction status:' , status . type ) ;
162+
163+ if ( status . type === 'BestChainBlockIncluded' ) {
164+ defer . resolve ( ) ;
165+ }
166+ } ) ;
167+
168+ return defer . promise ;
169+ } ;
170+
148171export const devPairs = ( ) => {
149172 const alice = KEYRING . addFromUri ( '//Alice' ) ;
150173 const bob = KEYRING . addFromUri ( '//Bob' ) ;
0 commit comments