Skip to content

Commit

Permalink
Merge pull request #124 from onflow/blocklist-followup
Browse files Browse the repository at this point in the history
Remove EVMBlocklist initialization
  • Loading branch information
sisyphusSmiling authored Sep 19, 2024
2 parents af98c38 + 77d0e6e commit a3e9cb8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 40 deletions.
25 changes: 8 additions & 17 deletions cadence/contracts/bridge/FlowEVMBridgeConfig.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,6 @@ contract FlowEVMBridgeConfig {
?? panic("Missing or mis-typed Blocklist in storage")
}

/// Temporary method to initialize the EVMBlocklist resource as this resource was added after the contract was
/// deployed
///
access(all)
fun initBlocklist() {
let path = /storage/evmBlocklist
if self.account.storage.type(at: path) != nil{
return
}
self.account.storage.save(<-create EVMBlocklist(), to: path)
}

/*****************
Constructs
*****************/
Expand Down Expand Up @@ -278,28 +266,28 @@ contract FlowEVMBridgeConfig {
access(all) resource EVMBlocklist {
/// Mapping of serialized EVM addresses to their blocked status
///
access(all) let blockList: {String: Bool}
access(all) let blocklist: {String: Bool}

init() {
self.blockList = {}
self.blocklist = {}
}

/// Returns whether the given EVM address is blocked from onboarding to the bridge
///
access(all) view fun isBlocked(_ evmAddress: EVM.EVMAddress): Bool {
return self.blockList[evmAddress.toString()] ?? false
return self.blocklist[evmAddress.toString()] ?? false
}

/// Blocks the given EVM address from onboarding to the bridge
///
access(Blocklist) fun block(_ evmAddress: EVM.EVMAddress) {
self.blockList[evmAddress.toString()] = true
self.blocklist[evmAddress.toString()] = true
}

/// Removes the given EVM address from the blocklist
///
access(Blocklist) fun unblock(_ evmAddress: EVM.EVMAddress) {
self.blockList.remove(key: evmAddress.toString())
self.blocklist.remove(key: evmAddress.toString())
}
}

Expand Down Expand Up @@ -508,5 +496,8 @@ contract FlowEVMBridgeConfig {
self.account.storage.save(<-create Admin(), to: self.adminStoragePath)
let adminCap = self.account.capabilities.storage.issue<&Admin>(self.adminStoragePath)
self.account.capabilities.publish(adminCap, at: self.adminPublicPath)

// Initialize the EVMBlocklist
self.account.storage.save(<-create EVMBlocklist(), to: /storage/evmBlocklist)
}
}
7 changes: 0 additions & 7 deletions cadence/tests/flow_evm_bridge_tests.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,6 @@ fun setup() {
arguments: []
)
Test.expect(err, Test.beNil())
// Initialize EVMBlocklist resource in account storage
let initBlocklistResult = executeTransaction(
"../transactions/bridge/admin/blocklist/init_blocklist.cdc",
[],
bridgeAccount
)
Test.expect(initBlocklistResult, Test.beSucceeded())

// Deploy registry
let registryDeploymentResult = executeTransaction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ transaction(evmContractHex: String) {
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")
Expand Down
14 changes: 0 additions & 14 deletions cadence/transactions/bridge/admin/blocklist/init_blocklist.cdc

This file was deleted.

2 changes: 1 addition & 1 deletion flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "f233dcee88fe0abe",
"testnet": "8c5303eaa26202d6"
"testnet": "9a0766d93b6608b7"
}
},
"EVM": {
Expand Down

0 comments on commit a3e9cb8

Please sign in to comment.