@bloxchain/contracts 1.0.0-alpha
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 +49 -0
- package/abi/BareBlox.abi.json +1341 -0
- package/abi/BaseStateMachine.abi.json +1308 -0
- package/abi/ControlBlox.abi.json +6210 -0
- package/abi/EngineBlox.abi.json +872 -0
- package/abi/GuardController.abi.json +3045 -0
- package/abi/IDefinition.abi.json +94 -0
- package/abi/RoleBlox.abi.json +4569 -0
- package/abi/RuntimeRBAC.abi.json +1857 -0
- package/abi/RuntimeRBACDefinitions.abi.json +133 -0
- package/abi/SecureBlox.abi.json +4085 -0
- package/abi/SecureOwnable.abi.json +4085 -0
- package/abi/SecureOwnableDefinitions.abi.json +354 -0
- package/abi/SimpleRWA20.abi.json +5545 -0
- package/abi/SimpleRWA20Definitions.abi.json +172 -0
- package/abi/SimpleVault.abi.json +5208 -0
- package/abi/SimpleVaultDefinitions.abi.json +250 -0
- package/contracts/core/access/RuntimeRBAC.sol +344 -0
- package/contracts/core/access/interface/IRuntimeRBAC.sol +108 -0
- package/contracts/core/access/lib/definitions/RuntimeRBACDefinitions.sol +168 -0
- package/contracts/core/base/BaseStateMachine.sol +834 -0
- package/contracts/core/base/interface/IBaseStateMachine.sol +153 -0
- package/contracts/core/execution/GuardController.sol +507 -0
- package/contracts/core/execution/interface/IGuardController.sol +120 -0
- package/contracts/core/execution/lib/definitions/GuardControllerDefinitions.sol +401 -0
- package/contracts/core/lib/EngineBlox.sol +2283 -0
- package/contracts/core/security/SecureOwnable.sol +419 -0
- package/contracts/core/security/interface/ISecureOwnable.sol +118 -0
- package/contracts/core/security/lib/definitions/SecureOwnableDefinitions.sol +757 -0
- package/contracts/interfaces/IDefinition.sol +40 -0
- package/contracts/interfaces/IEventForwarder.sol +33 -0
- package/contracts/interfaces/IOnActionHook.sol +79 -0
- package/contracts/utils/SharedValidation.sol +486 -0
- package/package.json +47 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
pragma solidity 0.8.33;
|
|
3
|
+
|
|
4
|
+
import "../../lib/EngineBlox.sol";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @title IGuardController
|
|
8
|
+
* @dev Interface for GuardController contract that GuardianSafeV3 and other contracts delegate to
|
|
9
|
+
* @notice This interface defines only GuardController-specific methods
|
|
10
|
+
* @notice Functions from BaseStateMachine (createMetaTxParams, generateUnsignedMetaTransaction*, getTransaction, functionSchemaExists, owner, getBroadcaster, getRecovery) should be accessed via IBaseStateMachine
|
|
11
|
+
* @notice Functions from RuntimeRBAC (registerFunction, unregisterFunction, getFunctionSchema, createNewRole, addWalletToRole, revokeWallet) should be accessed via IRuntimeRBAC
|
|
12
|
+
* @custom:security-contact security@particlecrypto.com
|
|
13
|
+
*/
|
|
14
|
+
interface IGuardController {
|
|
15
|
+
/**
|
|
16
|
+
* @notice Initializer to initialize GuardController
|
|
17
|
+
* @param initialOwner The initial owner address
|
|
18
|
+
* @param broadcaster The broadcaster address
|
|
19
|
+
* @param recovery The recovery address
|
|
20
|
+
* @param timeLockPeriodSec The timelock period in seconds
|
|
21
|
+
* @param eventForwarder The event forwarder address
|
|
22
|
+
*/
|
|
23
|
+
function initialize(
|
|
24
|
+
address initialOwner,
|
|
25
|
+
address broadcaster,
|
|
26
|
+
address recovery,
|
|
27
|
+
uint256 timeLockPeriodSec,
|
|
28
|
+
address eventForwarder
|
|
29
|
+
) external;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @dev Requests a time-locked execution via EngineBlox workflow
|
|
33
|
+
* @param target The address of the target contract
|
|
34
|
+
* @param value The ETH value to send (0 for standard function calls)
|
|
35
|
+
* @param functionSelector The function selector to execute (0x00000000 for simple ETH transfers)
|
|
36
|
+
* @param params The encoded parameters for the function (empty for simple ETH transfers)
|
|
37
|
+
* @param gasLimit The gas limit for execution
|
|
38
|
+
* @param operationType The operation type hash
|
|
39
|
+
* @return txId The transaction ID for the requested operation
|
|
40
|
+
* @notice Creates a time-locked transaction that must be approved after the timelock period
|
|
41
|
+
* @notice Requires EXECUTE_TIME_DELAY_REQUEST permission for the function selector
|
|
42
|
+
* @notice For standard function calls: value=0, functionSelector=non-zero, params=encoded data
|
|
43
|
+
* @notice For simple ETH transfers: value>0, functionSelector=0x00000000, params=""
|
|
44
|
+
*/
|
|
45
|
+
function executeWithTimeLock(
|
|
46
|
+
address target,
|
|
47
|
+
uint256 value,
|
|
48
|
+
bytes4 functionSelector,
|
|
49
|
+
bytes memory params,
|
|
50
|
+
uint256 gasLimit,
|
|
51
|
+
bytes32 operationType
|
|
52
|
+
) external returns (uint256 txId);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @dev Approves and executes a time-locked transaction
|
|
56
|
+
* @param txId The transaction ID
|
|
57
|
+
* @param expectedOperationType The expected operation type for validation
|
|
58
|
+
* @return result The execution result
|
|
59
|
+
* @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_APPROVE permission for the execution function
|
|
60
|
+
*/
|
|
61
|
+
function approveTimeLockExecution(
|
|
62
|
+
uint256 txId,
|
|
63
|
+
bytes32 expectedOperationType
|
|
64
|
+
) external returns (bytes memory result);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @dev Cancels a time-locked transaction
|
|
68
|
+
* @param txId The transaction ID
|
|
69
|
+
* @param expectedOperationType The expected operation type for validation
|
|
70
|
+
* @return The updated transaction record
|
|
71
|
+
* @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_CANCEL permission for the execution function
|
|
72
|
+
*/
|
|
73
|
+
function cancelTimeLockExecution(
|
|
74
|
+
uint256 txId,
|
|
75
|
+
bytes32 expectedOperationType
|
|
76
|
+
) external returns (EngineBlox.TxRecord memory);
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @dev Approves a time-locked transaction using a meta-transaction
|
|
80
|
+
* @param metaTx The meta-transaction containing the transaction record and signature
|
|
81
|
+
* @param expectedOperationType The expected operation type for validation
|
|
82
|
+
* @param requiredSelector The handler selector for validation
|
|
83
|
+
* @return The updated transaction record
|
|
84
|
+
* @notice Requires STANDARD execution type and EXECUTE_META_APPROVE permission for the execution function
|
|
85
|
+
*/
|
|
86
|
+
function approveTimeLockExecutionWithMetaTx(
|
|
87
|
+
EngineBlox.MetaTransaction memory metaTx,
|
|
88
|
+
bytes32 expectedOperationType,
|
|
89
|
+
bytes4 requiredSelector
|
|
90
|
+
) external returns (EngineBlox.TxRecord memory);
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @dev Cancels a time-locked transaction using a meta-transaction
|
|
94
|
+
* @param metaTx The meta-transaction containing the transaction record and signature
|
|
95
|
+
* @param expectedOperationType The expected operation type for validation
|
|
96
|
+
* @param requiredSelector The handler selector for validation
|
|
97
|
+
* @return The updated transaction record
|
|
98
|
+
* @notice Requires STANDARD execution type and EXECUTE_META_CANCEL permission for the execution function
|
|
99
|
+
*/
|
|
100
|
+
function cancelTimeLockExecutionWithMetaTx(
|
|
101
|
+
EngineBlox.MetaTransaction memory metaTx,
|
|
102
|
+
bytes32 expectedOperationType,
|
|
103
|
+
bytes4 requiredSelector
|
|
104
|
+
) external returns (EngineBlox.TxRecord memory);
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @dev Requests and approves a transaction in one step using a meta-transaction
|
|
108
|
+
* @param metaTx The meta-transaction containing the transaction record and signature
|
|
109
|
+
* @param requiredSelector The handler selector for validation
|
|
110
|
+
* @return The transaction record after request and approval
|
|
111
|
+
* @notice Requires STANDARD execution type
|
|
112
|
+
* @notice Validates function schema and permissions for the execution function (same as executeWithTimeLock)
|
|
113
|
+
* @notice Requires EXECUTE_META_REQUEST_AND_APPROVE permission for the execution function selector
|
|
114
|
+
*/
|
|
115
|
+
function requestAndApproveExecution(
|
|
116
|
+
EngineBlox.MetaTransaction memory metaTx,
|
|
117
|
+
bytes4 requiredSelector
|
|
118
|
+
) external returns (EngineBlox.TxRecord memory);
|
|
119
|
+
}
|
|
120
|
+
|
|
@@ -0,0 +1,401 @@
|
|
|
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 GuardControllerDefinitions
|
|
9
|
+
* @dev Library containing predefined definitions for GuardController initialization
|
|
10
|
+
* This library holds static data that can be used to initialize GuardController contracts
|
|
11
|
+
* without increasing the main contract size
|
|
12
|
+
*
|
|
13
|
+
* This library implements the IDefinition interface and provides both function schema definitions
|
|
14
|
+
* and role permissions for GuardController's public execution functions.
|
|
15
|
+
*
|
|
16
|
+
* Key Features:
|
|
17
|
+
* - Registers all 6 GuardController public execution functions
|
|
18
|
+
* - Defines role permissions for OWNER_ROLE and BROADCASTER_ROLE
|
|
19
|
+
* - Supports time-delay and meta-transaction workflows
|
|
20
|
+
* - Matches EngineBloxDefinitions pattern for consistency
|
|
21
|
+
*
|
|
22
|
+
* Role Permissions:
|
|
23
|
+
* - OWNER_ROLE: Can sign/request time-delay and meta-transaction operations (8 permissions)
|
|
24
|
+
* - BROADCASTER_ROLE: Can execute meta-transaction operations (5 permissions)
|
|
25
|
+
*
|
|
26
|
+
* @notice This definition provides complete initialization data including both function schemas
|
|
27
|
+
* and role permissions, matching the EngineBloxDefinitions pattern.
|
|
28
|
+
* @custom:security-contact security@particlecrypto.com
|
|
29
|
+
*/
|
|
30
|
+
library GuardControllerDefinitions {
|
|
31
|
+
|
|
32
|
+
// Operation Type Constants
|
|
33
|
+
bytes32 public constant CONTROLLER_OPERATION = keccak256("CONTROLLER_OPERATION");
|
|
34
|
+
|
|
35
|
+
// Function Selector Constants
|
|
36
|
+
// GuardController: executeWithTimeLock(address,bytes4,bytes,uint256,bytes32)
|
|
37
|
+
bytes4 public constant EXECUTE_WITH_TIMELOCK_SELECTOR = bytes4(keccak256("executeWithTimeLock(address,bytes4,bytes,uint256,bytes32)"));
|
|
38
|
+
|
|
39
|
+
// GuardController: approveTimeLockExecution(uint256)
|
|
40
|
+
bytes4 public constant APPROVE_TIMELOCK_EXECUTION_SELECTOR = bytes4(keccak256("approveTimeLockExecution(uint256)"));
|
|
41
|
+
|
|
42
|
+
// GuardController: cancelTimeLockExecution(uint256)
|
|
43
|
+
bytes4 public constant CANCEL_TIMELOCK_EXECUTION_SELECTOR = bytes4(keccak256("cancelTimeLockExecution(uint256)"));
|
|
44
|
+
|
|
45
|
+
// GuardController: approveTimeLockExecutionWithMetaTx(...)
|
|
46
|
+
bytes4 public constant APPROVE_TIMELOCK_EXECUTION_META_SELECTOR = bytes4(keccak256("approveTimeLockExecutionWithMetaTx((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))"));
|
|
47
|
+
|
|
48
|
+
// GuardController: cancelTimeLockExecutionWithMetaTx(...)
|
|
49
|
+
bytes4 public constant CANCEL_TIMELOCK_EXECUTION_META_SELECTOR = bytes4(keccak256("cancelTimeLockExecutionWithMetaTx((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))"));
|
|
50
|
+
|
|
51
|
+
// GuardController: requestAndApproveExecution(...)
|
|
52
|
+
bytes4 public constant REQUEST_AND_APPROVE_EXECUTION_SELECTOR = bytes4(keccak256("requestAndApproveExecution((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))"));
|
|
53
|
+
|
|
54
|
+
// GuardController: guardConfigBatchRequestAndApprove(...)
|
|
55
|
+
bytes4 public constant GUARD_CONFIG_BATCH_META_SELECTOR = bytes4(
|
|
56
|
+
keccak256(
|
|
57
|
+
"guardConfigBatchRequestAndApprove(((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))"
|
|
58
|
+
)
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
// GuardController: executeGuardConfigBatch((uint8,bytes)[])
|
|
62
|
+
bytes4 public constant GUARD_CONFIG_BATCH_EXECUTE_SELECTOR =
|
|
63
|
+
bytes4(keccak256("executeGuardConfigBatch((uint8,bytes)[])"));
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @dev Returns predefined function schemas for GuardController execution functions
|
|
67
|
+
* @return Array of function schema definitions
|
|
68
|
+
*
|
|
69
|
+
* Function schemas define:
|
|
70
|
+
* - GuardController public execution functions
|
|
71
|
+
* - What operation types they belong to (CONTROLLER_OPERATION)
|
|
72
|
+
* - What actions are supported (time-delay request/approve/cancel, meta-tx approve/cancel/request-and-approve)
|
|
73
|
+
* - Whether they are protected
|
|
74
|
+
*
|
|
75
|
+
* Permission System:
|
|
76
|
+
* - These schemas enable EngineBlox._checkExecutionPermissions to validate
|
|
77
|
+
* if callers have permission to call these GuardController functions
|
|
78
|
+
* - Role permissions are defined in getRolePermissions() matching EngineBloxDefinitions pattern
|
|
79
|
+
*/
|
|
80
|
+
function getFunctionSchemas() public pure returns (EngineBlox.FunctionSchema[] memory) {
|
|
81
|
+
EngineBlox.FunctionSchema[] memory schemas = new EngineBlox.FunctionSchema[](8);
|
|
82
|
+
|
|
83
|
+
// ============ TIME-DELAY WORKFLOW ACTIONS ============
|
|
84
|
+
// Request action for executeWithTimeLock
|
|
85
|
+
EngineBlox.TxAction[] memory timeDelayRequestActions = new EngineBlox.TxAction[](1);
|
|
86
|
+
timeDelayRequestActions[0] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_REQUEST;
|
|
87
|
+
|
|
88
|
+
// Approve action for approveTimeLockExecution
|
|
89
|
+
EngineBlox.TxAction[] memory timeDelayApproveActions = new EngineBlox.TxAction[](1);
|
|
90
|
+
timeDelayApproveActions[0] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_APPROVE;
|
|
91
|
+
|
|
92
|
+
// Cancel action for cancelTimeLockExecution
|
|
93
|
+
EngineBlox.TxAction[] memory timeDelayCancelActions = new EngineBlox.TxAction[](1);
|
|
94
|
+
timeDelayCancelActions[0] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_CANCEL;
|
|
95
|
+
|
|
96
|
+
// ============ META-TRANSACTION WORKFLOW ACTIONS ============
|
|
97
|
+
// Approve action for approveTimeLockExecutionWithMetaTx
|
|
98
|
+
EngineBlox.TxAction[] memory metaTxApproveActions = new EngineBlox.TxAction[](2);
|
|
99
|
+
metaTxApproveActions[0] = EngineBlox.TxAction.SIGN_META_APPROVE;
|
|
100
|
+
metaTxApproveActions[1] = EngineBlox.TxAction.EXECUTE_META_APPROVE;
|
|
101
|
+
|
|
102
|
+
// Cancel action for cancelTimeLockExecutionWithMetaTx
|
|
103
|
+
EngineBlox.TxAction[] memory metaTxCancelActions = new EngineBlox.TxAction[](2);
|
|
104
|
+
metaTxCancelActions[0] = EngineBlox.TxAction.SIGN_META_CANCEL;
|
|
105
|
+
metaTxCancelActions[1] = EngineBlox.TxAction.EXECUTE_META_CANCEL;
|
|
106
|
+
|
|
107
|
+
// Request and approve action for requestAndApproveExecution
|
|
108
|
+
EngineBlox.TxAction[] memory metaTxRequestApproveActions = new EngineBlox.TxAction[](2);
|
|
109
|
+
metaTxRequestApproveActions[0] = EngineBlox.TxAction.SIGN_META_REQUEST_AND_APPROVE;
|
|
110
|
+
metaTxRequestApproveActions[1] = EngineBlox.TxAction.EXECUTE_META_REQUEST_AND_APPROVE;
|
|
111
|
+
|
|
112
|
+
// ============ GUARDCONTROLLER FUNCTION SCHEMAS ============
|
|
113
|
+
|
|
114
|
+
// Execution selectors must have self-reference (at least one element pointing to themselves)
|
|
115
|
+
bytes4[] memory executeWithTimeLockHandlerForSelectors = new bytes4[](1);
|
|
116
|
+
executeWithTimeLockHandlerForSelectors[0] = EXECUTE_WITH_TIMELOCK_SELECTOR;
|
|
117
|
+
bytes4[] memory approveTimeLockExecutionHandlerForSelectors = new bytes4[](1);
|
|
118
|
+
approveTimeLockExecutionHandlerForSelectors[0] = APPROVE_TIMELOCK_EXECUTION_SELECTOR;
|
|
119
|
+
bytes4[] memory cancelTimeLockExecutionHandlerForSelectors = new bytes4[](1);
|
|
120
|
+
cancelTimeLockExecutionHandlerForSelectors[0] = CANCEL_TIMELOCK_EXECUTION_SELECTOR;
|
|
121
|
+
bytes4[] memory approveTimeLockExecutionMetaHandlerForSelectors = new bytes4[](1);
|
|
122
|
+
approveTimeLockExecutionMetaHandlerForSelectors[0] = APPROVE_TIMELOCK_EXECUTION_META_SELECTOR;
|
|
123
|
+
bytes4[] memory cancelTimeLockExecutionMetaHandlerForSelectors = new bytes4[](1);
|
|
124
|
+
cancelTimeLockExecutionMetaHandlerForSelectors[0] = CANCEL_TIMELOCK_EXECUTION_META_SELECTOR;
|
|
125
|
+
bytes4[] memory requestAndApproveExecutionHandlerForSelectors = new bytes4[](1);
|
|
126
|
+
requestAndApproveExecutionHandlerForSelectors[0] = REQUEST_AND_APPROVE_EXECUTION_SELECTOR;
|
|
127
|
+
bytes4[] memory guardConfigBatchExecuteHandlerForSelectors = new bytes4[](1);
|
|
128
|
+
guardConfigBatchExecuteHandlerForSelectors[0] = GUARD_CONFIG_BATCH_EXECUTE_SELECTOR;
|
|
129
|
+
|
|
130
|
+
// Handler selectors point to execution selectors
|
|
131
|
+
bytes4[] memory guardConfigHandlerForSelectors = new bytes4[](1);
|
|
132
|
+
guardConfigHandlerForSelectors[0] = GUARD_CONFIG_BATCH_EXECUTE_SELECTOR;
|
|
133
|
+
|
|
134
|
+
// Schema 0: GuardController.executeWithTimeLock
|
|
135
|
+
schemas[0] = EngineBlox.FunctionSchema({
|
|
136
|
+
functionSignature: "executeWithTimeLock(address,bytes4,bytes,uint256,bytes32)",
|
|
137
|
+
functionSelector: EXECUTE_WITH_TIMELOCK_SELECTOR,
|
|
138
|
+
operationType: CONTROLLER_OPERATION,
|
|
139
|
+
operationName: "CONTROLLER_OPERATION",
|
|
140
|
+
supportedActionsBitmap: EngineBlox.createBitmapFromActions(timeDelayRequestActions),
|
|
141
|
+
isProtected: true,
|
|
142
|
+
handlerForSelectors: executeWithTimeLockHandlerForSelectors
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Schema 1: GuardController.approveTimeLockExecution
|
|
146
|
+
schemas[1] = EngineBlox.FunctionSchema({
|
|
147
|
+
functionSignature: "approveTimeLockExecution(uint256)",
|
|
148
|
+
functionSelector: APPROVE_TIMELOCK_EXECUTION_SELECTOR,
|
|
149
|
+
operationType: CONTROLLER_OPERATION,
|
|
150
|
+
operationName: "CONTROLLER_OPERATION",
|
|
151
|
+
supportedActionsBitmap: EngineBlox.createBitmapFromActions(timeDelayApproveActions),
|
|
152
|
+
isProtected: true,
|
|
153
|
+
handlerForSelectors: approveTimeLockExecutionHandlerForSelectors
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Schema 2: GuardController.cancelTimeLockExecution
|
|
157
|
+
schemas[2] = EngineBlox.FunctionSchema({
|
|
158
|
+
functionSignature: "cancelTimeLockExecution(uint256)",
|
|
159
|
+
functionSelector: CANCEL_TIMELOCK_EXECUTION_SELECTOR,
|
|
160
|
+
operationType: CONTROLLER_OPERATION,
|
|
161
|
+
operationName: "CONTROLLER_OPERATION",
|
|
162
|
+
supportedActionsBitmap: EngineBlox.createBitmapFromActions(timeDelayCancelActions),
|
|
163
|
+
isProtected: true,
|
|
164
|
+
handlerForSelectors: cancelTimeLockExecutionHandlerForSelectors
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Schema 3: GuardController.approveTimeLockExecutionWithMetaTx
|
|
168
|
+
schemas[3] = EngineBlox.FunctionSchema({
|
|
169
|
+
functionSignature: "approveTimeLockExecutionWithMetaTx((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))",
|
|
170
|
+
functionSelector: APPROVE_TIMELOCK_EXECUTION_META_SELECTOR,
|
|
171
|
+
operationType: CONTROLLER_OPERATION,
|
|
172
|
+
operationName: "CONTROLLER_OPERATION",
|
|
173
|
+
supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxApproveActions),
|
|
174
|
+
isProtected: true,
|
|
175
|
+
handlerForSelectors: approveTimeLockExecutionMetaHandlerForSelectors
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// Schema 4: GuardController.cancelTimeLockExecutionWithMetaTx
|
|
179
|
+
schemas[4] = EngineBlox.FunctionSchema({
|
|
180
|
+
functionSignature: "cancelTimeLockExecutionWithMetaTx((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))",
|
|
181
|
+
functionSelector: CANCEL_TIMELOCK_EXECUTION_META_SELECTOR,
|
|
182
|
+
operationType: CONTROLLER_OPERATION,
|
|
183
|
+
operationName: "CONTROLLER_OPERATION",
|
|
184
|
+
supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxCancelActions),
|
|
185
|
+
isProtected: true,
|
|
186
|
+
handlerForSelectors: cancelTimeLockExecutionMetaHandlerForSelectors
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// Schema 5: GuardController.requestAndApproveExecution
|
|
190
|
+
schemas[5] = EngineBlox.FunctionSchema({
|
|
191
|
+
functionSignature: "requestAndApproveExecution((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))",
|
|
192
|
+
functionSelector: REQUEST_AND_APPROVE_EXECUTION_SELECTOR,
|
|
193
|
+
operationType: CONTROLLER_OPERATION,
|
|
194
|
+
operationName: "CONTROLLER_OPERATION",
|
|
195
|
+
supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxRequestApproveActions),
|
|
196
|
+
isProtected: true,
|
|
197
|
+
handlerForSelectors: requestAndApproveExecutionHandlerForSelectors
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// Schema 6: GuardController.guardConfigBatchRequestAndApprove
|
|
201
|
+
schemas[6] = EngineBlox.FunctionSchema({
|
|
202
|
+
functionSignature: "guardConfigBatchRequestAndApprove(((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))",
|
|
203
|
+
functionSelector: GUARD_CONFIG_BATCH_META_SELECTOR,
|
|
204
|
+
operationType: CONTROLLER_OPERATION,
|
|
205
|
+
operationName: "CONTROLLER_OPERATION",
|
|
206
|
+
supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxRequestApproveActions),
|
|
207
|
+
isProtected: true,
|
|
208
|
+
handlerForSelectors: guardConfigHandlerForSelectors
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Schema 7: GuardController.executeGuardConfigBatch
|
|
212
|
+
EngineBlox.TxAction[] memory guardConfigExecutionActions = new EngineBlox.TxAction[](2);
|
|
213
|
+
guardConfigExecutionActions[0] = EngineBlox.TxAction.SIGN_META_REQUEST_AND_APPROVE;
|
|
214
|
+
guardConfigExecutionActions[1] = EngineBlox.TxAction.EXECUTE_META_REQUEST_AND_APPROVE;
|
|
215
|
+
|
|
216
|
+
schemas[7] = EngineBlox.FunctionSchema({
|
|
217
|
+
functionSignature: "executeGuardConfigBatch((uint8,bytes)[])",
|
|
218
|
+
functionSelector: GUARD_CONFIG_BATCH_EXECUTE_SELECTOR,
|
|
219
|
+
operationType: CONTROLLER_OPERATION,
|
|
220
|
+
operationName: "CONTROLLER_OPERATION",
|
|
221
|
+
supportedActionsBitmap: EngineBlox.createBitmapFromActions(guardConfigExecutionActions),
|
|
222
|
+
isProtected: true,
|
|
223
|
+
handlerForSelectors: guardConfigBatchExecuteHandlerForSelectors
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
return schemas;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @dev Returns predefined role hashes and their corresponding function permissions
|
|
231
|
+
* @return RolePermission struct containing roleHashes and functionPermissions arrays
|
|
232
|
+
*
|
|
233
|
+
* Role Permissions:
|
|
234
|
+
* - OWNER_ROLE: Can sign/request time-delay and meta-transaction operations (8 permissions)
|
|
235
|
+
* - BROADCASTER_ROLE: Can execute meta-transaction operations (5 permissions)
|
|
236
|
+
*
|
|
237
|
+
* Total: 13 role permission entries matching EngineBloxDefinitions pattern
|
|
238
|
+
*/
|
|
239
|
+
function getRolePermissions() public pure returns (IDefinition.RolePermission memory) {
|
|
240
|
+
bytes32[] memory roleHashes;
|
|
241
|
+
EngineBlox.FunctionPermission[] memory functionPermissions;
|
|
242
|
+
roleHashes = new bytes32[](13);
|
|
243
|
+
functionPermissions = new EngineBlox.FunctionPermission[](13);
|
|
244
|
+
|
|
245
|
+
// Owner role permissions (8 entries)
|
|
246
|
+
EngineBlox.TxAction[] memory ownerTimeLockRequestActions = new EngineBlox.TxAction[](1);
|
|
247
|
+
ownerTimeLockRequestActions[0] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_REQUEST;
|
|
248
|
+
|
|
249
|
+
EngineBlox.TxAction[] memory ownerTimeLockApproveActions = new EngineBlox.TxAction[](1);
|
|
250
|
+
ownerTimeLockApproveActions[0] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_APPROVE;
|
|
251
|
+
|
|
252
|
+
EngineBlox.TxAction[] memory ownerTimeLockCancelActions = new EngineBlox.TxAction[](1);
|
|
253
|
+
ownerTimeLockCancelActions[0] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_CANCEL;
|
|
254
|
+
|
|
255
|
+
EngineBlox.TxAction[] memory ownerMetaTxRequestApproveActions = new EngineBlox.TxAction[](1);
|
|
256
|
+
ownerMetaTxRequestApproveActions[0] = EngineBlox.TxAction.SIGN_META_REQUEST_AND_APPROVE;
|
|
257
|
+
|
|
258
|
+
EngineBlox.TxAction[] memory ownerMetaTxApproveActions = new EngineBlox.TxAction[](1);
|
|
259
|
+
ownerMetaTxApproveActions[0] = EngineBlox.TxAction.SIGN_META_APPROVE;
|
|
260
|
+
|
|
261
|
+
EngineBlox.TxAction[] memory ownerMetaTxCancelActions = new EngineBlox.TxAction[](1);
|
|
262
|
+
ownerMetaTxCancelActions[0] = EngineBlox.TxAction.SIGN_META_CANCEL;
|
|
263
|
+
|
|
264
|
+
// Owner: Execute With TimeLock
|
|
265
|
+
roleHashes[0] = EngineBlox.OWNER_ROLE;
|
|
266
|
+
bytes4[] memory handlerForSelectors0 = new bytes4[](1);
|
|
267
|
+
handlerForSelectors0[0] = EXECUTE_WITH_TIMELOCK_SELECTOR;
|
|
268
|
+
functionPermissions[0] = EngineBlox.FunctionPermission({
|
|
269
|
+
functionSelector: EXECUTE_WITH_TIMELOCK_SELECTOR,
|
|
270
|
+
grantedActionsBitmap: EngineBlox.createBitmapFromActions(ownerTimeLockRequestActions),
|
|
271
|
+
handlerForSelectors: handlerForSelectors0 // Self-reference indicates execution selector
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// Owner: Approve TimeLock Execution
|
|
275
|
+
roleHashes[1] = EngineBlox.OWNER_ROLE;
|
|
276
|
+
bytes4[] memory handlerForSelectors1 = new bytes4[](1);
|
|
277
|
+
handlerForSelectors1[0] = APPROVE_TIMELOCK_EXECUTION_SELECTOR;
|
|
278
|
+
functionPermissions[1] = EngineBlox.FunctionPermission({
|
|
279
|
+
functionSelector: APPROVE_TIMELOCK_EXECUTION_SELECTOR,
|
|
280
|
+
grantedActionsBitmap: EngineBlox.createBitmapFromActions(ownerTimeLockApproveActions),
|
|
281
|
+
handlerForSelectors: handlerForSelectors1 // Self-reference indicates execution selector
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// Owner: Cancel TimeLock Execution
|
|
285
|
+
roleHashes[2] = EngineBlox.OWNER_ROLE;
|
|
286
|
+
bytes4[] memory handlerForSelectors2 = new bytes4[](1);
|
|
287
|
+
handlerForSelectors2[0] = CANCEL_TIMELOCK_EXECUTION_SELECTOR;
|
|
288
|
+
functionPermissions[2] = EngineBlox.FunctionPermission({
|
|
289
|
+
functionSelector: CANCEL_TIMELOCK_EXECUTION_SELECTOR,
|
|
290
|
+
grantedActionsBitmap: EngineBlox.createBitmapFromActions(ownerTimeLockCancelActions),
|
|
291
|
+
handlerForSelectors: handlerForSelectors2 // Self-reference indicates execution selector
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// Owner: Request And Approve Execution (Meta-Tx)
|
|
295
|
+
roleHashes[3] = EngineBlox.OWNER_ROLE;
|
|
296
|
+
bytes4[] memory handlerForSelectors3 = new bytes4[](1);
|
|
297
|
+
handlerForSelectors3[0] = REQUEST_AND_APPROVE_EXECUTION_SELECTOR;
|
|
298
|
+
functionPermissions[3] = EngineBlox.FunctionPermission({
|
|
299
|
+
functionSelector: REQUEST_AND_APPROVE_EXECUTION_SELECTOR,
|
|
300
|
+
grantedActionsBitmap: EngineBlox.createBitmapFromActions(ownerMetaTxRequestApproveActions),
|
|
301
|
+
handlerForSelectors: handlerForSelectors3 // Self-reference indicates execution selector
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
// Owner: Approve TimeLock Execution With MetaTx
|
|
305
|
+
roleHashes[4] = EngineBlox.OWNER_ROLE;
|
|
306
|
+
bytes4[] memory handlerForSelectors4 = new bytes4[](1);
|
|
307
|
+
handlerForSelectors4[0] = APPROVE_TIMELOCK_EXECUTION_META_SELECTOR;
|
|
308
|
+
functionPermissions[4] = EngineBlox.FunctionPermission({
|
|
309
|
+
functionSelector: APPROVE_TIMELOCK_EXECUTION_META_SELECTOR,
|
|
310
|
+
grantedActionsBitmap: EngineBlox.createBitmapFromActions(ownerMetaTxApproveActions),
|
|
311
|
+
handlerForSelectors: handlerForSelectors4 // Self-reference indicates execution selector
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// Owner: Cancel TimeLock Execution With MetaTx
|
|
315
|
+
roleHashes[5] = EngineBlox.OWNER_ROLE;
|
|
316
|
+
bytes4[] memory handlerForSelectors5 = new bytes4[](1);
|
|
317
|
+
handlerForSelectors5[0] = CANCEL_TIMELOCK_EXECUTION_META_SELECTOR;
|
|
318
|
+
functionPermissions[5] = EngineBlox.FunctionPermission({
|
|
319
|
+
functionSelector: CANCEL_TIMELOCK_EXECUTION_META_SELECTOR,
|
|
320
|
+
grantedActionsBitmap: EngineBlox.createBitmapFromActions(ownerMetaTxCancelActions),
|
|
321
|
+
handlerForSelectors: handlerForSelectors5 // Self-reference indicates execution selector
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
// Owner: Guard Config Batch (Meta-Tx handler)
|
|
325
|
+
roleHashes[6] = EngineBlox.OWNER_ROLE;
|
|
326
|
+
bytes4[] memory handlerForSelectors6 = new bytes4[](1);
|
|
327
|
+
handlerForSelectors6[0] = GUARD_CONFIG_BATCH_EXECUTE_SELECTOR;
|
|
328
|
+
functionPermissions[6] = EngineBlox.FunctionPermission({
|
|
329
|
+
functionSelector: GUARD_CONFIG_BATCH_META_SELECTOR,
|
|
330
|
+
grantedActionsBitmap: EngineBlox.createBitmapFromActions(ownerMetaTxRequestApproveActions),
|
|
331
|
+
handlerForSelectors: handlerForSelectors6
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// Owner: Guard Config Batch (Execution selector)
|
|
335
|
+
roleHashes[7] = EngineBlox.OWNER_ROLE;
|
|
336
|
+
functionPermissions[7] = EngineBlox.FunctionPermission({
|
|
337
|
+
functionSelector: GUARD_CONFIG_BATCH_EXECUTE_SELECTOR,
|
|
338
|
+
grantedActionsBitmap: EngineBlox.createBitmapFromActions(ownerMetaTxRequestApproveActions),
|
|
339
|
+
handlerForSelectors: handlerForSelectors6 // Self-reference indicates execution selector
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
// Broadcaster role permissions (5 entries)
|
|
343
|
+
EngineBlox.TxAction[] memory broadcasterMetaTxRequestApproveActions = new EngineBlox.TxAction[](1);
|
|
344
|
+
broadcasterMetaTxRequestApproveActions[0] = EngineBlox.TxAction.EXECUTE_META_REQUEST_AND_APPROVE;
|
|
345
|
+
|
|
346
|
+
EngineBlox.TxAction[] memory broadcasterMetaTxApproveActions = new EngineBlox.TxAction[](1);
|
|
347
|
+
broadcasterMetaTxApproveActions[0] = EngineBlox.TxAction.EXECUTE_META_APPROVE;
|
|
348
|
+
|
|
349
|
+
EngineBlox.TxAction[] memory broadcasterMetaTxCancelActions = new EngineBlox.TxAction[](1);
|
|
350
|
+
broadcasterMetaTxCancelActions[0] = EngineBlox.TxAction.EXECUTE_META_CANCEL;
|
|
351
|
+
|
|
352
|
+
// Broadcaster: Request And Approve Execution (Meta-Tx)
|
|
353
|
+
roleHashes[8] = EngineBlox.BROADCASTER_ROLE;
|
|
354
|
+
bytes4[] memory handlerForSelectors8 = new bytes4[](1);
|
|
355
|
+
handlerForSelectors8[0] = REQUEST_AND_APPROVE_EXECUTION_SELECTOR;
|
|
356
|
+
functionPermissions[8] = EngineBlox.FunctionPermission({
|
|
357
|
+
functionSelector: REQUEST_AND_APPROVE_EXECUTION_SELECTOR,
|
|
358
|
+
grantedActionsBitmap: EngineBlox.createBitmapFromActions(broadcasterMetaTxRequestApproveActions),
|
|
359
|
+
handlerForSelectors: handlerForSelectors8 // Self-reference indicates execution selector
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
// Broadcaster: Approve TimeLock Execution With MetaTx
|
|
363
|
+
roleHashes[9] = EngineBlox.BROADCASTER_ROLE;
|
|
364
|
+
functionPermissions[9] = EngineBlox.FunctionPermission({
|
|
365
|
+
functionSelector: APPROVE_TIMELOCK_EXECUTION_META_SELECTOR,
|
|
366
|
+
grantedActionsBitmap: EngineBlox.createBitmapFromActions(broadcasterMetaTxApproveActions),
|
|
367
|
+
handlerForSelectors: handlerForSelectors4 // Self-reference indicates execution selector
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
// Broadcaster: Cancel TimeLock Execution With MetaTx
|
|
371
|
+
roleHashes[10] = EngineBlox.BROADCASTER_ROLE;
|
|
372
|
+
bytes4[] memory handlerForSelectors10 = new bytes4[](1);
|
|
373
|
+
handlerForSelectors10[0] = CANCEL_TIMELOCK_EXECUTION_META_SELECTOR;
|
|
374
|
+
functionPermissions[10] = EngineBlox.FunctionPermission({
|
|
375
|
+
functionSelector: CANCEL_TIMELOCK_EXECUTION_META_SELECTOR,
|
|
376
|
+
grantedActionsBitmap: EngineBlox.createBitmapFromActions(broadcasterMetaTxCancelActions),
|
|
377
|
+
handlerForSelectors: handlerForSelectors10 // Self-reference indicates execution selector
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
// Broadcaster: Guard Config Batch (Meta-Tx handler)
|
|
381
|
+
roleHashes[11] = EngineBlox.BROADCASTER_ROLE;
|
|
382
|
+
functionPermissions[11] = EngineBlox.FunctionPermission({
|
|
383
|
+
functionSelector: GUARD_CONFIG_BATCH_META_SELECTOR,
|
|
384
|
+
grantedActionsBitmap: EngineBlox.createBitmapFromActions(broadcasterMetaTxRequestApproveActions),
|
|
385
|
+
handlerForSelectors: handlerForSelectors6
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
// Broadcaster: Guard Config Batch (Execution selector)
|
|
389
|
+
roleHashes[12] = EngineBlox.BROADCASTER_ROLE;
|
|
390
|
+
functionPermissions[12] = EngineBlox.FunctionPermission({
|
|
391
|
+
functionSelector: GUARD_CONFIG_BATCH_EXECUTE_SELECTOR,
|
|
392
|
+
grantedActionsBitmap: EngineBlox.createBitmapFromActions(broadcasterMetaTxRequestApproveActions),
|
|
393
|
+
handlerForSelectors: handlerForSelectors6 // Self-reference indicates execution selector
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
return IDefinition.RolePermission({
|
|
397
|
+
roleHashes: roleHashes,
|
|
398
|
+
functionPermissions: functionPermissions
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
}
|