diff --git a/cadence/tests/flow_evm_bridge_tests.cdc b/cadence/tests/flow_evm_bridge_tests.cdc index eeb21638..25e5b8e2 100644 --- a/cadence/tests/flow_evm_bridge_tests.cdc +++ b/cadence/tests/flow_evm_bridge_tests.cdc @@ -961,11 +961,37 @@ access(all) fun testOnboardERC721ByEVMAddressSucceeds() { snapshot = getCurrentBlockHeight() + // Validate EVMBlocklist works by blocking the EVM address + let blockResult = executeTransaction( + "../transactions/bridge/admin/blocklist/block_evm_address.cdc", + [erc721AddressHex], + bridgeAccount + ) + Test.expect(blockResult, Test.beSucceeded()) + + // onboarding should fail as the EVM address is blocked + var onboardingResult = executeTransaction( + "../transactions/bridge/onboarding/onboard_by_evm_address.cdc", + [erc721AddressHex], + alice + ) + Test.expect(onboardingResult, Test.beFailed()) + + // Unblock the EVM address + let unblockResult = executeTransaction( + "../transactions/bridge/admin/blocklist/remove_evm_address_from_blocklist.cdc", + [erc721AddressHex], + bridgeAccount + ) + Test.expect(unblockResult, Test.beSucceeded()) + + // And now onboarding should succeed + var requiresOnboarding = evmAddressRequiresOnboarding(erc721AddressHex) ?? panic("Problem getting onboarding requirement") Test.assertEqual(true, requiresOnboarding) - var onboardingResult = executeTransaction( + onboardingResult = executeTransaction( "../transactions/bridge/onboarding/onboard_by_evm_address.cdc", [erc721AddressHex], alice diff --git a/cadence/transactions/bridge/admin/blocklist/remove_evm_address_from_blocklist.cdc b/cadence/transactions/bridge/admin/blocklist/remove_evm_address_from_blocklist.cdc new file mode 100644 index 00000000..fb5f92fd --- /dev/null +++ b/cadence/transactions/bridge/admin/blocklist/remove_evm_address_from_blocklist.cdc @@ -0,0 +1,28 @@ +import "EVM" + +import "FlowEVMBridgeConfig" + +/// Removes the given EVM contract address from the EVMBlocklist if it exists. +/// +/// @param evmContractHex: The EVM contract address to remove from the blocklist +/// +transaction(evmContractHex: String) { + + let evmBlocklist: auth(FlowEVMBridgeConfig.Blocklist) &FlowEVMBridgeConfig.EVMBlocklist + let evmAddress: EVM.EVMAddress + + prepare(signer: auth(BorrowValue) &Account) { + self.evmBlocklist = signer.storage.borrow( + from: FlowEVMBridgeConfig.adminStoragePath + ) ?? panic("Could not borrow FlowEVMBridgeConfig Admin reference") + self.evmAddress = EVM.addressFromString(evmContractHex) + } + + execute { + self.evmBlocklist.block(self.evmAddress) + } + + post { + FlowEVMBridgeConfig.isEVMAddressBlocked(self.evmAddress): "Fee was not set correctly" + } +}