Skip to content
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

Proof of concept #4

Merged
merged 285 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 85 commits
Commits
Show all changes
285 commits
Select commit Hold shift + click to select a range
17751c8
update locker deployment to include EVM contract deployment
sisyphusSmiling Jan 11, 2024
c3c88ca
add EVM factory & simple ERC721 contract + dependencies
sisyphusSmiling Jan 12, 2024
7f42aef
add remappings.txt for VS Code .sol support
sisyphusSmiling Jan 12, 2024
9c474a4
update deploy transaction enabling custom deployment args
sisyphusSmiling Jan 12, 2024
7bd188b
update solidity contracts & add initial tests
sisyphusSmiling Jan 12, 2024
686010a
update NFT locker interface and template
sisyphusSmiling Jan 12, 2024
86d05b9
update FlowBridgeFactory.sol abi code
sisyphusSmiling Jan 12, 2024
d4cd2ea
update evm call transaction
sisyphusSmiling Jan 12, 2024
22dddeb
udpate transfer flow transaction
sisyphusSmiling Jan 12, 2024
dc01b51
update function signatures in Utils contract
sisyphusSmiling Jan 12, 2024
28effe7
update ExampleNFT & add setup + mint transactions
sisyphusSmiling Jan 12, 2024
dab1529
add onboarding query to bridge + script
sisyphusSmiling Jan 12, 2024
87c55b7
build NFT type onboarding path
sisyphusSmiling Jan 12, 2024
b93e82e
add util methods
sisyphusSmiling Jan 13, 2024
b3f27ae
fix NFT locker template to match util interfaces
sisyphusSmiling Jan 13, 2024
d877938
add util evm scripts & txns
sisyphusSmiling Jan 13, 2024
68a84b1
increase bridge call gas limits
sisyphusSmiling Jan 16, 2024
f5e7676
fix NFT Locker template & template serving contract
sisyphusSmiling Jan 16, 2024
fc1776c
fix mint function signature in utils init
sisyphusSmiling Jan 16, 2024
ba20782
update flow.json & add setup.sh script
sisyphusSmiling Jan 16, 2024
6a72b07
add deploy-factor-args.json
sisyphusSmiling Jan 16, 2024
3117197
update Factory solidity contract & bytecode
sisyphusSmiling Jan 17, 2024
c6a0069
add setup helper script & json args
sisyphusSmiling Jan 17, 2024
22ffb07
add helper methods, txns & scripts for Flow-native NFT path
sisyphusSmiling Jan 17, 2024
df6365b
fix bridge-deployed ERC721 names
sisyphusSmiling Jan 18, 2024
6212b7e
update encoding of ownerOf call in Utils
sisyphusSmiling Jan 18, 2024
38bd8a5
update solidity implementations and deployment args
sisyphusSmiling Jan 18, 2024
c16152a
add Solidity minting test case
sisyphusSmiling Jan 18, 2024
f5f1981
update NFT Locker template
sisyphusSmiling Jan 18, 2024
7199b3c
remove unused scripts
sisyphusSmiling Jan 18, 2024
649291b
fix NFT Locker template to burn on bridge from EVM
sisyphusSmiling Jan 18, 2024
2aa85cb
add ERC721 methods to solidity NFT
sisyphusSmiling Jan 18, 2024
d51c3c9
generalize evm call script
sisyphusSmiling Jan 18, 2024
f315cc8
update bridging transactions
sisyphusSmiling Jan 18, 2024
52b47a5
update Factory.sol bytecode
sisyphusSmiling Jan 18, 2024
efed0c6
update setup script & flow.json
sisyphusSmiling Jan 18, 2024
c434e24
restructure project directories
sisyphusSmiling Jan 18, 2024
7104d56
add python util to get template contract code chunks
sisyphusSmiling Jan 18, 2024
41104b6
move bridge COA into bridge account & add common Config contract
sisyphusSmiling Jan 18, 2024
1f1e331
update ERC721 detection
sisyphusSmiling Jan 19, 2024
86b598f
remove selectors & interface byte values from Utils & share call method
sisyphusSmiling Jan 19, 2024
4c5f896
add contract comments
sisyphusSmiling Jan 19, 2024
b92f672
add comments to transactions & scripts
sisyphusSmiling Jan 19, 2024
8e1b4f4
README updates
sisyphusSmiling Jan 19, 2024
e4c6237
update .gitmodules
sisyphusSmiling Jan 19, 2024
d38f56e
remove solidity dependencies attempting add as submodules
sisyphusSmiling Jan 20, 2024
55384dd
remove submodules
sisyphusSmiling Jan 20, 2024
25e2ff1
add forge-std dependency submodule
sisyphusSmiling Jan 20, 2024
934f570
add OZ contract submodule
sisyphusSmiling Jan 20, 2024
2523c71
clean up FlowEVMBridge.cdc comments
sisyphusSmiling Jan 22, 2024
681d125
add pre-condition on type for onboardNFTByType
sisyphusSmiling Jan 23, 2024
00945ec
replace FlowEVMBridgeTemplates fields with dictionary for upgradeability
sisyphusSmiling Jan 23, 2024
a8a345e
refactor update_nft_locker_code_chunks txn for new admin interface
sisyphusSmiling Jan 23, 2024
410dc8e
update comments in IEVMBridgeNFTLocker
sisyphusSmiling Jan 23, 2024
e499356
add helper to detect bridge-deployed EVM contracts
sisyphusSmiling Jan 24, 2024
ebca123
add context to nft briding transactions
sisyphusSmiling Jan 24, 2024
808a3c1
generalize onboardNFTByType to onboardByType
sisyphusSmiling Jan 26, 2024
ac7f7ae
fix bridge onboarding by type to cover only Flow-native path
sisyphusSmiling Jan 26, 2024
28bce63
add onboarding interface for EVM & supporting util methods
sisyphusSmiling Jan 26, 2024
796c25a
add and implement IFlowEVMNFTBridge contract
sisyphusSmiling Jan 27, 2024
5ec9387
fix function declaration in FlowEVMBridgeUtils
sisyphusSmiling Jan 27, 2024
56d4f15
move NFT bridging events to central bridge contract & implement
sisyphusSmiling Jan 27, 2024
a0c4fa4
add NFT uri assignment on bridging to EVM
sisyphusSmiling Jan 29, 2024
14224be
update locker contract name derivation pattern
sisyphusSmiling Jan 29, 2024
ed68da6
refactor evm/withdraw transaction for Cadence 1.0
sisyphusSmiling Jan 31, 2024
de9c83a
add bridge event emission in EVM contracts
sisyphusSmiling Jan 31, 2024
fbf892b
add metadata query for locked NFTs
sisyphusSmiling Jan 31, 2024
8e58a25
add shared config contract
sisyphusSmiling Feb 1, 2024
16ebc63
create EVMBridgedNFTTemplate contract & add to templates
sisyphusSmiling Jan 30, 2024
935b703
rename ICrossVMNFT to CrossVMNFT
sisyphusSmiling Jan 30, 2024
0d5cb6a
fix EVMBridgedNFTTemplate deployment errors
sisyphusSmiling Jan 30, 2024
ec829ea
add bridgeNFTFromEVM to bridged NFT Cadence template
sisyphusSmiling Jan 30, 2024
b508e18
fix FlowEVMBridgeUtils.getEVMAddressFromHexString
sisyphusSmiling Jan 31, 2024
301bb38
enable bridging to & from EVM via EVMBridgedNFTTemplate
sisyphusSmiling Jan 31, 2024
e566db9
update bridged NFT template in FlowEVMBridgeTemplates
sisyphusSmiling Jan 31, 2024
e40ca0f
generalize fee vault used in IFlowEVMNFTBridge methods & impl
sisyphusSmiling Jan 31, 2024
173e29f
add bridged NFT template serving & supporting utils
sisyphusSmiling Feb 1, 2024
6c5f292
refactor EVMBridgedNFTTemplate with new IFlowEVMNFTBridge interface
sisyphusSmiling Feb 1, 2024
7f380f8
add bridge onboarding by evm address transaction
sisyphusSmiling Feb 1, 2024
52e0502
complete evm-native nft flow end-to-end
sisyphusSmiling Feb 1, 2024
3505fa0
update bridge_nft_to_evm transaction interface
sisyphusSmiling Feb 2, 2024
d80c349
add example ERC721 contract for EVM-native NFT path poc
sisyphusSmiling Feb 2, 2024
3bb6e8b
add coverage for CrossVMNFT.EVMNFT tokens in Locker contract
sisyphusSmiling Feb 3, 2024
5e303bc
update NFT locker template to cover crossVM ID discrepancies
sisyphusSmiling Feb 7, 2024
5161019
remove unneeded EVM calls from nft locker template
sisyphusSmiling Feb 7, 2024
227e632
add comments to CrossVMNFT + getEVMID() method
sisyphusSmiling Feb 7, 2024
a2a0ff8
move NFT bridging events to IFlowEVMNFTBridge
sisyphusSmiling Feb 7, 2024
46ec28f
add CrossVMAsset contract & impl in CrossVMNFT interfaces
sisyphusSmiling Feb 7, 2024
8a12df8
add comments to EVMBridgedNFTTemplate & update template chunks
sisyphusSmiling Feb 7, 2024
63cc1e5
add getFeeAmount to IFlowEVMNFTBridge contract interface
sisyphusSmiling Feb 7, 2024
ebe802a
fix locker & bridged NFT template interface conformances
sisyphusSmiling Feb 7, 2024
56015f1
remove Factory bridging events
sisyphusSmiling Feb 7, 2024
c481995
update CrossVMNFT, IEVMBridgeNFTLocker & IFlowEVMNFTBridge interfaces
sisyphusSmiling Feb 7, 2024
4f587a4
implement updated interfaces in template contracts
sisyphusSmiling Feb 7, 2024
0eff28c
add evmContractAddress to CrossVMNFT.BridgedMetadata & implement
sisyphusSmiling Feb 7, 2024
8b9f9da
add borrowDefaultBridgeContract to Bridgeable asset & implement acros…
sisyphusSmiling Feb 8, 2024
b01983b
add comments to CrossVMNFT
sisyphusSmiling Feb 8, 2024
c44df89
add IFlowEVMNFTBridge.getFeeVaultType & implement
sisyphusSmiling Feb 9, 2024
939b16e
Update cadence/contracts/bridge/FlowEVMBridgeConfig.cdc
sisyphusSmiling Feb 16, 2024
81832da
Update cadence/contracts/bridge/IEVMBridgeNFTLocker.cdc
sisyphusSmiling Feb 16, 2024
3cba3b5
Merge pull request #11 from onflow/evm-native-nft-path
sisyphusSmiling Feb 17, 2024
9ba3290
update IEVMBridgeNFTLocker, implementation & template
sisyphusSmiling Feb 20, 2024
f16afd2
update EVMBridgedNFTTemplate to implement IEVMBridgeNFTLocker
sisyphusSmiling Feb 20, 2024
dd979f2
remove log statements from FlowEVMBridge
sisyphusSmiling Feb 20, 2024
dd5f8a5
update bridging events to include EVM Address as String
sisyphusSmiling Feb 20, 2024
4c91cb9
move EVM contract to cadence/contracts/standards
sisyphusSmiling Feb 20, 2024
e509a5d
add view modifiers to util methods & clean pre-conditions throughout
sisyphusSmiling Feb 20, 2024
5aeba6e
differentiate onboard & bridge fees in FlowEVMBridgeConfig
sisyphusSmiling Feb 20, 2024
7a9cb74
update FlowEVMBridgeTemplates.AdminStoragePath value
sisyphusSmiling Feb 20, 2024
0a364d0
add checks on decoded calls
sisyphusSmiling Feb 20, 2024
49ea76d
add comments to FlowEVMBridgeUtils
sisyphusSmiling Feb 20, 2024
970c229
Apply suggestions from code review
sisyphusSmiling Feb 21, 2024
5e2b204
update FlowEVMBridgeUtils.getEVMAddressFromHexString
sisyphusSmiling Feb 21, 2024
59ad614
update evm transfer transaction
sisyphusSmiling Feb 21, 2024
c9aaf3f
build bridging interface to EVM contract & mock bridging txns
sisyphusSmiling Feb 22, 2024
3366dcc
replace contract interface with resource interface as entrypoint
sisyphusSmiling Feb 22, 2024
464debb
update access controls in EVM.BridgeAccessor
sisyphusSmiling Feb 22, 2024
d41fe2c
update bridge_nft_to_evm txn on new coa interface
sisyphusSmiling Feb 22, 2024
cd14464
fix EVMBridgeRouter
sisyphusSmiling Feb 22, 2024
e041195
rename setup.sh to setup_emulator.sh & update
sisyphusSmiling Feb 22, 2024
15ee03a
replace locker template with escrow contract & update config
sisyphusSmiling Feb 22, 2024
bd25998
add FlowEVMBridgeConfig.bridgeAccessorStoragePath field
sisyphusSmiling Feb 22, 2024
69bdc70
update IFlowEVMNFTBridge access modifiers
sisyphusSmiling Feb 22, 2024
2a3f2ce
add escrow locker path derivation util
sisyphusSmiling Feb 22, 2024
b616079
fix syntax errors in FlowEVMBridgeNFTEscrow
sisyphusSmiling Feb 22, 2024
9e9d4a2
fix escrow syntax errors
sisyphusSmiling Feb 22, 2024
e6485d7
fix EVMBridgeRouter
sisyphusSmiling Feb 22, 2024
be31316
update FlowEVMBridgeConfig comments & formatting
sisyphusSmiling Feb 22, 2024
601e941
update escrow contract interface & implementation
sisyphusSmiling Feb 22, 2024
db2f4b6
update escrow locker derivation util method
sisyphusSmiling Feb 22, 2024
4098d6b
remove IFlowEVMNFTBridge interface & remove implementation
sisyphusSmiling Feb 22, 2024
1526325
remove locker template from FlowEVMBridgeTemplates
sisyphusSmiling Feb 22, 2024
3b277b2
add getter to FlowEVMBridgeConfig
sisyphusSmiling Feb 23, 2024
7389b2d
update bridge_nft_to_evm path
sisyphusSmiling Feb 23, 2024
2aefab4
update emulator setup script
sisyphusSmiling Feb 23, 2024
c21546a
add coa support for bridging NFTs from EVM
sisyphusSmiling Feb 23, 2024
48ad0c3
update CrossVMNFT & implementation
sisyphusSmiling Feb 23, 2024
b79f307
enable simplified flow-native NFT bridging round-trip
sisyphusSmiling Feb 23, 2024
7215010
update FlowEVMBridge events
sisyphusSmiling Feb 23, 2024
bd6ff5d
update emulator setup scripts due to CLI bug on deployment
sisyphusSmiling Feb 23, 2024
6def89a
add IEVMBridgeNFTMinter interface for bridge account NFT minting
sisyphusSmiling Feb 23, 2024
91e6b7b
update bridged NFT Cadence interfaces & template
sisyphusSmiling Feb 23, 2024
f0c7f26
update bridge from EVM path
sisyphusSmiling Feb 23, 2024
2339880
remove auxiliary bridging access via escrow contract
sisyphusSmiling Feb 23, 2024
4c90999
update flow.json
sisyphusSmiling Feb 23, 2024
9c8d6c2
add contract name delimiter to EVMBridgedNFTTemplate
sisyphusSmiling Feb 23, 2024
c3981dc
update formatting
sisyphusSmiling Feb 23, 2024
1af543d
fix nft escrow bug
sisyphusSmiling Feb 23, 2024
5ef9557
add new contract to setup script
sisyphusSmiling Feb 23, 2024
cee4bf6
update bridged NFT template
sisyphusSmiling Feb 23, 2024
1de4d92
fix bridge nft from evm bug
sisyphusSmiling Feb 23, 2024
c14c681
add BridgedNFTFromEVM event
sisyphusSmiling Feb 23, 2024
1745090
update template storage
sisyphusSmiling Feb 23, 2024
092fcc9
move emulator setup scripts
sisyphusSmiling Feb 23, 2024
2641a57
update template admin transaction
sisyphusSmiling Feb 23, 2024
9fd354b
add comment to templates
sisyphusSmiling Feb 23, 2024
3620f97
remove IEVMBridgeNFTEscrow contract interface
sisyphusSmiling Feb 23, 2024
894d898
update bridged NFT template
sisyphusSmiling Feb 23, 2024
bb716fe
rename scripts/locker -> escrow
sisyphusSmiling Feb 23, 2024
61473b2
update bridge scripts
sisyphusSmiling Feb 23, 2024
2496945
update token uri query
sisyphusSmiling Feb 23, 2024
a756a57
remove locker contract derivation method
sisyphusSmiling Feb 23, 2024
04f7776
add evm contract address query
sisyphusSmiling Feb 23, 2024
a0b9abc
update comments
sisyphusSmiling Feb 23, 2024
e7e70ab
add transfer check when bridging from EVM
sisyphusSmiling Feb 23, 2024
09e9713
update FlowEVMBridge.bridgeNFTFromEVM
sisyphusSmiling Mar 5, 2024
9aff715
update EVM contract for current previewnet deployment
sisyphusSmiling Mar 5, 2024
a194034
update standards implementations & flow.json for previewnet
sisyphusSmiling Mar 5, 2024
baebc1f
refactor EVM scripts
sisyphusSmiling Mar 5, 2024
f159015
refactor evm transactions
sisyphusSmiling Mar 5, 2024
8d0f913
rm unused bash scripts
sisyphusSmiling Mar 5, 2024
8114b3f
update ExampleNFT to recent v2 standard
sisyphusSmiling Mar 5, 2024
cc205b7
refactor FlowEVMBridgeUtils against updated EVM contract
sisyphusSmiling Mar 5, 2024
f9387c0
refactor FlowEVMBridgeNFTEscrow against updated EVM contract
sisyphusSmiling Mar 5, 2024
fe728f3
refactor EVMBridgedNFTTemplate for updated EVM contract
sisyphusSmiling Mar 5, 2024
79ecfc0
re-enable NFT bridging path in EVM contract
sisyphusSmiling Mar 5, 2024
40a5c86
update BridgeAccessor implementation in EVMBridgeRouter
sisyphusSmiling Mar 5, 2024
0014261
refactor FlowEVMBridge against updated EVM contract
sisyphusSmiling Mar 5, 2024
b8e03be
refactor transfer_flow txn for new v2 standards
sisyphusSmiling Mar 5, 2024
b325014
update ExampleNFT transactions against v2 standards
sisyphusSmiling Mar 5, 2024
5894f0d
update EVM txns & scripts
sisyphusSmiling Mar 5, 2024
6c2cd07
update setups scripts
sisyphusSmiling Mar 5, 2024
80eb2e1
update template & template server
sisyphusSmiling Mar 6, 2024
151fadd
update method of erc721 example minting
sisyphusSmiling Mar 6, 2024
476cf87
update bridging txns against updated EVM contract
sisyphusSmiling Mar 6, 2024
a6c789a
update .gitignore
sisyphusSmiling Mar 6, 2024
6b57dcc
update bridge fee calculation, Vault type & FlowEVMBridge access cont…
sisyphusSmiling Mar 7, 2024
1206ede
simplify FlowEVMBridge & EVMBridgeRouter contracts
sisyphusSmiling Mar 7, 2024
ed6e046
add getLockedEVMID method from escrow
sisyphusSmiling Mar 7, 2024
df97855
add opt out mechanism at bridge onboarding
sisyphusSmiling Mar 7, 2024
d71f6a8
add bridging opt out mechanism for solidity contracts
sisyphusSmiling Mar 7, 2024
69e8115
update bridge comments
sisyphusSmiling Mar 7, 2024
98c736d
update EVMBridgedNFTTemplate contract name placeholder
sisyphusSmiling Mar 7, 2024
1e66e3e
add util check for evm contract bridge opt-out
sisyphusSmiling Mar 7, 2024
14f6532
add borrow NFT path for bridged ERC721 owners
sisyphusSmiling Mar 7, 2024
c26ae77
add Serialize util contract to support URL encoding serialized metadata
sisyphusSmiling Mar 7, 2024
3b89778
remove decode/encodeABIWithSignature from utils
sisyphusSmiling Mar 7, 2024
21d28cc
remove CrossVM.Bridgeable entitlement
sisyphusSmiling Mar 7, 2024
4a8a249
fix syntax error in Utils contract
sisyphusSmiling Mar 7, 2024
d4a9573
update Serialize util contract
sisyphusSmiling Mar 8, 2024
ccf771c
add Serialize to flow.json & setup script
sisyphusSmiling Mar 8, 2024
1beef06
add NFT serialization to bridge + utils
sisyphusSmiling Mar 8, 2024
38d8cbb
update comments in FlowBridggedERC721.sol
sisyphusSmiling Mar 8, 2024
51892fa
configure EVMBridgeRouter.Router on contract init
sisyphusSmiling Mar 8, 2024
b6b2d92
update comments
sisyphusSmiling Mar 8, 2024
a07f1a9
update comments
sisyphusSmiling Mar 8, 2024
2a86a65
add NFT contract metadata serialization bridging as contractURI in EVM
sisyphusSmiling Mar 8, 2024
77ce612
update contract- & token-level URI handling
sisyphusSmiling Mar 8, 2024
70ef389
remove serialization
sisyphusSmiling Mar 8, 2024
599a62b
update fee calculation
sisyphusSmiling Mar 8, 2024
50ab40f
restrict borrowLockedNFT from escrow & remove public implementation
sisyphusSmiling Mar 9, 2024
7bb29a7
update evm bridge opt-out mechanism
sisyphusSmiling Mar 9, 2024
f81c6dc
update IBridgePermissions conformance in BridgePermissions.sol
sisyphusSmiling Mar 9, 2024
46a6ebb
update Cadence bridge opt-out mechanism
sisyphusSmiling Mar 9, 2024
0babf0f
updates utils comments
sisyphusSmiling Mar 9, 2024
03d5222
update FlowEVMBridgeUtils.borrowCOA to view
sisyphusSmiling Mar 11, 2024
55dd3fb
update CrossVMNFT.EVMNFTCollection.contractURI() & implementation
sisyphusSmiling Mar 11, 2024
b79382c
update FlowEVMBridgeTemplates to init templates from admin txn
sisyphusSmiling Mar 11, 2024
46ac13b
fix EVMBridgeRouter.Accessor init
sisyphusSmiling Mar 11, 2024
41b8746
fix FlowEVMBridge deployment errors
sisyphusSmiling Mar 11, 2024
0b2b14a
fix EVMBridgeRouter.Accessor implementation
sisyphusSmiling Mar 11, 2024
f250a27
add comments to EVMBridgeRouter
sisyphusSmiling Mar 11, 2024
6adc5d7
fix bridged NFT Cadence contract template & deployment
sisyphusSmiling Mar 11, 2024
4d9887c
update FlowEVMBridgeUtils comments & formatting
sisyphusSmiling Mar 11, 2024
2dd653f
add comments to FlowEVMBridgeUtils
sisyphusSmiling Mar 11, 2024
751634e
update FlowEVMBridgeConfig comments
sisyphusSmiling Mar 11, 2024
0a0ebce
update CrossVM & ICrossVM methods to view & update implementation
sisyphusSmiling Mar 11, 2024
f394973
add ScopedFTProviders & dependencies + update flow.json
sisyphusSmiling Mar 12, 2024
1559d0b
refactor COA.depositNFT & COA.withdrawNFT params to accept Provider i…
sisyphusSmiling Mar 12, 2024
fd89bfa
update utils attribution comments
sisyphusSmiling Mar 12, 2024
aceb4cd
fix FlowEVMBridge.deployERC721
sisyphusSmiling Mar 12, 2024
dab570b
update NFT bridging transactions
sisyphusSmiling Mar 12, 2024
15a9b19
update bridge onboarding interfaces & impl + comment updates
sisyphusSmiling Mar 12, 2024
1777f87
update contract formatting & comments
sisyphusSmiling Mar 12, 2024
fdcacb8
update bridge contract comments
sisyphusSmiling Mar 12, 2024
4985b48
update txns & scripts
sisyphusSmiling Mar 12, 2024
f4c35ae
update param names & comments
sisyphusSmiling Mar 13, 2024
6511d68
move JSON args to cadence/args
sisyphusSmiling Mar 13, 2024
c97192f
update setup scripts
sisyphusSmiling Mar 13, 2024
5bb7c0f
add ERC721Enumerable conformance to FlowBridgedERC721.sol
sisyphusSmiling Mar 13, 2024
dc7f5a4
update flow.json
sisyphusSmiling Mar 13, 2024
dfc9b11
update comments
sisyphusSmiling Mar 13, 2024
f614c5f
update script comments
sisyphusSmiling Mar 13, 2024
6fd44b3
add setup instructions to README
sisyphusSmiling Mar 13, 2024
5e640ec
update CODEOWNERS & PULL_REQUEST_TEMPLATE
sisyphusSmiling Mar 14, 2024
f020e51
add restricted COA access for transfers on FlowEVMBridge.bridgeNFTFro…
sisyphusSmiling Mar 14, 2024
7acc89a
Apply suggestions from code review
sisyphusSmiling Mar 18, 2024
f86b11e
add baseURI: String? field to CrossVMNFT.URI struct
sisyphusSmiling Mar 18, 2024
53ebde5
Merge pull request #14 from onflow/refactor-evm
sisyphusSmiling Mar 19, 2024
0214d7f
Merge pull request #12 from onflow/simplify-proof-of-concept
sisyphusSmiling Mar 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "lib/forge-std"]
path = lib/forge-std
[submodule "solidity/lib/forge-std"]
path = solidity/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "solidity/lib/openzeppelin-contracts"]
path = solidity/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
44 changes: 21 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
# [WIP] Flow EVM Bridge

> :warning: This repo is a work in progress

This repo contains the contracts enabling asset bridging between Flow and Flow EVM.

## Repository settings and configuration
- [ ] Repository info
- [ ] Add repo description
- [ ] Update website to https://onflow.org
- [ ] Add relevant repository topics (i.e. `blockchain` `onflow`, etc)
- [ ] Check issue labels on `.github/labels.yml` and do any commit to main to get them synced
- [ ] Define merge workflow (create new branch protection rule)
- [ ] `main` branch rule:
- [ ] **Require pull request reviews before merging (2 approving reviews)**
- [ ] **Require review from Code Owners**
- [ ] **Require status checks to pass before merging**
- [ ] **Require branches to be up to date before merging**
- [ ] **Require linear history**
- [ ] **Restrict who can push to matching branches**
- [ ] Choose `onflow/flow` team

- [ ] Add necessary team members, adjust access levels
- [ ] `onflow/flow-admin` ⇒ Admin access
- [ ] `onflow/flow-engineering ` ⇒ Write access
> :warning: This repo is a work in progress :building_construction:

This repo contains contracts enabling bridging of fungible & non-fungible assets between Flow and Flow EVM.

## Demo

Check out this video demo showcasing bridging between Flow & FlowEVM

:computer: [Bridging a Flow-native NFT between environments](https://www.loom.com/share/d5293000ff614f9693d48006ab1a842b?sid=3a2fff84-e951-4f3f-ae5d-4419bbd30d17)

## References

This repo is working on the basis of the design laid out in [FLIP #237](https://github.com/onflow/flips/pull/233).

### Additional Resource

For the current state of Flow EVM across various task paths, see the following resources:

- [Flow EVM Equivalence forum post](https://forum.flow.com/t/evm-equivalence-on-flow-proposal-and-path-forward/5478)
- [EVM Integration FLIP #223](https://github.com/onflow/flips/pull/225/files)
- [Gateway & JSON RPC FLIP #235](https://github.com/onflow/flips/pull/235)
sisyphusSmiling marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
312 changes: 312 additions & 0 deletions cadence/contracts/bridge/FlowEVMBridge.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,312 @@
import "FungibleToken"
import "NonFungibleToken"
import "FlowToken"

import "EVM"

import "ICrossVM"
import "FlowEVMBridgeConfig"
import "FlowEVMBridgeUtils"
import "IEVMBridgeNFTLocker"
import "FlowEVMBridgeTemplates"

/// The FlowEVMBridge contract is the main entrypoint for bridging NFT & FT assets between Flow & FlowEVM.
///
/// Before bridging, be sure to onboard the asset type which will configure the bridge to handle the asset. From there,
/// the asset can be bridged between VMs using the public entrypoints below, the only distinctions being the type of
/// asset being bridged (NFT vs FT) and the direction of bridging (to or from EVM).
///
/// See also:
/// - Code in context: https://github.com/onflow/flow-evm-bridge
/// - FLIP #237: https://github.com/onflow/flips/pull/233
sisyphusSmiling marked this conversation as resolved.
Show resolved Hide resolved
///
access(all) contract FlowEVMBridge {

/* --- Events --- */
//
/// Denotes a Locker contract was deployed to the bridge account
access(all) event BridgeLockerContractDeployed(type: Type, name: String, evmContractAddress: EVM.EVMAddress)
sisyphusSmiling marked this conversation as resolved.
Show resolved Hide resolved
/// Denotes a defining contract was deployed to the bridge account
access(all) event BridgeDefiningContractDeployed(type: Type, name: String, evmContractAddress: EVM.EVMAddress)

/**************************
Public NFT Handling
**************************/

/// Onboards a given type of NFT to the bridge. Since we're onboarding by Cadence Type, the asset must be defined
/// in a third-party contract. Attempting to onboard a bridge-defined asset will result in an error as onboarding
/// is not required
///
/// @param type: The Cadence Type of the NFT to be onboarded
/// @param tollFee: Fee paid for onboarding
///
access(all) fun onboardNFTByType(_ type: Type, tollFee: @FlowToken.Vault) {
pre {
self.typeRequiresOnboarding(type) == true: "Onboarding is not needed for this type"
}
FlowEVMBridgeUtils.depositTollFee(<-tollFee)
sisyphusSmiling marked this conversation as resolved.
Show resolved Hide resolved
if FlowEVMBridgeUtils.isFlowNative(type: type) {
self.deployLockerContract(forType: type)
} else {
// TODO: EVM-native NFT path - deploy defining contract
// self.deployLockerContract(forType: type)
}
}

/// Public entrypoint to bridge NFTs from Flow to EVM - cross-account bridging supported (e.g. straight to EOA)
///
/// @param token: The NFT to be bridged
/// @param to: The NFT recipient in FlowEVM
/// @param tollFee: The fee paid for bridging
///
access(all) fun bridgeNFTToEVM(token: @{NonFungibleToken.NFT}, to: EVM.EVMAddress, tollFee: @FlowToken.Vault) {
pre {
tollFee.balance >= FlowEVMBridgeConfig.fee: "Insufficient fee paid"
sisyphusSmiling marked this conversation as resolved.
Show resolved Hide resolved
token.isInstance(Type<@{FungibleToken.Vault}>()) == false: "Mixed asset types are not yet supported"
self.typeRequiresOnboarding(token.getType()) == false: "NFT must first be onboarded"
}
if FlowEVMBridgeUtils.isFlowNative(type: token.getType()) {
self.bridgeFlowNativeNFTToEVM(token: <-token, to: to, tollFee: <-tollFee)
} else {
// TODO: EVM-native NFT path
// self.bridgeEVMNativeNFTToEVM(token: <-token, to: to, tollFee: <-tollFee)
destroy <- token
destroy <- tollFee
}
}

/// Public entrypoint to bridge NFTs from EVM to Flow
///
/// @param caller: The caller executing the bridge - must be passed to check EVM state pre- & post-call in scope
/// @param calldata: Caller-provided approve() call, enabling contract COA to operate on NFT in EVM contract
/// @param id: The NFT ID to bridged
/// @param evmContractAddress: Address of the EVM address defining the NFT being bridged - also call target
/// @param tollFee: The fee paid for bridging
///
/// @returns The bridged NFT
///
access(all) fun bridgeNFTFromEVM(
caller: &EVM.BridgedAccount,
nvdtf marked this conversation as resolved.
Show resolved Hide resolved
calldata: [UInt8],
id: UInt256,
evmContractAddress: EVM.EVMAddress,
tollFee: @FlowToken.Vault
): @{NonFungibleToken.NFT} {
pre {
tollFee.balance >= FlowEVMBridgeConfig.fee: "Insufficient fee paid"
}
if FlowEVMBridgeUtils.isEVMNative(evmContractAddress: evmContractAddress) {
// TODO: EVM-native NFT path
} else {
return <- self.bridgeFlowNativeNFTFromEVM(
caller: caller,
calldata: calldata,
id: id,
evmContractAddress: evmContractAddress,
tollFee: <-tollFee
)
}
panic("Could not route bridge request for the requested NFT")
}

/**************************
Public FT Handling
***************************/
// TODO

/**************************
Public Getters
**************************/

/// Retrieves the bridge contract's COA EVMAddress
///
/// @returns The EVMAddress of the bridge contract's COA orchestrating actions in FlowEVM
///
// TODO: Can be made `view` when BridgedAccount.address() is `view`
access(all) fun getBridgeCOAEVMAddress(): EVM.EVMAddress {
return FlowEVMBridgeUtils.borrowCOA().address()
}

/// Retrieves the EVM address of the contract related to the bridge contract-defined asset
/// Useful for bridging flow-native assets back from EVM
///
/// @param type: The Cadence Type of the asset
///
/// @returns The EVMAddress of the contract defining the asset
///
access(all) fun getAssetEVMContractAddress(type: Type): EVM.EVMAddress? {
if self.typeRequiresOnboarding(type) != false {
return nil
}
if FlowEVMBridgeUtils.isFlowNative(type: type) {
if let lockerContractName: String = FlowEVMBridgeUtils.deriveLockerContractName(fromType: type) {
return self.account.contracts.borrow<&ICrossVM>(name: lockerContractName)?.getEVMContractAddress() ?? nil
}
} else {
if let assetContractName: String = FlowEVMBridgeUtils.getContractName(fromType: type) {
return self.account.contracts.borrow<&ICrossVM>(name: assetContractName)?.getEVMContractAddress() ?? nil
}
}
return nil
}

/// Retrieves the Flow address associated with the asset defined at the provided EVM address if it's defined
/// in a bridge-deployed contract
// access(all) fun getAssetFlowContractAddress(evmAddress: EVM.EVMAddress): Address?

/// Returns whether an asset needs to be onboarded to the bridge
///
/// @param type: The Cadence Type of the asset
///
/// @returns Whether the asset needs to be onboarded
///
access(all) view fun typeRequiresOnboarding(_ type: Type): Bool? {
// If type is not an NFT or FT type, it's not supported - return nil
if !type.isSubtype(of: Type<@{NonFungibleToken.NFT}>()) && !type.isSubtype(of: Type<@{FungibleToken.Vault}>()) {
return nil
}

// If the type is defined by the bridge, it's EVM-native and has already been onboarded
if FlowEVMBridgeUtils.getContractAddress(fromType: type) == self.account.address {
return false
}

// Otherwise, the type is Flow-native, so check if the locker contract is deployed
if let lockerContractName: String = FlowEVMBridgeUtils.deriveLockerContractName(fromType: type) {
return self.account.contracts.borrow<&IEVMBridgeNFTLocker>(name: lockerContractName) == nil
}

return nil
}

/// Returns whether an EVM-native asset needs to be onboarded to the bridge
// TODO
// access(all) fun evmAddressRequiresOnboarding(address: EVM.EVMAddress) {}

/// Borrows the locker contract from the bridge account for the given asset type
///
/// @param forType: The Cadence Type of the asset
///
/// @returns The locker contract handling the asset type or nil if non-existent
///
access(all) view fun borrowLockerContract(forType: Type): &IEVMBridgeNFTLocker? {
if let lockerContractName: String = FlowEVMBridgeUtils.deriveLockerContractName(fromType: forType) {
return self.account.contracts.borrow<&IEVMBridgeNFTLocker>(name: lockerContractName)
}
return nil
}

/**************************
Internal Helpers
***************************/

/// Handles bridging Flow-native NFTs to EVM - locks NFT in designated Flow locker contract & mints in EVM.
/// Within scope, locker contract is deployed if needed & call is passed on to said locker contract.
///
access(self) fun bridgeFlowNativeNFTToEVM(
token: @{NonFungibleToken.NFT},
to: EVM.EVMAddress,
tollFee: @FlowToken.Vault
) {
let lockerContractName: String = FlowEVMBridgeUtils.deriveLockerContractName(fromType: token.getType()) ??
panic("Could not derive locker contract name for token type: ".concat(token.getType().identifier))
if self.account.contracts.borrow<&IEVMBridgeNFTLocker>(name: lockerContractName) == nil {
self.deployLockerContract(forType: token.getType())
}

let lockerContract: &IEVMBridgeNFTLocker = self.account.contracts.borrow<&IEVMBridgeNFTLocker>(name: lockerContractName)
?? panic("Problem locating Locker contract for token type: ".concat(token.getType().identifier))
lockerContract.bridgeToEVM(token: <-token, to: to, tollFee: <-tollFee)
}
/// Handles bridging Flow-native NFTs from EVM - unlocks NFT from designated Flow locker contract & burns in EVM
/// Within scope, locker contract is deployed if needed & passing on call to said contract
///
access(self) fun bridgeFlowNativeNFTFromEVM(
sisyphusSmiling marked this conversation as resolved.
Show resolved Hide resolved
caller: &EVM.BridgedAccount,
calldata: [UInt8],
id: UInt256,
evmContractAddress: EVM.EVMAddress,
tollFee: @FlowToken.Vault
): @{NonFungibleToken.NFT} {
let response: [UInt8] = FlowEVMBridgeUtils.call(
signature: "getFlowAssetIdentifier(address)",
targetEVMAddress: FlowEVMBridgeUtils.bridgeFactoryEVMAddress,
args: [evmContractAddress],
gasLimit: 15000000,
value: 0.0
)
let decodedResponse: [AnyStruct] = EVM.decodeABI(types: [Type<String>()], data: response)
let identifier: String = decodedResponse[0] as! String
let lockedType: Type = CompositeType(identifier) ?? panic("Invalid identifier returned from EVM contract")
let lockerContractName: String = FlowEVMBridgeUtils.deriveLockerContractName(fromType: lockedType) ??
panic("Could not derive locker contract name for token type: ".concat(lockedType.identifier))
let lockerContract: &IEVMBridgeNFTLocker = self.account.contracts.borrow<&IEVMBridgeNFTLocker>(name: lockerContractName)
?? panic("Problem configuring Locker contract for token type: ".concat(lockedType.identifier))
return <- lockerContract.bridgeFromEVM(
caller: caller,
calldata: calldata,
id: id,
evmContractAddress: evmContractAddress,
tollFee: <-tollFee
)
}

/// Helper for deploying templated Locker contract supporting Flow-native asset bridging to EVM
/// Deploys either NFT or FT locker depending on the asset type
///
/// @param forType: The Cadence Type of the asset
///
access(self) fun deployLockerContract(forType: Type) {
let evmContractAddress: EVM.EVMAddress = self.deployEVMContract(forAssetType: forType)

let code: [UInt8] = FlowEVMBridgeTemplates.getLockerContractCode(forType: forType)
?? panic("Could not retrieve code for given asset type: ".concat(forType.identifier))
let name: String = FlowEVMBridgeUtils.deriveLockerContractName(fromType: forType)
?? panic("Could not derive locker contract name for token type: ".concat(forType.identifier))
let contractAddress: Address = FlowEVMBridgeUtils.getContractAddress(fromType: forType)
?? panic("Could not derive locker contract address for token type: ".concat(forType.identifier))
self.account.contracts.add(name: name, code: code, forType, contractAddress, evmContractAddress)

emit BridgeLockerContractDeployed(type: forType, name: name, evmContractAddress: evmContractAddress)
}

/// Deploys templated EVM contract via Solidity Factory contract supporting bridging of a given asset type
///
/// @param forAssetType: The Cadence Type of the asset
///
/// @returns The EVMAddress of the deployed contract
///
access(self) fun deployEVMContract(forAssetType: Type): EVM.EVMAddress {
nvdtf marked this conversation as resolved.
Show resolved Hide resolved
if forAssetType.isSubtype(of: Type<@{NonFungibleToken.NFT}>()) {
return self.deployERC721(forAssetType)
} else if forAssetType.isSubtype(of: Type<@{FungibleToken.Vault}>()) {
// TODO
// return self.deployERC20(name: forAssetType.identifier)
}
panic("Unsupported asset type: ".concat(forAssetType.identifier))
}

access(self) fun deployERC721(_ forNFTType: Type): EVM.EVMAddress {
let name: String = FlowEVMBridgeUtils.getContractName(fromType: forNFTType)
?? panic("Could not contract name from type: ".concat(forNFTType.identifier))
let identifier: String = forNFTType.identifier
let cadenceAddressStr: String = FlowEVMBridgeUtils.getContractAddress(fromType: forNFTType)?.toString()
?? panic("Could not derive contract address for token type: ".concat(identifier))

let response: [UInt8] = FlowEVMBridgeUtils.call(
signature: "deployERC721(string,string,string,string)",
targetEVMAddress: FlowEVMBridgeUtils.bridgeFactoryEVMAddress,
args: [name, "BRDG", cadenceAddressStr, identifier],
gasLimit: 15000000,
value: 0.0
)
let decodedResponse: [AnyStruct] = EVM.decodeABI(types: [Type<EVM.EVMAddress>()], data: response)
let erc721Address: EVM.EVMAddress = decodedResponse[0] as! EVM.EVMAddress
return erc721Address
}

/// Helper for deploying templated defining contract supporting EVM-native asset bridging to Flow
/// Deploys either NFT or FT contract depending on the provided type
// TODO
// access(self) fun deployDefiningContract(type: Type) {}
}
Loading