Skip to content

Commit

Permalink
update wrap_and_mint txn
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed Nov 26, 2024
1 parent a96b79b commit 719eb45
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cadence/transactions/bundled/wrap_and_mint.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,14 @@ transaction(wflowAddressHex: String, maybeMintERC721AddressHex: String) {

/* Approve the ERC721 address for the mint amount */
//
// Convert the mintAmount from UFix64 to UInt256 (given 18 decimal precision on WFLOW contract)
let ufixAllowance = EVM.Balance(attoflow: 0)
ufixAllowance.setFLOW(flow: self.mintCost)
let uintAllowance = UInt256(ufixAllowance.inAttoFLOW())
// Encode calldata approve(address,uint) calldata, providing the ERC721 address & mint amount
let approveCalldata = EVM.encodeABIWithSignature(
"approve(address,uint256)",
[self.erc721Address, UInt256(1_000_000_000_000_000_000)]
[self.erc721Address, uintAllowance]
)
// Call the WFLOW contract, approving the ERC721 address to move the mint amount
let approveResult = self.coa.call(
Expand All @@ -121,10 +125,6 @@ transaction(wflowAddressHex: String, maybeMintERC721AddressHex: String) {

/* Attempt to mint ERC721 */
//
// Convert the mintAmount from UFix64 to UInt256 (given 18 decimal precision on WFLOW contract)
let ufixAllowance = EVM.Balance(attoflow: 0)
ufixAllowance.setFLOW(flow: self.mintCost)
let convertedAllowance = ufixAllowance.inAttoFLOW() as! UInt256
// Encode the mint() calldata
let mintCalldata = EVM.encodeABIWithSignature("mint()", [])
// Call the ERC721 contract, attempting to mint
Expand All @@ -141,4 +141,3 @@ transaction(wflowAddressHex: String, maybeMintERC721AddressHex: String) {
)
}
}

0 comments on commit 719eb45

Please sign in to comment.