-
Notifications
You must be signed in to change notification settings - Fork 7
/
BridgePermissions.sol
52 lines (46 loc) · 2.23 KB
/
BridgePermissions.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {IBridgePermissions} from "./IBridgePermissions.sol";
/**
* @dev Contract for which implementation is checked by the Flow VM bridge as an opt-out mechanism
* for non-standard asset contracts that wish to opt-out of bridging between Cadence & EVM. By
* default, the VM bridge operates on a permissionless basis, meaning anyone can request an asset
* be onboarded. However, some small subset of non-standard projects may wish to opt-out of this
* and this contract provides a way to do so while also enabling future opt-in.
*
* Note: The Flow VM bridge checks for permissions at asset onboarding. If your asset has already
* been onboarded, setting `permissions` to `false` will not affect movement between VMs.
*/
abstract contract BridgePermissions is ERC165, IBridgePermissions {
// The permissions for the contract to allow or disallow bridging of its assets.
bool private _permissions;
constructor() {
_permissions = false;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IBridgePermissions).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns true if the contract allows bridging of its assets. Checked by the Flow VM
* bridge at asset onboarding to enable non-standard asset contracts to opt-out of bridging
* between Cadence & EVM. Implementing this contract opts out by default but can be
* overridden to opt-in or used in conjunction with a switch to enable opting in.
*/
function allowsBridging() external view virtual returns (bool) {
return _permissions;
}
/**
* @dev Set the permissions for the contract to allow or disallow bridging of its assets.
*
* Emits a {PermissionsUpdated} event.
*/
function _setPermissions(bool permissions) internal {
_permissions = permissions;
emit PermissionsUpdated(permissions);
}
}