|
| 1 | +import "FungibleToken" |
| 2 | +import "USDCFlow" |
| 3 | +import "FungibleTokenMetadataViews" |
| 4 | + |
| 5 | +import "FlowEVMBridgeHandlerInterfaces" |
| 6 | + |
| 7 | +/// This transaction is what the minter Account uses to mint new ExampleTokens |
| 8 | +/// They provide the recipient address and amount to mint, and the tokens |
| 9 | +/// are transferred to the address after minting |
| 10 | + |
| 11 | +transaction(recipient: Address, amount: UFix64) { |
| 12 | + |
| 13 | + /// Reference to the Example Token Minter Resource object |
| 14 | + let tokenMinter: auth(FlowEVMBridgeHandlerInterfaces.Mint) &USDCFlow.Minter |
| 15 | + |
| 16 | + /// Reference to the Fungible Token Receiver of the recipient |
| 17 | + let tokenReceiver: &{FungibleToken.Receiver} |
| 18 | + |
| 19 | + /// The total supply of tokens before the burn |
| 20 | + let supplyBefore: UFix64 |
| 21 | + |
| 22 | + prepare(signer: auth(BorrowValue) &Account) { |
| 23 | + self.supplyBefore = USDCFlow.totalSupply |
| 24 | + |
| 25 | + // Borrow a reference to the admin object |
| 26 | + self.tokenMinter = signer.storage.borrow<auth(FlowEVMBridgeHandlerInterfaces.Mint) &USDCFlow.Minter>( |
| 27 | + from: /storage/usdcFlowMinter |
| 28 | + ) ?? panic("Signer is not the token admin") |
| 29 | + |
| 30 | + let vaultData = USDCFlow.resolveContractView( |
| 31 | + resourceType: nil, |
| 32 | + viewType: Type<FungibleTokenMetadataViews.FTVaultData>() |
| 33 | + ) as! FungibleTokenMetadataViews.FTVaultData? |
| 34 | + ?? panic("Could not get vault data view for the contract") |
| 35 | + |
| 36 | + self.tokenReceiver = getAccount(recipient).capabilities.borrow<&{FungibleToken.Receiver}>(vaultData.receiverPath) |
| 37 | + ?? panic("Could not borrow receiver reference to the Vault") |
| 38 | + } |
| 39 | + |
| 40 | + execute { |
| 41 | + |
| 42 | + // Create mint tokens |
| 43 | + let mintedVault <- self.tokenMinter.mint(amount: amount) |
| 44 | + |
| 45 | + // Deposit them to the receiever |
| 46 | + self.tokenReceiver.deposit(from: <-mintedVault) |
| 47 | + } |
| 48 | + |
| 49 | + post { |
| 50 | + USDCFlow.totalSupply == self.supplyBefore + amount: "The total supply must be increased by the amount" |
| 51 | + } |
| 52 | +} |
0 commit comments