Skip to content

Commit

Permalink
add test cases for e2e cadence- & evm-native NFT bridging
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed Apr 1, 2024
1 parent 113b301 commit ad8ca3e
Show file tree
Hide file tree
Showing 3 changed files with 242 additions and 103 deletions.
15 changes: 15 additions & 0 deletions cadence/scripts/nft/get_evm_id_from_evm_nft.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import "NonFungibleToken"

import "CrossVMNFT"

access(all)
fun main(ownerAddr: Address, cadenceID: UInt64, collectionStoragePath: StoragePath): UInt256? {
if let collection = getAuthAccount<auth(BorrowValue) &Account>(ownerAddr).storage.borrow<&{NonFungibleToken.Collection}>(
from: collectionStoragePath
) {
if let nft = collection.borrowNFT(cadenceID) {
return CrossVMNFT.getEVMID(from: nft)
}
}
return nil
}
10 changes: 10 additions & 0 deletions cadence/scripts/utils/derive_bridged_nft_contract_name.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import "EVM"

import "FlowEVMBridgeUtils"

access(all)
fun main(evmAddressHex: String): String {
return FlowEVMBridgeUtils.deriveBridgedNFTContractName(
from: FlowEVMBridgeUtils.getEVMAddressFromHexString(address: evmAddressHex) ?? panic("Could not parse EVM address from hex string")
)
}
Loading

0 comments on commit ad8ca3e

Please sign in to comment.