-
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 pull request #139 from onflow/gio/add-cadence-onboarding-blocklist
Add Cadence Type onboarding blocklist functionality
- Loading branch information
Showing
6 changed files
with
141 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import "EVM" | ||
|
||
import "FlowEVMBridgeConfig" | ||
|
||
/// Returns whether a Cadence Type is blocked from onboarded to the FlowEVMBridge | ||
/// | ||
/// @param typeIdentifier: The Cadence Type identifier of the asset in question | ||
/// | ||
/// @return Whether the Cadence type is blocked from onboarding to the FlowEVMBridge | ||
/// | ||
access(all) fun main(typeIdentifier: String): Bool { | ||
let type = CompositeType(typeIdentifier) ?? panic("Invalid type identifier ".concat(typeIdentifier)) | ||
return FlowEVMBridgeConfig.isCadenceTypeBlocked(type) | ||
} |
28 changes: 28 additions & 0 deletions
28
cadence/transactions/bridge/admin/blocklist/block_cadence_type.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" | ||
|
||
/// Blocks the given Cadence Type from onboarding. | ||
/// | ||
/// @param typeIdentifier: The Cadence identifier of the type to block | ||
/// | ||
transaction(typeIdentifier: String) { | ||
|
||
let cadenceBlocklist: auth(FlowEVMBridgeConfig.Blocklist) &FlowEVMBridgeConfig.CadenceBlocklist | ||
let type: Type | ||
|
||
prepare(signer: auth(BorrowValue) &Account) { | ||
self.cadenceBlocklist = signer.storage.borrow<auth(FlowEVMBridgeConfig.Blocklist) &FlowEVMBridgeConfig.CadenceBlocklist>( | ||
from: /storage/cadenceBlocklist | ||
) ?? panic("Could not borrow FlowEVMBridgeConfig Admin reference") | ||
self.type = CompositeType(typeIdentifier) ?? panic("Invalid type identifier ".concat(typeIdentifier)) | ||
} | ||
|
||
execute { | ||
self.cadenceBlocklist.block(self.type) | ||
} | ||
|
||
post { | ||
FlowEVMBridgeConfig.isCadenceTypeBlocked(self.type): "Type was not blocked" | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
cadence/transactions/bridge/admin/blocklist/init_cadence_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,9 @@ | ||
import "FlowEVMBridgeConfig" | ||
|
||
transaction { | ||
prepare(signer: &Account) {} | ||
|
||
execute { | ||
FlowEVMBridgeConfig.initCadenceBlocklist() | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
cadence/transactions/bridge/admin/blocklist/unblock_cadence_type.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 Cadence Type from onboarding. | ||
/// | ||
/// @param typeIdentifier: The Cadence identifier of the type to block | ||
/// | ||
transaction(typeIdentifier: String) { | ||
|
||
let cadenceBlocklist: auth(FlowEVMBridgeConfig.Blocklist) &FlowEVMBridgeConfig.CadenceBlocklist | ||
let type: Type | ||
|
||
prepare(signer: auth(BorrowValue) &Account) { | ||
self.cadenceBlocklist = signer.storage.borrow<auth(FlowEVMBridgeConfig.Blocklist) &FlowEVMBridgeConfig.CadenceBlocklist>( | ||
from: /storage/cadenceBlocklist | ||
) ?? panic("Could not borrow FlowEVMBridgeConfig Admin reference") | ||
self.type = CompositeType(typeIdentifier) ?? panic("Invalid type identifier ".concat(typeIdentifier)) | ||
} | ||
|
||
execute { | ||
self.cadenceBlocklist.unblock(self.type) | ||
} | ||
|
||
post { | ||
!FlowEVMBridgeConfig.isCadenceTypeBlocked(self.type): "Type was not unblocked" | ||
} | ||
} |