@bloxchain/contracts 1.0.0-alpha.2 → 1.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/abi/BaseStateMachine.abi.json +798 -753
- package/abi/EngineBlox.abi.json +566 -576
- package/abi/GuardController.abi.json +1546 -2095
- package/abi/GuardControllerDefinitions.abi.json +416 -0
- package/abi/IDefinition.abi.json +57 -47
- package/abi/RuntimeRBAC.abi.json +901 -959
- package/abi/RuntimeRBACDefinitions.abi.json +265 -81
- package/abi/SecureOwnable.abi.json +1522 -2581
- package/abi/SecureOwnableDefinitions.abi.json +174 -164
- package/components/README.md +8 -0
- package/core/access/RuntimeRBAC.sol +253 -270
- package/core/access/interface/IRuntimeRBAC.sol +55 -84
- package/core/access/lib/definitions/RuntimeRBACDefinitions.sol +97 -4
- package/core/base/BaseStateMachine.sol +198 -108
- package/core/base/interface/IBaseStateMachine.sol +153 -153
- package/core/execution/GuardController.sol +156 -131
- package/core/execution/interface/IGuardController.sol +146 -120
- package/core/execution/lib/definitions/GuardControllerDefinitions.sol +207 -45
- package/core/lib/EngineBlox.sol +2636 -2322
- package/{interfaces → core/lib/interfaces}/IDefinition.sol +49 -49
- package/{interfaces → core/lib/interfaces}/IEventForwarder.sol +5 -3
- package/{utils → core/lib/utils}/SharedValidation.sol +69 -22
- package/core/pattern/Account.sol +84 -0
- package/core/security/SecureOwnable.sol +180 -146
- package/core/security/interface/ISecureOwnable.sol +105 -104
- package/core/security/lib/definitions/SecureOwnableDefinitions.sol +818 -786
- package/package.json +5 -5
- package/standards/README.md +12 -0
- package/standards/behavior/ICopyable.sol +34 -0
- package/standards/hooks/IOnActionHook.sol +21 -0
- package/abi/AccountBlox.abi.json +0 -5799
- package/abi/BareBlox.abi.json +0 -1284
- package/abi/RoleBlox.abi.json +0 -4209
- package/abi/SecureBlox.abi.json +0 -3828
- package/abi/SimpleRWA20.abi.json +0 -5288
- package/abi/SimpleRWA20Definitions.abi.json +0 -191
- package/abi/SimpleVault.abi.json +0 -4951
- package/abi/SimpleVaultDefinitions.abi.json +0 -269
- package/core/research/BloxchainWallet.sol +0 -306
- package/core/research/erc20-blox/ERC20Blox.sol +0 -140
- package/core/research/erc20-blox/lib/definitions/ERC20BloxDefinitions.sol +0 -185
- package/interfaces/IOnActionHook.sol +0 -79
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
pragma solidity 0.8.33;
|
|
3
|
-
|
|
4
|
-
// OpenZeppelin
|
|
5
|
-
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
|
|
6
|
-
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";
|
|
7
|
-
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
8
|
-
|
|
9
|
-
// Core
|
|
10
|
-
import "../../security/SecureOwnable.sol";
|
|
11
|
-
import "../../access/RuntimeRBAC.sol";
|
|
12
|
-
import "../../execution/GuardController.sol";
|
|
13
|
-
import "../../base/BaseStateMachine.sol";
|
|
14
|
-
import "../../../utils/SharedValidation.sol";
|
|
15
|
-
import "../../../interfaces/IDefinition.sol";
|
|
16
|
-
import "./lib/definitions/ERC20BloxDefinitions.sol";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @title ERC20Blox
|
|
20
|
-
* @dev ERC20 token (IERC20) with SecureOwnable, RuntimeRBAC, and GuardController.
|
|
21
|
-
* Exposes transfer (ERC20), mint (owner-only), and burn (ERC20Burnable).
|
|
22
|
-
* @custom:security-contact security@particlecrypto.com
|
|
23
|
-
*/
|
|
24
|
-
contract ERC20Blox is
|
|
25
|
-
IERC20,
|
|
26
|
-
ERC20Upgradeable,
|
|
27
|
-
ERC20BurnableUpgradeable,
|
|
28
|
-
SecureOwnable,
|
|
29
|
-
RuntimeRBAC,
|
|
30
|
-
GuardController
|
|
31
|
-
{
|
|
32
|
-
using SharedValidation for *;
|
|
33
|
-
|
|
34
|
-
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
35
|
-
constructor() {
|
|
36
|
-
_disableInitializers();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @dev Override to resolve diamond: SecureOwnable, RuntimeRBAC, GuardController all define initialize(5 params).
|
|
41
|
-
* Call this first, then initializeToken(name, symbol) to set ERC20 metadata.
|
|
42
|
-
*/
|
|
43
|
-
function initialize(
|
|
44
|
-
address initialOwner,
|
|
45
|
-
address broadcaster,
|
|
46
|
-
address recovery,
|
|
47
|
-
uint256 timeLockPeriodSec,
|
|
48
|
-
address eventForwarder
|
|
49
|
-
) public virtual override(GuardController, RuntimeRBAC, SecureOwnable) initializer {
|
|
50
|
-
GuardController.initialize(initialOwner, broadcaster, recovery, timeLockPeriodSec, eventForwarder);
|
|
51
|
-
RuntimeRBAC.initialize(initialOwner, broadcaster, recovery, timeLockPeriodSec, eventForwarder);
|
|
52
|
-
SecureOwnable.initialize(initialOwner, broadcaster, recovery, timeLockPeriodSec, eventForwarder);
|
|
53
|
-
|
|
54
|
-
// Load ERC20Blox execution selectors (transfer, transferFrom, mint, burn, burnFrom) so controller can execute them
|
|
55
|
-
IDefinition.RolePermission memory erc20Permissions = ERC20BloxDefinitions.getRolePermissions();
|
|
56
|
-
_loadDefinitions(
|
|
57
|
-
ERC20BloxDefinitions.getFunctionSchemas(),
|
|
58
|
-
erc20Permissions.roleHashes,
|
|
59
|
-
erc20Permissions.functionPermissions,
|
|
60
|
-
true
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
// Register ERC20Blox system macro selectors (allowed to target address(this) for time-lock/meta-tx execution)
|
|
64
|
-
_addMacroSelector(ERC20BloxDefinitions.TRANSFER_SELECTOR);
|
|
65
|
-
_addMacroSelector(ERC20BloxDefinitions.TRANSFER_FROM_SELECTOR);
|
|
66
|
-
_addMacroSelector(ERC20BloxDefinitions.MINT_SELECTOR);
|
|
67
|
-
_addMacroSelector(ERC20BloxDefinitions.BURN_SELECTOR);
|
|
68
|
-
_addMacroSelector(ERC20BloxDefinitions.BURN_FROM_SELECTOR);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* @notice Initialize the ERC20 token name and symbol. Call after initialize(5 params).
|
|
73
|
-
* @param name Token name
|
|
74
|
-
* @param symbol Token symbol
|
|
75
|
-
*/
|
|
76
|
-
function initializeToken(string memory name, string memory symbol) public reinitializer(2) {
|
|
77
|
-
__ERC20_init(name, symbol);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* @dev Override to resolve ambiguity between BaseStateMachine and SecureOwnable.
|
|
82
|
-
*/
|
|
83
|
-
function _updateTimeLockPeriod(uint256 newTimeLockPeriodSec) internal virtual override(BaseStateMachine, SecureOwnable) {
|
|
84
|
-
SecureOwnable._updateTimeLockPeriod(newTimeLockPeriodSec);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* @notice Transfer tokens to an account (callable only by this contract via GuardController)
|
|
89
|
-
* @param to Recipient address
|
|
90
|
-
* @param value Amount to transfer
|
|
91
|
-
*/
|
|
92
|
-
function transfer(address to, uint256 value) public virtual override(ERC20Upgradeable, IERC20) returns (bool) {
|
|
93
|
-
SharedValidation.validateInternalCall(address(this));
|
|
94
|
-
return super.transfer(to, value);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* @notice Transfer tokens from one account to another (with allowance); callable only by this contract via GuardController
|
|
99
|
-
* @param from Sender address
|
|
100
|
-
* @param to Recipient address
|
|
101
|
-
* @param value Amount to transfer
|
|
102
|
-
*/
|
|
103
|
-
function transferFrom(address from, address to, uint256 value) public virtual override(ERC20Upgradeable, IERC20) returns (bool) {
|
|
104
|
-
SharedValidation.validateInternalCall(address(this));
|
|
105
|
-
return super.transferFrom(from, to, value);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* @notice Mint tokens to an account (callable only by this contract via GuardController)
|
|
110
|
-
* @param to Recipient address
|
|
111
|
-
* @param amount Amount to mint
|
|
112
|
-
*/
|
|
113
|
-
function mint(address to, uint256 amount) external virtual {
|
|
114
|
-
SharedValidation.validateInternalCall(address(this));
|
|
115
|
-
_mint(to, amount);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* @notice Burn tokens from caller (callable only by this contract via GuardController)
|
|
120
|
-
* @param value Amount to burn
|
|
121
|
-
*/
|
|
122
|
-
function burn(uint256 value) public virtual override(ERC20BurnableUpgradeable) {
|
|
123
|
-
SharedValidation.validateInternalCall(address(this));
|
|
124
|
-
super.burn(value);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* @notice Burn tokens from an account (with allowance); callable only by this contract via GuardController
|
|
129
|
-
* @param account Account to burn from
|
|
130
|
-
* @param value Amount to burn
|
|
131
|
-
*/
|
|
132
|
-
function burnFrom(address account, uint256 value) public virtual override(ERC20BurnableUpgradeable) {
|
|
133
|
-
SharedValidation.validateInternalCall(address(this));
|
|
134
|
-
super.burnFrom(account, value);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function supportsInterface(bytes4 interfaceId) public view virtual override(SecureOwnable, RuntimeRBAC, GuardController) returns (bool) {
|
|
138
|
-
return interfaceId == type(IERC20).interfaceId || GuardController.supportsInterface(interfaceId);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
pragma solidity 0.8.33;
|
|
3
|
-
|
|
4
|
-
import "../../../../lib/EngineBlox.sol";
|
|
5
|
-
import "../../../../../interfaces/IDefinition.sol";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @title ERC20BloxDefinitions
|
|
9
|
-
* @dev Definition library for ERC20Blox execution selectors (transfer, transferFrom, mint, burn, burnFrom).
|
|
10
|
-
* Registers function schemas and role permissions so the GuardController can execute these functions
|
|
11
|
-
* via time-lock and meta-transaction workflows. Handler permissions (executeWithTimeLock, etc.) are
|
|
12
|
-
* defined in GuardControllerDefinitions.
|
|
13
|
-
* @custom:security-contact security@particlecrypto.com
|
|
14
|
-
*/
|
|
15
|
-
library ERC20BloxDefinitions {
|
|
16
|
-
|
|
17
|
-
// System macro selectors (allowed to target address(this) for GuardController execution)
|
|
18
|
-
bytes4 public constant TRANSFER_SELECTOR = bytes4(keccak256("transfer(address,uint256)"));
|
|
19
|
-
bytes4 public constant TRANSFER_FROM_SELECTOR = bytes4(keccak256("transferFrom(address,address,uint256)"));
|
|
20
|
-
bytes4 public constant MINT_SELECTOR = bytes4(keccak256("mint(address,uint256)"));
|
|
21
|
-
bytes4 public constant BURN_SELECTOR = bytes4(keccak256("burn(uint256)"));
|
|
22
|
-
bytes4 public constant BURN_FROM_SELECTOR = bytes4(keccak256("burnFrom(address,uint256)"));
|
|
23
|
-
|
|
24
|
-
bytes32 public constant ERC20_OPERATION = keccak256("ERC20_OPERATION");
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @dev Returns function schemas for ERC20Blox execution selectors (used by controller).
|
|
28
|
-
*/
|
|
29
|
-
function getFunctionSchemas() public pure returns (EngineBlox.FunctionSchema[] memory) {
|
|
30
|
-
EngineBlox.FunctionSchema[] memory schemas = new EngineBlox.FunctionSchema[](5);
|
|
31
|
-
|
|
32
|
-
EngineBlox.TxAction[] memory timeDelayRequestActions = new EngineBlox.TxAction[](1);
|
|
33
|
-
timeDelayRequestActions[0] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_REQUEST;
|
|
34
|
-
EngineBlox.TxAction[] memory timeDelayApproveActions = new EngineBlox.TxAction[](1);
|
|
35
|
-
timeDelayApproveActions[0] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_APPROVE;
|
|
36
|
-
EngineBlox.TxAction[] memory timeDelayCancelActions = new EngineBlox.TxAction[](1);
|
|
37
|
-
timeDelayCancelActions[0] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_CANCEL;
|
|
38
|
-
EngineBlox.TxAction[] memory metaTxRequestApproveActions = new EngineBlox.TxAction[](2);
|
|
39
|
-
metaTxRequestApproveActions[0] = EngineBlox.TxAction.SIGN_META_REQUEST_AND_APPROVE;
|
|
40
|
-
metaTxRequestApproveActions[1] = EngineBlox.TxAction.EXECUTE_META_REQUEST_AND_APPROVE;
|
|
41
|
-
EngineBlox.TxAction[] memory metaTxApproveActions = new EngineBlox.TxAction[](2);
|
|
42
|
-
metaTxApproveActions[0] = EngineBlox.TxAction.SIGN_META_APPROVE;
|
|
43
|
-
metaTxApproveActions[1] = EngineBlox.TxAction.EXECUTE_META_APPROVE;
|
|
44
|
-
EngineBlox.TxAction[] memory metaTxCancelActions = new EngineBlox.TxAction[](2);
|
|
45
|
-
metaTxCancelActions[0] = EngineBlox.TxAction.SIGN_META_CANCEL;
|
|
46
|
-
metaTxCancelActions[1] = EngineBlox.TxAction.EXECUTE_META_CANCEL;
|
|
47
|
-
|
|
48
|
-
uint16 actionsBitmap = EngineBlox.createBitmapFromActions(timeDelayRequestActions)
|
|
49
|
-
| EngineBlox.createBitmapFromActions(timeDelayApproveActions)
|
|
50
|
-
| EngineBlox.createBitmapFromActions(timeDelayCancelActions)
|
|
51
|
-
| EngineBlox.createBitmapFromActions(metaTxRequestApproveActions)
|
|
52
|
-
| EngineBlox.createBitmapFromActions(metaTxApproveActions)
|
|
53
|
-
| EngineBlox.createBitmapFromActions(metaTxCancelActions);
|
|
54
|
-
|
|
55
|
-
bytes4[] memory transferHandlers = new bytes4[](1);
|
|
56
|
-
transferHandlers[0] = TRANSFER_SELECTOR;
|
|
57
|
-
bytes4[] memory transferFromHandlers = new bytes4[](1);
|
|
58
|
-
transferFromHandlers[0] = TRANSFER_FROM_SELECTOR;
|
|
59
|
-
bytes4[] memory mintHandlers = new bytes4[](1);
|
|
60
|
-
mintHandlers[0] = MINT_SELECTOR;
|
|
61
|
-
bytes4[] memory burnHandlers = new bytes4[](1);
|
|
62
|
-
burnHandlers[0] = BURN_SELECTOR;
|
|
63
|
-
bytes4[] memory burnFromHandlers = new bytes4[](1);
|
|
64
|
-
burnFromHandlers[0] = BURN_FROM_SELECTOR;
|
|
65
|
-
|
|
66
|
-
schemas[0] = EngineBlox.FunctionSchema({
|
|
67
|
-
functionSignature: "transfer(address,uint256)",
|
|
68
|
-
functionSelector: TRANSFER_SELECTOR,
|
|
69
|
-
operationType: ERC20_OPERATION,
|
|
70
|
-
operationName: "ERC20_TRANSFER",
|
|
71
|
-
supportedActionsBitmap: actionsBitmap,
|
|
72
|
-
isProtected: true,
|
|
73
|
-
handlerForSelectors: transferHandlers
|
|
74
|
-
});
|
|
75
|
-
schemas[1] = EngineBlox.FunctionSchema({
|
|
76
|
-
functionSignature: "transferFrom(address,address,uint256)",
|
|
77
|
-
functionSelector: TRANSFER_FROM_SELECTOR,
|
|
78
|
-
operationType: ERC20_OPERATION,
|
|
79
|
-
operationName: "ERC20_TRANSFER_FROM",
|
|
80
|
-
supportedActionsBitmap: actionsBitmap,
|
|
81
|
-
isProtected: true,
|
|
82
|
-
handlerForSelectors: transferFromHandlers
|
|
83
|
-
});
|
|
84
|
-
schemas[2] = EngineBlox.FunctionSchema({
|
|
85
|
-
functionSignature: "mint(address,uint256)",
|
|
86
|
-
functionSelector: MINT_SELECTOR,
|
|
87
|
-
operationType: ERC20_OPERATION,
|
|
88
|
-
operationName: "ERC20_MINT",
|
|
89
|
-
supportedActionsBitmap: actionsBitmap,
|
|
90
|
-
isProtected: true,
|
|
91
|
-
handlerForSelectors: mintHandlers
|
|
92
|
-
});
|
|
93
|
-
schemas[3] = EngineBlox.FunctionSchema({
|
|
94
|
-
functionSignature: "burn(uint256)",
|
|
95
|
-
functionSelector: BURN_SELECTOR,
|
|
96
|
-
operationType: ERC20_OPERATION,
|
|
97
|
-
operationName: "ERC20_BURN",
|
|
98
|
-
supportedActionsBitmap: actionsBitmap,
|
|
99
|
-
isProtected: true,
|
|
100
|
-
handlerForSelectors: burnHandlers
|
|
101
|
-
});
|
|
102
|
-
schemas[4] = EngineBlox.FunctionSchema({
|
|
103
|
-
functionSignature: "burnFrom(address,uint256)",
|
|
104
|
-
functionSelector: BURN_FROM_SELECTOR,
|
|
105
|
-
operationType: ERC20_OPERATION,
|
|
106
|
-
operationName: "ERC20_BURN_FROM",
|
|
107
|
-
supportedActionsBitmap: actionsBitmap,
|
|
108
|
-
isProtected: true,
|
|
109
|
-
handlerForSelectors: burnFromHandlers
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
return schemas;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* @dev Returns role permissions for ERC20Blox execution selectors (OWNER and BROADCASTER).
|
|
117
|
-
*/
|
|
118
|
-
function getRolePermissions() public pure returns (IDefinition.RolePermission memory) {
|
|
119
|
-
bytes32[] memory roleHashes = new bytes32[](10);
|
|
120
|
-
EngineBlox.FunctionPermission[] memory functionPermissions = new EngineBlox.FunctionPermission[](10);
|
|
121
|
-
|
|
122
|
-
EngineBlox.TxAction[] memory ownerTimeLockRequest = new EngineBlox.TxAction[](1);
|
|
123
|
-
ownerTimeLockRequest[0] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_REQUEST;
|
|
124
|
-
EngineBlox.TxAction[] memory ownerTimeLockApprove = new EngineBlox.TxAction[](1);
|
|
125
|
-
ownerTimeLockApprove[0] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_APPROVE;
|
|
126
|
-
EngineBlox.TxAction[] memory ownerTimeLockCancel = new EngineBlox.TxAction[](1);
|
|
127
|
-
ownerTimeLockCancel[0] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_CANCEL;
|
|
128
|
-
EngineBlox.TxAction[] memory ownerMetaSign = new EngineBlox.TxAction[](1);
|
|
129
|
-
ownerMetaSign[0] = EngineBlox.TxAction.SIGN_META_REQUEST_AND_APPROVE;
|
|
130
|
-
EngineBlox.TxAction[] memory ownerMetaApprove = new EngineBlox.TxAction[](1);
|
|
131
|
-
ownerMetaApprove[0] = EngineBlox.TxAction.SIGN_META_APPROVE;
|
|
132
|
-
EngineBlox.TxAction[] memory ownerMetaCancel = new EngineBlox.TxAction[](1);
|
|
133
|
-
ownerMetaCancel[0] = EngineBlox.TxAction.SIGN_META_CANCEL;
|
|
134
|
-
EngineBlox.TxAction[] memory broadcasterMetaExec = new EngineBlox.TxAction[](1);
|
|
135
|
-
broadcasterMetaExec[0] = EngineBlox.TxAction.EXECUTE_META_REQUEST_AND_APPROVE;
|
|
136
|
-
EngineBlox.TxAction[] memory broadcasterMetaApprove = new EngineBlox.TxAction[](1);
|
|
137
|
-
broadcasterMetaApprove[0] = EngineBlox.TxAction.EXECUTE_META_APPROVE;
|
|
138
|
-
EngineBlox.TxAction[] memory broadcasterMetaCancel = new EngineBlox.TxAction[](1);
|
|
139
|
-
broadcasterMetaCancel[0] = EngineBlox.TxAction.EXECUTE_META_CANCEL;
|
|
140
|
-
|
|
141
|
-
uint16 ownerBitmap = EngineBlox.createBitmapFromActions(ownerTimeLockRequest)
|
|
142
|
-
| EngineBlox.createBitmapFromActions(ownerTimeLockApprove)
|
|
143
|
-
| EngineBlox.createBitmapFromActions(ownerTimeLockCancel)
|
|
144
|
-
| EngineBlox.createBitmapFromActions(ownerMetaSign)
|
|
145
|
-
| EngineBlox.createBitmapFromActions(ownerMetaApprove)
|
|
146
|
-
| EngineBlox.createBitmapFromActions(ownerMetaCancel);
|
|
147
|
-
uint16 broadcasterBitmap = EngineBlox.createBitmapFromActions(broadcasterMetaExec)
|
|
148
|
-
| EngineBlox.createBitmapFromActions(broadcasterMetaApprove)
|
|
149
|
-
| EngineBlox.createBitmapFromActions(broadcasterMetaCancel);
|
|
150
|
-
|
|
151
|
-
bytes4[5] memory selectors = [TRANSFER_SELECTOR, TRANSFER_FROM_SELECTOR, MINT_SELECTOR, BURN_SELECTOR, BURN_FROM_SELECTOR];
|
|
152
|
-
for (uint256 i = 0; i < 5; i++) {
|
|
153
|
-
bytes4[] memory selfRef = new bytes4[](1);
|
|
154
|
-
selfRef[0] = selectors[i];
|
|
155
|
-
roleHashes[i] = EngineBlox.OWNER_ROLE;
|
|
156
|
-
functionPermissions[i] = EngineBlox.FunctionPermission({
|
|
157
|
-
functionSelector: selectors[i],
|
|
158
|
-
grantedActionsBitmap: ownerBitmap,
|
|
159
|
-
handlerForSelectors: selfRef
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
for (uint256 i = 0; i < 5; i++) {
|
|
163
|
-
bytes4[] memory selfRef = new bytes4[](1);
|
|
164
|
-
selfRef[0] = selectors[i];
|
|
165
|
-
roleHashes[5 + i] = EngineBlox.BROADCASTER_ROLE;
|
|
166
|
-
functionPermissions[5 + i] = EngineBlox.FunctionPermission({
|
|
167
|
-
functionSelector: selectors[i],
|
|
168
|
-
grantedActionsBitmap: broadcasterBitmap,
|
|
169
|
-
handlerForSelectors: selfRef
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return IDefinition.RolePermission({
|
|
174
|
-
roleHashes: roleHashes,
|
|
175
|
-
functionPermissions: functionPermissions
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* @dev ERC165: report support for IDefinition when this library is used at an address
|
|
181
|
-
*/
|
|
182
|
-
function supportsInterface(bytes4 interfaceId) external pure returns (bool) {
|
|
183
|
-
return interfaceId == type(IDefinition).interfaceId;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
pragma solidity 0.8.33;
|
|
3
|
-
|
|
4
|
-
import "../core/lib/EngineBlox.sol";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @title IOnActionHook
|
|
8
|
-
* @dev Minimal interface for external hook contracts attached to state machine actions
|
|
9
|
-
*
|
|
10
|
-
* @notice This interface is intentionally small to keep overall contract size low.
|
|
11
|
-
* @notice Implementations can choose which functions to support; unneeded ones can revert.
|
|
12
|
-
*/
|
|
13
|
-
interface IOnActionHook {
|
|
14
|
-
/**
|
|
15
|
-
* @dev Called after a transaction request is created
|
|
16
|
-
* @param txRecord The created transaction record
|
|
17
|
-
* @param caller The address that initiated the request
|
|
18
|
-
*/
|
|
19
|
-
function onRequest(
|
|
20
|
-
EngineBlox.TxRecord memory txRecord,
|
|
21
|
-
address caller
|
|
22
|
-
) external;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @dev Called after a pending transaction is approved (time-lock flow)
|
|
26
|
-
* @param txRecord The updated transaction record
|
|
27
|
-
* @param caller The address that approved the transaction
|
|
28
|
-
*/
|
|
29
|
-
function onApprove(
|
|
30
|
-
EngineBlox.TxRecord memory txRecord,
|
|
31
|
-
address caller
|
|
32
|
-
) external;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @dev Called after a pending transaction is cancelled
|
|
36
|
-
* @param txRecord The updated transaction record
|
|
37
|
-
* @param caller The address that cancelled the transaction
|
|
38
|
-
*/
|
|
39
|
-
function onCancel(
|
|
40
|
-
EngineBlox.TxRecord memory txRecord,
|
|
41
|
-
address caller
|
|
42
|
-
) external;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @dev Called after a transaction is approved via meta-transaction
|
|
46
|
-
* @param txRecord The updated transaction record
|
|
47
|
-
* @param metaTx The meta-transaction used for approval
|
|
48
|
-
* @param caller The address executing the meta-transaction
|
|
49
|
-
*/
|
|
50
|
-
function onMetaApprove(
|
|
51
|
-
EngineBlox.TxRecord memory txRecord,
|
|
52
|
-
EngineBlox.MetaTransaction memory metaTx,
|
|
53
|
-
address caller
|
|
54
|
-
) external;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @dev Called after a transaction is cancelled via meta-transaction
|
|
58
|
-
* @param txRecord The updated transaction record
|
|
59
|
-
* @param metaTx The meta-transaction used for cancellation
|
|
60
|
-
* @param caller The address executing the meta-transaction
|
|
61
|
-
*/
|
|
62
|
-
function onMetaCancel(
|
|
63
|
-
EngineBlox.TxRecord memory txRecord,
|
|
64
|
-
EngineBlox.MetaTransaction memory metaTx,
|
|
65
|
-
address caller
|
|
66
|
-
) external;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @dev Called after a transaction is requested and approved in one step via meta-transaction
|
|
70
|
-
* @param txRecord The created + approved transaction record
|
|
71
|
-
* @param metaTx The meta-transaction used for the operation
|
|
72
|
-
* @param caller The address executing the meta-transaction
|
|
73
|
-
*/
|
|
74
|
-
function onRequestAndApprove(
|
|
75
|
-
EngineBlox.TxRecord memory txRecord,
|
|
76
|
-
EngineBlox.MetaTransaction memory metaTx,
|
|
77
|
-
address caller
|
|
78
|
-
) external;
|
|
79
|
-
}
|