Skip to content

Commit

Permalink
Merge pull request #52 from onflow/repo-reorg
Browse files Browse the repository at this point in the history
Restructure directories and contract content + README updates
  • Loading branch information
sisyphusSmiling authored Apr 26, 2024
2 parents 8910028 + 36718c2 commit 360536b
Show file tree
Hide file tree
Showing 48 changed files with 818 additions and 516 deletions.
229 changes: 147 additions & 82 deletions README.md

Large diffs are not rendered by default.

257 changes: 62 additions & 195 deletions cadence/contracts/bridge/FlowEVMBridge.cdc

Large diffs are not rendered by default.

40 changes: 39 additions & 1 deletion cadence/contracts/bridge/FlowEVMBridgeConfig.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ contract FlowEVMBridgeConfig {
*******************/

access(all) entitlement Fee
access(all) entitlement Pause

/*************
Fields
Expand All @@ -29,6 +30,9 @@ contract FlowEVMBridgeConfig {
/// Default ERC20.decimals() value
access(all)
let defaultDecimals: UInt8
/// Flag enabling pausing of bridge operations
access(self)
var paused: Bool
/// Mapping of Type to its associated EVMAddress as relevant to the bridge
access(self)
let typeToEVMAddress: {Type: EVM.EVMAddress}
Expand Down Expand Up @@ -65,14 +69,25 @@ contract FlowEVMBridgeConfig {
///
access(all)
event BridgeFeeUpdated(old: UFix64, new: UFix64, isOnboarding: Bool)
// TODO
/// Emitted whenever a TokenHandler is configured
///
access(all)
event HandlerConfigured(targetType: Type, targetEVMAddress: String?, isEnabled: Bool)
/// Emitted whenever the bridge is paused
///
access(all)
event PauseStatusUpdated(paused: Bool)

/*************
Getters
*************/

/// Returns whether the bridge is paused
access(all)
view fun isPaused(): Bool {
return self.paused
}

/// Retrieves the EVMAddress associated with a given Type if it has been onboarded to the bridge
///
access(all)
Expand Down Expand Up @@ -220,6 +235,28 @@ contract FlowEVMBridgeConfig {
FlowEVMBridgeConfig.baseFee = new
}

/// Pauses the bridge, preventing all bridge operations
///
access(Pause)
fun pauseBridge() {
if FlowEVMBridgeConfig.isPaused() {
return
}
FlowEVMBridgeConfig.paused = true
emit PauseStatusUpdated(paused: true)
}

/// Unpauses the bridge, allowing bridge operations to resume
///
access(Pause)
fun unpauseBridge() {
if !FlowEVMBridgeConfig.isPaused() {
return
}
FlowEVMBridgeConfig.paused = false
emit PauseStatusUpdated(paused: false)
}

/// Sets the target EVM contract address on the handler for a given Type, associating the Cadence type with the
/// provided EVM address. If a TokenHandler does not exist for the given Type, the operation reverts.
///
Expand Down Expand Up @@ -282,6 +319,7 @@ contract FlowEVMBridgeConfig {
self.onboardFee = 0.0
self.baseFee = 0.0
self.defaultDecimals = 18
self.paused = false

// Although $FLOW does not have ERC20 address, we associate the the Vault with the EVM address from which
// EVM transfers originate
Expand Down
Loading

0 comments on commit 360536b

Please sign in to comment.