-
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 'main' into add-wflow-handler
- Loading branch information
Showing
7 changed files
with
179 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import "EVM" | ||
|
||
import "FlowEVMBridgeConfig" | ||
|
||
/// Returns whether a EVM contract is blocked from onboarded to the FlowEVMBridge | ||
/// | ||
/// @param evmAddressHex: The hex-encoded address of the EVM contract as a String | ||
/// | ||
/// @return Whether the contract is blocked from onboarding to the FlowEVMBridge | ||
/// | ||
access(all) fun main(evmAddressHex: String): Bool { | ||
let address = EVM.addressFromString(evmAddressHex) | ||
return FlowEVMBridgeConfig.isEVMAddressBlocked(address) | ||
} |
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
29 changes: 29 additions & 0 deletions
29
cadence/transactions/bridge/admin/blocklist/block_evm_address.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,29 @@ | ||
import "EVM" | ||
|
||
import "FlowEVMBridgeConfig" | ||
|
||
/// Blocks the given EVM contract address from onboarding. | ||
/// | ||
/// @param evmContractHex: The EVM contract address to block from onboarding | ||
/// | ||
transaction(evmContractHex: String) { | ||
|
||
let evmBlocklist: auth(FlowEVMBridgeConfig.Blocklist) &FlowEVMBridgeConfig.EVMBlocklist | ||
let evmAddress: EVM.EVMAddress | ||
|
||
prepare(signer: auth(BorrowValue) &Account) { | ||
FlowEVMBridgeConfig.initBlocklist() | ||
self.evmBlocklist = signer.storage.borrow<auth(FlowEVMBridgeConfig.Blocklist) &FlowEVMBridgeConfig.EVMBlocklist>( | ||
from: /storage/evmBlocklist | ||
) ?? panic("Could not borrow FlowEVMBridgeConfig Admin reference") | ||
self.evmAddress = EVM.addressFromString(evmContractHex) | ||
} | ||
|
||
execute { | ||
self.evmBlocklist.block(self.evmAddress) | ||
} | ||
|
||
post { | ||
FlowEVMBridgeConfig.isEVMAddressBlocked(self.evmAddress): "EVM address was not blocked" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
cadence/transactions/bridge/admin/blocklist/init_blocklist.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,14 @@ | ||
import "EVM" | ||
|
||
import "FlowEVMBridgeConfig" | ||
|
||
/// Initializes the EVMBlocklist in the bridge account if it does not yet exist at the expected path | ||
/// | ||
transaction { | ||
|
||
prepare(signer: &Account) {} | ||
|
||
execute { | ||
FlowEVMBridgeConfig.initBlocklist() | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
cadence/transactions/bridge/admin/blocklist/unblock_evm_address.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,28 @@ | ||
import "EVM" | ||
|
||
import "FlowEVMBridgeConfig" | ||
|
||
/// Unblocks the given EVM contract address from onboarding to the bridge. | ||
/// | ||
/// @param evmContractHex: The EVM contract address to unblock | ||
/// | ||
transaction(evmContractHex: String) { | ||
|
||
let evmBlocklist: auth(FlowEVMBridgeConfig.Blocklist) &FlowEVMBridgeConfig.EVMBlocklist | ||
let evmAddress: EVM.EVMAddress | ||
|
||
prepare(signer: auth(BorrowValue) &Account) { | ||
self.evmBlocklist = signer.storage.borrow<auth(FlowEVMBridgeConfig.Blocklist) &FlowEVMBridgeConfig.EVMBlocklist>( | ||
from: /storage/evmBlocklist | ||
) ?? panic("Could not borrow FlowEVMBridgeConfig EVMBlocklist reference") | ||
self.evmAddress = EVM.addressFromString(evmContractHex) | ||
} | ||
|
||
execute { | ||
self.evmBlocklist.unblock(self.evmAddress) | ||
} | ||
|
||
post { | ||
!FlowEVMBridgeConfig.isEVMAddressBlocked(self.evmAddress): "EVM address was not unblocked" | ||
} | ||
} |