Skip to content

Commit

Permalink
move type construction out of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahannan committed Jan 14, 2025
1 parent 27e6344 commit 72ca6ab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions lib/go/templates/internal/assets/assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions transactions/generic_destroy_nft.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,29 @@ transaction(contractAddress: Address, contractName: String, nftTypeName: String,

execute {

// Get the string representation of the address without the 0x
var addressString = contractAddress.toString()
if addressString.length == 18 {
addressString = addressString.slice(from: 2, upTo: 18)
}
let typeString: String = "A.".concat(addressString).concat(".").concat(contractName).concat(".").concat(nftTypeName)
let type = CompositeType(typeString)
assert(
type != nil,
message: "Could not create a type out of the contract name "
.concat(contractName)
.concat(" and address ")
.concat(addressString)
.concat("!")
)

// iterate through the ids and burn each one
for id in ids {

if self.withdrawRef.borrowNFT(id) == nil { continue }

let tempNFT <- self.withdrawRef.withdraw(withdrawID: id)

// Get the string representation of the address without the 0x
var addressString = contractAddress.toString()
if addressString.length == 18 {
addressString = addressString.slice(from: 2, upTo: 18)
}
let typeString: String = "A.".concat(addressString).concat(".").concat(contractName).concat(".").concat(nftTypeName)
let type = CompositeType(typeString)
assert(
type != nil,
message: "Could not create a type out of the contract name "
.concat(contractName)
.concat(" and address ")
.concat(addressString)
.concat("!")
)

assert(
tempNFT.getType() == type!,
message: "The type NFT that was withdrawn to destroy <"
Expand Down

0 comments on commit 72ca6ab

Please sign in to comment.