Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove EVMBlocklist initialization #124

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading