@bloxchain/contracts 1.0.0-alpha.7 → 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 (52) 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 +235 -199
  7. package/abi/IDefinition.abi.json +57 -47
  8. package/abi/RuntimeRBAC.abi.json +841 -842
  9. package/abi/RuntimeRBACDefinitions.abi.json +212 -202
  10. package/abi/SecureOwnable.abi.json +1365 -1349
  11. package/abi/SecureOwnableDefinitions.abi.json +174 -164
  12. package/core/AUDIT.md +45 -0
  13. package/core/access/RuntimeRBAC.sol +130 -61
  14. package/core/access/interface/IRuntimeRBAC.sol +3 -3
  15. package/core/access/lib/definitions/RuntimeRBACDefinitions.sol +7 -3
  16. package/core/base/BaseStateMachine.sol +971 -967
  17. package/core/base/interface/IBaseStateMachine.sol +153 -160
  18. package/core/execution/GuardController.sol +89 -75
  19. package/core/execution/interface/IGuardController.sol +146 -160
  20. package/core/execution/lib/definitions/GuardControllerDefinitions.sol +136 -25
  21. package/core/lib/EngineBlox.sol +577 -327
  22. package/core/lib/interfaces/IDefinition.sol +49 -49
  23. package/core/lib/interfaces/IEventForwarder.sol +4 -2
  24. package/core/lib/utils/SharedValidation.sol +534 -490
  25. package/core/pattern/Account.sol +84 -75
  26. package/core/security/SecureOwnable.sol +446 -390
  27. package/core/security/interface/ISecureOwnable.sol +105 -105
  28. package/core/security/lib/definitions/SecureOwnableDefinitions.sol +49 -17
  29. package/package.json +51 -49
  30. package/standards/behavior/ICopyable.sol +3 -11
  31. package/standards/hooks/IOnActionHook.sol +1 -1
  32. package/abi/AccountBlox.abi.json +0 -3935
  33. package/abi/BareBlox.abi.json +0 -1378
  34. package/abi/RoleBlox.abi.json +0 -2983
  35. package/abi/SecureBlox.abi.json +0 -2753
  36. package/abi/SimpleRWA20.abi.json +0 -4032
  37. package/abi/SimpleRWA20Definitions.abi.json +0 -191
  38. package/abi/SimpleVault.abi.json +0 -3407
  39. package/abi/SimpleVaultDefinitions.abi.json +0 -269
  40. package/core/research/BloxchainWallet.sol +0 -133
  41. package/core/research/FactoryBlox/FactoryBlox.sol +0 -343
  42. package/core/research/FactoryBlox/FactoryBloxDefinitions.sol +0 -143
  43. package/core/research/erc1155-blox/ERC1155Blox.sol +0 -169
  44. package/core/research/erc1155-blox/lib/definitions/ERC1155BloxDefinitions.sol +0 -203
  45. package/core/research/erc20-blox/ERC20Blox.sol +0 -167
  46. package/core/research/erc20-blox/lib/definitions/ERC20BloxDefinitions.sol +0 -185
  47. package/core/research/erc721-blox/ERC721Blox.sol +0 -131
  48. package/core/research/erc721-blox/lib/definitions/ERC721BloxDefinitions.sol +0 -172
  49. package/core/research/lending-blox/.gitkeep +0 -1
  50. package/core/research/p2p-blox/P2PBlox.sol +0 -266
  51. package/core/research/p2p-blox/README.md +0 -85
  52. package/core/research/p2p-blox/lib/definitions/P2PBloxDefinitions.sol +0 -19
@@ -1,160 +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, getFunctionSchema, owner, getBroadcaster, getRecovery) should be accessed via IBaseStateMachine
11
- * @notice Functions from RuntimeRBAC (registerFunction, unregisterFunction, createNewRole, addWalletToRole, revokeWallet) should be accessed via IRuntimeRBAC
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
- * @param expectedOperationType The expected operation type for validation
98
- * @return txId The transaction ID (use getTransaction(txId) for full record and result)
99
- * @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_APPROVE permission for the execution function
100
- */
101
- function approveTimeLockExecution(
102
- uint256 txId,
103
- bytes32 expectedOperationType
104
- ) external returns (uint256);
105
-
106
- /**
107
- * @dev Cancels a time-locked transaction
108
- * @param txId The transaction ID
109
- * @param expectedOperationType The expected operation type for validation
110
- * @return txId The transaction ID (use getTransaction(txId) for full record)
111
- * @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_CANCEL permission for the execution function
112
- */
113
- function cancelTimeLockExecution(
114
- uint256 txId,
115
- bytes32 expectedOperationType
116
- ) external returns (uint256);
117
-
118
- /**
119
- * @dev Approves a time-locked transaction using a meta-transaction
120
- * @param metaTx The meta-transaction containing the transaction record and signature
121
- * @param expectedOperationType The expected operation type for validation
122
- * @param requiredSelector The handler selector for validation
123
- * @return The transaction ID (use getTransaction(txId) for full record)
124
- * @notice Requires STANDARD execution type and EXECUTE_META_APPROVE permission for the execution function
125
- */
126
- function approveTimeLockExecutionWithMetaTx(
127
- EngineBlox.MetaTransaction memory metaTx,
128
- bytes32 expectedOperationType,
129
- bytes4 requiredSelector
130
- ) external returns (uint256);
131
-
132
- /**
133
- * @dev Cancels a time-locked transaction using a meta-transaction
134
- * @param metaTx The meta-transaction containing the transaction record and signature
135
- * @param expectedOperationType The expected operation type for validation
136
- * @param requiredSelector The handler selector for validation
137
- * @return The transaction ID (use getTransaction(txId) for full record)
138
- * @notice Requires STANDARD execution type and EXECUTE_META_CANCEL permission for the execution function
139
- */
140
- function cancelTimeLockExecutionWithMetaTx(
141
- EngineBlox.MetaTransaction memory metaTx,
142
- bytes32 expectedOperationType,
143
- bytes4 requiredSelector
144
- ) external returns (uint256);
145
-
146
- /**
147
- * @dev Requests and approves a transaction in one step using a meta-transaction
148
- * @param metaTx The meta-transaction containing the transaction record and signature
149
- * @param requiredSelector The handler selector for validation
150
- * @return The transaction ID (use getTransaction(txId) for full record)
151
- * @notice Requires STANDARD execution type
152
- * @notice Validates function schema and permissions for the execution function (same as executeWithTimeLock)
153
- * @notice Requires EXECUTE_META_REQUEST_AND_APPROVE permission for the execution function selector
154
- */
155
- function requestAndApproveExecution(
156
- EngineBlox.MetaTransaction memory metaTx,
157
- bytes4 requiredSelector
158
- ) external returns (uint256);
159
- }
160
-
1
+ // SPDX-License-Identifier: MPL-2.0
2
+ pragma solidity 0.8.35;
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,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
 
@@ -463,7 +574,7 @@ library GuardControllerDefinitions {
463
574
  /**
464
575
  * @dev Encodes data for UNREGISTER_FUNCTION. Use with GuardConfigActionType.UNREGISTER_FUNCTION.
465
576
  * @param functionSelector Selector of the function to unregister
466
- * @param safeRemoval If true, reverts when the function has whitelisted targets
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).
467
578
  */
468
579
  function encodeUnregisterFunction(bytes4 functionSelector, bool safeRemoval) public pure returns (bytes memory) {
469
580
  return abi.encode(functionSelector, safeRemoval);