@bloxchain/sdk 1.0.0-alpha.2 → 1.0.0-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +377 -376
  2. package/abi/AccountBlox.abi.json +2679 -4500
  3. package/abi/BareBlox.abi.json +94 -0
  4. package/abi/BaseStateMachine.abi.json +798 -753
  5. package/abi/CopyBlox.abi.json +1609 -0
  6. package/abi/EngineBlox.abi.json +566 -576
  7. package/abi/GuardController.abi.json +1546 -2095
  8. package/abi/GuardControllerDefinitions.abi.json +416 -0
  9. package/abi/IDefinition.abi.json +57 -47
  10. package/abi/RoleBlox.abi.json +2993 -4208
  11. package/abi/RuntimeRBAC.abi.json +901 -959
  12. package/abi/RuntimeRBACDefinitions.abi.json +265 -81
  13. package/abi/SecureBlox.abi.json +2752 -3827
  14. package/abi/SecureOwnable.abi.json +1522 -2581
  15. package/abi/SecureOwnableDefinitions.abi.json +174 -164
  16. package/dist/abi/AccountBlox.abi.json +3978 -0
  17. package/dist/abi/BareBlox.abi.json +1378 -0
  18. package/dist/abi/BaseStateMachine.abi.json +1281 -1236
  19. package/dist/abi/CopyBlox.abi.json +1609 -0
  20. package/dist/abi/EngineBlox.abi.json +862 -0
  21. package/dist/abi/GuardController.abi.json +2328 -2877
  22. package/dist/abi/GuardControllerDefinitions.abi.json +416 -0
  23. package/dist/abi/IDefinition.abi.json +122 -112
  24. package/dist/abi/RoleBlox.abi.json +2994 -0
  25. package/dist/abi/RuntimeRBAC.abi.json +1629 -1687
  26. package/dist/abi/RuntimeRBACDefinitions.abi.json +386 -0
  27. package/dist/abi/SecureBlox.abi.json +2753 -0
  28. package/dist/abi/SecureOwnable.abi.json +2733 -3792
  29. package/dist/abi/SecureOwnableDefinitions.abi.json +421 -0
  30. package/{abi → dist/abi}/SimpleRWA20.abi.json +478 -1756
  31. package/{abi → dist/abi}/SimpleRWA20Definitions.abi.json +5 -0
  32. package/{abi → dist/abi}/SimpleVault.abi.json +648 -2214
  33. package/{abi → dist/abi}/SimpleVaultDefinitions.abi.json +5 -0
  34. package/dist/abi.d.ts +11 -0
  35. package/dist/abi.d.ts.map +1 -0
  36. package/dist/abi.js +10 -0
  37. package/dist/abi.js.map +1 -0
  38. package/dist/contracts/{BaseStateMachine.d.ts → core/BaseStateMachine.d.ts} +20 -6
  39. package/dist/contracts/core/BaseStateMachine.d.ts.map +1 -0
  40. package/dist/contracts/{BaseStateMachine.js → core/BaseStateMachine.js} +88 -38
  41. package/dist/contracts/core/BaseStateMachine.js.map +1 -0
  42. package/dist/contracts/{GuardController.d.ts → core/GuardController.d.ts} +22 -15
  43. package/dist/contracts/core/GuardController.d.ts.map +1 -0
  44. package/dist/contracts/{GuardController.js → core/GuardController.js} +19 -21
  45. package/dist/contracts/core/GuardController.js.map +1 -0
  46. package/dist/contracts/core/RuntimeRBAC.d.ts +27 -0
  47. package/dist/contracts/core/RuntimeRBAC.d.ts.map +1 -0
  48. package/dist/contracts/core/RuntimeRBAC.js +33 -0
  49. package/dist/contracts/core/RuntimeRBAC.js.map +1 -0
  50. package/dist/contracts/{SecureOwnable.d.ts → core/SecureOwnable.d.ts} +5 -15
  51. package/dist/contracts/core/SecureOwnable.d.ts.map +1 -0
  52. package/dist/contracts/{SecureOwnable.js → core/SecureOwnable.js} +4 -23
  53. package/dist/contracts/core/SecureOwnable.js.map +1 -0
  54. package/dist/index.d.ts +8 -7
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +6 -6
  57. package/dist/index.js.map +1 -1
  58. package/dist/interfaces/base.index.d.ts +10 -2
  59. package/dist/interfaces/base.index.d.ts.map +1 -1
  60. package/dist/interfaces/base.state.machine.index.d.ts +3 -2
  61. package/dist/interfaces/base.state.machine.index.d.ts.map +1 -1
  62. package/dist/interfaces/core.access.index.d.ts +2 -16
  63. package/dist/interfaces/core.access.index.d.ts.map +1 -1
  64. package/dist/interfaces/core.execution.index.d.ts +8 -11
  65. package/dist/interfaces/core.execution.index.d.ts.map +1 -1
  66. package/dist/interfaces/core.security.index.d.ts +1 -4
  67. package/dist/interfaces/core.security.index.d.ts.map +1 -1
  68. package/dist/interfaces/lib.index.d.ts +1 -1
  69. package/dist/interfaces/lib.index.d.ts.map +1 -1
  70. package/dist/lib/Definition.d.ts.map +1 -1
  71. package/dist/lib/Definition.js +2 -0
  72. package/dist/lib/Definition.js.map +1 -1
  73. package/dist/lib/EngineBlox.d.ts +17 -51
  74. package/dist/lib/EngineBlox.d.ts.map +1 -1
  75. package/dist/lib/EngineBlox.js +26 -110
  76. package/dist/lib/EngineBlox.js.map +1 -1
  77. package/dist/lib/definitions/GuardControllerDefinitions.d.ts +34 -7
  78. package/dist/lib/definitions/GuardControllerDefinitions.d.ts.map +1 -1
  79. package/dist/lib/definitions/GuardControllerDefinitions.js +62 -10
  80. package/dist/lib/definitions/GuardControllerDefinitions.js.map +1 -1
  81. package/dist/lib/definitions/RuntimeRBACDefinitions.d.ts +48 -7
  82. package/dist/lib/definitions/RuntimeRBACDefinitions.d.ts.map +1 -1
  83. package/dist/lib/definitions/RuntimeRBACDefinitions.js +73 -10
  84. package/dist/lib/definitions/RuntimeRBACDefinitions.js.map +1 -1
  85. package/dist/lib/definitions/SecureOwnableDefinitions.d.ts +12 -7
  86. package/dist/lib/definitions/SecureOwnableDefinitions.d.ts.map +1 -1
  87. package/dist/lib/definitions/SecureOwnableDefinitions.js +25 -9
  88. package/dist/lib/definitions/SecureOwnableDefinitions.js.map +1 -1
  89. package/dist/lib/definitions/index.d.ts +6 -4
  90. package/dist/lib/definitions/index.d.ts.map +1 -1
  91. package/dist/lib/definitions/index.js +5 -4
  92. package/dist/lib/definitions/index.js.map +1 -1
  93. package/dist/types/base.state.machine.index.d.ts +0 -2
  94. package/dist/types/base.state.machine.index.d.ts.map +1 -1
  95. package/dist/types/base.state.machine.index.js +1 -3
  96. package/dist/types/base.state.machine.index.js.map +1 -1
  97. package/dist/types/core.execution.index.d.ts +1 -0
  98. package/dist/types/core.execution.index.d.ts.map +1 -1
  99. package/dist/types/core.execution.index.js +1 -0
  100. package/dist/types/core.execution.index.js.map +1 -1
  101. package/dist/types/core.security.index.d.ts.map +1 -1
  102. package/dist/types/core.security.index.js +2 -2
  103. package/dist/types/core.security.index.js.map +1 -1
  104. package/dist/types/definition.index.d.ts +7 -0
  105. package/dist/types/definition.index.d.ts.map +1 -1
  106. package/dist/types/definition.index.js.map +1 -1
  107. package/dist/types/lib.index.d.ts +0 -1
  108. package/dist/types/lib.index.d.ts.map +1 -1
  109. package/dist/types/lib.index.js +1 -2
  110. package/dist/types/lib.index.js.map +1 -1
  111. package/dist/utils/contract-errors.d.ts +125 -13
  112. package/dist/utils/contract-errors.d.ts.map +1 -1
  113. package/dist/utils/contract-errors.js +370 -107
  114. package/dist/utils/contract-errors.js.map +1 -1
  115. package/dist/utils/interface-ids.js +8 -8
  116. package/dist/utils/interface-ids.js.map +1 -1
  117. package/dist/utils/metaTx/metaTransaction.d.ts +103 -7
  118. package/dist/utils/metaTx/metaTransaction.d.ts.map +1 -1
  119. package/dist/utils/metaTx/metaTransaction.js +136 -25
  120. package/dist/utils/metaTx/metaTransaction.js.map +1 -1
  121. package/dist/utils/validations.d.ts.map +1 -1
  122. package/dist/utils/validations.js +10 -11
  123. package/dist/utils/validations.js.map +1 -1
  124. package/package.json +10 -6
  125. package/dist/contracts/BaseStateMachine.d.ts.map +0 -1
  126. package/dist/contracts/BaseStateMachine.js.map +0 -1
  127. package/dist/contracts/GuardController.d.ts.map +0 -1
  128. package/dist/contracts/GuardController.js.map +0 -1
  129. package/dist/contracts/RuntimeRBAC.d.ts +0 -54
  130. package/dist/contracts/RuntimeRBAC.d.ts.map +0 -1
  131. package/dist/contracts/RuntimeRBAC.js +0 -58
  132. package/dist/contracts/RuntimeRBAC.js.map +0 -1
  133. package/dist/contracts/SecureOwnable.d.ts.map +0 -1
  134. package/dist/contracts/SecureOwnable.js.map +0 -1
@@ -20,7 +20,7 @@ const keccak256 = (str) => {
20
20
  *
21
21
  * // Access constants
22
22
  * const protocolName = EngineBlox.PROTOCOL_NAME_HASH;
23
- * const version = `${EngineBlox.VERSION_MAJOR}.${EngineBlox.VERSION_MINOR}.${EngineBlox.VERSION_PATCH}`;
23
+ * const version = EngineBlox.VERSION;
24
24
  *
25
25
  * // Use pure functions
26
26
  * const signer = EngineBlox.recoverSigner(messageHash, signature);
@@ -32,113 +32,28 @@ const keccak256 = (str) => {
32
32
  export class EngineBlox {
33
33
  // ============ PURE FUNCTIONS ============
34
34
  /**
35
- * @dev Recovers the signer address from a message hash and signature
36
- * @param messageHash The hash of the message that was signed (bytes32)
37
- * @param signature The signature to recover the address from (65 bytes)
35
+ * @dev Recovers the signer address from the EIP-712 digest and signature (standard EIP-712; no EIP-191 prefix).
36
+ * @param messageHash The EIP-712 digest (keccak256("\x19\x01" || domainSeparator || structHash))
37
+ * @param signature The signature (65 bytes)
38
38
  * @returns Promise that resolves to the address of the signer
39
- * @throws Error if signature is invalid or recovery fails
40
- *
41
- * @notice This matches the contract's recoverSigner function which uses
42
- * messageHash.toEthSignedMessageHash() to convert to EIP-191 format
43
- *
44
- * @example
45
- * ```typescript
46
- * const messageHash = "0x1234...";
47
- * const signature = "0xabcd...";
48
- * const signer = await EngineBlox.recoverSigner(messageHash, signature);
49
- * ```
39
+ * @notice Matches the contract's recoverSigner which uses ecrecover(messageHash, v, r, s) on the raw digest.
50
40
  */
51
41
  static async recoverSigner(messageHash, signature) {
52
- // Validate signature length (65 bytes = 130 hex chars + '0x' prefix)
53
42
  if (signature.length !== 132) {
54
- throw new Error(`Invalid signature length: expected 65 bytes (132 hex chars), got ${signature.length - 2} bytes`);
43
+ throw new Error(`Invalid signature length: expected 65 bytes (132 hex chars), got ${(signature.length - 2) / 2} bytes`);
55
44
  }
56
45
  try {
57
- // The contract uses messageHash.toEthSignedMessageHash() which converts to EIP-191 format
58
- // EIP-191 format for 32-byte hash: keccak256("\x19Ethereum Signed Message:\n32" + messageHash)
59
- // We need to create the EIP-191 formatted hash and then recover from it
60
- const prefix = '\x19Ethereum Signed Message:\n32';
61
- const messageHashBytes = Buffer.from(messageHash.slice(2), 'hex');
62
- // Concatenate prefix and hash
63
- const eip191Message = Buffer.concat([
64
- Buffer.from(prefix, 'utf8'),
65
- messageHashBytes
66
- ]);
67
- // Convert Buffer to Uint8Array for viem
68
- const eip191MessageBytes = new Uint8Array(eip191Message);
69
- // Hash the EIP-191 formatted message
70
- const eip191Hash = (await k256(eip191MessageBytes));
71
- // Recover address from the EIP-191 formatted hash
72
- // Note: recoverAddress is async in viem
73
- const recovered = await recoverAddress({
74
- hash: eip191Hash,
75
- signature: signature
46
+ const signer = await recoverAddress({
47
+ hash: messageHash,
48
+ signature
76
49
  });
77
- return recovered;
50
+ return signer;
78
51
  }
79
52
  catch (error) {
80
53
  throw new Error(`Failed to recover signer: ${error instanceof Error ? error.message : 'Unknown error'}`);
81
54
  }
82
55
  }
83
56
  // ============ VIEW FUNCTIONS (No storage access) ============
84
- /**
85
- * @dev Checks if a function selector exists in a contract's bytecode
86
- * @param client PublicClient instance for reading contract bytecode
87
- * @param contractAddress The address of the contract to check
88
- * @param selector The 4-byte function selector to search for
89
- * @returns Promise that resolves to true if the selector is found in the contract's function selector dispatch table
90
- *
91
- * @notice Searches the first 2KB where function selectors are stored in the dispatch table
92
- * @notice This is a heuristic check - false positives are possible but unlikely
93
- *
94
- * @example
95
- * ```typescript
96
- * const exists = await EngineBlox.selectorExistsInContract(
97
- * publicClient,
98
- * '0x1234...',
99
- * '0xabcd1234'
100
- * );
101
- * ```
102
- */
103
- static async selectorExistsInContract(client, contractAddress, selector) {
104
- try {
105
- // Get the contract's bytecode
106
- const code = await client.getCode({ address: contractAddress });
107
- if (!code || code.length < 12) { // Need at least '0x' + PUSH4 (1 byte = 2 hex chars) + selector (4 bytes = 8 hex chars) = 12 chars
108
- return false;
109
- }
110
- // Function selectors are in the dispatch table at the beginning
111
- // Typical dispatch tables are < 2KB even for large contracts
112
- // Searching only this area reduces gas cost and false positives from metadata/data
113
- // 2KB = 2048 bytes = 4096 hex chars (plus '0x' prefix = 4098 total)
114
- const maxSearchBytes = 2048;
115
- const codeHexLength = code.length - 2; // Remove '0x' prefix
116
- const maxSearchHexChars = maxSearchBytes * 2; // Each byte is 2 hex chars
117
- const searchLength = codeHexLength < maxSearchHexChars ? codeHexLength : maxSearchHexChars;
118
- // Convert hex strings for searching (normalize to lowercase)
119
- const codeBytes = code.slice(2).toLowerCase(); // Remove '0x' prefix and normalize
120
- const selectorBytes = selector.slice(2).toLowerCase(); // Remove '0x' and normalize
121
- // Scan for PUSH4 opcode (0x63 = "63" in hex) with 1-byte sliding window
122
- // PUSH4 opcode is followed by 4 bytes (8 hex chars) which is the function selector
123
- // Function selectors in EVM bytecode are emitted as PUSH4 <selector> instructions
124
- // These can start at any byte offset, not just 4-byte-aligned positions
125
- for (let i = 0; i + 10 <= searchLength; i += 2) { // i += 2 because each byte is 2 hex chars
126
- // Check if current byte is PUSH4 opcode (0x63 = "63" in hex)
127
- if (codeBytes.slice(i, i + 2) === '63') {
128
- // Check if the next 8 hex chars (4 bytes) match the selector
129
- const candidate = codeBytes.slice(i + 2, i + 10);
130
- if (candidate === selectorBytes) {
131
- return true;
132
- }
133
- }
134
- }
135
- return false;
136
- }
137
- catch (error) {
138
- // If we can't read the bytecode, return false
139
- return false;
140
- }
141
- }
142
57
  // ============ BITMAP HELPER FUNCTIONS ============
143
58
  /**
144
59
  * @dev Checks if a TxAction is present in a bitmap
@@ -209,6 +124,15 @@ export class EngineBlox {
209
124
  }
210
125
  return actions;
211
126
  }
127
+ /**
128
+ * Hash of execution returndata (`bytes32(0)` when empty). Matches `EngineBlox.executionResultHash` on-chain.
129
+ */
130
+ static executionResultHash(executionResult) {
131
+ if (!executionResult || executionResult === '0x') {
132
+ return `0x${'0'.repeat(64)}`;
133
+ }
134
+ return k256(executionResult);
135
+ }
212
136
  }
213
137
  // ============ VERSION INFORMATION ============
214
138
  /**
@@ -216,17 +140,9 @@ export class EngineBlox {
216
140
  */
217
141
  EngineBlox.PROTOCOL_NAME_HASH = keccak256("Bloxchain");
218
142
  /**
219
- * Major version number
220
- */
221
- EngineBlox.VERSION_MAJOR = 1;
222
- /**
223
- * Minor version number
224
- */
225
- EngineBlox.VERSION_MINOR = 0;
226
- /**
227
- * Patch version number
143
+ * Protocol version string (semver, e.g. "1.0.0"). Matches EngineBlox.sol VERSION and EIP-712 domain version.
228
144
  */
229
- EngineBlox.VERSION_PATCH = 0;
145
+ EngineBlox.VERSION = "1.0.0";
230
146
  // ============ FUNCTION SELECTORS ============
231
147
  /**
232
148
  * Native token transfer selector (reserved signature for simple ETH transfers)
@@ -238,14 +154,14 @@ EngineBlox.NATIVE_TRANSFER_SELECTOR = ('0x' + k256(new TextEncoder().encode("__b
238
154
  */
239
155
  EngineBlox.NATIVE_TRANSFER_OPERATION = keccak256("NATIVE_TRANSFER");
240
156
  /**
241
- * Payment update selector (reserved signature for payment detail updates)
242
- * Computed as bytes4(keccak256("__bloxchain_update_payment__()"))
157
+ * Pseudo-selector: whitelist key for attached payment recipients (native + ERC20 payout addresses).
158
+ * Matches `ATTACHED_PAYMENT_RECIPIENT_SELECTOR` in EngineBlox.sol.
243
159
  */
244
- EngineBlox.UPDATE_PAYMENT_SELECTOR = ('0x' + k256(new TextEncoder().encode("__bloxchain_update_payment__()")).slice(2, 10));
160
+ EngineBlox.ATTACHED_PAYMENT_RECIPIENT_SELECTOR = ('0x' + k256(new TextEncoder().encode('__bloxchain_attached_payment_recipient__()')).slice(2, 10));
245
161
  /**
246
- * Payment update operation type hash
162
+ * Standard IERC20 `transfer(address,uint256)` whitelist key for token contracts in attached ERC20 payments.
247
163
  */
248
- EngineBlox.UPDATE_PAYMENT_OPERATION = keccak256("UPDATE_PAYMENT");
164
+ EngineBlox.ERC20_TRANSFER_SELECTOR = ('0x' + k256(new TextEncoder().encode('transfer(address,uint256)')).slice(2, 10));
249
165
  // ============ ROLE CONSTANTS ============
250
166
  /**
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helpers for building execution params for GuardController operations.
4
- * Mirrors GuardControllerDefinitions.sol; no contract calls.
5
- * Uses parseAbiParameters + array-of-[actionType,data] to match web3 encodeParameter('tuple(uint8,bytes)[]', [[actionType, data], ...]).
3
+ * Calls the deployed GuardControllerDefinitions contract for specs and encoding.
4
+ * Single source of truth: action names, formats, and encoding come from the contract.
5
+ * @see contracts/core/execution/lib/definitions/GuardControllerDefinitions.sol
6
+ * @see scripts/sanity/guard-controller/base-test.cjs createGuardConfigBatchMetaTx (actionsArray = [actionType, data] per element)
6
7
  */
7
- import { Hex } from 'viem';
8
+ import { type Address, type Hex, type PublicClient } from 'viem';
8
9
  import type { GuardConfigAction } from '../../types/core.execution.index';
10
+ import type { TxAction } from '../../types/lib.index';
9
11
  /**
10
12
  * Builds execution params for executeGuardConfigBatch((uint8,bytes)[]).
11
- * Equivalent to GuardControllerDefinitions.guardConfigBatchExecutionParams in Solidity.
12
- * Same encoding as web3.eth.abi.encodeParameter('tuple(uint8,bytes)[]', actionsArray).
13
+ * Encoding matches GuardControllerDefinitions.sol guardConfigBatchExecutionParams (abi.encode(actions)).
14
+ * Same format as scripts/sanity (direct contract tests); single source of truth in this module.
13
15
  */
14
- export declare function guardConfigBatchExecutionParams(actions: GuardConfigAction[]): Hex;
16
+ export declare function guardConfigBatchExecutionParams(_client: PublicClient, _definitionAddress: Address, actions: GuardConfigAction[]): Hex;
17
+ /**
18
+ * Returns all available GuardConfig action types and their ABI decode formats from the contract.
19
+ * Index i in both arrays corresponds to GuardConfigActionType enum value i.
20
+ */
21
+ export declare function getGuardConfigActionSpecs(client: PublicClient, definitionAddress: Address): Promise<{
22
+ actionNames: string[];
23
+ formats: string[];
24
+ }>;
25
+ /**
26
+ * Encodes data for ADD_TARGET_TO_WHITELIST. Matches GuardControllerDefinitions.sol encodeAddTargetToWhitelist (abi.encode(functionSelector, target)).
27
+ */
28
+ export declare function encodeAddTargetToWhitelist(_client: PublicClient, _definitionAddress: Address, functionSelector: Hex, target: Address): Hex;
29
+ /**
30
+ * Encodes data for REMOVE_TARGET_FROM_WHITELIST. Matches GuardControllerDefinitions.sol encodeRemoveTargetFromWhitelist (abi.encode(functionSelector, target)).
31
+ */
32
+ export declare function encodeRemoveTargetFromWhitelist(_client: PublicClient, _definitionAddress: Address, functionSelector: Hex, target: Address): Hex;
33
+ /**
34
+ * Encodes data for REGISTER_FUNCTION. Matches GuardControllerDefinitions.sol encodeRegisterFunction (abi.encode(functionSignature, operationName, supportedActions)).
35
+ * supportedActions: array of TxAction enum values (e.g. TxAction.EXECUTE_TIME_DELAY_REQUEST).
36
+ */
37
+ export declare function encodeRegisterFunction(_client: PublicClient, _definitionAddress: Address, functionSignature: string, operationName: string, supportedActions: TxAction[]): Hex;
38
+ /**
39
+ * Encodes data for UNREGISTER_FUNCTION. Matches GuardControllerDefinitions.sol encodeUnregisterFunction (abi.encode(functionSelector, safeRemoval)).
40
+ */
41
+ export declare function encodeUnregisterFunction(_client: PublicClient, _definitionAddress: Address, functionSelector: Hex, safeRemoval: boolean): Hex;
15
42
  //# sourceMappingURL=GuardControllerDefinitions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GuardControllerDefinitions.d.ts","sourceRoot":"","sources":["../../../lib/definitions/GuardControllerDefinitions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAA2C,MAAM,MAAM,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,GAAG,CASjF"}
1
+ {"version":3,"file":"GuardControllerDefinitions.d.ts","sourceRoot":"","sources":["../../../lib/definitions/GuardControllerDefinitions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAY,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,EAAuD,MAAM,MAAM,CAAC;AAEhI,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAWtD;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,YAAY,EACrB,kBAAkB,EAAE,OAAO,EAC3B,OAAO,EAAE,iBAAiB,EAAE,GAC3B,GAAG,CASL;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,YAAY,EACpB,iBAAiB,EAAE,OAAO,GACzB,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAOvD;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,YAAY,EACrB,kBAAkB,EAAE,OAAO,EAC3B,gBAAgB,EAAE,GAAG,EACrB,MAAM,EAAE,OAAO,GACd,GAAG,CAEL;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,YAAY,EACrB,kBAAkB,EAAE,OAAO,EAC3B,gBAAgB,EAAE,GAAG,EACrB,MAAM,EAAE,OAAO,GACd,GAAG,CAEL;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,YAAY,EACrB,kBAAkB,EAAE,OAAO,EAC3B,iBAAiB,EAAE,MAAM,EACzB,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,QAAQ,EAAE,GAC3B,GAAG,CAML;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,YAAY,EACrB,kBAAkB,EAAE,OAAO,EAC3B,gBAAgB,EAAE,GAAG,EACrB,WAAW,EAAE,OAAO,GACnB,GAAG,CAEL"}
@@ -1,20 +1,72 @@
1
1
  /**
2
2
  * GuardControllerDefinitions
3
- * Pure helpers for building execution params for GuardController operations.
4
- * Mirrors GuardControllerDefinitions.sol; no contract calls.
5
- * Uses parseAbiParameters + array-of-[actionType,data] to match web3 encodeParameter('tuple(uint8,bytes)[]', [[actionType, data], ...]).
3
+ * Calls the deployed GuardControllerDefinitions contract for specs and encoding.
4
+ * Single source of truth: action names, formats, and encoding come from the contract.
5
+ * @see contracts/core/execution/lib/definitions/GuardControllerDefinitions.sol
6
+ * @see scripts/sanity/guard-controller/base-test.cjs createGuardConfigBatchMetaTx (actionsArray = [actionType, data] per element)
6
7
  */
7
- import { encodeAbiParameters, parseAbiParameters } from 'viem';
8
+ import { bytesToHex, encodeAbiParameters, parseAbiParameters } from 'viem';
9
+ import GuardControllerDefinitionsAbi from '../../abi/GuardControllerDefinitions.abi.json';
10
+ const ABI = GuardControllerDefinitionsAbi;
11
+ /** Normalize bytes to ABI Hex (0x-prefixed); empty -> '0x'. */
12
+ function normalizeData(data) {
13
+ if (data === undefined || data === null)
14
+ return '0x';
15
+ if (typeof data === 'string')
16
+ return data.startsWith('0x') ? data : `0x${data}`;
17
+ return bytesToHex(data);
18
+ }
8
19
  /**
9
20
  * Builds execution params for executeGuardConfigBatch((uint8,bytes)[]).
10
- * Equivalent to GuardControllerDefinitions.guardConfigBatchExecutionParams in Solidity.
11
- * Same encoding as web3.eth.abi.encodeParameter('tuple(uint8,bytes)[]', actionsArray).
21
+ * Encoding matches GuardControllerDefinitions.sol guardConfigBatchExecutionParams (abi.encode(actions)).
22
+ * Same format as scripts/sanity (direct contract tests); single source of truth in this module.
12
23
  */
13
- export function guardConfigBatchExecutionParams(actions) {
14
- const actionsArray = actions.map((a) => ({
24
+ export function guardConfigBatchExecutionParams(_client, _definitionAddress, actions) {
25
+ const actionsTuple = actions.map((a) => ({
15
26
  actionType: Number(a.actionType),
16
- data: a.data
27
+ data: normalizeData(a.data)
28
+ }));
29
+ return encodeAbiParameters(parseAbiParameters('(uint8 actionType, bytes data)[]'), [actionsTuple]);
30
+ }
31
+ /**
32
+ * Returns all available GuardConfig action types and their ABI decode formats from the contract.
33
+ * Index i in both arrays corresponds to GuardConfigActionType enum value i.
34
+ */
35
+ export async function getGuardConfigActionSpecs(client, definitionAddress) {
36
+ const result = (await client.readContract({
37
+ address: definitionAddress,
38
+ abi: ABI,
39
+ functionName: 'getGuardConfigActionSpecs'
17
40
  }));
18
- return encodeAbiParameters(parseAbiParameters('(uint8 actionType, bytes data)[]'), [actionsArray]);
41
+ return { actionNames: result[0], formats: result[1] };
42
+ }
43
+ /**
44
+ * Encodes data for ADD_TARGET_TO_WHITELIST. Matches GuardControllerDefinitions.sol encodeAddTargetToWhitelist (abi.encode(functionSelector, target)).
45
+ */
46
+ export function encodeAddTargetToWhitelist(_client, _definitionAddress, functionSelector, target) {
47
+ return encodeAbiParameters(parseAbiParameters('bytes4, address'), [functionSelector, target]);
48
+ }
49
+ /**
50
+ * Encodes data for REMOVE_TARGET_FROM_WHITELIST. Matches GuardControllerDefinitions.sol encodeRemoveTargetFromWhitelist (abi.encode(functionSelector, target)).
51
+ */
52
+ export function encodeRemoveTargetFromWhitelist(_client, _definitionAddress, functionSelector, target) {
53
+ return encodeAbiParameters(parseAbiParameters('bytes4, address'), [functionSelector, target]);
54
+ }
55
+ /**
56
+ * Encodes data for REGISTER_FUNCTION. Matches GuardControllerDefinitions.sol encodeRegisterFunction (abi.encode(functionSignature, operationName, supportedActions)).
57
+ * supportedActions: array of TxAction enum values (e.g. TxAction.EXECUTE_TIME_DELAY_REQUEST).
58
+ */
59
+ export function encodeRegisterFunction(_client, _definitionAddress, functionSignature, operationName, supportedActions) {
60
+ return encodeAbiParameters(parseAbiParameters('string, string, uint8[]'), [
61
+ functionSignature,
62
+ operationName,
63
+ supportedActions.map((a) => Number(a))
64
+ ]);
65
+ }
66
+ /**
67
+ * Encodes data for UNREGISTER_FUNCTION. Matches GuardControllerDefinitions.sol encodeUnregisterFunction (abi.encode(functionSelector, safeRemoval)).
68
+ */
69
+ export function encodeUnregisterFunction(_client, _definitionAddress, functionSelector, safeRemoval) {
70
+ return encodeAbiParameters(parseAbiParameters('bytes4, bool'), [functionSelector, safeRemoval]);
19
71
  }
20
72
  //# sourceMappingURL=GuardControllerDefinitions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GuardControllerDefinitions.js","sourceRoot":"","sources":["../../../lib/definitions/GuardControllerDefinitions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAO,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAGpE;;;;GAIG;AACH,MAAM,UAAU,+BAA+B,CAAC,OAA4B;IAC1E,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACvC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC;QAChC,IAAI,EAAE,CAAC,CAAC,IAAI;KACb,CAAC,CAAC,CAAC;IACJ,OAAO,mBAAmB,CACxB,kBAAkB,CAAC,kCAAkC,CAAC,EACtD,CAAC,YAAY,CAAC,CACR,CAAC;AACX,CAAC"}
1
+ {"version":3,"file":"GuardControllerDefinitions.js","sourceRoot":"","sources":["../../../lib/definitions/GuardControllerDefinitions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAuD,UAAU,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAChI,OAAO,6BAA6B,MAAM,+CAA+C,CAAC;AAI1F,MAAM,GAAG,GAAG,6BAAoC,CAAC;AAEjD,+DAA+D;AAC/D,SAAS,aAAa,CAAC,IAAyC;IAC9D,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACrD,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,IAAY,CAAC,CAAC,CAAE,KAAK,IAAI,EAAU,CAAC;IAClG,OAAO,UAAU,CAAC,IAAkB,CAAQ,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,U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,EAC3B,iBAAyB,EACzB,aAAqB,EACrB,gBAA4B;IAE5B,OAAO,mBAAmB,CAAC,kBAAkB,CAAC,yBAAyB,CAAC,EAAE;QACxE,iBAAiB;QACjB,aAAa;QACb,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KACvC,CAAQ,CAAC;AACZ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAAqB,EACrB,kBAA2B,EAC3B,gBAAqB,EACrB,WAAoB;IAEpB,OAAO,mBAAmB,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAQ,CAAC;AACzG,CAAC"}
@@ -1,15 +1,56 @@
1
1
  /**
2
2
  * RuntimeRBACDefinitions
3
- * Pure helpers for building execution params for RuntimeRBAC operations.
4
- * Mirrors RuntimeRBACDefinitions.sol; no contract calls.
5
- * Uses parseAbiParameters + array-of-[actionType,data] to match web3 encodeParameter('tuple(uint8,bytes)[]', ...).
3
+ * Calls the deployed RuntimeRBACDefinitions contract for specs and encoding.
4
+ * Single source of truth: action names, formats, and encoding come from the contract.
5
+ * @see contracts/core/access/lib/definitions/RuntimeRBACDefinitions.sol
6
6
  */
7
- import { Hex } from 'viem';
7
+ import { type Address, type Hex, type PublicClient } from 'viem';
8
8
  import type { RoleConfigAction } from '../../types/core.access.index';
9
+ /**
10
+ * FunctionPermission shape for encodeAddFunctionToRole.
11
+ * Matches Solidity EngineBlox.FunctionPermission (functionSelector, grantedActionsBitmap, handlerForSelectors).
12
+ */
13
+ export interface FunctionPermissionForEncoding {
14
+ functionSelector: Hex;
15
+ grantedActionsBitmap: number;
16
+ handlerForSelectors: readonly Hex[];
17
+ }
9
18
  /**
10
19
  * Builds execution params for executeRoleConfigBatch((uint8,bytes)[]).
11
- * Equivalent to RuntimeRBACDefinitions.roleConfigBatchExecutionParams in Solidity.
12
- * Same encoding as web3.eth.abi.encodeParameter('tuple(uint8,bytes)[]', actionsArray).
20
+ * Encoding matches RuntimeRBACDefinitions.sol roleConfigBatchExecutionParams (abi.encode(actions)).
21
+ * Same format as scripts/sanity (direct contract tests); single source of truth in this module.
22
+ */
23
+ export declare function roleConfigBatchExecutionParams(_client: PublicClient, _definitionAddress: Address, actions: RoleConfigAction[]): Hex;
24
+ /**
25
+ * Returns all available RoleConfig action types and their ABI decode formats from the contract.
26
+ * Index i in both arrays corresponds to RoleConfigActionType enum value i.
27
+ */
28
+ export declare function getRoleConfigActionSpecs(client: PublicClient, definitionAddress: Address): Promise<{
29
+ actionNames: string[];
30
+ formats: string[];
31
+ }>;
32
+ /**
33
+ * Encodes data for CREATE_ROLE. Matches RuntimeRBACDefinitions.sol encodeCreateRole (abi.encode(roleName, maxWallets)).
34
+ */
35
+ export declare function encodeCreateRole(_client: PublicClient, _definitionAddress: Address, roleName: string, maxWallets: bigint): Hex;
36
+ /**
37
+ * Encodes data for REMOVE_ROLE. Matches RuntimeRBACDefinitions.sol encodeRemoveRole (abi.encode(roleHash)).
38
+ */
39
+ export declare function encodeRemoveRole(_client: PublicClient, _definitionAddress: Address, roleHash: Hex): Hex;
40
+ /**
41
+ * Encodes data for ADD_WALLET. Matches RuntimeRBACDefinitions.sol encodeAddWallet (abi.encode(roleHash, wallet)).
42
+ */
43
+ export declare function encodeAddWallet(_client: PublicClient, _definitionAddress: Address, roleHash: Hex, wallet: Address): Hex;
44
+ /**
45
+ * Encodes data for REVOKE_WALLET. Matches RuntimeRBACDefinitions.sol encodeRevokeWallet (abi.encode(roleHash, wallet)).
46
+ */
47
+ export declare function encodeRevokeWallet(_client: PublicClient, _definitionAddress: Address, roleHash: Hex, wallet: Address): Hex;
48
+ /**
49
+ * Encodes data for ADD_FUNCTION_TO_ROLE. Matches RuntimeRBACDefinitions.sol encodeAddFunctionToRole (abi.encode(roleHash, functionPermission)).
50
+ */
51
+ export declare function encodeAddFunctionToRole(_client: PublicClient, _definitionAddress: Address, roleHash: Hex, functionPermission: FunctionPermissionForEncoding): Hex;
52
+ /**
53
+ * Encodes data for REMOVE_FUNCTION_FROM_ROLE. Matches RuntimeRBACDefinitions.sol encodeRemoveFunctionFromRole (abi.encode(roleHash, functionSelector)).
13
54
  */
14
- export declare function roleConfigBatchExecutionParams(actions: RoleConfigAction[]): Hex;
55
+ export declare function encodeRemoveFunctionFromRole(_client: PublicClient, _definitionAddress: Address, roleHash: Hex, functionSelector: Hex): Hex;
15
56
  //# sourceMappingURL=RuntimeRBACDefinitions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RuntimeRBACDefinitions.d.ts","sourceRoot":"","sources":["../../../lib/definitions/RuntimeRBACDefinitions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAA2C,MAAM,MAAM,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,GAAG,CAS/E"}
1
+ {"version":3,"file":"RuntimeRBACDefinitions.d.ts","sourceRoot":"","sources":["../../../lib/definitions/RuntimeRBACDefinitions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAY,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,EAAuD,MAAM,MAAM,CAAC;AAEhI,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAWtE;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C,gBAAgB,EAAE,GAAG,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,SAAS,GAAG,EAAE,CAAC;CACrC;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,YAAY,EACrB,kBAAkB,EAAE,OAAO,EAC3B,OAAO,EAAE,gBAAgB,EAAE,GAC1B,GAAG,CASL;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,YAAY,EACpB,iBAAiB,EAAE,OAAO,GACzB,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAOvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,EACrB,kBAAkB,EAAE,OAAO,EAC3B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,GAAG,CAEL;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,EACrB,kBAAkB,EAAE,OAAO,EAC3B,QAAQ,EAAE,GAAG,GACZ,GAAG,CAEL;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,YAAY,EACrB,kBAAkB,EAAE,OAAO,EAC3B,QAAQ,EAAE,GAAG,EACb,MAAM,EAAE,OAAO,GACd,GAAG,CAEL;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,YAAY,EACrB,kBAAkB,EAAE,OAAO,EAC3B,QAAQ,EAAE,GAAG,EACb,MAAM,EAAE,OAAO,GACd,GAAG,CAEL;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,YAAY,EACrB,kBAAkB,EAAE,OAAO,EAC3B,QAAQ,EAAE,GAAG,EACb,kBAAkB,EAAE,6BAA6B,GAChD,GAAG,CAUL;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,YAAY,EACrB,kBAAkB,EAAE,OAAO,EAC3B,QAAQ,EAAE,GAAG,EACb,gBAAgB,EAAE,GAAG,GACpB,GAAG,CAEL"}
@@ -1,20 +1,83 @@
1
1
  /**
2
2
  * RuntimeRBACDefinitions
3
- * Pure helpers for building execution params for RuntimeRBAC operations.
4
- * Mirrors RuntimeRBACDefinitions.sol; no contract calls.
5
- * Uses parseAbiParameters + array-of-[actionType,data] to match web3 encodeParameter('tuple(uint8,bytes)[]', ...).
3
+ * Calls the deployed RuntimeRBACDefinitions contract for specs and encoding.
4
+ * Single source of truth: action names, formats, and encoding come from the contract.
5
+ * @see contracts/core/access/lib/definitions/RuntimeRBACDefinitions.sol
6
6
  */
7
- import { encodeAbiParameters, parseAbiParameters } from 'viem';
7
+ import { bytesToHex, encodeAbiParameters, parseAbiParameters } from 'viem';
8
+ import RuntimeRBACDefinitionsAbi from '../../abi/RuntimeRBACDefinitions.abi.json';
9
+ const ABI = RuntimeRBACDefinitionsAbi;
10
+ /** Normalize bytes to ABI Hex (0x-prefixed); empty -> '0x'. */
11
+ function normalizeData(data) {
12
+ if (data === undefined || data === null)
13
+ return '0x';
14
+ if (typeof data === 'string')
15
+ return data.startsWith('0x') ? data : `0x${data}`;
16
+ return bytesToHex(data);
17
+ }
8
18
  /**
9
19
  * Builds execution params for executeRoleConfigBatch((uint8,bytes)[]).
10
- * Equivalent to RuntimeRBACDefinitions.roleConfigBatchExecutionParams in Solidity.
11
- * Same encoding as web3.eth.abi.encodeParameter('tuple(uint8,bytes)[]', actionsArray).
20
+ * Encoding matches RuntimeRBACDefinitions.sol roleConfigBatchExecutionParams (abi.encode(actions)).
21
+ * Same format as scripts/sanity (direct contract tests); single source of truth in this module.
12
22
  */
13
- export function roleConfigBatchExecutionParams(actions) {
14
- const actionsArray = actions.map((a) => ({
23
+ export function roleConfigBatchExecutionParams(_client, _definitionAddress, actions) {
24
+ const actionsTuple = actions.map((a) => ({
15
25
  actionType: Number(a.actionType),
16
- data: a.data
26
+ data: normalizeData(a.data)
27
+ }));
28
+ return encodeAbiParameters(parseAbiParameters('(uint8 actionType, bytes data)[]'), [actionsTuple]);
29
+ }
30
+ /**
31
+ * Returns all available RoleConfig action types and their ABI decode formats from the contract.
32
+ * Index i in both arrays corresponds to RoleConfigActionType enum value i.
33
+ */
34
+ export async function getRoleConfigActionSpecs(client, definitionAddress) {
35
+ const result = (await client.readContract({
36
+ address: definitionAddress,
37
+ abi: ABI,
38
+ functionName: 'getRoleConfigActionSpecs'
17
39
  }));
18
- return encodeAbiParameters(parseAbiParameters('(uint8 actionType, bytes data)[]'), [actionsArray]);
40
+ return { actionNames: result[0], formats: result[1] };
41
+ }
42
+ /**
43
+ * Encodes data for CREATE_ROLE. Matches RuntimeRBACDefinitions.sol encodeCreateRole (abi.encode(roleName, maxWallets)).
44
+ */
45
+ export function encodeCreateRole(_client, _definitionAddress, roleName, maxWallets) {
46
+ return encodeAbiParameters(parseAbiParameters('string, uint256'), [roleName, maxWallets]);
47
+ }
48
+ /**
49
+ * Encodes data for REMOVE_ROLE. Matches RuntimeRBACDefinitions.sol encodeRemoveRole (abi.encode(roleHash)).
50
+ */
51
+ export function encodeRemoveRole(_client, _definitionAddress, roleHash) {
52
+ return encodeAbiParameters(parseAbiParameters('bytes32'), [roleHash]);
53
+ }
54
+ /**
55
+ * Encodes data for ADD_WALLET. Matches RuntimeRBACDefinitions.sol encodeAddWallet (abi.encode(roleHash, wallet)).
56
+ */
57
+ export function encodeAddWallet(_client, _definitionAddress, roleHash, wallet) {
58
+ return encodeAbiParameters(parseAbiParameters('bytes32, address'), [roleHash, wallet]);
59
+ }
60
+ /**
61
+ * Encodes data for REVOKE_WALLET. Matches RuntimeRBACDefinitions.sol encodeRevokeWallet (abi.encode(roleHash, wallet)).
62
+ */
63
+ export function encodeRevokeWallet(_client, _definitionAddress, roleHash, wallet) {
64
+ return encodeAbiParameters(parseAbiParameters('bytes32, address'), [roleHash, wallet]);
65
+ }
66
+ /**
67
+ * Encodes data for ADD_FUNCTION_TO_ROLE. Matches RuntimeRBACDefinitions.sol encodeAddFunctionToRole (abi.encode(roleHash, functionPermission)).
68
+ */
69
+ export function encodeAddFunctionToRole(_client, _definitionAddress, roleHash, functionPermission) {
70
+ const tuple = [
71
+ functionPermission.functionSelector,
72
+ functionPermission.grantedActionsBitmap,
73
+ [...functionPermission.handlerForSelectors]
74
+ ];
75
+ return encodeAbiParameters(parseAbiParameters('bytes32, (bytes4, uint16, bytes4[])'), [roleHash, tuple]);
76
+ }
77
+ /**
78
+ * Encodes data for REMOVE_FUNCTION_FROM_ROLE. Matches RuntimeRBACDefinitions.sol encodeRemoveFunctionFromRole (abi.encode(roleHash, functionSelector)).
79
+ */
80
+ export function encodeRemoveFunctionFromRole(_client, _definitionAddress, roleHash, functionSelector) {
81
+ return encodeAbiParameters(parseAbiParameters('bytes32, bytes4'), [roleHash, functionSelector]);
19
82
  }
20
83
  //# sourceMappingURL=RuntimeRBACDefinitions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RuntimeRBACDefinitions.js","sourceRoot":"","sources":["../../../lib/definitions/RuntimeRBACDefinitions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAO,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAGpE;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAAC,OAA2B;IACxE,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACvC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC;QAChC,IAAI,EAAE,CAAC,CAAC,IAAI;KACb,CAAC,CAAC,CAAC;IACJ,OAAO,mBAAmB,CACxB,kBAAkB,CAAC,kCAAkC,CAAC,EACtD,CAAC,YAAY,CAAC,CACR,CAAC;AACX,CAAC"}
1
+ {"version":3,"file":"RuntimeRBACDefinitions.js","sourceRoot":"","sources":["../../../lib/definitions/RuntimeRBACDefinitions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAuD,UAAU,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAChI,OAAO,yBAAyB,MAAM,2CAA2C,CAAC;AAGlF,MAAM,GAAG,GAAG,yBAAgC,CAAC;AAE7C,+DAA+D;AAC/D,SAAS,aAAa,CAAC,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/**
2
2
  * SecureOwnableDefinitions
3
- * Pure helpers for building execution params for SecureOwnable operations.
4
- * Mirrors SecureOwnableDefinitions.sol; no contract calls.
3
+ * Calls the deployed SecureOwnableDefinitions contract for execution params.
4
+ * Single source of truth: encoding is done by the contract to avoid TypeScript/Solidity drift.
5
+ * @see contracts/core/security/lib/definitions/SecureOwnableDefinitions.sol
5
6
  */
6
- import { Address, Hex } from 'viem';
7
+ import { type Address, type Hex, type PublicClient } from 'viem';
7
8
  /**
8
- * Builds execution params for executeRecoveryUpdate(address).
9
+ * Builds execution params for executeRecoveryUpdate(address) by calling the definition contract.
9
10
  * Equivalent to SecureOwnableDefinitions.updateRecoveryExecutionParams in Solidity.
11
+ * @param client Viem public client
12
+ * @param definitionAddress Deployed SecureOwnableDefinitions library address (e.g. from deployed-addresses.json)
10
13
  */
11
- export declare function updateRecoveryExecutionParams(newRecoveryAddress: Address): Hex;
14
+ export declare function updateRecoveryExecutionParams(client: PublicClient, definitionAddress: Address, newRecoveryAddress: Address): Promise<Hex>;
12
15
  /**
13
- * Builds execution params for executeTimeLockUpdate(uint256).
16
+ * Builds execution params for executeTimeLockUpdate(uint256) by calling the definition contract.
14
17
  * Equivalent to SecureOwnableDefinitions.updateTimeLockExecutionParams in Solidity.
18
+ * @param client Viem public client
19
+ * @param definitionAddress Deployed SecureOwnableDefinitions library address
15
20
  */
16
- export declare function updateTimeLockExecutionParams(newTimeLockPeriodSec: bigint): Hex;
21
+ export declare function updateTimeLockExecutionParams(client: PublicClient, definitionAddress: Address, newTimeLockPeriodSec: bigint): Promise<Hex>;
17
22
  //# sourceMappingURL=SecureOwnableDefinitions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SecureOwnableDefinitions.d.ts","sourceRoot":"","sources":["../../../lib/definitions/SecureOwnableDefinitions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,GAAG,EAAuB,MAAM,MAAM,CAAC;AAEzD;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,kBAAkB,EAAE,OAAO,GAAG,GAAG,CAK9E;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,oBAAoB,EAAE,MAAM,GAAG,GAAG,CAK/E"}
1
+ {"version":3,"file":"SecureOwnableDefinitions.d.ts","sourceRoot":"","sources":["../../../lib/definitions/SecureOwnableDefinitions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAKjE;;;;;GAKG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,YAAY,EACpB,iBAAiB,EAAE,OAAO,EAC1B,kBAAkB,EAAE,OAAO,GAC1B,OAAO,CAAC,GAAG,CAAC,CAOd;AAED;;;;;GAKG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,YAAY,EACpB,iBAAiB,EAAE,OAAO,EAC1B,oBAAoB,EAAE,MAAM,GAC3B,OAAO,CAAC,GAAG,CAAC,CAOd"}
@@ -1,21 +1,37 @@
1
1
  /**
2
2
  * SecureOwnableDefinitions
3
- * Pure helpers for building execution params for SecureOwnable operations.
4
- * Mirrors SecureOwnableDefinitions.sol; no contract calls.
3
+ * Calls the deployed SecureOwnableDefinitions contract for execution params.
4
+ * Single source of truth: encoding is done by the contract to avoid TypeScript/Solidity drift.
5
+ * @see contracts/core/security/lib/definitions/SecureOwnableDefinitions.sol
5
6
  */
6
- import { encodeAbiParameters } from 'viem';
7
+ import SecureOwnableDefinitionsAbi from '../../abi/SecureOwnableDefinitions.abi.json';
8
+ const ABI = SecureOwnableDefinitionsAbi;
7
9
  /**
8
- * Builds execution params for executeRecoveryUpdate(address).
10
+ * Builds execution params for executeRecoveryUpdate(address) by calling the definition contract.
9
11
  * Equivalent to SecureOwnableDefinitions.updateRecoveryExecutionParams in Solidity.
12
+ * @param client Viem public client
13
+ * @param definitionAddress Deployed SecureOwnableDefinitions library address (e.g. from deployed-addresses.json)
10
14
  */
11
- export function updateRecoveryExecutionParams(newRecoveryAddress) {
12
- return encodeAbiParameters([{ name: 'newRecoveryAddress', type: 'address' }], [newRecoveryAddress]);
15
+ export async function updateRecoveryExecutionParams(client, definitionAddress, newRecoveryAddress) {
16
+ return client.readContract({
17
+ address: definitionAddress,
18
+ abi: ABI,
19
+ functionName: 'updateRecoveryExecutionParams',
20
+ args: [newRecoveryAddress]
21
+ });
13
22
  }
14
23
  /**
15
- * Builds execution params for executeTimeLockUpdate(uint256).
24
+ * Builds execution params for executeTimeLockUpdate(uint256) by calling the definition contract.
16
25
  * Equivalent to SecureOwnableDefinitions.updateTimeLockExecutionParams in Solidity.
26
+ * @param client Viem public client
27
+ * @param definitionAddress Deployed SecureOwnableDefinitions library address
17
28
  */
18
- export function updateTimeLockExecutionParams(newTimeLockPeriodSec) {
19
- return encodeAbiParameters([{ name: 'newTimeLockPeriodSec', type: 'uint256' }], [newTimeLockPeriodSec]);
29
+ export async function updateTimeLockExecutionParams(client, definitionAddress, newTimeLockPeriodSec) {
30
+ return client.readContract({
31
+ address: definitionAddress,
32
+ abi: ABI,
33
+ functionName: 'updateTimeLockExecutionParams',
34
+ args: [newTimeLockPeriodSec]
35
+ });
20
36
  }
21
37
  //# sourceMappingURL=SecureOwnableDefinitions.js.map