-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'merge-test-fix-backup' into merge-test-fix-base
- Loading branch information
Showing
18 changed files
with
343 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 15 additions & 15 deletions
30
cadence/contracts/templates/testing/EVMBridgedNFTTemplate.cdc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
import "EVM" | ||
|
||
/// This contract utilized for test purposes only for the sake of capturing the deployment address | ||
/// of a contract for which one would otherwise have to inspect the event emitting on deployment. | ||
/// Assumes a COA is already configured with sufficient balance to deploy the contract. | ||
/// This contract is intended for testing purposes for the sake of capturing a deployed contract address while native | ||
/// `evm.TransactionExecuted` event types are not available in Cadence testing framework. The deploying account should | ||
/// already be configured with a `CadenceOwnedAccount` resource in storage at `/storage/evm`. | ||
/// | ||
access(all) contract EVMDeployer { | ||
|
||
access(all) let deployedContractAddress: EVM.EVMAddress | ||
access(all) let deployedAddress: EVM.EVMAddress | ||
|
||
init(bytecode: String, valueAmount: UFix64) { | ||
init(bytecode: String, value: UInt) { | ||
let coa = self.account.storage.borrow<auth(EVM.Deploy) &EVM.CadenceOwnedAccount>(from: /storage/evm) | ||
?? panic("Could not borrow COA from deployment account storage") | ||
|
||
let value = EVM.Balance(attoflow: 0) | ||
value.setFLOW(flow: valueAmount) | ||
self.deployedContractAddress = coa.deploy( | ||
?? panic("No COA found in storage") | ||
self.deployedAddress = coa.deploy( | ||
code: bytecode.decodeHex(), | ||
gasLimit: 12_000_000, | ||
value: value | ||
gasLimit: 15_000_000, | ||
value: EVM.Balance(attoflow: value) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
cadence/scripts/test/get_deployed_erc721_address_string.cdc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import "EVM" | ||
|
||
import "EVMDeployer" | ||
|
||
import "FlowEVMBridgeUtils" | ||
|
||
access(all) | ||
fun main(): String { | ||
return FlowEVMBridgeUtils.getEVMAddressAsHexString(address: EVMDeployer.deployedAddress) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import "EVMBridgeRouter" | ||
|
||
access(all) | ||
fun main(): Bool { | ||
let serviceAccount = getAuthAccount<auth(Storage) &Account>(0x0000000000000001) | ||
let router = serviceAccount.storage.borrow<&EVMBridgeRouter.Router>( | ||
from: /storage/evmBridgeRouter | ||
) ?? panic("Could not borrow Router") | ||
|
||
assert(router.bridgeAddress == 0x0000000000000007) | ||
assert(router.bridgeContractName == "FlowEVMBridge") | ||
|
||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import "EVM" | ||
|
||
import "FlowEVMBridgeUtils" | ||
|
||
/// Returns whether the given owner (hex-encoded EVM address - minus 0x prefix) is the owner of the given ERC721 NFT | ||
/// defined at the hex-encoded EVM contract address | ||
/// | ||
/// @param ofNFT: The ERC721 ID of the NFT | ||
/// @param owner: The hex-encoded EVM address of the owner without the 0x prefix | ||
/// @param evmContractAddress: The hex-encoded EVM contract address of the ERC721 contract without the 0x prefix | ||
/// | ||
/// @return Whether the given owner is the owner of the given ERC721 NFT. Reverts on call failure. | ||
/// | ||
access(all) fun main(ofNFT: UInt256, owner: String, evmContractAddress: String): Bool { | ||
return FlowEVMBridgeUtils.isOwner( | ||
ofNFT: ofNFT, | ||
owner: FlowEVMBridgeUtils.getEVMAddressFromHexString(address: owner) | ||
?? panic("Invalid owner address"), | ||
evmContractAddress: FlowEVMBridgeUtils.getEVMAddressFromHexString(address: evmContractAddress) | ||
?? panic("Invalid EVM contract address") | ||
) | ||
} |
Oops, something went wrong.