@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.
Files changed (43) hide show
  1. package/README.md +7 -7
  2. package/abi/BaseStateMachine.abi.json +798 -753
  3. package/abi/EngineBlox.abi.json +566 -576
  4. package/abi/GuardController.abi.json +1546 -2095
  5. package/abi/GuardControllerDefinitions.abi.json +416 -0
  6. package/abi/IDefinition.abi.json +57 -47
  7. package/abi/RuntimeRBAC.abi.json +901 -959
  8. package/abi/RuntimeRBACDefinitions.abi.json +265 -81
  9. package/abi/SecureOwnable.abi.json +1522 -2581
  10. package/abi/SecureOwnableDefinitions.abi.json +174 -164
  11. package/components/README.md +8 -0
  12. package/core/access/RuntimeRBAC.sol +253 -270
  13. package/core/access/interface/IRuntimeRBAC.sol +55 -84
  14. package/core/access/lib/definitions/RuntimeRBACDefinitions.sol +97 -4
  15. package/core/base/BaseStateMachine.sol +198 -108
  16. package/core/base/interface/IBaseStateMachine.sol +153 -153
  17. package/core/execution/GuardController.sol +156 -131
  18. package/core/execution/interface/IGuardController.sol +146 -120
  19. package/core/execution/lib/definitions/GuardControllerDefinitions.sol +207 -45
  20. package/core/lib/EngineBlox.sol +2636 -2322
  21. package/{interfaces → core/lib/interfaces}/IDefinition.sol +49 -49
  22. package/{interfaces → core/lib/interfaces}/IEventForwarder.sol +5 -3
  23. package/{utils → core/lib/utils}/SharedValidation.sol +69 -22
  24. package/core/pattern/Account.sol +84 -0
  25. package/core/security/SecureOwnable.sol +180 -146
  26. package/core/security/interface/ISecureOwnable.sol +105 -104
  27. package/core/security/lib/definitions/SecureOwnableDefinitions.sol +818 -786
  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/abi/SimpleVaultDefinitions.abi.json +0 -269
  40. package/core/research/BloxchainWallet.sol +0 -306
  41. package/core/research/erc20-blox/ERC20Blox.sol +0 -140
  42. package/core/research/erc20-blox/lib/definitions/ERC20BloxDefinitions.sol +0 -185
  43. package/interfaces/IOnActionHook.sol +0 -79
@@ -1,9 +1,10 @@
1
1
  // SPDX-License-Identifier: MPL-2.0
2
- pragma solidity 0.8.33;
2
+ pragma solidity 0.8.35;
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,19 +49,32 @@ 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,bytes32,(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,bytes32,(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,bytes32,(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(
57
76
  keccak256(
58
- "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))"
77
+ "guardConfigBatchRequestAndApprove(((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes32,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))"
59
78
  )
60
79
  );
61
80
 
@@ -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,12 +156,14 @@ 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,
166
+ isGrantRevocable: false,
161
167
  handlerForSelectors: executeWithTimeLockHandlerForSelectors
162
168
  });
163
169
 
@@ -168,7 +174,9 @@ library GuardControllerDefinitions {
168
174
  operationType: CONTROLLER_OPERATION,
169
175
  operationName: "CONTROLLER_OPERATION",
170
176
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(timeDelayApproveActions),
177
+ enforceHandlerRelations: false,
171
178
  isProtected: true,
179
+ isGrantRevocable: false,
172
180
  handlerForSelectors: approveTimeLockExecutionHandlerForSelectors
173
181
  });
174
182
 
@@ -179,51 +187,61 @@ library GuardControllerDefinitions {
179
187
  operationType: CONTROLLER_OPERATION,
180
188
  operationName: "CONTROLLER_OPERATION",
181
189
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(timeDelayCancelActions),
190
+ enforceHandlerRelations: false,
182
191
  isProtected: true,
192
+ isGrantRevocable: false,
183
193
  handlerForSelectors: cancelTimeLockExecutionHandlerForSelectors
184
194
  });
185
195
 
186
196
  // Schema 3: GuardController.approveTimeLockExecutionWithMetaTx
187
197
  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))",
198
+ functionSignature: "approveTimeLockExecutionWithMetaTx(((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes32,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))",
189
199
  functionSelector: APPROVE_TIMELOCK_EXECUTION_META_SELECTOR,
190
200
  operationType: CONTROLLER_OPERATION,
191
201
  operationName: "CONTROLLER_OPERATION",
192
202
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxApproveActions),
203
+ enforceHandlerRelations: false,
193
204
  isProtected: true,
205
+ isGrantRevocable: false,
194
206
  handlerForSelectors: approveTimeLockExecutionMetaHandlerForSelectors
195
207
  });
196
208
 
197
209
  // Schema 4: GuardController.cancelTimeLockExecutionWithMetaTx
198
210
  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))",
211
+ functionSignature: "cancelTimeLockExecutionWithMetaTx(((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes32,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))",
200
212
  functionSelector: CANCEL_TIMELOCK_EXECUTION_META_SELECTOR,
201
213
  operationType: CONTROLLER_OPERATION,
202
214
  operationName: "CONTROLLER_OPERATION",
203
215
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxCancelActions),
216
+ enforceHandlerRelations: false,
204
217
  isProtected: true,
218
+ isGrantRevocable: false,
205
219
  handlerForSelectors: cancelTimeLockExecutionMetaHandlerForSelectors
206
220
  });
207
221
 
208
222
  // Schema 5: GuardController.requestAndApproveExecution
209
223
  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))",
224
+ functionSignature: "requestAndApproveExecution(((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes32,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))",
211
225
  functionSelector: REQUEST_AND_APPROVE_EXECUTION_SELECTOR,
212
226
  operationType: CONTROLLER_OPERATION,
213
227
  operationName: "CONTROLLER_OPERATION",
214
228
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxRequestApproveActions),
229
+ enforceHandlerRelations: false,
215
230
  isProtected: true,
231
+ isGrantRevocable: false,
216
232
  handlerForSelectors: requestAndApproveExecutionHandlerForSelectors
217
233
  });
218
234
 
219
235
  // Schema 6: GuardController.guardConfigBatchRequestAndApprove
220
236
  schemas[6] = EngineBlox.FunctionSchema({
221
- 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))",
237
+ functionSignature: "guardConfigBatchRequestAndApprove(((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes32,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))",
222
238
  functionSelector: GUARD_CONFIG_BATCH_META_SELECTOR,
223
- operationType: CONTROLLER_OPERATION,
224
- operationName: "CONTROLLER_OPERATION",
239
+ operationType: CONTROLLER_CONFIG_BATCH,
240
+ operationName: "CONTROLLER_CONFIG_BATCH",
225
241
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxRequestApproveActions),
242
+ enforceHandlerRelations: true,
226
243
  isProtected: true,
244
+ isGrantRevocable: false,
227
245
  handlerForSelectors: guardConfigHandlerForSelectors
228
246
  });
229
247
 
@@ -235,13 +253,89 @@ library GuardControllerDefinitions {
235
253
  schemas[7] = EngineBlox.FunctionSchema({
236
254
  functionSignature: "executeGuardConfigBatch((uint8,bytes)[])",
237
255
  functionSelector: GUARD_CONFIG_BATCH_EXECUTE_SELECTOR,
238
- operationType: CONTROLLER_OPERATION,
239
- operationName: "CONTROLLER_OPERATION",
256
+ operationType: CONTROLLER_CONFIG_BATCH,
257
+ operationName: "CONTROLLER_CONFIG_BATCH",
240
258
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(guardConfigExecutionActions),
259
+ enforceHandlerRelations: false,
241
260
  isProtected: true,
261
+ isGrantRevocable: false,
242
262
  handlerForSelectors: guardConfigBatchExecuteHandlerForSelectors
243
263
  });
244
264
 
265
+ // Schema 8: GuardController.executeWithPayment (same time-delay request action as executeWithTimeLock).
266
+ // Default definitions intentionally omit an OWNER_ROLE FunctionPermission for this selector (minimal surface).
267
+ // `getGuardConfigActionSpecs()` only exposes whitelist add/remove, REGISTER_FUNCTION, and UNREGISTER_FUNCTION —
268
+ // there is no guard-config action to attach `executeWithPayment` to a role. Deployments that need owner-driven
269
+ // `executeWithPayment` must add the FunctionPermission via an RBAC batch (`ADD_FUNCTION_TO_ROLE` / encoders in
270
+ // `RuntimeRBACDefinitions.sol`), following that file's ordering and action constraints and the handler/schema
271
+ // rules in this `GuardControllerDefinitions.sol` bundle.
272
+ schemas[8] = EngineBlox.FunctionSchema({
273
+ functionSignature: "executeWithPayment(address,uint256,bytes4,bytes,uint256,bytes32,(address,uint256,address,uint256))",
274
+ functionSelector: EXECUTE_WITH_PAYMENT_SELECTOR,
275
+ operationType: CONTROLLER_OPERATION,
276
+ operationName: "CONTROLLER_OPERATION",
277
+ supportedActionsBitmap: EngineBlox.createBitmapFromActions(timeDelayRequestActions),
278
+ enforceHandlerRelations: false,
279
+ isProtected: true,
280
+ isGrantRevocable: false,
281
+ handlerForSelectors: executeWithPaymentHandlerForSelectors
282
+ });
283
+
284
+ // Policy-only schemas for `executeWithPayment` whitelist keys; bitmap = all TxActions so roles may grant any action if needed.
285
+ EngineBlox.TxAction[] memory allTxActions = new EngineBlox.TxAction[](9);
286
+ allTxActions[0] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_REQUEST;
287
+ allTxActions[1] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_APPROVE;
288
+ allTxActions[2] = EngineBlox.TxAction.EXECUTE_TIME_DELAY_CANCEL;
289
+ allTxActions[3] = EngineBlox.TxAction.SIGN_META_REQUEST_AND_APPROVE;
290
+ allTxActions[4] = EngineBlox.TxAction.SIGN_META_APPROVE;
291
+ allTxActions[5] = EngineBlox.TxAction.SIGN_META_CANCEL;
292
+ allTxActions[6] = EngineBlox.TxAction.EXECUTE_META_REQUEST_AND_APPROVE;
293
+ allTxActions[7] = EngineBlox.TxAction.EXECUTE_META_APPROVE;
294
+ allTxActions[8] = EngineBlox.TxAction.EXECUTE_META_CANCEL;
295
+ uint16 allActionsBitmap = EngineBlox.createBitmapFromActions(allTxActions);
296
+
297
+ bytes4[] memory attachedPaymentRecipientHandlers = new bytes4[](1);
298
+ attachedPaymentRecipientHandlers[0] = EngineBlox.ATTACHED_PAYMENT_RECIPIENT_SELECTOR;
299
+ schemas[9] = EngineBlox.FunctionSchema({
300
+ functionSignature: "__bloxchain_attached_payment_recipient__()",
301
+ functionSelector: EngineBlox.ATTACHED_PAYMENT_RECIPIENT_SELECTOR,
302
+ operationType: keccak256(bytes("ATTACHED_PAYMENT_RECIPIENT")),
303
+ operationName: "ATTACHED_PAYMENT_RECIPIENT",
304
+ supportedActionsBitmap: allActionsBitmap,
305
+ enforceHandlerRelations: false,
306
+ isProtected: true,
307
+ isGrantRevocable: true,
308
+ handlerForSelectors: attachedPaymentRecipientHandlers
309
+ });
310
+
311
+ bytes4[] memory nativeTransferHandlers = new bytes4[](1);
312
+ nativeTransferHandlers[0] = EngineBlox.NATIVE_TRANSFER_SELECTOR;
313
+ schemas[10] = EngineBlox.FunctionSchema({
314
+ functionSignature: "__bloxchain_native_transfer__()",
315
+ functionSelector: EngineBlox.NATIVE_TRANSFER_SELECTOR,
316
+ operationType: keccak256(bytes("NATIVE_TRANSFER")),
317
+ operationName: "NATIVE_TRANSFER",
318
+ supportedActionsBitmap: allActionsBitmap,
319
+ enforceHandlerRelations: false,
320
+ isProtected: true,
321
+ isGrantRevocable: true,
322
+ handlerForSelectors: nativeTransferHandlers
323
+ });
324
+
325
+ bytes4[] memory erc20TransferHandlers = new bytes4[](1);
326
+ erc20TransferHandlers[0] = EngineBlox.ERC20_TRANSFER_SELECTOR;
327
+ schemas[11] = EngineBlox.FunctionSchema({
328
+ functionSignature: "transfer(address,uint256)",
329
+ functionSelector: EngineBlox.ERC20_TRANSFER_SELECTOR,
330
+ operationType: keccak256(bytes("ERC20_TRANSFER")),
331
+ operationName: "ERC20_TRANSFER",
332
+ supportedActionsBitmap: allActionsBitmap,
333
+ enforceHandlerRelations: false,
334
+ isProtected: true,
335
+ isGrantRevocable: true,
336
+ handlerForSelectors: erc20TransferHandlers
337
+ });
338
+
245
339
  return schemas;
246
340
  }
247
341
 
@@ -418,13 +512,81 @@ library GuardControllerDefinitions {
418
512
  });
419
513
  }
420
514
 
515
+ /**
516
+ * @dev Returns all available GuardConfig action types and their decode formats for discovery.
517
+ * @return actionNames Human-readable action names (same order as GuardConfigActionType enum)
518
+ * @return formats ABI decode format for each action's data, e.g. "(bytes4 functionSelector, address target)"
519
+ * @notice Use with GuardConfigActionType enum: actionNames[i] and formats[i] describe enum value i
520
+ */
521
+ function getGuardConfigActionSpecs() public pure returns (string[] memory actionNames, string[] memory formats) {
522
+ actionNames = new string[](4);
523
+ formats = new string[](4);
524
+
525
+ actionNames[0] = "ADD_TARGET_TO_WHITELIST";
526
+ formats[0] = "(bytes4 functionSelector, address target)";
527
+
528
+ actionNames[1] = "REMOVE_TARGET_FROM_WHITELIST";
529
+ formats[1] = "(bytes4 functionSelector, address target)";
530
+
531
+ actionNames[2] = "REGISTER_FUNCTION";
532
+ formats[2] = "(string functionSignature, string operationName, TxAction[] supportedActions)";
533
+
534
+ actionNames[3] = "UNREGISTER_FUNCTION";
535
+ formats[3] = "(bytes4 functionSelector, bool safeRemoval)";
536
+ }
537
+
538
+ // ============ GUARD CONFIG ACTION DATA ENCODERS ============
539
+ // Use these helpers to build action.data for each GuardConfigActionType without reading the contract.
540
+ // Each encoder returns bytes suitable for GuardConfigAction(actionType, data).
541
+
542
+ /**
543
+ * @dev Encodes data for ADD_TARGET_TO_WHITELIST. Use with GuardConfigActionType.ADD_TARGET_TO_WHITELIST.
544
+ * @param functionSelector Function whose whitelist is updated
545
+ * @param target Address to add to the whitelist
546
+ */
547
+ function encodeAddTargetToWhitelist(bytes4 functionSelector, address target) public pure returns (bytes memory) {
548
+ return abi.encode(functionSelector, target);
549
+ }
550
+
551
+ /**
552
+ * @dev Encodes data for REMOVE_TARGET_FROM_WHITELIST. Use with GuardConfigActionType.REMOVE_TARGET_FROM_WHITELIST.
553
+ * @param functionSelector Function whose whitelist is updated
554
+ * @param target Address to remove from the whitelist
555
+ */
556
+ function encodeRemoveTargetFromWhitelist(bytes4 functionSelector, address target) public pure returns (bytes memory) {
557
+ return abi.encode(functionSelector, target);
558
+ }
559
+
560
+ /**
561
+ * @dev Encodes data for REGISTER_FUNCTION. Use with GuardConfigActionType.REGISTER_FUNCTION.
562
+ * @param functionSignature Full function signature string (e.g. "executeWithTimeLock(address,bytes4,bytes,uint256,bytes32)")
563
+ * @param operationName Human-readable operation name
564
+ * @param supportedActions TxActions supported by this function (e.g. EXECUTE_TIME_DELAY_REQUEST)
565
+ */
566
+ function encodeRegisterFunction(
567
+ string memory functionSignature,
568
+ string memory operationName,
569
+ EngineBlox.TxAction[] memory supportedActions
570
+ ) public pure returns (bytes memory) {
571
+ return abi.encode(functionSignature, operationName, supportedActions);
572
+ }
573
+
574
+ /**
575
+ * @dev Encodes data for UNREGISTER_FUNCTION. Use with GuardConfigActionType.UNREGISTER_FUNCTION.
576
+ * @param functionSelector Selector of the function to unregister
577
+ * @param safeRemoval If true, `EngineBlox.unregisterFunction` reverts when **any role** still lists this selector (not a whitelist-emptiness check; whitelist/hook entries may remain).
578
+ */
579
+ function encodeUnregisterFunction(bytes4 functionSelector, bool safeRemoval) public pure returns (bytes memory) {
580
+ return abi.encode(functionSelector, safeRemoval);
581
+ }
582
+
421
583
  /**
422
584
  * @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[])
585
+ * @param actions Encoded guard configuration actions (same layout as IGuardController.GuardConfigAction[])
424
586
  * @return The execution params for EngineBlox
425
587
  */
426
588
  function guardConfigBatchExecutionParams(
427
- GuardConfigAction[] memory actions
589
+ IGuardController.GuardConfigAction[] memory actions
428
590
  ) public pure returns (bytes memory) {
429
591
  return abi.encode(actions);
430
592
  }