@bloxchain/contracts 1.0.0-alpha.13 → 1.0.0-alpha.15

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.
@@ -94,67 +94,53 @@ interface IGuardController {
94
94
  /**
95
95
  * @dev Approves and executes a time-locked transaction
96
96
  * @param txId The transaction ID
97
- * @param expectedOperationType The expected operation type for validation
98
97
  * @return txId The transaction ID (use getTransaction(txId) for full record and result)
99
98
  * @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_APPROVE permission for the execution function
100
99
  */
101
100
  function approveTimeLockExecution(
102
- uint256 txId,
103
- bytes32 expectedOperationType
101
+ uint256 txId
104
102
  ) external returns (uint256);
105
103
 
106
104
  /**
107
105
  * @dev Cancels a time-locked transaction
108
106
  * @param txId The transaction ID
109
- * @param expectedOperationType The expected operation type for validation
110
107
  * @return txId The transaction ID (use getTransaction(txId) for full record)
111
108
  * @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_CANCEL permission for the execution function
112
109
  */
113
110
  function cancelTimeLockExecution(
114
- uint256 txId,
115
- bytes32 expectedOperationType
111
+ uint256 txId
116
112
  ) external returns (uint256);
117
113
 
118
114
  /**
119
115
  * @dev Approves a time-locked transaction using a meta-transaction
120
116
  * @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
117
  * @return The transaction ID (use getTransaction(txId) for full record)
124
118
  * @notice Requires STANDARD execution type and EXECUTE_META_APPROVE permission for the execution function
125
119
  */
126
120
  function approveTimeLockExecutionWithMetaTx(
127
- EngineBlox.MetaTransaction memory metaTx,
128
- bytes32 expectedOperationType,
129
- bytes4 requiredSelector
121
+ EngineBlox.MetaTransaction memory metaTx
130
122
  ) external returns (uint256);
131
123
 
132
124
  /**
133
125
  * @dev Cancels a time-locked transaction using a meta-transaction
134
126
  * @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
127
  * @return The transaction ID (use getTransaction(txId) for full record)
138
128
  * @notice Requires STANDARD execution type and EXECUTE_META_CANCEL permission for the execution function
139
129
  */
140
130
  function cancelTimeLockExecutionWithMetaTx(
141
- EngineBlox.MetaTransaction memory metaTx,
142
- bytes32 expectedOperationType,
143
- bytes4 requiredSelector
131
+ EngineBlox.MetaTransaction memory metaTx
144
132
  ) external returns (uint256);
145
133
 
146
134
  /**
147
135
  * @dev Requests and approves a transaction in one step using a meta-transaction
148
136
  * @param metaTx The meta-transaction containing the transaction record and signature
149
- * @param requiredSelector The handler selector for validation
150
137
  * @return The transaction ID (use getTransaction(txId) for full record)
151
138
  * @notice Requires STANDARD execution type
152
139
  * @notice Validates function schema and permissions for the execution function (same as executeWithTimeLock)
153
140
  * @notice Requires EXECUTE_META_REQUEST_AND_APPROVE permission for the execution function selector
154
141
  */
155
142
  function requestAndApproveExecution(
156
- EngineBlox.MetaTransaction memory metaTx,
157
- bytes4 requiredSelector
143
+ EngineBlox.MetaTransaction memory metaTx
158
144
  ) external returns (uint256);
159
145
  }
160
146
 
@@ -47,14 +47,27 @@ library GuardControllerDefinitions {
47
47
  // GuardController: cancelTimeLockExecution(uint256)
48
48
  bytes4 public constant CANCEL_TIMELOCK_EXECUTION_SELECTOR = bytes4(keccak256("cancelTimeLockExecution(uint256)"));
49
49
 
50
- // GuardController: approveTimeLockExecutionWithMetaTx(...)
51
- 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))"));
50
+
51
+ // GuardController: approveTimeLockExecutionWithMetaTx(EngineBlox.MetaTransaction)
52
+ bytes4 public constant APPROVE_TIMELOCK_EXECUTION_META_SELECTOR = bytes4(
53
+ keccak256(
54
+ "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))"
55
+ )
56
+ );
52
57
 
53
- // GuardController: cancelTimeLockExecutionWithMetaTx(...)
54
- 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))"));
58
+ // GuardController: cancelTimeLockExecutionWithMetaTx(EngineBlox.MetaTransaction)
59
+ bytes4 public constant CANCEL_TIMELOCK_EXECUTION_META_SELECTOR = bytes4(
60
+ keccak256(
61
+ "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))"
62
+ )
63
+ );
55
64
 
56
- // GuardController: requestAndApproveExecution(...)
57
- 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))"));
65
+ // GuardController: requestAndApproveExecution(EngineBlox.MetaTransaction)
66
+ bytes4 public constant REQUEST_AND_APPROVE_EXECUTION_SELECTOR = bytes4(
67
+ keccak256(
68
+ "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))"
69
+ )
70
+ );
58
71
 
59
72
  // GuardController: guardConfigBatchRequestAndApprove(...)
60
73
  bytes4 public constant GUARD_CONFIG_BATCH_META_SELECTOR = bytes4(
@@ -171,7 +184,7 @@ library GuardControllerDefinitions {
171
184
 
172
185
  // Schema 3: GuardController.approveTimeLockExecutionWithMetaTx
173
186
  schemas[3] = EngineBlox.FunctionSchema({
174
- 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))",
187
+ 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))",
175
188
  functionSelector: APPROVE_TIMELOCK_EXECUTION_META_SELECTOR,
176
189
  operationType: CONTROLLER_OPERATION,
177
190
  operationName: "CONTROLLER_OPERATION",
@@ -182,7 +195,7 @@ library GuardControllerDefinitions {
182
195
 
183
196
  // Schema 4: GuardController.cancelTimeLockExecutionWithMetaTx
184
197
  schemas[4] = EngineBlox.FunctionSchema({
185
- 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))",
198
+ 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))",
186
199
  functionSelector: CANCEL_TIMELOCK_EXECUTION_META_SELECTOR,
187
200
  operationType: CONTROLLER_OPERATION,
188
201
  operationName: "CONTROLLER_OPERATION",
@@ -193,7 +206,7 @@ library GuardControllerDefinitions {
193
206
 
194
207
  // Schema 5: GuardController.requestAndApproveExecution
195
208
  schemas[5] = EngineBlox.FunctionSchema({
196
- 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))",
209
+ 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))",
197
210
  functionSelector: REQUEST_AND_APPROVE_EXECUTION_SELECTOR,
198
211
  operationType: CONTROLLER_OPERATION,
199
212
  operationName: "CONTROLLER_OPERATION",
@@ -266,11 +266,11 @@ library EngineBlox {
266
266
  /**
267
267
  * @dev Updates the time lock period for the SecureOperationState.
268
268
  * @param self The SecureOperationState to modify.
269
- * @param _newTimeLockPeriodSec The new time lock period in seconds.
269
+ * @param periodSec The new time lock period in seconds.
270
270
  */
271
- function updateTimeLockPeriod(SecureOperationState storage self, uint256 _newTimeLockPeriodSec) public {
272
- SharedValidation.validateTimeLockPeriod(_newTimeLockPeriodSec);
273
- self.timeLockPeriodSec = _newTimeLockPeriodSec;
271
+ function updateTimeLockPeriod(SecureOperationState storage self, uint256 periodSec) public {
272
+ SharedValidation.validateTimeLockPeriod(periodSec);
273
+ self.timeLockPeriodSec = periodSec;
274
274
  }
275
275
 
276
276
  // ============ TRANSACTION MANAGEMENT FUNCTIONS ============
@@ -322,7 +322,7 @@ library EngineBlox {
322
322
  operationType,
323
323
  executionSelector,
324
324
  executionParams,
325
- _noPayment()
325
+ _emptyPayment()
326
326
  );
327
327
  }
328
328
 
@@ -396,9 +396,9 @@ library EngineBlox {
396
396
  ) private returns (TxRecord memory) {
397
397
  SharedValidation.validateNotZeroAddress(target);
398
398
  // enforce that the requested target is whitelisted for this selector.
399
- _validateFunctionTargetWhitelist(self, executionSelector, target);
399
+ _validateTargetWhitelist(self, executionSelector, target);
400
400
 
401
- TxRecord memory txRequestRecord = createNewTxRecord(
401
+ TxRecord memory txRequestRecord = createTxRecord(
402
402
  self,
403
403
  requester,
404
404
  target,
@@ -414,7 +414,7 @@ library EngineBlox {
414
414
  self.txCounter++;
415
415
 
416
416
  // Add to pending transactions list
417
- addToPendingTransactionsList(self, txRequestRecord.txId);
417
+ addPendingTx(self, txRequestRecord.txId);
418
418
 
419
419
  logTxEvent(self, txRequestRecord.txId, executionSelector);
420
420
 
@@ -576,7 +576,7 @@ library EngineBlox {
576
576
  // This proves reentrancy protection is active at entry point
577
577
  _validateTxStatus(self, record.txId, TxStatus.EXECUTING);
578
578
 
579
- bytes memory txData = prepareTransactionData(record);
579
+ bytes memory txData = buildCallData(record);
580
580
  uint gas = record.params.gasLimit;
581
581
  if (gas == 0) {
582
582
  gas = gasleft();
@@ -662,11 +662,11 @@ library EngineBlox {
662
662
  }
663
663
 
664
664
  /**
665
- * @dev Prepares transaction data from execution selector and params without executing it.
665
+ * @dev Builds transaction call data from execution selector and params without executing it.
666
666
  * @param record The transaction record to prepare data for.
667
667
  * @return The prepared transaction data.
668
668
  */
669
- function prepareTransactionData(TxRecord memory record) private pure returns (bytes memory) {
669
+ function buildCallData(TxRecord memory record) private pure returns (bytes memory) {
670
670
  // If executionSelector is NATIVE_TRANSFER_SELECTOR, it's a simple native token transfer (no function call)
671
671
  if (record.params.executionSelector == NATIVE_TRANSFER_SELECTOR) {
672
672
  // SECURITY: Validate empty params to prevent confusion with real function calls
@@ -683,7 +683,7 @@ library EngineBlox {
683
683
 
684
684
 
685
685
  /**
686
- * @notice Creates a new transaction record with basic fields populated
686
+ * @notice Creates a transaction record with basic fields populated
687
687
  * @dev Initializes a TxRecord struct with the provided parameters and default values
688
688
  * @param self The SecureOperationState to reference for txId and timelock
689
689
  * @param requester The address initiating the transaction
@@ -696,7 +696,7 @@ library EngineBlox {
696
696
  * @param payment The payment details to attach to the record (use empty struct for no payment)
697
697
  * @return TxRecord A new transaction record with populated fields
698
698
  */
699
- function createNewTxRecord(
699
+ function createTxRecord(
700
700
  SecureOperationState storage self,
701
701
  address requester,
702
702
  address target,
@@ -731,7 +731,7 @@ library EngineBlox {
731
731
  * @param self The SecureOperationState to modify.
732
732
  * @param txId The transaction ID to add to the pending set.
733
733
  */
734
- function addToPendingTransactionsList(SecureOperationState storage self, uint256 txId) private {
734
+ function addPendingTx(SecureOperationState storage self, uint256 txId) private {
735
735
  SharedValidation.validateTransactionExists(txId);
736
736
  _validateTxStatus(self, txId, TxStatus.PENDING);
737
737
 
@@ -746,7 +746,7 @@ library EngineBlox {
746
746
  * @param self The SecureOperationState to modify.
747
747
  * @param txId The transaction ID to remove from the pending set.
748
748
  */
749
- function removeFromPendingTransactionsList(SecureOperationState storage self, uint256 txId) private {
749
+ function removePendingTx(SecureOperationState storage self, uint256 txId) private {
750
750
  SharedValidation.validateTransactionExists(txId);
751
751
 
752
752
  // Remove the transaction ID from the set (O(1) operation)
@@ -914,13 +914,13 @@ library EngineBlox {
914
914
  }
915
915
 
916
916
  /**
917
- * @dev Updates a role from an old address to a new address.
917
+ * @dev Updates a wallet in a role (replaces oldWallet with newWallet).
918
918
  * @param self The SecureOperationState to modify.
919
919
  * @param role The role to update.
920
920
  * @param newWallet The new wallet address to assign the role to.
921
921
  * @param oldWallet The old wallet address to remove from the role.
922
922
  */
923
- function updateAssignedWallet(SecureOperationState storage self, bytes32 role, address newWallet, address oldWallet) public {
923
+ function updateWallet(SecureOperationState storage self, bytes32 role, address newWallet, address oldWallet) public {
924
924
  _validateRoleExists(self, role);
925
925
  SharedValidation.validateNotZeroAddress(newWallet);
926
926
  SharedValidation.validateNewAddress(newWallet, oldWallet);
@@ -1107,7 +1107,7 @@ library EngineBlox {
1107
1107
  // ============ FUNCTION MANAGEMENT FUNCTIONS ============
1108
1108
 
1109
1109
  /**
1110
- * @dev Creates a function access control with specified permissions.
1110
+ * @dev Registers a function access control with specified permissions.
1111
1111
  * @param self The SecureOperationState to check.
1112
1112
  * @param functionSignature Function signature (e.g., "transfer(address,uint256)") or function name.
1113
1113
  * @param functionSelector Hash identifier for the function.
@@ -1116,7 +1116,7 @@ library EngineBlox {
1116
1116
  * @param isProtected Whether the function schema is protected from removal.
1117
1117
  * @param handlerForSelectors Non-empty array required - execution selectors must contain self-reference, handler selectors must point to execution selectors
1118
1118
  */
1119
- function createFunctionSchema(
1119
+ function registerFunction(
1120
1120
  SecureOperationState storage self,
1121
1121
  string memory functionSignature,
1122
1122
  bytes4 functionSelector,
@@ -1183,15 +1183,15 @@ library EngineBlox {
1183
1183
  }
1184
1184
 
1185
1185
  /**
1186
- * @dev Removes a function schema from the system.
1186
+ * @dev Unregisters a function schema from the system.
1187
1187
  * @param self The SecureOperationState to modify.
1188
- * @param functionSelector The function selector to remove.
1188
+ * @param functionSelector The function selector to unregister.
1189
1189
  * @param safeRemoval If true, reverts with ResourceAlreadyExists when any role still references this function.
1190
1190
  * The safeRemoval check is done inside this function (iterating supportedRolesSet directly) for efficiency.
1191
- * @notice Security: Cannot remove protected function schemas to maintain system integrity.
1191
+ * @notice Security: Cannot unregister protected function schemas to maintain system integrity.
1192
1192
  * @notice Cleanup: Automatically removes unused operation types from supportedOperationTypesSet.
1193
1193
  */
1194
- function removeFunctionSchema(
1194
+ function unregisterFunction(
1195
1195
  SecureOperationState storage self,
1196
1196
  bytes4 functionSelector,
1197
1197
  bool safeRemoval
@@ -1238,34 +1238,13 @@ library EngineBlox {
1238
1238
  }
1239
1239
  }
1240
1240
 
1241
- /**
1242
- * @dev Checks if a specific action is supported by a function.
1243
- * @param self The SecureOperationState to check.
1244
- * @param functionSelector The function selector to check.
1245
- * @param action The action to check for support.
1246
- * @return True if the action is supported by the function, false otherwise.
1247
- */
1248
- function isActionSupportedByFunction(
1249
- SecureOperationState storage self,
1250
- bytes4 functionSelector,
1251
- TxAction action
1252
- ) public view returns (bool) {
1253
- // Check if function exists in supportedFunctionsSet
1254
- if (!self.supportedFunctionsSet.contains(bytes32(functionSelector))) {
1255
- return false;
1256
- }
1257
-
1258
- FunctionSchema memory functionSchema = self.functions[functionSelector];
1259
- return hasActionInBitmap(functionSchema.supportedActionsBitmap, action);
1260
- }
1261
-
1262
1241
  /**
1263
1242
  * @dev Adds a target address to the whitelist for a function selector.
1264
1243
  * @param self The SecureOperationState to modify.
1265
1244
  * @param functionSelector The function selector whose whitelist will be updated.
1266
1245
  * @param target The target address to add to the whitelist.
1267
1246
  */
1268
- function addTargetToFunctionWhitelist(
1247
+ function addTargetToWhitelist(
1269
1248
  SecureOperationState storage self,
1270
1249
  bytes4 functionSelector,
1271
1250
  address target
@@ -1289,7 +1268,7 @@ library EngineBlox {
1289
1268
  * @param functionSelector The function selector whose whitelist will be updated.
1290
1269
  * @param target The target address to remove from the whitelist.
1291
1270
  */
1292
- function removeTargetFromFunctionWhitelist(
1271
+ function removeTargetFromWhitelist(
1293
1272
  SecureOperationState storage self,
1294
1273
  bytes4 functionSelector,
1295
1274
  address target
@@ -1311,7 +1290,7 @@ library EngineBlox {
1311
1290
  * @notice Target MUST be present in functionTargetWhitelist[functionSelector] unless target is address(this).
1312
1291
  * If whitelist is empty (no entries), no targets are allowed - explicit deny for security.
1313
1292
  */
1314
- function _validateFunctionTargetWhitelist(
1293
+ function _validateTargetWhitelist(
1315
1294
  SecureOperationState storage self,
1316
1295
  bytes4 functionSelector,
1317
1296
  address target
@@ -1387,17 +1366,17 @@ library EngineBlox {
1387
1366
  // ============ FUNCTION TARGET HOOKS MANAGEMENT ============
1388
1367
 
1389
1368
  /**
1390
- * @dev Adds a target address to the hooks for a function selector.
1369
+ * @dev Sets (adds) a hook contract for a function selector.
1391
1370
  * @param self The SecureOperationState to modify.
1392
1371
  * @param functionSelector The function selector whose hooks will be updated.
1393
- * @param target The target address to add to the hooks.
1372
+ * @param hook The hook contract address to add (must not be zero).
1394
1373
  */
1395
- function addTargetToFunctionHooks(
1374
+ function setHook(
1396
1375
  SecureOperationState storage self,
1397
1376
  bytes4 functionSelector,
1398
- address target
1377
+ address hook
1399
1378
  ) public {
1400
- SharedValidation.validateNotZeroAddress(target);
1379
+ SharedValidation.validateNotZeroAddress(hook);
1401
1380
 
1402
1381
  // Function selector must be registered in the schema set
1403
1382
  if (!self.supportedFunctionsSet.contains(bytes32(functionSelector))) {
@@ -1412,36 +1391,38 @@ library EngineBlox {
1412
1391
  MAX_HOOKS_PER_SELECTOR
1413
1392
  );
1414
1393
 
1415
- if (!set.add(target)) {
1416
- revert SharedValidation.ItemAlreadyExists(target);
1394
+ if (!set.add(hook)) {
1395
+ revert SharedValidation.ItemAlreadyExists(hook);
1417
1396
  }
1418
1397
  }
1419
1398
 
1420
1399
  /**
1421
- * @dev Removes a target address from the hooks for a function selector.
1400
+ * @dev Clears (removes) a hook contract for a function selector.
1422
1401
  * @param self The SecureOperationState to modify.
1423
1402
  * @param functionSelector The function selector whose hooks will be updated.
1424
- * @param target The target address to remove from the hooks.
1403
+ * @param hook The hook contract address to remove (must not be zero).
1425
1404
  */
1426
- function removeTargetFromFunctionHooks(
1405
+ function clearHook(
1427
1406
  SecureOperationState storage self,
1428
1407
  bytes4 functionSelector,
1429
- address target
1408
+ address hook
1430
1409
  ) public {
1410
+ SharedValidation.validateNotZeroAddress(hook);
1411
+
1431
1412
  EnumerableSet.AddressSet storage set = self.functionTargetHooks[functionSelector];
1432
- if (!set.remove(target)) {
1433
- revert SharedValidation.ItemNotFound(target);
1413
+ if (!set.remove(hook)) {
1414
+ revert SharedValidation.ItemNotFound(hook);
1434
1415
  }
1435
1416
  }
1436
1417
 
1437
1418
  /**
1438
- * @dev Returns all hook target addresses for a function selector.
1419
+ * @dev Returns all configured hooks for a function selector.
1439
1420
  * @param self The SecureOperationState to check.
1440
1421
  * @param functionSelector The function selector to query.
1441
- * @return Array of hook target addresses.
1422
+ * @return Array of hook contract addresses.
1442
1423
  * @notice Access control should be enforced by the calling contract.
1443
1424
  */
1444
- function getFunctionHookTargets(
1425
+ function getHooks(
1445
1426
  SecureOperationState storage self,
1446
1427
  bytes4 functionSelector
1447
1428
  ) public view returns (address[] memory) {
@@ -1465,7 +1446,7 @@ library EngineBlox {
1465
1446
 
1466
1447
  /**
1467
1448
  * @dev Internal: Returns all function schemas that use a specific operation type.
1468
- * Used by removeFunctionSchema and getFunctionsByOperationType.
1449
+ * Used by unregisterFunction and getFunctionsByOperationType.
1469
1450
  */
1470
1451
  function _getFunctionsByOperationType(
1471
1452
  SecureOperationState storage self,
@@ -1496,42 +1477,42 @@ library EngineBlox {
1496
1477
  // ============ BACKWARD COMPATIBILITY FUNCTIONS ============
1497
1478
 
1498
1479
  /**
1499
- * @dev Gets all pending transaction IDs as an array for backward compatibility
1480
+ * @dev Gets all pending transaction IDs
1500
1481
  * @param self The SecureOperationState to check
1501
1482
  * @return Array of pending transaction IDs
1502
1483
  * @notice Access control should be enforced by the calling contract.
1503
1484
  */
1504
- function getPendingTransactionsList(SecureOperationState storage self) public view returns (uint256[] memory) {
1485
+ function getPendingTransactions(SecureOperationState storage self) public view returns (uint256[] memory) {
1505
1486
  return _convertUintSetToArray(self.pendingTransactionsSet);
1506
1487
  }
1507
1488
 
1508
1489
  /**
1509
- * @dev Gets all supported roles as an array for backward compatibility
1490
+ * @dev Gets all supported roles as an array
1510
1491
  * @param self The SecureOperationState to check
1511
1492
  * @return Array of supported role hashes
1512
1493
  * @notice Access control should be enforced by the calling contract.
1513
1494
  */
1514
- function getSupportedRolesList(SecureOperationState storage self) public view returns (bytes32[] memory) {
1495
+ function getSupportedRoles(SecureOperationState storage self) public view returns (bytes32[] memory) {
1515
1496
  return _convertBytes32SetToArray(self.supportedRolesSet);
1516
1497
  }
1517
1498
 
1518
1499
  /**
1519
- * @dev Gets all supported function selectors as an array for backward compatibility
1500
+ * @dev Gets all supported function selectors as an array
1520
1501
  * @param self The SecureOperationState to check
1521
1502
  * @return Array of supported function selectors
1522
1503
  * @notice Access control should be enforced by the calling contract.
1523
1504
  */
1524
- function getSupportedFunctionsList(SecureOperationState storage self) public view returns (bytes4[] memory) {
1505
+ function getSupportedFunctions(SecureOperationState storage self) public view returns (bytes4[] memory) {
1525
1506
  return _convertBytes4SetToArray(self.supportedFunctionsSet);
1526
1507
  }
1527
1508
 
1528
1509
  /**
1529
- * @dev Gets all supported operation types as an array for backward compatibility
1510
+ * @dev Gets all supported operation types as an array
1530
1511
  * @param self The SecureOperationState to check
1531
1512
  * @return Array of supported operation type hashes
1532
1513
  * @notice Access control should be enforced by the calling contract.
1533
1514
  */
1534
- function getSupportedOperationTypesList(SecureOperationState storage self) public view returns (bytes32[] memory) {
1515
+ function getSupportedOperationTypes(SecureOperationState storage self) public view returns (bytes32[] memory) {
1535
1516
  return _convertBytes32SetToArray(self.supportedOperationTypesSet);
1536
1517
  }
1537
1518
 
@@ -1555,7 +1536,7 @@ library EngineBlox {
1555
1536
  * @return Array of authorized wallet addresses
1556
1537
  * @notice Access control should be enforced by the calling contract.
1557
1538
  */
1558
- function _getAuthorizedWallets(
1539
+ function getAuthorizedWallets(
1559
1540
  SecureOperationState storage self,
1560
1541
  bytes32 roleHash
1561
1542
  ) public view returns (address[] memory) {
@@ -1767,7 +1748,7 @@ library EngineBlox {
1767
1748
  ) public view returns (MetaTransaction memory) {
1768
1749
  SharedValidation.validateNotZeroAddress(txParams.target);
1769
1750
 
1770
- TxRecord memory txRecord = createNewTxRecord(
1751
+ TxRecord memory txRecord = createTxRecord(
1771
1752
  self,
1772
1753
  txParams.requester,
1773
1754
  txParams.target,
@@ -1776,7 +1757,7 @@ library EngineBlox {
1776
1757
  txParams.operationType,
1777
1758
  txParams.executionSelector,
1778
1759
  txParams.executionParams,
1779
- _noPayment()
1760
+ _emptyPayment()
1780
1761
  );
1781
1762
 
1782
1763
  return generateMetaTransaction(self, txRecord, metaTxParams);
@@ -1830,7 +1811,7 @@ library EngineBlox {
1830
1811
  params: metaTxParams,
1831
1812
  message: 0,
1832
1813
  signature: "",
1833
- data: prepareTransactionData(txRecord)
1814
+ data: buildCallData(txRecord)
1834
1815
  });
1835
1816
 
1836
1817
  // Generate the message hash for ready to sign meta-transaction
@@ -2020,7 +2001,7 @@ library EngineBlox {
2020
2001
  bytes memory result
2021
2002
  ) private {
2022
2003
  // enforce that the requested target is whitelisted for this selector.
2023
- _validateFunctionTargetWhitelist(self, self.txRecords[txId].params.executionSelector, self.txRecords[txId].params.target);
2004
+ _validateTargetWhitelist(self, self.txRecords[txId].params.executionSelector, self.txRecords[txId].params.target);
2024
2005
 
2025
2006
  // Update storage with new status and result
2026
2007
  if (success) {
@@ -2035,7 +2016,7 @@ library EngineBlox {
2035
2016
  }
2036
2017
 
2037
2018
  // Remove from pending transactions list
2038
- removeFromPendingTransactionsList(self, txId);
2019
+ removePendingTx(self, txId);
2039
2020
 
2040
2021
  logTxEvent(self, txId, self.txRecords[txId].params.executionSelector);
2041
2022
  }
@@ -2050,12 +2031,12 @@ library EngineBlox {
2050
2031
  uint256 txId
2051
2032
  ) private {
2052
2033
  // enforce that the requested target is whitelisted for this selector.
2053
- _validateFunctionTargetWhitelist(self, self.txRecords[txId].params.executionSelector, self.txRecords[txId].params.target);
2034
+ _validateTargetWhitelist(self, self.txRecords[txId].params.executionSelector, self.txRecords[txId].params.target);
2054
2035
 
2055
2036
  self.txRecords[txId].status = TxStatus.CANCELLED;
2056
2037
 
2057
2038
  // Remove from pending transactions list
2058
- removeFromPendingTransactionsList(self, txId);
2039
+ removePendingTx(self, txId);
2059
2040
 
2060
2041
  logTxEvent(self, txId, self.txRecords[txId].params.executionSelector);
2061
2042
  }
@@ -2135,6 +2116,10 @@ library EngineBlox {
2135
2116
  bytes4 handlerSelector,
2136
2117
  TxAction action
2137
2118
  ) internal view {
2119
+ // Ensure both execution and handler selectors have registered function schemas
2120
+ _validateFunctionSchemaExists(self, executionSelector);
2121
+ _validateFunctionSchemaExists(self, handlerSelector);
2122
+
2138
2123
  // Validate permission for the execution selector (underlying operation)
2139
2124
  if (!hasActionPermission(self, wallet, executionSelector, action)) {
2140
2125
  revert SharedValidation.NoPermission(wallet);
@@ -2227,14 +2212,32 @@ library EngineBlox {
2227
2212
  revert SharedValidation.ConflictingMetaTxPermissions(functionPermission.functionSelector);
2228
2213
  }
2229
2214
 
2230
- // Validate that each action in the bitmap is supported by the function
2231
- // This still requires iteration, but we can optimize it
2232
- for (uint i = 0; i < 9; i++) { // TxAction enum has 9 values (0-8)
2233
- if (hasActionInBitmap(bitmap, TxAction(i))) {
2234
- if (!isActionSupportedByFunction(self, functionPermission.functionSelector, TxAction(i))) {
2235
- revert SharedValidation.NotSupported();
2236
- }
2237
- }
2215
+ _validateActionsSupportedByFunction(self, functionPermission.functionSelector, bitmap);
2216
+ }
2217
+
2218
+ /**
2219
+ * @dev Validates that all actions present in the bitmap are supported by the function schema.
2220
+ * @param self The SecureOperationState to check.
2221
+ * @param functionSelector The function selector to check.
2222
+ * @param bitmap The granted actions bitmap to validate.
2223
+ */
2224
+ function _validateActionsSupportedByFunction(
2225
+ SecureOperationState storage self,
2226
+ bytes4 functionSelector,
2227
+ uint16 bitmap
2228
+ ) internal view {
2229
+ // If the function itself is not supported, none of its actions can be considered valid
2230
+ if (!self.supportedFunctionsSet.contains(bytes32(functionSelector))) {
2231
+ revert SharedValidation.NotSupported();
2232
+ }
2233
+
2234
+ uint16 granted = bitmap;
2235
+ uint16 supported = self.functions[functionSelector].supportedActionsBitmap;
2236
+
2237
+ // Any bit set in granted but not in supported is invalid
2238
+ uint16 invalid = granted & ~supported;
2239
+ if (invalid != 0) {
2240
+ revert SharedValidation.NotSupported();
2238
2241
  }
2239
2242
  }
2240
2243
 
@@ -2302,7 +2305,7 @@ library EngineBlox {
2302
2305
  * @dev Returns an empty PaymentDetails struct for use when no payment is attached.
2303
2306
  * @return payment Empty payment details (recipient and amounts zero).
2304
2307
  */
2305
- function _noPayment() internal pure returns (PaymentDetails memory payment) {
2308
+ function _emptyPayment() internal pure returns (PaymentDetails memory payment) {
2306
2309
  return PaymentDetails({
2307
2310
  recipient: address(0),
2308
2311
  nativeTokenAmount: 0,