-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cross-VM transfer NFT/FT to and from EVM #90
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #90 +/- ##
==========================================
+ Coverage 86.19% 86.21% +0.01%
==========================================
Files 18 17 -1
Lines 884 921 +37
==========================================
+ Hits 762 794 +32
- Misses 122 127 +5 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work! Well documented transactions
cadence/transactions/bridge/nft/bridge_nft_to_any_cadence_address.cdc
Outdated
Show resolved
Hide resolved
self.nftType = FlowEVMBridgeUtils.buildCompositeType( | ||
address: nftContractAddress, | ||
contractName: nftContractName, | ||
resourceName: "NFT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the new token standards, NFTs aren't required to have the name NFT
any more, so there is a small chance that NFTs might have different names in the future. Maybe this should be a transaction argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I think it'd be best to update txn interfaces to take type identifier and parse the identifier for the contract name and address. Then we can just build the composite type from the identifier without the risk that the NFT has some other name.
let withdrawnStorageUsage = signer.storage.used | ||
var approxFee = FlowEVMBridgeUtils.calculateBridgeFee( | ||
bytes: currentStorageUsage - withdrawnStorageUsage | ||
) * 1.10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 1.10?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extra 10% is a buffer, but tbh the exact buffer of 10% is about the limit of what was successful in my testing - nothing very rigorous or formal.
When I was testing, I found that the storage used as calculated on withdrawal was different from storage used when escrowing. This is likely because the bridge may additionally store extra pieces of information that weren't present in the source NFT collection when it was withdrawn.
cadence/transactions/bridge/tokens/bridge_tokens_to_any_cadence_address.cdc
Outdated
Show resolved
Hide resolved
self.vaultType = FlowEVMBridgeUtils.buildCompositeType( | ||
address: tokenContractAddress, | ||
contractName: tokenContractName, | ||
resourceName: "Vault" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about naming of types as the NFT one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add these generic transactions to the flow-nft and flow-ft repos also?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah definitely. I may do so without the dependency on FlowEVMBridgeUtils and just parse the contract address & name in the transaction.
…e_address.cdc Co-authored-by: Joshua Hannan <[email protected]>
d22f2db
to
dbd804d
Compare
Updated transaction interfaces in dbd804d to allow for more precise asset bridging due to the issue raised by @joshuahannan in this comment
This new interface, in addition to being simpler in the number of arguments required to execute, will resolve the vault & collection metadata for the exact type from the source contract. |
Closes: #85
Description
Adds transactions that transfer tokens & NFT between VMs. Functionally, this allows a signer to both bridge an asset & transfer to any address within the target VM in a single Cadence transaction. The caveat here is that bridging and transferring from EVM to Cadence has the same limitation as any transfer in Cadence - the recipient must be configured to receive the transferred asset.
For contributor use:
main
branchFiles changed
in the Github PR explorer