@bloxchain/sdk 1.0.0-alpha

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 (132) hide show
  1. package/README.md +338 -0
  2. package/abi/BareBlox.abi.json +1341 -0
  3. package/abi/BaseStateMachine.abi.json +1308 -0
  4. package/abi/ControlBlox.abi.json +6210 -0
  5. package/abi/EngineBlox.abi.json +872 -0
  6. package/abi/GuardController.abi.json +3045 -0
  7. package/abi/IDefinition.abi.json +94 -0
  8. package/abi/RoleBlox.abi.json +4569 -0
  9. package/abi/RuntimeRBAC.abi.json +1857 -0
  10. package/abi/RuntimeRBACDefinitions.abi.json +133 -0
  11. package/abi/SecureBlox.abi.json +4085 -0
  12. package/abi/SecureOwnable.abi.json +4085 -0
  13. package/abi/SecureOwnableDefinitions.abi.json +354 -0
  14. package/abi/SimpleRWA20.abi.json +5545 -0
  15. package/abi/SimpleRWA20Definitions.abi.json +172 -0
  16. package/abi/SimpleVault.abi.json +5208 -0
  17. package/abi/SimpleVaultDefinitions.abi.json +250 -0
  18. package/dist/abi/BaseStateMachine.abi.json +1308 -0
  19. package/dist/abi/GuardController.abi.json +3045 -0
  20. package/dist/abi/IDefinition.abi.json +94 -0
  21. package/dist/abi/RuntimeRBAC.abi.json +1857 -0
  22. package/dist/abi/SecureOwnable.abi.json +4085 -0
  23. package/dist/contracts/BaseStateMachine.d.ts +83 -0
  24. package/dist/contracts/BaseStateMachine.d.ts.map +1 -0
  25. package/dist/contracts/BaseStateMachine.js +251 -0
  26. package/dist/contracts/BaseStateMachine.js.map +1 -0
  27. package/dist/contracts/GuardController.d.ts +120 -0
  28. package/dist/contracts/GuardController.d.ts.map +1 -0
  29. package/dist/contracts/GuardController.js +149 -0
  30. package/dist/contracts/GuardController.js.map +1 -0
  31. package/dist/contracts/RuntimeRBAC.d.ts +56 -0
  32. package/dist/contracts/RuntimeRBAC.d.ts.map +1 -0
  33. package/dist/contracts/RuntimeRBAC.js +57 -0
  34. package/dist/contracts/RuntimeRBAC.js.map +1 -0
  35. package/dist/contracts/SecureOwnable.d.ts +41 -0
  36. package/dist/contracts/SecureOwnable.d.ts.map +1 -0
  37. package/dist/contracts/SecureOwnable.js +82 -0
  38. package/dist/contracts/SecureOwnable.js.map +1 -0
  39. package/dist/index.d.ts +30 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +32 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/interfaces/base.index.d.ts +18 -0
  44. package/dist/interfaces/base.index.d.ts.map +1 -0
  45. package/dist/interfaces/base.index.js +2 -0
  46. package/dist/interfaces/base.index.js.map +1 -0
  47. package/dist/interfaces/base.state.machine.index.d.ts +72 -0
  48. package/dist/interfaces/base.state.machine.index.d.ts.map +1 -0
  49. package/dist/interfaces/base.state.machine.index.js +2 -0
  50. package/dist/interfaces/base.state.machine.index.js.map +1 -0
  51. package/dist/interfaces/core.access.index.d.ts +37 -0
  52. package/dist/interfaces/core.access.index.d.ts.map +1 -0
  53. package/dist/interfaces/core.access.index.js +2 -0
  54. package/dist/interfaces/core.access.index.js.map +1 -0
  55. package/dist/interfaces/core.execution.index.d.ts +44 -0
  56. package/dist/interfaces/core.execution.index.d.ts.map +1 -0
  57. package/dist/interfaces/core.execution.index.js +2 -0
  58. package/dist/interfaces/core.execution.index.js.map +1 -0
  59. package/dist/interfaces/core.security.index.d.ts +83 -0
  60. package/dist/interfaces/core.security.index.d.ts.map +1 -0
  61. package/dist/interfaces/core.security.index.js +2 -0
  62. package/dist/interfaces/core.security.index.js.map +1 -0
  63. package/dist/interfaces/definition.index.d.ts +38 -0
  64. package/dist/interfaces/definition.index.d.ts.map +1 -0
  65. package/dist/interfaces/definition.index.js +2 -0
  66. package/dist/interfaces/definition.index.js.map +1 -0
  67. package/dist/interfaces/lib.index.d.ts +83 -0
  68. package/dist/interfaces/lib.index.d.ts.map +1 -0
  69. package/dist/interfaces/lib.index.js +2 -0
  70. package/dist/interfaces/lib.index.js.map +1 -0
  71. package/dist/lib/Definition.d.ts +84 -0
  72. package/dist/lib/Definition.d.ts.map +1 -0
  73. package/dist/lib/Definition.js +159 -0
  74. package/dist/lib/Definition.js.map +1 -0
  75. package/dist/lib/EngineBlox.d.ts +167 -0
  76. package/dist/lib/EngineBlox.d.ts.map +1 -0
  77. package/dist/lib/EngineBlox.js +266 -0
  78. package/dist/lib/EngineBlox.js.map +1 -0
  79. package/dist/types/base.state.machine.index.d.ts +45 -0
  80. package/dist/types/base.state.machine.index.d.ts.map +1 -0
  81. package/dist/types/base.state.machine.index.js +49 -0
  82. package/dist/types/base.state.machine.index.js.map +1 -0
  83. package/dist/types/core.access.index.d.ts +51 -0
  84. package/dist/types/core.access.index.d.ts.map +1 -0
  85. package/dist/types/core.access.index.js +41 -0
  86. package/dist/types/core.access.index.js.map +1 -0
  87. package/dist/types/core.execution.index.d.ts +36 -0
  88. package/dist/types/core.execution.index.d.ts.map +1 -0
  89. package/dist/types/core.execution.index.js +30 -0
  90. package/dist/types/core.execution.index.js.map +1 -0
  91. package/dist/types/core.security.index.d.ts +36 -0
  92. package/dist/types/core.security.index.d.ts.map +1 -0
  93. package/dist/types/core.security.index.js +37 -0
  94. package/dist/types/core.security.index.js.map +1 -0
  95. package/dist/types/definition.index.d.ts +36 -0
  96. package/dist/types/definition.index.d.ts.map +1 -0
  97. package/dist/types/definition.index.js +4 -0
  98. package/dist/types/definition.index.js.map +1 -0
  99. package/dist/types/lib.index.d.ts +66 -0
  100. package/dist/types/lib.index.d.ts.map +1 -0
  101. package/dist/types/lib.index.js +68 -0
  102. package/dist/types/lib.index.js.map +1 -0
  103. package/dist/utils/bitmap.d.ts +75 -0
  104. package/dist/utils/bitmap.d.ts.map +1 -0
  105. package/dist/utils/bitmap.js +124 -0
  106. package/dist/utils/bitmap.js.map +1 -0
  107. package/dist/utils/contract-errors.d.ts +536 -0
  108. package/dist/utils/contract-errors.d.ts.map +1 -0
  109. package/dist/utils/contract-errors.js +412 -0
  110. package/dist/utils/contract-errors.js.map +1 -0
  111. package/dist/utils/erc20/ERC20Token.abi.json +217 -0
  112. package/dist/utils/erc20/erc20Token.d.ts +83 -0
  113. package/dist/utils/erc20/erc20Token.d.ts.map +1 -0
  114. package/dist/utils/erc20/erc20Token.js +173 -0
  115. package/dist/utils/erc20/erc20Token.js.map +1 -0
  116. package/dist/utils/interface-ids.d.ts +59 -0
  117. package/dist/utils/interface-ids.d.ts.map +1 -0
  118. package/dist/utils/interface-ids.js +149 -0
  119. package/dist/utils/interface-ids.js.map +1 -0
  120. package/dist/utils/metaTx/metaTransaction.d.ts +138 -0
  121. package/dist/utils/metaTx/metaTransaction.d.ts.map +1 -0
  122. package/dist/utils/metaTx/metaTransaction.js +271 -0
  123. package/dist/utils/metaTx/metaTransaction.js.map +1 -0
  124. package/dist/utils/validations.d.ts +104 -0
  125. package/dist/utils/validations.d.ts.map +1 -0
  126. package/dist/utils/validations.js +254 -0
  127. package/dist/utils/validations.js.map +1 -0
  128. package/dist/utils/viem-error-handler.d.ts +48 -0
  129. package/dist/utils/viem-error-handler.d.ts.map +1 -0
  130. package/dist/utils/viem-error-handler.js +172 -0
  131. package/dist/utils/viem-error-handler.js.map +1 -0
  132. package/package.json +65 -0
@@ -0,0 +1,83 @@
1
+ import { Address, PublicClient, WalletClient, Chain, Hex } from 'viem';
2
+ import { TransactionOptions, TransactionResult } from '../interfaces/base.index';
3
+ import { IBaseStateMachine } from '../interfaces/base.state.machine.index';
4
+ import { TxRecord, MetaTransaction, MetaTxParams } from '../interfaces/lib.index';
5
+ import { TxAction } from '../types/lib.index';
6
+ /**
7
+ * @title BaseStateMachine
8
+ * @notice TypeScript wrapper for BaseStateMachine smart contract with common utilities
9
+ */
10
+ export declare abstract class BaseStateMachine implements IBaseStateMachine {
11
+ protected client: PublicClient;
12
+ protected walletClient: WalletClient | undefined;
13
+ protected contractAddress: Address;
14
+ protected chain: Chain;
15
+ protected abi: any;
16
+ constructor(client: PublicClient, walletClient: WalletClient | undefined, contractAddress: Address, chain: Chain, abi: any);
17
+ /**
18
+ * Validates that wallet client is available for write operations
19
+ */
20
+ protected validateWalletClient(): void;
21
+ /**
22
+ * Common method to execute write contract operations
23
+ */
24
+ protected executeWriteContract(functionName: string, args: any[], options: TransactionOptions): Promise<TransactionResult>;
25
+ /**
26
+ * Common method to execute read contract operations
27
+ */
28
+ protected executeReadContract<T>(functionName: string, args?: any[]): Promise<T>;
29
+ createMetaTxParams(handlerContract: Address, handlerSelector: Hex, action: TxAction, deadline: bigint, maxGasPrice: bigint, signer: Address): Promise<MetaTxParams>;
30
+ generateUnsignedMetaTransactionForNew(requester: Address, target: Address, value: bigint, gasLimit: bigint, operationType: Hex, executionSelector: Hex, executionParams: Hex, metaTxParams: MetaTxParams): Promise<MetaTransaction>;
31
+ generateUnsignedMetaTransactionForExisting(txId: bigint, metaTxParams: MetaTxParams): Promise<MetaTransaction>;
32
+ getTransactionHistory(fromTxId: bigint, toTxId: bigint): Promise<TxRecord[]>;
33
+ getTransaction(txId: bigint): Promise<TxRecord>;
34
+ getPendingTransactions(): Promise<bigint[]>;
35
+ getRole(roleHash: Hex): Promise<{
36
+ roleName: string;
37
+ roleHashReturn: Hex;
38
+ maxWallets: bigint;
39
+ walletCount: bigint;
40
+ isProtected: boolean;
41
+ }>;
42
+ hasRole(roleHash: Hex, wallet: Address): Promise<boolean>;
43
+ /**
44
+ * Gets all roles assigned to a wallet
45
+ * @param wallet The wallet address to get roles for
46
+ * @returns Array of role hashes assigned to the wallet
47
+ * @notice Requires caller to have any role for privacy protection
48
+ * @notice This function uses the reverse index for efficient lookup
49
+ */
50
+ getWalletRoles(wallet: Address): Promise<Hex[]>;
51
+ isActionSupportedByFunction(functionSelector: Hex, action: TxAction): Promise<boolean>;
52
+ getActiveRolePermissions(roleHash: Hex): Promise<any[]>;
53
+ functionSchemaExists(functionSelector: Hex): Promise<boolean>;
54
+ getSignerNonce(signer: Address): Promise<bigint>;
55
+ getSupportedOperationTypes(): Promise<Hex[]>;
56
+ getSupportedRoles(): Promise<Hex[]>;
57
+ getSupportedFunctions(): Promise<Hex[]>;
58
+ getTimeLockPeriodSec(): Promise<bigint>;
59
+ initialized(): Promise<boolean>;
60
+ /**
61
+ * @dev Returns the owner of the contract
62
+ * @return The owner of the contract
63
+ */
64
+ owner(): Promise<Address>;
65
+ /**
66
+ * @dev Returns all broadcaster addresses
67
+ * @return Array of broadcaster addresses
68
+ */
69
+ getBroadcasters(): Promise<Address[]>;
70
+ /**
71
+ * @dev Returns the recovery address
72
+ * @return The recovery address
73
+ */
74
+ getRecovery(): Promise<Address>;
75
+ supportsInterface(interfaceId: Hex): Promise<boolean>;
76
+ /**
77
+ * @dev Check if this contract supports IBaseStateMachine interface
78
+ * @return Promise<boolean> indicating if IBaseStateMachine is supported
79
+ */
80
+ supportsBaseStateMachineInterface(): Promise<boolean>;
81
+ }
82
+ export default BaseStateMachine;
83
+ //# sourceMappingURL=BaseStateMachine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseStateMachine.d.ts","sourceRoot":"","sources":["../../contracts/BaseStateMachine.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C;;;GAGG;AACH,8BAAsB,gBAAiB,YAAW,iBAAiB;IAE/D,SAAS,CAAC,MAAM,EAAE,YAAY;IAC9B,SAAS,CAAC,YAAY,EAAE,YAAY,GAAG,SAAS;IAChD,SAAS,CAAC,eAAe,EAAE,OAAO;IAClC,SAAS,CAAC,KAAK,EA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,iCAAiC,IAAI,OAAO,CAAC,OAAO,CAAC;CAK5D;AAED,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,251 @@
1
+ import { handleViemError } from '../utils/viem-error-handler';
2
+ /**
3
+ * @title BaseStateMachine
4
+ * @notice TypeScript wrapper for BaseStateMachine smart contract with common utilities
5
+ */
6
+ export class BaseStateMachine {
7
+ constructor(client, walletClient, contractAddress, chain, abi) {
8
+ this.client = client;
9
+ this.walletClient = walletClient;
10
+ this.contractAddress = contractAddress;
11
+ this.chain = chain;
12
+ this.abi = abi;
13
+ }
14
+ // ============ COMMON UTILITY METHODS ============
15
+ /**
16
+ * Validates that wallet client is available for write operations
17
+ */
18
+ validateWalletClient() {
19
+ if (!this.walletClient) {
20
+ throw new Error('Wallet client is required for this operation');
21
+ }
22
+ }
23
+ /**
24
+ * Common method to execute write contract operations
25
+ */
26
+ async executeWriteContract(functionName, args, options) {
27
+ this.validateWalletClient();
28
+ // Viem's writeContract will use the WalletClient's account if available
29
+ // Only pass account explicitly if it differs from WalletClient's account
30
+ // Otherwise, let Viem use the WalletClient's account automatically
31
+ const walletClientAccount = this.walletClient.account?.address;
32
+ const requestedAccount = options.from.toLowerCase();
33
+ // For meta-transaction functions, ensure the structure is correct
34
+ if (functionName.includes('RequestAndApprove') || functionName.includes('MetaTx')) {
35
+ if (args.length > 0 && args[0] && typeof args[0] === 'object' && 'txRecord' in args[0]) {
36
+ const metaTx = args[0];
37
+ // Ensure all nested structures are properly formatted
38
+ if (metaTx.txRecord && typeof metaTx.txRecord === 'object') {
39
+ // Ensure txRecord.params exists and is an object
40
+ if (!metaTx.txRecord.params || typeof metaTx.txRecord.params !== 'object') {
41
+ throw new Error('Invalid meta-transaction: txRecord.params must be an object');
42
+ }
43
+ // Ensure txRecord.payment exists and is an object
44
+ if (!metaTx.txRecord.payment || typeof metaTx.txRecord.payment !== 'object') {
45
+ throw new Error('Invalid meta-transaction: txRecord.payment must be an object');
46
+ }
47
+ }
48
+ if (metaTx.params && typeof metaTx.params === 'object') {
49
+ // Ensure params is properly formatted
50
+ if (typeof metaTx.params.action !== 'number') {
51
+ throw new Error('Invalid meta-transaction: params.action must be a number');
52
+ }
53
+ }
54
+ }
55
+ }
56
+ const writeContractParams = {
57
+ chain: this.chain,
58
+ address: this.contractAddress,
59
+ abi: this.abi,
60
+ functionName,
61
+ args,
62
+ };
63
+ // Only set account if it differs from WalletClient's account
64
+ // This ensures consistency and avoids potential conflicts
65
+ if (!walletClientAccount || walletClientAccount.toLowerCase() !== requestedAccount) {
66
+ writeContractParams.account = options.from;
67
+ }
68
+ try {
69
+ // First, simulate the contract call to get better error messages
70
+ try {
71
+ await this.client.simulateContract({
72
+ ...writeContractParams,
73
+ account: writeContractParams.account || this.walletClient.account
74
+ });
75
+ }
76
+ catch (simulateError) {
77
+ // Re-throw to get better error handling
78
+ throw simulateError;
79
+ }
80
+ const hash = await this.walletClient.writeContract(writeContractParams);
81
+ return {
82
+ hash,
83
+ wait: () => this.client.waitForTransactionReceipt({ hash })
84
+ };
85
+ }
86
+ catch (error) {
87
+ // Use utility to handle and enhance error with contract error decoding
88
+ // handleViemError returns Promise<never> and always throws, so this will never return
89
+ // TypeScript doesn't recognize Promise<never> in control flow, so we explicitly throw
90
+ throw await handleViemError(error, this.abi);
91
+ }
92
+ }
93
+ /**
94
+ * Common method to execute read contract operations
95
+ */
96
+ async executeReadContract(functionName, args = []) {
97
+ try {
98
+ const result = await this.client.readContract({
99
+ address: this.contractAddress,
100
+ abi: this.abi,
101
+ functionName,
102
+ args,
103
+ // Include account for permission checks if wallet client is available
104
+ account: this.walletClient?.account
105
+ });
106
+ return result;
107
+ }
108
+ catch (error) {
109
+ // Try to decode the error if it's a contract revert
110
+ if (error.data || error.cause?.data) {
111
+ const errorData = error.data || error.cause?.data;
112
+ if (errorData && typeof errorData === 'string' && errorData.startsWith('0x')) {
113
+ try {
114
+ const { decodeErrorResult } = await import('viem');
115
+ const decoded = decodeErrorResult({
116
+ abi: this.abi,
117
+ data: errorData
118
+ });
119
+ throw new Error(`${decoded.errorName}(${JSON.stringify(decoded.args)})`);
120
+ }
121
+ catch (decodeError) {
122
+ // If decoding fails, throw the original error
123
+ throw error;
124
+ }
125
+ }
126
+ }
127
+ throw error;
128
+ }
129
+ }
130
+ // ============ META-TRANSACTION UTILITIES ============
131
+ async createMetaTxParams(handlerContract, handlerSelector, action, deadline, maxGasPrice, signer) {
132
+ return this.executeReadContract('createMetaTxParams', [
133
+ handlerContract,
134
+ handlerSelector,
135
+ action,
136
+ deadline,
137
+ maxGasPrice,
138
+ signer
139
+ ]);
140
+ }
141
+ async generateUnsignedMetaTransactionForNew(requester, target, value, gasLimit, operationType, executionSelector, executionParams, metaTxParams) {
142
+ return this.executeReadContract('generateUnsignedMetaTransactionForNew', [
143
+ requester,
144
+ target,
145
+ value,
146
+ gasLimit,
147
+ operationType,
148
+ executionSelector,
149
+ executionParams,
150
+ metaTxParams
151
+ ]);
152
+ }
153
+ async generateUnsignedMetaTransactionForExisting(txId, metaTxParams) {
154
+ return this.executeReadContract('generateUnsignedMetaTransactionForExisting', [
155
+ txId,
156
+ metaTxParams
157
+ ]);
158
+ }
159
+ // ============ STATE QUERIES ============
160
+ async getTransactionHistory(fromTxId, toTxId) {
161
+ return this.executeReadContract('getTransactionHistory', [fromTxId, toTxId]);
162
+ }
163
+ async getTransaction(txId) {
164
+ return this.executeReadContract('getTransaction', [txId]);
165
+ }
166
+ async getPendingTransactions() {
167
+ return this.executeReadContract('getPendingTransactions');
168
+ }
169
+ // ============ ROLE AND PERMISSION QUERIES ============
170
+ async getRole(roleHash) {
171
+ return this.executeReadContract('getRole', [roleHash]);
172
+ }
173
+ async hasRole(roleHash, wallet) {
174
+ return this.executeReadContract('hasRole', [roleHash, wallet]);
175
+ }
176
+ /**
177
+ * Gets all roles assigned to a wallet
178
+ * @param wallet The wallet address to get roles for
179
+ * @returns Array of role hashes assigned to the wallet
180
+ * @notice Requires caller to have any role for privacy protection
181
+ * @notice This function uses the reverse index for efficient lookup
182
+ */
183
+ async getWalletRoles(wallet) {
184
+ return this.executeReadContract('getWalletRoles', [wallet]);
185
+ }
186
+ async isActionSupportedByFunction(functionSelector, action) {
187
+ return this.executeReadContract('isActionSupportedByFunction', [functionSelector, action]);
188
+ }
189
+ async getActiveRolePermissions(roleHash) {
190
+ return this.executeReadContract('getActiveRolePermissions', [roleHash]);
191
+ }
192
+ async functionSchemaExists(functionSelector) {
193
+ return this.executeReadContract('functionSchemaExists', [functionSelector]);
194
+ }
195
+ async getSignerNonce(signer) {
196
+ return this.executeReadContract('getSignerNonce', [signer]);
197
+ }
198
+ // ============ SYSTEM STATE QUERIES ============
199
+ async getSupportedOperationTypes() {
200
+ return this.executeReadContract('getSupportedOperationTypes');
201
+ }
202
+ async getSupportedRoles() {
203
+ return this.executeReadContract('getSupportedRoles');
204
+ }
205
+ async getSupportedFunctions() {
206
+ return this.executeReadContract('getSupportedFunctions');
207
+ }
208
+ async getTimeLockPeriodSec() {
209
+ return this.executeReadContract('getTimeLockPeriodSec');
210
+ }
211
+ async initialized() {
212
+ return this.executeReadContract('initialized');
213
+ }
214
+ // ============ SYSTEM ROLE QUERY FUNCTIONS ============
215
+ /**
216
+ * @dev Returns the owner of the contract
217
+ * @return The owner of the contract
218
+ */
219
+ async owner() {
220
+ return this.executeReadContract('owner');
221
+ }
222
+ /**
223
+ * @dev Returns all broadcaster addresses
224
+ * @return Array of broadcaster addresses
225
+ */
226
+ async getBroadcasters() {
227
+ return this.executeReadContract('getBroadcasters');
228
+ }
229
+ /**
230
+ * @dev Returns the recovery address
231
+ * @return The recovery address
232
+ */
233
+ async getRecovery() {
234
+ return this.executeReadContract('getRecovery');
235
+ }
236
+ // ============ INTERFACE SUPPORT ============
237
+ async supportsInterface(interfaceId) {
238
+ return this.executeReadContract('supportsInterface', [interfaceId]);
239
+ }
240
+ /**
241
+ * @dev Check if this contract supports IBaseStateMachine interface
242
+ * @return Promise<boolean> indicating if IBaseStateMachine is supported
243
+ */
244
+ async supportsBaseStateMachineInterface() {
245
+ // Import dynamically to avoid circular dependencies
246
+ const { INTERFACE_IDS } = await import('../utils/interface-ids');
247
+ return this.supportsInterface(INTERFACE_IDS.IBaseStateMachine);
248
+ }
249
+ }
250
+ export default BaseStateMachine;
251
+ //# sourceMappingURL=BaseStateMachine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseStateMachine.js","sourceRoot":"","sources":["../../contracts/BaseStateMachine.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D;;;GAGG;AACH,MAAM,OAAgB,gBAAgB;IACpC,YACY,MAAoB,EACpB,YAAsC,EACtC,eAAwB,EACxB,KAAY,EACZ,GAAQ;QAJR,WAAM,GAAN,MAAM,CAAc;QACpB,iBAAY,GAAZ,YAAY,CAA0B;QACtC,oBAAe,GAAf,eAAe,CAAS;QACxB,UAAK,GAAL,KAAK,CAAO;QACZ,QAAG,GAAH,GAAG,CAAK;IACjB,CAAC;IAEJ,mDAAmD;IAEnD;;OAEG;IACO,oBAAoB;QAC5B,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,oBAAoB,CAClC,YAAoB,EACpB,IAAW,EACX,OAA2B;QAE3B,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAE5B,wEAAwE;QACxE,yEAAyE;QACzE,mEAAmE;QACnE,MAAM,mBAAmB,GAAG,IAAI,CAAC,YAAa,CAAC,OAAO,EAAE,OAAO,CAAC;QAChE,MAAM,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAEpD,kEAAkE;QAClE,IAAI,YAAY,CAAC,QAAQ,CAAC,mBAAmB,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClF,IAAI,IA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IAED;;;OAGG;IACH,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,mBAAmB,CAAU,aAAa,CAAC,CAAC;IAC1D,CAAC;IAED,8CAA8C;IAE9C,KAAK,CAAC,iBAAiB,CAAC,WAAgB;QACtC,OAAO,IAAI,CAAC,mBAAmB,CAAU,mBAAmB,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,iCAAiC;QACrC,oDAAoD;QACpD,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACjE,CAAC;CACF;AAED,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,120 @@
1
+ import { Address, PublicClient, WalletClient, Chain, Hex } from 'viem';
2
+ import { TransactionOptions, TransactionResult } from '../interfaces/base.index';
3
+ import { IGuardController } from '../interfaces/core.execution.index';
4
+ import { MetaTransaction } from '../interfaces/lib.index';
5
+ import { BaseStateMachine } from './BaseStateMachine';
6
+ /**
7
+ * @title GuardController
8
+ * @notice TypeScript wrapper for GuardController smart contract
9
+ * @dev Lightweight controller for generic contract delegation with full EngineBlox workflows
10
+ *
11
+ * This contract provides a complete solution for delegating control to external addresses.
12
+ * It extends BaseStateMachine for core state machine functionality and supports all EngineBlox
13
+ * execution patterns including time-locked transactions, meta-transactions, and payment management.
14
+ *
15
+ * This contract is modular and can be combined with RuntimeRBAC and SecureOwnable for role management.
16
+ */
17
+ export declare class GuardController extends BaseStateMachine implements IGuardController {
18
+ constructor(client: PublicClient, walletClient: WalletClient | undefined, contractAddress: Address, chain: Chain);
19
+ /**
20
+ * @notice Initializer to initialize GuardController
21
+ * @param initialOwner The initial owner address
22
+ * @param broadcaster The broadcaster address
23
+ * @param recovery The recovery address
24
+ * @param timeLockPeriodSec The timelock period in seconds
25
+ * @param eventForwarder The event forwarder address
26
+ * @param options Transaction options including from address
27
+ * @return TransactionResult with hash and wait function
28
+ */
29
+ initialize(initialOwner: Address, broadcaster: Address, recovery: Address, timeLockPeriodSec: bigint, eventForwarder: Address, options: TransactionOptions): Promise<TransactionResult>;
30
+ /**
31
+ * @dev Requests a time-locked execution via EngineBlox workflow
32
+ * @param target The address of the target contract
33
+ * @param value The ETH value to send (0 for standard function calls)
34
+ * @param functionSelector The function selector to execute (0x00000000 for simple ETH transfers)
35
+ * @param params The encoded parameters for the function (empty for simple ETH transfers)
36
+ * @param gasLimit The gas limit for execution
37
+ * @param operationType The operation type hash
38
+ * @param options Transaction options including from address
39
+ * @return TransactionResult with hash and wait function
40
+ * @notice Creates a time-locked transaction that must be approved after the timelock period
41
+ * @notice Requires EXECUTE_TIME_DELAY_REQUEST permission for the function selector
42
+ * @notice For standard function calls: value=0, functionSelector=non-zero, params=encoded data
43
+ * @notice For simple ETH transfers: value>0, functionSelector=0x00000000, params=""
44
+ */
45
+ executeWithTimeLock(target: Address, value: bigint, functionSelector: Hex, params: Hex, gasLimit: bigint, operationType: Hex, options: TransactionOptions): Promise<TransactionResult>;
46
+ /**
47
+ * @dev Approves and executes a time-locked transaction
48
+ * @param txId The transaction ID
49
+ * @param options Transaction options including from address
50
+ * @return TransactionResult with hash and wait function
51
+ * @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_APPROVE permission for the execution function
52
+ */
53
+ approveTimeLockExecution(txId: bigint, options: TransactionOptions): Promise<TransactionResult>;
54
+ /**
55
+ * @dev Cancels a time-locked transaction
56
+ * @param txId The transaction ID
57
+ * @param options Transaction options including from address
58
+ * @return TransactionResult with hash and wait function
59
+ * @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_CANCEL permission for the execution function
60
+ */
61
+ cancelTimeLockExecution(txId: bigint, options: TransactionOptions): Promise<TransactionResult>;
62
+ /**
63
+ * @dev Approves a time-locked transaction using a meta-transaction
64
+ * @param metaTx The meta-transaction containing the transaction record and signature
65
+ * @param options Transaction options including from address
66
+ * @return TransactionResult with hash and wait function
67
+ * @notice Requires STANDARD execution type and EXECUTE_META_APPROVE permission for the execution function
68
+ */
69
+ approveTimeLockExecutionWithMetaTx(metaTx: MetaTransaction, options: TransactionOptions): Promise<TransactionResult>;
70
+ /**
71
+ * @dev Cancels a time-locked transaction using a meta-transaction
72
+ * @param metaTx The meta-transaction containing the transaction record and signature
73
+ * @param options Transaction options including from address
74
+ * @return TransactionResult with hash and wait function
75
+ * @notice Requires STANDARD execution type and EXECUTE_META_CANCEL permission for the execution function
76
+ */
77
+ cancelTimeLockExecutionWithMetaTx(metaTx: MetaTransaction, options: TransactionOptions): Promise<TransactionResult>;
78
+ /**
79
+ * @dev Requests and approves a transaction in one step using a meta-transaction
80
+ * @param metaTx The meta-transaction containing the transaction record and signature
81
+ * @param options Transaction options including from address
82
+ * @return TransactionResult with hash and wait function
83
+ * @notice Requires STANDARD execution type
84
+ * @notice Validates function schema and permissions for the execution function (same as executeWithTimeLock)
85
+ * @notice Requires EXECUTE_META_REQUEST_AND_APPROVE permission for the execution function selector
86
+ */
87
+ requestAndApproveExecution(metaTx: MetaTransaction, options: TransactionOptions): Promise<TransactionResult>;
88
+ /**
89
+ * @dev Creates execution params for a guard configuration batch
90
+ * @param actions Encoded guard configuration actions
91
+ * @return Promise<Hex> The execution params to be used in a meta-transaction
92
+ */
93
+ guardConfigBatchExecutionParams(actions: Array<{
94
+ actionType: number;
95
+ data: Hex;
96
+ }>): Promise<Hex>;
97
+ /**
98
+ * @dev Requests and approves a guard configuration batch using a meta-transaction
99
+ * @param metaTx The meta-transaction describing the guard configuration batch
100
+ * @param options Transaction options including from address
101
+ * @return TransactionResult with hash and wait function
102
+ * @notice OWNER signs, BROADCASTER executes according to GuardControllerDefinitions
103
+ * @notice Supports whitelist management and function schema registration
104
+ */
105
+ guardConfigBatchRequestAndApprove(metaTx: MetaTransaction, options: TransactionOptions): Promise<TransactionResult>;
106
+ /**
107
+ * @dev Gets all whitelisted targets for a function selector.
108
+ * @param functionSelector The function selector
109
+ * @return Promise<Address[]> Array of whitelisted target addresses
110
+ * @notice Requires caller to have any role (via _validateAnyRole) for privacy protection
111
+ */
112
+ getAllowedTargets(functionSelector: Hex): Promise<Address[]>;
113
+ /**
114
+ * @dev Check if this contract supports IGuardController interface
115
+ * @return Promise<boolean> indicating if IGuardController is supported
116
+ */
117
+ supportsGuardControllerInterface(): Promise<boolean>;
118
+ }
119
+ export default GuardController;
120
+ //# sourceMappingURL=GuardController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GuardController.d.ts","sourceRoot":"","sources":["../../contracts/GuardController.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;;;;;;;;;GAUG;AACH,qBAAa,eAAgB,SAAQ,gBAAiB,YAAW,gBAAgB;gBAE7E,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,eAAe,EAAE,OAAO,EACxB,KAAK,EAAE,KAAK;IAOd;;;;;;;;;OASG;IACG,UAAU,CACd,YAAY,EAAE,OAAO,EACrB,WAAW,EAAE,OAAO,EACpB,QAAQ,EAAE,OAAO,EACjB,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,OAAO,EACvB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC;IAU7B;;;;;;;;;;;;;;OAcG;IACG,mBAAmB,CACvB,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,MAAM,EACb,gBAAgB,EA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llerABIJson from '../abi/GuardController.abi.json';
2
+ import { BaseStateMachine } from './BaseStateMachine';
3
+ import { INTERFACE_IDS } from '../utils/interface-ids';
4
+ /**
5
+ * @title GuardController
6
+ * @notice TypeScript wrapper for GuardController smart contract
7
+ * @dev Lightweight controller for generic contract delegation with full EngineBlox workflows
8
+ *
9
+ * This contract provides a complete solution for delegating control to external addresses.
10
+ * It extends BaseStateMachine for core state machine functionality and supports all EngineBlox
11
+ * execution patterns including time-locked transactions, meta-transactions, and payment management.
12
+ *
13
+ * This contract is modular and can be combined with RuntimeRBAC and SecureOwnable for role management.
14
+ */
15
+ export class GuardController extends BaseStateMachine {
16
+ constructor(client, walletClient, contractAddress, chain) {
17
+ super(client, walletClient, contractAddress, chain, GuardControllerABIJson);
18
+ }
19
+ // ============ INITIALIZATION ============
20
+ /**
21
+ * @notice Initializer to initialize GuardController
22
+ * @param initialOwner The initial owner address
23
+ * @param broadcaster The broadcaster address
24
+ * @param recovery The recovery address
25
+ * @param timeLockPeriodSec The timelock period in seconds
26
+ * @param eventForwarder The event forwarder address
27
+ * @param options Transaction options including from address
28
+ * @return TransactionResult with hash and wait function
29
+ */
30
+ async initialize(initialOwner, broadcaster, recovery, timeLockPeriodSec, eventForwarder, options) {
31
+ return this.executeWriteContract('initialize', [initialOwner, broadcaster, recovery, timeLockPeriodSec, eventForwarder], options);
32
+ }
33
+ // ============ EXECUTION FUNCTIONS ============
34
+ /**
35
+ * @dev Requests a time-locked execution via EngineBlox workflow
36
+ * @param target The address of the target contract
37
+ * @param value The ETH value to send (0 for standard function calls)
38
+ * @param functionSelector The function selector to execute (0x00000000 for simple ETH transfers)
39
+ * @param params The encoded parameters for the function (empty for simple ETH transfers)
40
+ * @param gasLimit The gas limit for execution
41
+ * @param operationType The operation type hash
42
+ * @param options Transaction options including from address
43
+ * @return TransactionResult with hash and wait function
44
+ * @notice Creates a time-locked transaction that must be approved after the timelock period
45
+ * @notice Requires EXECUTE_TIME_DELAY_REQUEST permission for the function selector
46
+ * @notice For standard function calls: value=0, functionSelector=non-zero, params=encoded data
47
+ * @notice For simple ETH transfers: value>0, functionSelector=0x00000000, params=""
48
+ */
49
+ async executeWithTimeLock(target, value, functionSelector, params, gasLimit, operationType, options) {
50
+ return this.executeWriteContract('executeWithTimeLock', [target, value, functionSelector, params, gasLimit, operationType], options);
51
+ }
52
+ /**
53
+ * @dev Approves and executes a time-locked transaction
54
+ * @param txId The transaction ID
55
+ * @param options Transaction options including from address
56
+ * @return TransactionResult with hash and wait function
57
+ * @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_APPROVE permission for the execution function
58
+ */
59
+ async approveTimeLockExecution(txId, options) {
60
+ return this.executeWriteContract('approveTimeLockExecution', [txId], options);
61
+ }
62
+ /**
63
+ * @dev Cancels a time-locked transaction
64
+ * @param txId The transaction ID
65
+ * @param options Transaction options including from address
66
+ * @return TransactionResult with hash and wait function
67
+ * @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_CANCEL permission for the execution function
68
+ */
69
+ async cancelTimeLockExecution(txId, options) {
70
+ return this.executeWriteContract('cancelTimeLockExecution', [txId], options);
71
+ }
72
+ /**
73
+ * @dev Approves a time-locked transaction using a meta-transaction
74
+ * @param metaTx The meta-transaction containing the transaction record and signature
75
+ * @param options Transaction options including from address
76
+ * @return TransactionResult with hash and wait function
77
+ * @notice Requires STANDARD execution type and EXECUTE_META_APPROVE permission for the execution function
78
+ */
79
+ async approveTimeLockExecutionWithMetaTx(metaTx, options) {
80
+ return this.executeWriteContract('approveTimeLockExecutionWithMetaTx', [metaTx], options);
81
+ }
82
+ /**
83
+ * @dev Cancels a time-locked transaction using a meta-transaction
84
+ * @param metaTx The meta-transaction containing the transaction record and signature
85
+ * @param options Transaction options including from address
86
+ * @return TransactionResult with hash and wait function
87
+ * @notice Requires STANDARD execution type and EXECUTE_META_CANCEL permission for the execution function
88
+ */
89
+ async cancelTimeLockExecutionWithMetaTx(metaTx, options) {
90
+ return this.executeWriteContract('cancelTimeLockExecutionWithMetaTx', [metaTx], options);
91
+ }
92
+ /**
93
+ * @dev Requests and approves a transaction in one step using a meta-transaction
94
+ * @param metaTx The meta-transaction containing the transaction record and signature
95
+ * @param options Transaction options including from address
96
+ * @return TransactionResult with hash and wait function
97
+ * @notice Requires STANDARD execution type
98
+ * @notice Validates function schema and permissions for the execution function (same as executeWithTimeLock)
99
+ * @notice Requires EXECUTE_META_REQUEST_AND_APPROVE permission for the execution function selector
100
+ */
101
+ async requestAndApproveExecution(metaTx, options) {
102
+ return this.executeWriteContract('requestAndApproveExecution', [metaTx], options);
103
+ }
104
+ // ============ GUARD CONFIGURATION BATCH ============
105
+ /**
106
+ * @dev Creates execution params for a guard configuration batch
107
+ * @param actions Encoded guard configuration actions
108
+ * @return Promise<Hex> The execution params to be used in a meta-transaction
109
+ */
110
+ async guardConfigBatchExecutionParams(actions) {
111
+ return this.executeReadContract('guardConfigBatchExecutionParams', [actions]);
112
+ }
113
+ /**
114
+ * @dev Requests and approves a guard configuration batch using a meta-transaction
115
+ * @param metaTx The meta-transaction describing the guard configuration batch
116
+ * @param options Transaction options including from address
117
+ * @return TransactionResult with hash and wait function
118
+ * @notice OWNER signs, BROADCASTER executes according to GuardControllerDefinitions
119
+ * @notice Supports whitelist management and function schema registration
120
+ */
121
+ async guardConfigBatchRequestAndApprove(metaTx, options) {
122
+ return this.executeWriteContract('guardConfigBatchRequestAndApprove', [metaTx], options);
123
+ }
124
+ /**
125
+ * @dev Gets all whitelisted targets for a function selector.
126
+ * @param functionSelector The function selector
127
+ * @return Promise<Address[]> Array of whitelisted target addresses
128
+ * @notice Requires caller to have any role (via _validateAnyRole) for privacy protection
129
+ */
130
+ async getAllowedTargets(functionSelector) {
131
+ const result = await this.executeReadContract('getAllowedTargets', [
132
+ functionSelector
133
+ ]);
134
+ if (!Array.isArray(result)) {
135
+ throw new Error(`Unexpected return type from getAllowedTargets: ${typeof result}`);
136
+ }
137
+ return result;
138
+ }
139
+ // ============ INTERFACE SUPPORT ============
140
+ /**
141
+ * @dev Check if this contract supports IGuardController interface
142
+ * @return Promise<boolean> indicating if IGuardController is supported
143
+ */
144
+ async supportsGuardControllerInterface() {
145
+ return this.supportsInterface(INTERFACE_IDS.IGuardController);
146
+ }
147
+ }
148
+ export default GuardController;
149
+ //# sourceMappingURL=GuardController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GuardController.js","sourceRoot":"","sources":["../../contracts/GuardController.tsx"],"names":[],"mappings":"AACA,OAAO,sBAAsB,MAAM,iCAAiC,CAAC;AAIrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,eAAgB,SAAQ,gBAAgB;IACnD,YACE,MAAoB,EACpB,YAAsC,EACtC,eAAwB,EACxB,KAAY;QAEZ,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC;IAC9E,CAAC;IAED,2CAA2C;IAE3C;;;;;;;;;OASG;IACH,KAAK,CAAC,UAAU,CACd,YAAqB,EACrB,WAAoB,EACpB,QAAiB,EACjB,iBAAyB,EACzB,cAAuB,EACvB,OAA2B;QAE3B,OAAO,IAAI,CAAC,oBAAoB,CAC9B,YAAY,EACZ,CAAC,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,EAAE,cAAc,CAAC,EACxE,OAAO,CACR,CAAC;IACJ,CAAC;IAED,gDAAgD;IAEhD;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,mBAAmB,CACvB,MAAe,EACf,KAAa,EACb,gBAAqB,EACrB,MAAW,EACX,QAAgB,EAChB,aAAkB,EAClB,OAA2B;QAE3B,OAAO,IAAI,CAAC,oBAAoB,CAC9B,qBAAqB,EACrB,CAAC,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,CA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