Skip to content

Commit

Permalink
restructure project directories
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed Jan 18, 2024
1 parent efed0c6 commit c434e24
Show file tree
Hide file tree
Showing 679 changed files with 111,115 additions and 108 deletions.
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "lib/forge-std"]
path = lib/forge-std
[submodule "./soliditylib/forge-std"]
path = ./solidity/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
[submodule "./solidity/lib/openzeppelin-contracts"]
path = ./solidity/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions cadence/scripts/bridge/name.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import "EVM"

import "FlowEVMBridgeUtils"

access(all) fun main(coaHost: Address, contractAddressHex: String): String {
let coa: &EVM.BridgedAccount = getAuthAccount<auth(BorrowValue) &Account>(coaHost).storage.borrow<&EVM.BridgedAccount>(
from: /storage/evm
)!
let calldata: [UInt8] = FlowEVMBridgeUtils.encodeABIWithSignature("name()", [])
let response: [UInt8] = coa.call(
to: FlowEVMBridgeUtils.getEVMAddressFromHexString(address: contractAddressHex)!,
data: calldata,
gasLimit: 15000000,
value: EVM.Balance(flow: 0.0)
)
let decodedResponse: [AnyStruct] = EVM.decodeABI(types: [Type<String>()], data: response)
return decodedResponse[0] as! String
}
18 changes: 18 additions & 0 deletions cadence/scripts/bridge/owner_of.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import "EVM"

import "FlowEVMBridgeUtils"

access(all) fun main(coaHost: Address, id: UInt256, contractAddressHex: String): EVM.EVMAddress {
let coa: &EVM.BridgedAccount = getAuthAccount<auth(BorrowValue) &Account>(coaHost).storage.borrow<&EVM.BridgedAccount>(
from: /storage/evm
)!
let calldata: [UInt8] = FlowEVMBridgeUtils.encodeABIWithSignature("ownerOf(uint256)", [id])
let response: [UInt8] = coa.call(
to: FlowEVMBridgeUtils.getEVMAddressFromHexString(address: contractAddressHex)!,
data: calldata,
gasLimit: 15000000,
value: EVM.Balance(flow: 0.0)
)
let decodedResponse: [AnyStruct] = EVM.decodeABI(types: [Type<EVM.EVMAddress>()], data: response)
return decodedResponse[0] as! EVM.EVMAddress
}
18 changes: 18 additions & 0 deletions cadence/scripts/bridge/token_uri.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import "EVM"

import "FlowEVMBridgeUtils"

access(all) fun main(coaHost: Address, tokenID: UInt256, contractAddressHex: String): String {
let coa: &EVM.BridgedAccount = getAuthAccount<auth(BorrowValue) &Account>(coaHost).storage.borrow<&EVM.BridgedAccount>(
from: /storage/evm
)!
let calldata: [UInt8] = FlowEVMBridgeUtils.encodeABIWithSignature("tokenURI(uint256)", [tokenID])
let response: [UInt8] = coa.call(
to: FlowEVMBridgeUtils.getEVMAddressFromHexString(address: contractAddressHex)!,
data: calldata,
gasLimit: 15000000,
value: EVM.Balance(flow: 0.0)
)
let decodedResponse: [AnyStruct] = EVM.decodeABI(types: [Type<String>()], data: response)
return decodedResponse[0] as! String
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion factory.code

This file was deleted.

26 changes: 13 additions & 13 deletions flow.json
Original file line number Diff line number Diff line change
@@ -1,89 +1,89 @@
{
"contracts": {
"EVM": {
"source": "./contracts/EVM.cdc",
"source": "./cadence/contracts/EVM.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7"
}
},
"ExampleNFT": {
"source": "./contracts/example-assets/ExampleNFT.cdc",
"source": "./cadence/contracts/example-assets/ExampleNFT.cdc",
"aliases": {
"emulator": "179b6b1cb6755e31"
}
},
"FlowEVMBridge": {
"source": "./contracts/bridge/FlowEVMBridge.cdc",
"source": "./cadence/contracts/bridge/FlowEVMBridge.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7"
}
},
"FlowEVMBridgeTemplates": {
"source": "./contracts/bridge/FlowEVMBridgeTemplates.cdc",
"source": "./cadence/contracts/bridge/FlowEVMBridgeTemplates.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7"
}
},
"FlowEVMBridgeUtils": {
"source": "./contracts/bridge/FlowEVMBridgeUtils.cdc",
"source": "./cadence/contracts/bridge/FlowEVMBridgeUtils.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7"
}
},
"FlowToken": {
"source": "./contracts/standards/FlowToken.cdc",
"source": "./cadence/contracts/standards/FlowToken.cdc",
"aliases": {
"emulator": "0ae53cb6e3f42a79",
"mainnet": "1654653399040a61",
"testnet": "7e60df042a9c0868"
}
},
"FungibleToken": {
"source": "./contracts/standards/FungibleToken.cdc",
"source": "./cadence/contracts/standards/FungibleToken.cdc",
"aliases": {
"emulator": "ee82856bf20e2aa6",
"mainnet": "f233dcee88fe0abe",
"testnet": "9a0766d93b6608b7"
}
},
"FungibleTokenMetadataViews": {
"source": "./contracts/standards/FungibleTokenMetadataViews.cdc",
"source": "./cadence/contracts/standards/FungibleTokenMetadataViews.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "f233dcee88fe0abe",
"testnet": "9a0766d93b6608b7"
}
},
"ICrossVM": {
"source": "./contracts/bridge/ICrossVM.cdc",
"source": "./cadence/contracts/bridge/ICrossVM.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7"
}
},
"IEVMBridgeNFTLocker": {
"source": "./contracts/bridge/IEVMBridgeNFTLocker.cdc",
"source": "./cadence/contracts/bridge/IEVMBridgeNFTLocker.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7"
}
},
"MetadataViews": {
"source": "./contracts/standards/MetadataViews.cdc",
"source": "./cadence/contracts/standards/MetadataViews.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "1d7e57aa55817448",
"testnet": "631e88ae7f1d7c20"
}
},
"NonFungibleToken": {
"source": "./contracts/standards/NonFungibleToken.cdc",
"source": "./cadence/contracts/standards/NonFungibleToken.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "1d7e57aa55817448",
"testnet": "631e88ae7f1d7c20"
}
},
"ViewResolver": {
"source": "./contracts/standards/ViewResolver.cdc",
"source": "./cadence/contracts/standards/ViewResolver.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "1d7e57aa55817448",
Expand Down
10 changes: 6 additions & 4 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
eth_rpc_url = "http://127.0.0.1:9000"
src = "./solidity/src"
out = "./solidity/out"
libs = ["./solidity/lib"]
script = "./solidity/script"
test = "./solidity/test"
eth_rpc_url = "http://127.0.0.1:8545"

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
1 change: 0 additions & 1 deletion lib/forge-std
Submodule forge-std deleted from 2f1126
1 change: 0 additions & 1 deletion lib/openzeppelin-contracts
Submodule openzeppelin-contracts deleted from a4b98b
50 changes: 25 additions & 25 deletions pass_precompiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,76 @@
# We need to get past the 20 sequential pre-compile COA addresses in this emulator version

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc

flow evm create-account 0.0
flow transactions send ./transactions/evm/destroy_coa.cdc
flow transactions send ./cadence/transactions/evm/destroy_coa.cdc
10 changes: 5 additions & 5 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
ds-test/=lib/forge-std/lib/ds-test/src/
erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/
forge-std/=lib/forge-std/src/
openzeppelin-contracts/=lib/openzeppelin-contracts/
@openzeppelin/contracts/=solidity/lib/openzeppelin-contracts/contracts/
ds-test/=solidity/lib/forge-std/lib/ds-test/src/
erc4626-tests/=solidity/lib/openzeppelin-contracts/lib/erc4626-tests/
forge-std/=solidity/lib/forge-std/src/
openzeppelin-contracts/=solidity/lib/openzeppelin-contracts/
24 changes: 12 additions & 12 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
sh pass_precompiles.sh

# Deploy initial bridge contracts
flow accounts add-contract ./contracts/bridge/ICrossVM.cdc
flow accounts add-contract ./contracts/bridge/IEVMBridgeNFTLocker.cdc
flow accounts add-contract ./cadence/contracts/bridge/ICrossVM.cdc
flow accounts add-contract ./cadence/contracts/bridge/IEVMBridgeNFTLocker.cdc

# Create COA in emulator-account
flow evm create-account 100.0

# Deploy the Factory contract in EVM - the address is required by the FlowEVMBridgeUtils contract
flow transactions send ./transactions/evm/deploy.cdc --args-json "$(cat deploy-factory-args.json)"
flow transactions send ./cadence/transactions/evm/deploy.cdc --args-json "$(cat deploy-factory-args.json)"

# Provided address is the address of the Factory contract deployed in the previous txn
flow accounts add-contract ./contracts/bridge/FlowEVMBridgeUtils.cdc 9ca416871ee388c7a41e0b7886dfcc47e08bbdef
flow accounts add-contract ./contracts/bridge/FlowEVMBridgeTemplates.cdc
flow accounts add-contract ./cadence/contracts/bridge/FlowEVMBridgeUtils.cdc 9ca416871ee388c7a41e0b7886dfcc47e08bbdef
flow accounts add-contract ./cadence/contracts/bridge/FlowEVMBridgeTemplates.cdc

# Fund the Utils contract COA
flow evm fund 000000000000000000000000000000000000001b 100.0

# Deploy main bridge contract
flow accounts add-contract ./contracts/bridge/FlowEVMBridge.cdc
flow accounts add-contract ./cadence/contracts/bridge/FlowEVMBridge.cdc

# Create `example-nft` account 179b6b1cb6755e31 with private key 96dfbadf086daa187100a24b1fd2b709b702954bbd030a394148e11bcbb799ef
flow accounts create --key "351e1310301a7374430f6077d7b1b679c9574f8e045234eac09568ceb15c4f5d937104b4c3180df1e416da20c9d58aac576ffc328a342198a5eae4a29a13c47a"
Expand All @@ -29,18 +29,18 @@ flow accounts create --key "351e1310301a7374430f6077d7b1b679c9574f8e045234eac095
flow accounts create --key "c695fa608bd40821552fae13bb710c917309690ed69c22866abad19d276c99296379358321d0123d7074c817dd646ae8f651734526179eaed9f33eba16601ff6"

# Give the user some FLOW
flow transactions send ./transactions/flow-token/transfer_flow.cdc 0xf3fcd2c1a78f5eee 100.0
flow transactions send ./cadence/transactions/flow-token/transfer_flow.cdc 0xf3fcd2c1a78f5eee 100.0

# Create a COA for the user
flow transactions send ./transactions/evm/create_account.cdc 10.0 --signer user
flow transactions send ./cadence/transactions/evm/create_account.cdc 10.0 --signer user

# User transfers Flow to the COA
flow transactions send ./transactions/evm/deposit.cdc 10.0 --signer user
flow transactions send ./cadence/transactions/evm/deposit.cdc 10.0 --signer user

# Setup User with Example NFT collection
flow accounts add-contract ./contracts/example-assets/ExampleNFT.cdc --signer example-nft
flow transactions send ./transactions/example-assets/setup_collection.cdc --signer user
flow transactions send ./transactions/example-assets/mint_nft.cdc f3fcd2c1a78f5eee example description thumbnail '[]' '[]' '[]' --signer example-nft
flow accounts add-contract ./cadence/contracts/example-assets/ExampleNFT.cdc --signer example-nft
flow transactions send ./cadence/transactions/example-assets/setup_collection.cdc --signer user
flow transactions send ./cadence/transactions/example-assets/mint_nft.cdc f3fcd2c1a78f5eee example description thumbnail '[]' '[]' '[]' --signer example-nft

# Replace the COA in the emulator-account that was loaded into the bridge contract storage for RPC purposes
flow evm create-account 100.0
Loading

0 comments on commit c434e24

Please sign in to comment.