@bloxchain/contracts 1.0.0-alpha.2 → 1.0.0-alpha.20

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.
Files changed (42) hide show
  1. package/README.md +7 -7
  2. package/abi/BaseStateMachine.abi.json +85 -45
  3. package/abi/EngineBlox.abi.json +73 -90
  4. package/abi/GuardController.abi.json +252 -806
  5. package/abi/{SimpleVaultDefinitions.abi.json → GuardControllerDefinitions.abi.json} +170 -28
  6. package/abi/IDefinition.abi.json +5 -0
  7. package/abi/RuntimeRBAC.abi.json +155 -218
  8. package/abi/RuntimeRBACDefinitions.abi.json +179 -0
  9. package/abi/SecureOwnable.abi.json +524 -1621
  10. package/abi/SecureOwnableDefinitions.abi.json +5 -0
  11. package/components/README.md +8 -0
  12. package/core/access/RuntimeRBAC.sol +255 -270
  13. package/core/access/interface/IRuntimeRBAC.sol +55 -84
  14. package/core/access/lib/definitions/RuntimeRBACDefinitions.sol +93 -2
  15. package/core/base/BaseStateMachine.sol +193 -107
  16. package/core/base/interface/IBaseStateMachine.sol +153 -153
  17. package/core/execution/GuardController.sol +155 -131
  18. package/core/execution/interface/IGuardController.sol +146 -120
  19. package/core/execution/lib/definitions/GuardControllerDefinitions.sol +193 -43
  20. package/core/lib/EngineBlox.sol +2683 -2322
  21. package/{interfaces → core/lib/interfaces}/IDefinition.sol +49 -49
  22. package/{interfaces → core/lib/interfaces}/IEventForwarder.sol +33 -33
  23. package/{utils → core/lib/utils}/SharedValidation.sol +61 -8
  24. package/core/pattern/Account.sol +84 -0
  25. package/core/security/SecureOwnable.sol +456 -412
  26. package/core/security/interface/ISecureOwnable.sol +105 -104
  27. package/core/security/lib/definitions/SecureOwnableDefinitions.sol +22 -6
  28. package/package.json +5 -5
  29. package/standards/README.md +12 -0
  30. package/standards/behavior/ICopyable.sol +34 -0
  31. package/standards/hooks/IOnActionHook.sol +21 -0
  32. package/abi/AccountBlox.abi.json +0 -5799
  33. package/abi/BareBlox.abi.json +0 -1284
  34. package/abi/RoleBlox.abi.json +0 -4209
  35. package/abi/SecureBlox.abi.json +0 -3828
  36. package/abi/SimpleRWA20.abi.json +0 -5288
  37. package/abi/SimpleRWA20Definitions.abi.json +0 -191
  38. package/abi/SimpleVault.abi.json +0 -4951
  39. package/core/research/BloxchainWallet.sol +0 -306
  40. package/core/research/erc20-blox/ERC20Blox.sol +0 -140
  41. package/core/research/erc20-blox/lib/definitions/ERC20BloxDefinitions.sol +0 -185
  42. package/interfaces/IOnActionHook.sol +0 -79
@@ -1,120 +1,146 @@
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
-
1
+ // SPDX-License-Identifier: MPL-2.0
2
+ pragma solidity 0.8.34;
3
+
4
+ import "../../lib/EngineBlox.sol";
5
+
6
+ /**
7
+ * @title IGuardController
8
+ * @dev Interface for GuardController contract that AccountBlox and other contracts delegate to
9
+ * @notice This interface defines only GuardController-specific methods
10
+ * @notice Functions from BaseStateMachine (createMetaTxParams, generateUnsignedMetaTransaction*, getTransaction, getFunctionSchema, owner, getBroadcasters, getRecovery) should be accessed via IBaseStateMachine
11
+ * @notice Functions from RuntimeRBAC (role management: createNewRole, addWalletToRole, revokeWallet, etc.) should be accessed via IRuntimeRBAC. Function schema registration is performed via GuardController (guard config batch), not RuntimeRBAC.
12
+ * @custom:security-contact security@particlecrypto.com
13
+ */
14
+ interface IGuardController {
15
+ /**
16
+ * @dev Action types for batched Guard configuration
17
+ */
18
+ enum GuardConfigActionType {
19
+ ADD_TARGET_TO_WHITELIST,
20
+ REMOVE_TARGET_FROM_WHITELIST,
21
+ REGISTER_FUNCTION,
22
+ UNREGISTER_FUNCTION
23
+ }
24
+
25
+ /**
26
+ * @dev Encodes a single Guard configuration action in a batch
27
+ */
28
+ struct GuardConfigAction {
29
+ GuardConfigActionType actionType;
30
+ bytes data;
31
+ }
32
+
33
+ /**
34
+ * @notice Initializer to initialize GuardController
35
+ * @param initialOwner The initial owner address
36
+ * @param broadcaster The broadcaster address
37
+ * @param recovery The recovery address
38
+ * @param timeLockPeriodSec The timelock period in seconds
39
+ * @param eventForwarder The event forwarder address
40
+ */
41
+ function initialize(
42
+ address initialOwner,
43
+ address broadcaster,
44
+ address recovery,
45
+ uint256 timeLockPeriodSec,
46
+ address eventForwarder
47
+ ) external;
48
+
49
+ /**
50
+ * @dev Requests a time-locked execution via EngineBlox workflow
51
+ * @param target The address of the target contract
52
+ * @param value The ETH value to send (0 for standard function calls)
53
+ * @param functionSelector The function selector to execute (0x00000000 for simple ETH transfers)
54
+ * @param params The encoded parameters for the function (empty for simple ETH transfers)
55
+ * @param gasLimit The gas limit for execution
56
+ * @param operationType The operation type hash
57
+ * @return txId The transaction ID for the requested operation
58
+ * @notice Creates a time-locked transaction that must be approved after the timelock period
59
+ * @notice Requires EXECUTE_TIME_DELAY_REQUEST permission for the function selector
60
+ * @notice For standard function calls: value=0, functionSelector=non-zero, params=encoded data
61
+ * @notice For simple ETH transfers: value>0, functionSelector=0x00000000, params=""
62
+ */
63
+ function executeWithTimeLock(
64
+ address target,
65
+ uint256 value,
66
+ bytes4 functionSelector,
67
+ bytes memory params,
68
+ uint256 gasLimit,
69
+ bytes32 operationType
70
+ ) external returns (uint256 txId);
71
+
72
+ /**
73
+ * @dev Requests a time-locked execution with payment details attached (same permissions as executeWithTimeLock)
74
+ * @param target The address of the target contract
75
+ * @param value The ETH value to send (0 for standard function calls)
76
+ * @param functionSelector The function selector to execute (NATIVE_TRANSFER_SELECTOR for simple native token transfers)
77
+ * @param params The encoded parameters for the function (empty for simple native token transfers)
78
+ * @param gasLimit The gas limit for execution
79
+ * @param operationType The operation type hash
80
+ * @param paymentDetails The payment details to attach to the transaction
81
+ * @return txId The transaction ID for the requested operation (use getTransaction(txId) for full record)
82
+ * @notice Reuses EXECUTE_TIME_DELAY_REQUEST permission; approval/cancel same as executeWithTimeLock
83
+ */
84
+ function executeWithPayment(
85
+ address target,
86
+ uint256 value,
87
+ bytes4 functionSelector,
88
+ bytes memory params,
89
+ uint256 gasLimit,
90
+ bytes32 operationType,
91
+ EngineBlox.PaymentDetails memory paymentDetails
92
+ ) external returns (uint256 txId);
93
+
94
+ /**
95
+ * @dev Approves and executes a time-locked transaction
96
+ * @param txId The transaction ID
97
+ * @return txId The transaction ID (use getTransaction(txId) for full record and result)
98
+ * @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_APPROVE permission for the execution function
99
+ */
100
+ function approveTimeLockExecution(
101
+ uint256 txId
102
+ ) external returns (uint256);
103
+
104
+ /**
105
+ * @dev Cancels a time-locked transaction
106
+ * @param txId The transaction ID
107
+ * @return txId The transaction ID (use getTransaction(txId) for full record)
108
+ * @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_CANCEL permission for the execution function
109
+ */
110
+ function cancelTimeLockExecution(
111
+ uint256 txId
112
+ ) external returns (uint256);
113
+
114
+ /**
115
+ * @dev Approves a time-locked transaction using a meta-transaction
116
+ * @param metaTx The meta-transaction containing the transaction record and signature
117
+ * @return The transaction ID (use getTransaction(txId) for full record)
118
+ * @notice Requires STANDARD execution type and EXECUTE_META_APPROVE permission for the execution function
119
+ */
120
+ function approveTimeLockExecutionWithMetaTx(
121
+ EngineBlox.MetaTransaction memory metaTx
122
+ ) external returns (uint256);
123
+
124
+ /**
125
+ * @dev Cancels a time-locked transaction using a meta-transaction
126
+ * @param metaTx The meta-transaction containing the transaction record and signature
127
+ * @return The transaction ID (use getTransaction(txId) for full record)
128
+ * @notice Requires STANDARD execution type and EXECUTE_META_CANCEL permission for the execution function
129
+ */
130
+ function cancelTimeLockExecutionWithMetaTx(
131
+ EngineBlox.MetaTransaction memory metaTx
132
+ ) external returns (uint256);
133
+
134
+ /**
135
+ * @dev Requests and approves a transaction in one step using a meta-transaction
136
+ * @param metaTx The meta-transaction containing the transaction record and signature
137
+ * @return The transaction ID (use getTransaction(txId) for full record)
138
+ * @notice Requires STANDARD execution type
139
+ * @notice Validates function schema and permissions for the execution function (same as executeWithTimeLock)
140
+ * @notice Requires EXECUTE_META_REQUEST_AND_APPROVE permission for the execution function selector
141
+ */
142
+ function requestAndApproveExecution(
143
+ EngineBlox.MetaTransaction memory metaTx
144
+ ) external returns (uint256);
145
+ }
146
+
@@ -1,9 +1,10 @@
1
1
  // SPDX-License-Identifier: MPL-2.0
2
- pragma solidity 0.8.33;
2
+ pragma solidity 0.8.34;
3
3
 
4
4
  import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5
5
  import "../../../lib/EngineBlox.sol";
6
- import "../../../../interfaces/IDefinition.sol";
6
+ import "../../../lib/interfaces/IDefinition.sol";
7
+ import "../../interface/IGuardController.sol";
7
8
 
8
9
  /**
9
10
  * @title GuardControllerDefinitions
@@ -15,7 +16,7 @@ import "../../../../interfaces/IDefinition.sol";
15
16
  * and role permissions for GuardController's public execution functions.
16
17
  *
17
18
  * Key Features:
18
- * - Registers all 6 GuardController public execution functions
19
+ * - Registers all 9 GuardController public execution functions plus 3 attached-payment policy schemas
19
20
  * - Defines role permissions for OWNER_ROLE and BROADCASTER_ROLE
20
21
  * - Supports time-delay and meta-transaction workflows
21
22
  * - Matches EngineBloxDefinitions pattern for consistency
@@ -32,10 +33,15 @@ library GuardControllerDefinitions {
32
33
 
33
34
  // Operation Type Constants
34
35
  bytes32 public constant CONTROLLER_OPERATION = keccak256("CONTROLLER_OPERATION");
36
+ // Guard config batch only (whitelist / register-unregister function); distinct execution operation type bitmap.
37
+ bytes32 public constant CONTROLLER_CONFIG_BATCH = keccak256("CONTROLLER_CONFIG_BATCH");
35
38
 
36
39
  // Function Selector Constants
37
- // GuardController: executeWithTimeLock(address,bytes4,bytes,uint256,bytes32)
38
- bytes4 public constant EXECUTE_WITH_TIMELOCK_SELECTOR = bytes4(keccak256("executeWithTimeLock(address,bytes4,bytes,uint256,bytes32)"));
40
+ // GuardController: executeWithTimeLock(address,uint256,bytes4,bytes,uint256,bytes32)
41
+ bytes4 public constant EXECUTE_WITH_TIMELOCK_SELECTOR = bytes4(keccak256("executeWithTimeLock(address,uint256,bytes4,bytes,uint256,bytes32)"));
42
+
43
+ // GuardController: executeWithPayment(address,uint256,bytes4,bytes,uint256,bytes32,(address,uint256,address,uint256))
44
+ bytes4 public constant EXECUTE_WITH_PAYMENT_SELECTOR = bytes4(keccak256("executeWithPayment(address,uint256,bytes4,bytes,uint256,bytes32,(address,uint256,address,uint256))"));
39
45
 
40
46
  // GuardController: approveTimeLockExecution(uint256)
41
47
  bytes4 public constant APPROVE_TIMELOCK_EXECUTION_SELECTOR = bytes4(keccak256("approveTimeLockExecution(uint256)"));
@@ -43,14 +49,27 @@ library GuardControllerDefinitions {
43
49
  // GuardController: cancelTimeLockExecution(uint256)
44
50
  bytes4 public constant CANCEL_TIMELOCK_EXECUTION_SELECTOR = bytes4(keccak256("cancelTimeLockExecution(uint256)"));
45
51
 
46
- // GuardController: approveTimeLockExecutionWithMetaTx(...)
47
- 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))"));
52
+
53
+ // GuardController: approveTimeLockExecutionWithMetaTx(EngineBlox.MetaTransaction)
54
+ bytes4 public constant APPROVE_TIMELOCK_EXECUTION_META_SELECTOR = bytes4(
55
+ keccak256(
56
+ "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))"
57
+ )
58
+ );
48
59
 
49
- // GuardController: cancelTimeLockExecutionWithMetaTx(...)
50
- 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))"));
60
+ // GuardController: cancelTimeLockExecutionWithMetaTx(EngineBlox.MetaTransaction)
61
+ bytes4 public constant CANCEL_TIMELOCK_EXECUTION_META_SELECTOR = bytes4(
62
+ keccak256(
63
+ "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))"
64
+ )
65
+ );
51
66
 
52
- // GuardController: requestAndApproveExecution(...)
53
- 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))"));
67
+ // GuardController: requestAndApproveExecution(EngineBlox.MetaTransaction)
68
+ bytes4 public constant REQUEST_AND_APPROVE_EXECUTION_SELECTOR = bytes4(
69
+ keccak256(
70
+ "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))"
71
+ )
72
+ );
54
73
 
55
74
  // GuardController: guardConfigBatchRequestAndApprove(...)
56
75
  bytes4 public constant GUARD_CONFIG_BATCH_META_SELECTOR = bytes4(
@@ -64,30 +83,12 @@ library GuardControllerDefinitions {
64
83
  bytes4(keccak256("executeGuardConfigBatch((uint8,bytes)[])"));
65
84
 
66
85
  /**
67
- * @dev Action types for batched Guard configuration (matches GuardController for encoding)
68
- */
69
- enum GuardConfigActionType {
70
- ADD_TARGET_TO_WHITELIST,
71
- REMOVE_TARGET_FROM_WHITELIST,
72
- REGISTER_FUNCTION,
73
- UNREGISTER_FUNCTION
74
- }
75
-
76
- /**
77
- * @dev Encodes a single Guard configuration action in a batch (matches GuardController for encoding)
78
- */
79
- struct GuardConfigAction {
80
- GuardConfigActionType actionType;
81
- bytes data;
82
- }
83
-
84
- /**
85
- * @dev Returns predefined function schemas for GuardController execution functions
86
- * @return Array of function schema definitions
86
+ * @dev Returns predefined function schemas for GuardController execution functions and attached-payment policy keys
87
+ * @return Array of function schema definitions (12 entries: 9 controller surfaces + 3 payment whitelist selectors)
87
88
  *
88
89
  * Function schemas define:
89
90
  * - GuardController public execution functions
90
- * - What operation types they belong to (CONTROLLER_OPERATION)
91
+ * - What operation types they belong to (CONTROLLER_OPERATION vs CONTROLLER_CONFIG_BATCH)
91
92
  * - What actions are supported (time-delay request/approve/cancel, meta-tx approve/cancel/request-and-approve)
92
93
  * - Whether they are protected
93
94
  *
@@ -97,7 +98,7 @@ library GuardControllerDefinitions {
97
98
  * - Role permissions are defined in getRolePermissions() matching EngineBloxDefinitions pattern
98
99
  */
99
100
  function getFunctionSchemas() public pure returns (EngineBlox.FunctionSchema[] memory) {
100
- EngineBlox.FunctionSchema[] memory schemas = new EngineBlox.FunctionSchema[](8);
101
+ EngineBlox.FunctionSchema[] memory schemas = new EngineBlox.FunctionSchema[](12);
101
102
 
102
103
  // ============ TIME-DELAY WORKFLOW ACTIONS ============
103
104
  // Request action for executeWithTimeLock
@@ -145,6 +146,9 @@ library GuardControllerDefinitions {
145
146
  requestAndApproveExecutionHandlerForSelectors[0] = REQUEST_AND_APPROVE_EXECUTION_SELECTOR;
146
147
  bytes4[] memory guardConfigBatchExecuteHandlerForSelectors = new bytes4[](1);
147
148
  guardConfigBatchExecuteHandlerForSelectors[0] = GUARD_CONFIG_BATCH_EXECUTE_SELECTOR;
149
+
150
+ bytes4[] memory executeWithPaymentHandlerForSelectors = new bytes4[](1);
151
+ executeWithPaymentHandlerForSelectors[0] = EXECUTE_WITH_PAYMENT_SELECTOR;
148
152
 
149
153
  // Handler selectors point to execution selectors
150
154
  bytes4[] memory guardConfigHandlerForSelectors = new bytes4[](1);
@@ -152,11 +156,12 @@ library GuardControllerDefinitions {
152
156
 
153
157
  // Schema 0: GuardController.executeWithTimeLock
154
158
  schemas[0] = EngineBlox.FunctionSchema({
155
- functionSignature: "executeWithTimeLock(address,bytes4,bytes,uint256,bytes32)",
159
+ functionSignature: "executeWithTimeLock(address,uint256,bytes4,bytes,uint256,bytes32)",
156
160
  functionSelector: EXECUTE_WITH_TIMELOCK_SELECTOR,
157
161
  operationType: CONTROLLER_OPERATION,
158
162
  operationName: "CONTROLLER_OPERATION",
159
163
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(timeDelayRequestActions),
164
+ enforceHandlerRelations: false,
160
165
  isProtected: true,
161
166
  handlerForSelectors: executeWithTimeLockHandlerForSelectors
162
167
  });
@@ -168,6 +173,7 @@ library GuardControllerDefinitions {
168
173
  operationType: CONTROLLER_OPERATION,
169
174
  operationName: "CONTROLLER_OPERATION",
170
175
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(timeDelayApproveActions),
176
+ enforceHandlerRelations: false,
171
177
  isProtected: true,
172
178
  handlerForSelectors: approveTimeLockExecutionHandlerForSelectors
173
179
  });
@@ -179,39 +185,43 @@ library GuardControllerDefinitions {
179
185
  operationType: CONTROLLER_OPERATION,
180
186
  operationName: "CONTROLLER_OPERATION",
181
187
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(timeDelayCancelActions),
188
+ enforceHandlerRelations: false,
182
189
  isProtected: true,
183
190
  handlerForSelectors: cancelTimeLockExecutionHandlerForSelectors
184
191
  });
185
192
 
186
193
  // Schema 3: GuardController.approveTimeLockExecutionWithMetaTx
187
194
  schemas[3] = EngineBlox.FunctionSchema({
188
- 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))",
195
+ 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))",
189
196
  functionSelector: APPROVE_TIMELOCK_EXECUTION_META_SELECTOR,
190
197
  operationType: CONTROLLER_OPERATION,
191
198
  operationName: "CONTROLLER_OPERATION",
192
199
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxApproveActions),
200
+ enforceHandlerRelations: false,
193
201
  isProtected: true,
194
202
  handlerForSelectors: approveTimeLockExecutionMetaHandlerForSelectors
195
203
  });
196
204
 
197
205
  // Schema 4: GuardController.cancelTimeLockExecutionWithMetaTx
198
206
  schemas[4] = EngineBlox.FunctionSchema({
199
- 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))",
207
+ 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))",
200
208
  functionSelector: CANCEL_TIMELOCK_EXECUTION_META_SELECTOR,
201
209
  operationType: CONTROLLER_OPERATION,
202
210
  operationName: "CONTROLLER_OPERATION",
203
211
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxCancelActions),
212
+ enforceHandlerRelations: false,
204
213
  isProtected: true,
205
214
  handlerForSelectors: cancelTimeLockExecutionMetaHandlerForSelectors
206
215
  });
207
216
 
208
217
  // Schema 5: GuardController.requestAndApproveExecution
209
218
  schemas[5] = EngineBlox.FunctionSchema({
210
- 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))",
219
+ 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))",
211
220
  functionSelector: REQUEST_AND_APPROVE_EXECUTION_SELECTOR,
212
221
  operationType: CONTROLLER_OPERATION,
213
222
  operationName: "CONTROLLER_OPERATION",
214
223
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxRequestApproveActions),
224
+ enforceHandlerRelations: false,
215
225
  isProtected: true,
216
226
  handlerForSelectors: requestAndApproveExecutionHandlerForSelectors
217
227
  });
@@ -220,9 +230,10 @@ library GuardControllerDefinitions {
220
230
  schemas[6] = EngineBlox.FunctionSchema({
221
231
  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))",
222
232
  functionSelector: GUARD_CONFIG_BATCH_META_SELECTOR,
223
- operationType: CONTROLLER_OPERATION,
224
- operationName: "CONTROLLER_OPERATION",
233
+ operationType: CONTROLLER_CONFIG_BATCH,
234
+ operationName: "CONTROLLER_CONFIG_BATCH",
225
235
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxRequestApproveActions),
236
+ enforceHandlerRelations: true,
226
237
  isProtected: true,
227
238
  handlerForSelectors: guardConfigHandlerForSelectors
228
239
  });
@@ -235,13 +246,84 @@ library GuardControllerDefinitions {
235
246
  schemas[7] = EngineBlox.FunctionSchema({
236
247
  functionSignature: "executeGuardConfigBatch((uint8,bytes)[])",
237
248
  functionSelector: GUARD_CONFIG_BATCH_EXECUTE_SELECTOR,
238
- operationType: CONTROLLER_OPERATION,
239
- operationName: "CONTROLLER_OPERATION",
249
+ operationType: CONTROLLER_CONFIG_BATCH,
250
+ operationName: "CONTROLLER_CONFIG_BATCH",
240
251
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(guardConfigExecutionActions),
252
+ enforceHandlerRelations: false,
241
253
  isProtected: true,
242
254
  handlerForSelectors: guardConfigBatchExecuteHandlerForSelectors
243
255
  });
244
256
 
257
+ // Schema 8: GuardController.executeWithPayment (same time-delay request action as executeWithTimeLock).
258
+ // Default definitions intentionally omit an OWNER_ROLE FunctionPermission for this selector (minimal surface).
259
+ // `getGuardConfigActionSpecs()` only exposes whitelist add/remove, REGISTER_FUNCTION, and UNREGISTER_FUNCTION —
260
+ // there is no guard-config action to attach `executeWithPayment` to a role. Deployments that need owner-driven
261
+ // `executeWithPayment` must add the FunctionPermission via an RBAC batch (`ADD_FUNCTION_TO_ROLE` / encoders in
262
+ // `RuntimeRBACDefinitions.sol`), following that file's ordering and action constraints and the handler/schema
263
+ // rules in this `GuardControllerDefinitions.sol` bundle.
264
+ schemas[8] = EngineBlox.FunctionSchema({
265
+ functionSignature: "executeWithPayment(address,uint256,bytes4,bytes,uint256,bytes32,(address,uint256,address,uint256))",
266
+ functionSelector: EXECUTE_WITH_PAYMENT_SELECTOR,
267
+ operationType: CONTROLLER_OPERATION,
268
+ operationName: "CONTROLLER_OPERATION",
269
+ supportedActionsBitmap: EngineBlox.createBitmapFromActions(timeDelayRequestActions),
270
+ enforceHandlerRelations: false,
271
+ isProtected: true,
272
+ handlerForSelectors: executeWithPaymentHandlerForSelectors
273
+ });
274
+
275
+ // Policy-only schemas for `executeWithPayment` whitelist keys; bitmap = all TxActions so roles may grant any action if needed.
276
+ EngineBlox.TxAction[] memory allTxActions = new EngineBlox.TxAction[](9);
277
+ allTxActions[0] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_REQUEST;
278
+ allTxActions[1] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_APPROVE;
279
+ allTxActions[2] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_CANCEL;
280
+ allTxActions[3] = EngineBlox.TxAction.SIGN_META_REQUEST_AND_APPROVE;
281
+ allTxActions[4] = EngineBlox.TxAction.SIGN_META_APPROVE;
282
+ allTxActions[5] = EngineBlox.TxAction.SIGN_META_CANCEL;
283
+ allTxActions[6] = EngineBlox.TxAction.EXECUTE_META_REQUEST_AND_APPROVE;
284
+ allTxActions[7] = EngineBlox.TxAction.EXECUTE_META_APPROVE;
285
+ allTxActions[8] = EngineBlox.TxAction.EXECUTE_META_CANCEL;
286
+ uint16 allActionsBitmap = EngineBlox.createBitmapFromActions(allTxActions);
287
+
288
+ bytes4[] memory attachedPaymentRecipientHandlers = new bytes4[](1);
289
+ attachedPaymentRecipientHandlers[0] = EngineBlox.ATTACHED_PAYMENT_RECIPIENT_SELECTOR;
290
+ schemas[9] = EngineBlox.FunctionSchema({
291
+ functionSignature: "__bloxchain_attached_payment_recipient__()",
292
+ functionSelector: EngineBlox.ATTACHED_PAYMENT_RECIPIENT_SELECTOR,
293
+ operationType: keccak256(bytes("ATTACHED_PAYMENT_RECIPIENT")),
294
+ operationName: "ATTACHED_PAYMENT_RECIPIENT",
295
+ supportedActionsBitmap: allActionsBitmap,
296
+ enforceHandlerRelations: false,
297
+ isProtected: true,
298
+ handlerForSelectors: attachedPaymentRecipientHandlers
299
+ });
300
+
301
+ bytes4[] memory nativeTransferHandlers = new bytes4[](1);
302
+ nativeTransferHandlers[0] = EngineBlox.NATIVE_TRANSFER_SELECTOR;
303
+ schemas[10] = EngineBlox.FunctionSchema({
304
+ functionSignature: "__bloxchain_native_transfer__()",
305
+ functionSelector: EngineBlox.NATIVE_TRANSFER_SELECTOR,
306
+ operationType: keccak256(bytes("NATIVE_TRANSFER")),
307
+ operationName: "NATIVE_TRANSFER",
308
+ supportedActionsBitmap: allActionsBitmap,
309
+ enforceHandlerRelations: false,
310
+ isProtected: true,
311
+ handlerForSelectors: nativeTransferHandlers
312
+ });
313
+
314
+ bytes4[] memory erc20TransferHandlers = new bytes4[](1);
315
+ erc20TransferHandlers[0] = EngineBlox.ERC20_TRANSFER_SELECTOR;
316
+ schemas[11] = EngineBlox.FunctionSchema({
317
+ functionSignature: "transfer(address,uint256)",
318
+ functionSelector: EngineBlox.ERC20_TRANSFER_SELECTOR,
319
+ operationType: keccak256(bytes("ERC20_TRANSFER")),
320
+ operationName: "ERC20_TRANSFER",
321
+ supportedActionsBitmap: allActionsBitmap,
322
+ enforceHandlerRelations: false,
323
+ isProtected: true,
324
+ handlerForSelectors: erc20TransferHandlers
325
+ });
326
+
245
327
  return schemas;
246
328
  }
247
329
 
@@ -418,13 +500,81 @@ library GuardControllerDefinitions {
418
500
  });
419
501
  }
420
502
 
503
+ /**
504
+ * @dev Returns all available GuardConfig action types and their decode formats for discovery.
505
+ * @return actionNames Human-readable action names (same order as GuardConfigActionType enum)
506
+ * @return formats ABI decode format for each action's data, e.g. "(bytes4 functionSelector, address target)"
507
+ * @notice Use with GuardConfigActionType enum: actionNames[i] and formats[i] describe enum value i
508
+ */
509
+ function getGuardConfigActionSpecs() public pure returns (string[] memory actionNames, string[] memory formats) {
510
+ actionNames = new string[](4);
511
+ formats = new string[](4);
512
+
513
+ actionNames[0] = "ADD_TARGET_TO_WHITELIST";
514
+ formats[0] = "(bytes4 functionSelector, address target)";
515
+
516
+ actionNames[1] = "REMOVE_TARGET_FROM_WHITELIST";
517
+ formats[1] = "(bytes4 functionSelector, address target)";
518
+
519
+ actionNames[2] = "REGISTER_FUNCTION";
520
+ formats[2] = "(string functionSignature, string operationName, TxAction[] supportedActions)";
521
+
522
+ actionNames[3] = "UNREGISTER_FUNCTION";
523
+ formats[3] = "(bytes4 functionSelector, bool safeRemoval)";
524
+ }
525
+
526
+ // ============ GUARD CONFIG ACTION DATA ENCODERS ============
527
+ // Use these helpers to build action.data for each GuardConfigActionType without reading the contract.
528
+ // Each encoder returns bytes suitable for GuardConfigAction(actionType, data).
529
+
530
+ /**
531
+ * @dev Encodes data for ADD_TARGET_TO_WHITELIST. Use with GuardConfigActionType.ADD_TARGET_TO_WHITELIST.
532
+ * @param functionSelector Function whose whitelist is updated
533
+ * @param target Address to add to the whitelist
534
+ */
535
+ function encodeAddTargetToWhitelist(bytes4 functionSelector, address target) public pure returns (bytes memory) {
536
+ return abi.encode(functionSelector, target);
537
+ }
538
+
539
+ /**
540
+ * @dev Encodes data for REMOVE_TARGET_FROM_WHITELIST. Use with GuardConfigActionType.REMOVE_TARGET_FROM_WHITELIST.
541
+ * @param functionSelector Function whose whitelist is updated
542
+ * @param target Address to remove from the whitelist
543
+ */
544
+ function encodeRemoveTargetFromWhitelist(bytes4 functionSelector, address target) public pure returns (bytes memory) {
545
+ return abi.encode(functionSelector, target);
546
+ }
547
+
548
+ /**
549
+ * @dev Encodes data for REGISTER_FUNCTION. Use with GuardConfigActionType.REGISTER_FUNCTION.
550
+ * @param functionSignature Full function signature string (e.g. "executeWithTimeLock(address,bytes4,bytes,uint256,bytes32)")
551
+ * @param operationName Human-readable operation name
552
+ * @param supportedActions TxActions supported by this function (e.g. EXECUTE_TIME_DELAY_REQUEST)
553
+ */
554
+ function encodeRegisterFunction(
555
+ string memory functionSignature,
556
+ string memory operationName,
557
+ EngineBlox.TxAction[] memory supportedActions
558
+ ) public pure returns (bytes memory) {
559
+ return abi.encode(functionSignature, operationName, supportedActions);
560
+ }
561
+
562
+ /**
563
+ * @dev Encodes data for UNREGISTER_FUNCTION. Use with GuardConfigActionType.UNREGISTER_FUNCTION.
564
+ * @param functionSelector Selector of the function to unregister
565
+ * @param safeRemoval If true, `EngineBlox.unregisterFunction` reverts when **any role** still lists this selector (not a whitelist-emptiness check; whitelist/hook entries may remain).
566
+ */
567
+ function encodeUnregisterFunction(bytes4 functionSelector, bool safeRemoval) public pure returns (bytes memory) {
568
+ return abi.encode(functionSelector, safeRemoval);
569
+ }
570
+
421
571
  /**
422
572
  * @dev Creates execution params for a Guard configuration batch (pure helper for EngineBlox).
423
- * @param actions Encoded guard configuration actions (same layout as GuardControllerDefinitions.GuardConfigAction[])
573
+ * @param actions Encoded guard configuration actions (same layout as IGuardController.GuardConfigAction[])
424
574
  * @return The execution params for EngineBlox
425
575
  */
426
576
  function guardConfigBatchExecutionParams(
427
- GuardConfigAction[] memory actions
577
+ IGuardController.GuardConfigAction[] memory actions
428
578
  ) public pure returns (bytes memory) {
429
579
  return abi.encode(actions);
430
580
  }