@bloxchain/contracts 1.0.0-alpha.6 → 1.0.0

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 (54) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +8 -9
  3. package/abi/BaseStateMachine.abi.json +773 -822
  4. package/abi/EngineBlox.abi.json +562 -552
  5. package/abi/GuardController.abi.json +1597 -1609
  6. package/abi/GuardControllerDefinitions.abi.json +257 -120
  7. package/abi/IDefinition.abi.json +57 -47
  8. package/abi/RuntimeRBAC.abi.json +841 -842
  9. package/abi/RuntimeRBACDefinitions.abi.json +265 -99
  10. package/abi/SecureOwnable.abi.json +1365 -1349
  11. package/abi/SecureOwnableDefinitions.abi.json +174 -164
  12. package/components/README.md +8 -0
  13. package/core/AUDIT.md +45 -0
  14. package/core/access/RuntimeRBAC.sol +130 -61
  15. package/core/access/interface/IRuntimeRBAC.sol +3 -3
  16. package/core/access/lib/definitions/RuntimeRBACDefinitions.sol +67 -3
  17. package/core/base/BaseStateMachine.sol +971 -967
  18. package/core/base/interface/IBaseStateMachine.sol +153 -160
  19. package/core/execution/GuardController.sol +89 -75
  20. package/core/execution/interface/IGuardController.sol +146 -160
  21. package/core/execution/lib/definitions/GuardControllerDefinitions.sol +180 -24
  22. package/core/lib/EngineBlox.sol +577 -327
  23. package/core/lib/interfaces/IDefinition.sol +49 -49
  24. package/core/lib/interfaces/IEventForwarder.sol +4 -2
  25. package/core/lib/utils/SharedValidation.sol +534 -487
  26. package/core/pattern/Account.sol +84 -65
  27. package/core/security/SecureOwnable.sol +446 -390
  28. package/core/security/interface/ISecureOwnable.sol +105 -105
  29. package/core/security/lib/definitions/SecureOwnableDefinitions.sol +49 -17
  30. package/package.json +11 -7
  31. package/standards/README.md +12 -0
  32. package/{core/research → standards/behavior}/ICopyable.sol +3 -11
  33. package/standards/hooks/IOnActionHook.sol +21 -0
  34. package/abi/AccountBlox.abi.json +0 -3916
  35. package/abi/BareBlox.abi.json +0 -1378
  36. package/abi/RoleBlox.abi.json +0 -2983
  37. package/abi/SecureBlox.abi.json +0 -2753
  38. package/abi/SimpleRWA20.abi.json +0 -4032
  39. package/abi/SimpleRWA20Definitions.abi.json +0 -191
  40. package/abi/SimpleVault.abi.json +0 -3407
  41. package/abi/SimpleVaultDefinitions.abi.json +0 -269
  42. package/core/research/BloxchainWallet.sol +0 -292
  43. package/core/research/FactoryBlox/FactoryBlox.sol +0 -346
  44. package/core/research/FactoryBlox/FactoryBloxDefinitions.sol +0 -143
  45. package/core/research/erc1155-blox/ERC1155Blox.sol +0 -169
  46. package/core/research/erc1155-blox/lib/definitions/ERC1155BloxDefinitions.sol +0 -203
  47. package/core/research/erc20-blox/ERC20Blox.sol +0 -167
  48. package/core/research/erc20-blox/lib/definitions/ERC20BloxDefinitions.sol +0 -185
  49. package/core/research/erc721-blox/ERC721Blox.sol +0 -131
  50. package/core/research/erc721-blox/lib/definitions/ERC721BloxDefinitions.sol +0 -172
  51. package/core/research/lending-blox/.gitkeep +0 -1
  52. package/core/research/p2p-blox/P2PBlox.sol +0 -266
  53. package/core/research/p2p-blox/README.md +0 -85
  54. package/core/research/p2p-blox/lib/definitions/P2PBloxDefinitions.sol +0 -19
@@ -1,5 +1,5 @@
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";
@@ -16,7 +16,7 @@ import "../../interface/IGuardController.sol";
16
16
  * and role permissions for GuardController's public execution functions.
17
17
  *
18
18
  * Key Features:
19
- * - Registers all 6 GuardController public execution functions
19
+ * - Registers all 9 GuardController public execution functions plus 3 attached-payment policy schemas
20
20
  * - Defines role permissions for OWNER_ROLE and BROADCASTER_ROLE
21
21
  * - Supports time-delay and meta-transaction workflows
22
22
  * - Matches EngineBloxDefinitions pattern for consistency
@@ -33,10 +33,15 @@ library GuardControllerDefinitions {
33
33
 
34
34
  // Operation Type Constants
35
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");
36
38
 
37
39
  // Function Selector Constants
38
- // GuardController: executeWithTimeLock(address,bytes4,bytes,uint256,bytes32)
39
- 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))"));
40
45
 
41
46
  // GuardController: approveTimeLockExecution(uint256)
42
47
  bytes4 public constant APPROVE_TIMELOCK_EXECUTION_SELECTOR = bytes4(keccak256("approveTimeLockExecution(uint256)"));
@@ -44,19 +49,32 @@ library GuardControllerDefinitions {
44
49
  // GuardController: cancelTimeLockExecution(uint256)
45
50
  bytes4 public constant CANCEL_TIMELOCK_EXECUTION_SELECTOR = bytes4(keccak256("cancelTimeLockExecution(uint256)"));
46
51
 
47
- // GuardController: approveTimeLockExecutionWithMetaTx(...)
48
- 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
+ );
49
59
 
50
- // GuardController: cancelTimeLockExecutionWithMetaTx(...)
51
- 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
+ );
52
66
 
53
- // GuardController: requestAndApproveExecution(...)
54
- 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
+ );
55
73
 
56
74
  // GuardController: guardConfigBatchRequestAndApprove(...)
57
75
  bytes4 public constant GUARD_CONFIG_BATCH_META_SELECTOR = bytes4(
58
76
  keccak256(
59
- "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))"
60
78
  )
61
79
  );
62
80
 
@@ -65,12 +83,12 @@ library GuardControllerDefinitions {
65
83
  bytes4(keccak256("executeGuardConfigBatch((uint8,bytes)[])"));
66
84
 
67
85
  /**
68
- * @dev Returns predefined function schemas for GuardController execution functions
69
- * @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)
70
88
  *
71
89
  * Function schemas define:
72
90
  * - GuardController public execution functions
73
- * - What operation types they belong to (CONTROLLER_OPERATION)
91
+ * - What operation types they belong to (CONTROLLER_OPERATION vs CONTROLLER_CONFIG_BATCH)
74
92
  * - What actions are supported (time-delay request/approve/cancel, meta-tx approve/cancel/request-and-approve)
75
93
  * - Whether they are protected
76
94
  *
@@ -80,7 +98,7 @@ library GuardControllerDefinitions {
80
98
  * - Role permissions are defined in getRolePermissions() matching EngineBloxDefinitions pattern
81
99
  */
82
100
  function getFunctionSchemas() public pure returns (EngineBlox.FunctionSchema[] memory) {
83
- EngineBlox.FunctionSchema[] memory schemas = new EngineBlox.FunctionSchema[](8);
101
+ EngineBlox.FunctionSchema[] memory schemas = new EngineBlox.FunctionSchema[](12);
84
102
 
85
103
  // ============ TIME-DELAY WORKFLOW ACTIONS ============
86
104
  // Request action for executeWithTimeLock
@@ -128,6 +146,9 @@ library GuardControllerDefinitions {
128
146
  requestAndApproveExecutionHandlerForSelectors[0] = REQUEST_AND_APPROVE_EXECUTION_SELECTOR;
129
147
  bytes4[] memory guardConfigBatchExecuteHandlerForSelectors = new bytes4[](1);
130
148
  guardConfigBatchExecuteHandlerForSelectors[0] = GUARD_CONFIG_BATCH_EXECUTE_SELECTOR;
149
+
150
+ bytes4[] memory executeWithPaymentHandlerForSelectors = new bytes4[](1);
151
+ executeWithPaymentHandlerForSelectors[0] = EXECUTE_WITH_PAYMENT_SELECTOR;
131
152
 
132
153
  // Handler selectors point to execution selectors
133
154
  bytes4[] memory guardConfigHandlerForSelectors = new bytes4[](1);
@@ -135,12 +156,14 @@ library GuardControllerDefinitions {
135
156
 
136
157
  // Schema 0: GuardController.executeWithTimeLock
137
158
  schemas[0] = EngineBlox.FunctionSchema({
138
- functionSignature: "executeWithTimeLock(address,bytes4,bytes,uint256,bytes32)",
159
+ functionSignature: "executeWithTimeLock(address,uint256,bytes4,bytes,uint256,bytes32)",
139
160
  functionSelector: EXECUTE_WITH_TIMELOCK_SELECTOR,
140
161
  operationType: CONTROLLER_OPERATION,
141
162
  operationName: "CONTROLLER_OPERATION",
142
163
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(timeDelayRequestActions),
164
+ enforceHandlerRelations: false,
143
165
  isProtected: true,
166
+ isGrantRevocable: false,
144
167
  handlerForSelectors: executeWithTimeLockHandlerForSelectors
145
168
  });
146
169
 
@@ -151,7 +174,9 @@ library GuardControllerDefinitions {
151
174
  operationType: CONTROLLER_OPERATION,
152
175
  operationName: "CONTROLLER_OPERATION",
153
176
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(timeDelayApproveActions),
177
+ enforceHandlerRelations: false,
154
178
  isProtected: true,
179
+ isGrantRevocable: false,
155
180
  handlerForSelectors: approveTimeLockExecutionHandlerForSelectors
156
181
  });
157
182
 
@@ -162,51 +187,61 @@ library GuardControllerDefinitions {
162
187
  operationType: CONTROLLER_OPERATION,
163
188
  operationName: "CONTROLLER_OPERATION",
164
189
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(timeDelayCancelActions),
190
+ enforceHandlerRelations: false,
165
191
  isProtected: true,
192
+ isGrantRevocable: false,
166
193
  handlerForSelectors: cancelTimeLockExecutionHandlerForSelectors
167
194
  });
168
195
 
169
196
  // Schema 3: GuardController.approveTimeLockExecutionWithMetaTx
170
197
  schemas[3] = EngineBlox.FunctionSchema({
171
- 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))",
172
199
  functionSelector: APPROVE_TIMELOCK_EXECUTION_META_SELECTOR,
173
200
  operationType: CONTROLLER_OPERATION,
174
201
  operationName: "CONTROLLER_OPERATION",
175
202
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxApproveActions),
203
+ enforceHandlerRelations: false,
176
204
  isProtected: true,
205
+ isGrantRevocable: false,
177
206
  handlerForSelectors: approveTimeLockExecutionMetaHandlerForSelectors
178
207
  });
179
208
 
180
209
  // Schema 4: GuardController.cancelTimeLockExecutionWithMetaTx
181
210
  schemas[4] = EngineBlox.FunctionSchema({
182
- 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))",
183
212
  functionSelector: CANCEL_TIMELOCK_EXECUTION_META_SELECTOR,
184
213
  operationType: CONTROLLER_OPERATION,
185
214
  operationName: "CONTROLLER_OPERATION",
186
215
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxCancelActions),
216
+ enforceHandlerRelations: false,
187
217
  isProtected: true,
218
+ isGrantRevocable: false,
188
219
  handlerForSelectors: cancelTimeLockExecutionMetaHandlerForSelectors
189
220
  });
190
221
 
191
222
  // Schema 5: GuardController.requestAndApproveExecution
192
223
  schemas[5] = EngineBlox.FunctionSchema({
193
- 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))",
194
225
  functionSelector: REQUEST_AND_APPROVE_EXECUTION_SELECTOR,
195
226
  operationType: CONTROLLER_OPERATION,
196
227
  operationName: "CONTROLLER_OPERATION",
197
228
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxRequestApproveActions),
229
+ enforceHandlerRelations: false,
198
230
  isProtected: true,
231
+ isGrantRevocable: false,
199
232
  handlerForSelectors: requestAndApproveExecutionHandlerForSelectors
200
233
  });
201
234
 
202
235
  // Schema 6: GuardController.guardConfigBatchRequestAndApprove
203
236
  schemas[6] = EngineBlox.FunctionSchema({
204
- 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))",
205
238
  functionSelector: GUARD_CONFIG_BATCH_META_SELECTOR,
206
- operationType: CONTROLLER_OPERATION,
207
- operationName: "CONTROLLER_OPERATION",
239
+ operationType: CONTROLLER_CONFIG_BATCH,
240
+ operationName: "CONTROLLER_CONFIG_BATCH",
208
241
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(metaTxRequestApproveActions),
242
+ enforceHandlerRelations: true,
209
243
  isProtected: true,
244
+ isGrantRevocable: false,
210
245
  handlerForSelectors: guardConfigHandlerForSelectors
211
246
  });
212
247
 
@@ -218,13 +253,89 @@ library GuardControllerDefinitions {
218
253
  schemas[7] = EngineBlox.FunctionSchema({
219
254
  functionSignature: "executeGuardConfigBatch((uint8,bytes)[])",
220
255
  functionSelector: GUARD_CONFIG_BATCH_EXECUTE_SELECTOR,
221
- operationType: CONTROLLER_OPERATION,
222
- operationName: "CONTROLLER_OPERATION",
256
+ operationType: CONTROLLER_CONFIG_BATCH,
257
+ operationName: "CONTROLLER_CONFIG_BATCH",
223
258
  supportedActionsBitmap: EngineBlox.createBitmapFromActions(guardConfigExecutionActions),
259
+ enforceHandlerRelations: false,
224
260
  isProtected: true,
261
+ isGrantRevocable: false,
225
262
  handlerForSelectors: guardConfigBatchExecuteHandlerForSelectors
226
263
  });
227
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
+
228
339
  return schemas;
229
340
  }
230
341
 
@@ -424,6 +535,51 @@ library GuardControllerDefinitions {
424
535
  formats[3] = "(bytes4 functionSelector, bool safeRemoval)";
425
536
  }
426
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
+
427
583
  /**
428
584
  * @dev Creates execution params for a Guard configuration batch (pure helper for EngineBlox).
429
585
  * @param actions Encoded guard configuration actions (same layout as IGuardController.GuardConfigAction[])