@veridex/sdk 1.0.0-beta.1

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 (82) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/LICENSE +21 -0
  3. package/README.md +212 -0
  4. package/dist/chains/aptos/index.d.mts +140 -0
  5. package/dist/chains/aptos/index.d.ts +140 -0
  6. package/dist/chains/aptos/index.js +563 -0
  7. package/dist/chains/aptos/index.js.map +1 -0
  8. package/dist/chains/aptos/index.mjs +536 -0
  9. package/dist/chains/aptos/index.mjs.map +1 -0
  10. package/dist/chains/evm/index.d.mts +5 -0
  11. package/dist/chains/evm/index.d.ts +5 -0
  12. package/dist/chains/evm/index.js +1233 -0
  13. package/dist/chains/evm/index.js.map +1 -0
  14. package/dist/chains/evm/index.mjs +1205 -0
  15. package/dist/chains/evm/index.mjs.map +1 -0
  16. package/dist/chains/solana/index.d.mts +116 -0
  17. package/dist/chains/solana/index.d.ts +116 -0
  18. package/dist/chains/solana/index.js +513 -0
  19. package/dist/chains/solana/index.js.map +1 -0
  20. package/dist/chains/solana/index.mjs +491 -0
  21. package/dist/chains/solana/index.mjs.map +1 -0
  22. package/dist/chains/starknet/index.d.mts +172 -0
  23. package/dist/chains/starknet/index.d.ts +172 -0
  24. package/dist/chains/starknet/index.js +534 -0
  25. package/dist/chains/starknet/index.js.map +1 -0
  26. package/dist/chains/starknet/index.mjs +507 -0
  27. package/dist/chains/starknet/index.mjs.map +1 -0
  28. package/dist/chains/sui/index.d.mts +182 -0
  29. package/dist/chains/sui/index.d.ts +182 -0
  30. package/dist/chains/sui/index.js +560 -0
  31. package/dist/chains/sui/index.js.map +1 -0
  32. package/dist/chains/sui/index.mjs +533 -0
  33. package/dist/chains/sui/index.mjs.map +1 -0
  34. package/dist/constants.d.mts +150 -0
  35. package/dist/constants.d.ts +150 -0
  36. package/dist/constants.js +430 -0
  37. package/dist/constants.js.map +1 -0
  38. package/dist/constants.mjs +392 -0
  39. package/dist/constants.mjs.map +1 -0
  40. package/dist/index-0NXfbk0z.d.ts +637 -0
  41. package/dist/index-D0dLVjTA.d.mts +637 -0
  42. package/dist/index.d.mts +3101 -0
  43. package/dist/index.d.ts +3101 -0
  44. package/dist/index.js +13186 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/index.mjs +13011 -0
  47. package/dist/index.mjs.map +1 -0
  48. package/dist/payload.d.mts +125 -0
  49. package/dist/payload.d.ts +125 -0
  50. package/dist/payload.js +315 -0
  51. package/dist/payload.js.map +1 -0
  52. package/dist/payload.mjs +269 -0
  53. package/dist/payload.mjs.map +1 -0
  54. package/dist/queries/index.d.mts +148 -0
  55. package/dist/queries/index.d.ts +148 -0
  56. package/dist/queries/index.js +1533 -0
  57. package/dist/queries/index.js.map +1 -0
  58. package/dist/queries/index.mjs +1508 -0
  59. package/dist/queries/index.mjs.map +1 -0
  60. package/dist/types-ChIsqCiw.d.mts +565 -0
  61. package/dist/types-ChIsqCiw.d.ts +565 -0
  62. package/dist/types-FJL7j6gQ.d.mts +172 -0
  63. package/dist/types-FJL7j6gQ.d.ts +172 -0
  64. package/dist/types.d.mts +407 -0
  65. package/dist/types.d.ts +407 -0
  66. package/dist/types.js +19 -0
  67. package/dist/types.js.map +1 -0
  68. package/dist/types.mjs +1 -0
  69. package/dist/types.mjs.map +1 -0
  70. package/dist/utils.d.mts +81 -0
  71. package/dist/utils.d.ts +81 -0
  72. package/dist/utils.js +430 -0
  73. package/dist/utils.js.map +1 -0
  74. package/dist/utils.mjs +390 -0
  75. package/dist/utils.mjs.map +1 -0
  76. package/dist/wormhole.d.mts +167 -0
  77. package/dist/wormhole.d.ts +167 -0
  78. package/dist/wormhole.js +468 -0
  79. package/dist/wormhole.js.map +1 -0
  80. package/dist/wormhole.mjs +422 -0
  81. package/dist/wormhole.mjs.map +1 -0
  82. package/package.json +151 -0
@@ -0,0 +1,563 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/chains/aptos/index.ts
21
+ var aptos_exports = {};
22
+ __export(aptos_exports, {
23
+ AptosClient: () => AptosClient
24
+ });
25
+ module.exports = __toCommonJS(aptos_exports);
26
+
27
+ // src/chains/aptos/AptosClient.ts
28
+ var import_aptos = require("aptos");
29
+ var import_js_sha3 = require("js-sha3");
30
+
31
+ // src/payload.ts
32
+ var import_ethers = require("ethers");
33
+
34
+ // src/constants.ts
35
+ var ACTION_TRANSFER = 1;
36
+ var ACTION_EXECUTE = 2;
37
+ var ACTION_BRIDGE = 4;
38
+
39
+ // src/payload.ts
40
+ function encodeTransferAction(token, recipient, amount) {
41
+ const tokenPadded = padTo32Bytes(token);
42
+ const recipientPadded = padTo32Bytes(recipient);
43
+ const amountBytes = import_ethers.ethers.zeroPadValue(import_ethers.ethers.toBeHex(amount), 32);
44
+ return import_ethers.ethers.concat([
45
+ import_ethers.ethers.toBeHex(ACTION_TRANSFER, 1),
46
+ tokenPadded,
47
+ recipientPadded,
48
+ amountBytes
49
+ ]);
50
+ }
51
+ function encodeBridgeAction(token, amount, targetChain, recipient) {
52
+ const tokenPadded = padTo32Bytes(token);
53
+ const amountBytes = import_ethers.ethers.zeroPadValue(import_ethers.ethers.toBeHex(amount), 32);
54
+ const targetChainBytes = import_ethers.ethers.toBeHex(targetChain, 2);
55
+ const recipientPadded = padTo32Bytes(recipient);
56
+ return import_ethers.ethers.concat([
57
+ import_ethers.ethers.toBeHex(ACTION_BRIDGE, 1),
58
+ tokenPadded,
59
+ amountBytes,
60
+ targetChainBytes,
61
+ recipientPadded
62
+ ]);
63
+ }
64
+ function encodeExecuteAction(target, value, data) {
65
+ const targetPadded = padTo32Bytes(target);
66
+ const valueBytes = import_ethers.ethers.zeroPadValue(import_ethers.ethers.toBeHex(value), 32);
67
+ const dataBytes = import_ethers.ethers.getBytes(data);
68
+ const dataLengthBytes = import_ethers.ethers.toBeHex(dataBytes.length, 2);
69
+ return import_ethers.ethers.concat([
70
+ import_ethers.ethers.toBeHex(ACTION_EXECUTE, 1),
71
+ targetPadded,
72
+ valueBytes,
73
+ dataLengthBytes,
74
+ data
75
+ ]);
76
+ }
77
+ function padTo32Bytes(address) {
78
+ if (address.toLowerCase() === "native") {
79
+ return "0x" + "0".repeat(64);
80
+ }
81
+ if (address.startsWith("0x")) {
82
+ const hex2 = address.replace("0x", "");
83
+ if (!/^[0-9a-fA-F]*$/.test(hex2)) {
84
+ throw new Error(`Invalid address: ${address}. Expected hex string or 'native'.`);
85
+ }
86
+ return "0x" + hex2.padStart(64, "0");
87
+ }
88
+ const base58Chars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
89
+ for (const char of address) {
90
+ if (!base58Chars.includes(char)) {
91
+ throw new Error(`Invalid address: ${address}. Contains invalid base58 character '${char}'.`);
92
+ }
93
+ }
94
+ let value = BigInt(0);
95
+ for (const char of address) {
96
+ value = value * 58n + BigInt(base58Chars.indexOf(char));
97
+ }
98
+ let hex = value.toString(16);
99
+ if (hex.length > 64) {
100
+ throw new Error(`Invalid address: ${address}. Decoded value too large for 32 bytes.`);
101
+ }
102
+ return "0x" + hex.padStart(64, "0");
103
+ }
104
+
105
+ // src/chains/aptos/AptosClient.ts
106
+ var AptosClient = class {
107
+ config;
108
+ client;
109
+ moduleAddress;
110
+ constructor(config) {
111
+ this.config = {
112
+ name: `Aptos ${config.network || "mainnet"}`,
113
+ chainId: config.wormholeChainId,
114
+ wormholeChainId: config.wormholeChainId,
115
+ rpcUrl: config.rpcUrl,
116
+ explorerUrl: config.network === "testnet" ? "https://explorer.aptoslabs.com?network=testnet" : "https://explorer.aptoslabs.com",
117
+ isEvm: false,
118
+ contracts: {
119
+ hub: void 0,
120
+ // Aptos is a spoke only
121
+ wormholeCoreBridge: config.wormholeCoreBridge,
122
+ tokenBridge: config.tokenBridge
123
+ }
124
+ };
125
+ this.client = new import_aptos.AptosClient(config.rpcUrl);
126
+ this.moduleAddress = config.moduleAddress;
127
+ }
128
+ getConfig() {
129
+ return this.config;
130
+ }
131
+ async getNonce(userKeyHash) {
132
+ try {
133
+ const vaultAddress = this.computeVaultAddressFromHash(userKeyHash);
134
+ const resource = await this.client.getAccountResource(
135
+ vaultAddress,
136
+ `${this.moduleAddress}::vault::Vault`
137
+ );
138
+ if (resource && resource.data) {
139
+ const data = resource.data;
140
+ return BigInt(data.nonce || 0);
141
+ }
142
+ return 0n;
143
+ } catch (error) {
144
+ console.error("Error getting nonce:", error);
145
+ return 0n;
146
+ }
147
+ }
148
+ async getMessageFee() {
149
+ try {
150
+ return 0n;
151
+ } catch (error) {
152
+ console.error("Error getting message fee:", error);
153
+ return 0n;
154
+ }
155
+ }
156
+ async buildTransferPayload(params) {
157
+ return encodeTransferAction(
158
+ params.token,
159
+ params.recipient,
160
+ params.amount
161
+ );
162
+ }
163
+ async buildExecutePayload(params) {
164
+ return encodeExecuteAction(
165
+ params.target,
166
+ params.value,
167
+ params.data
168
+ );
169
+ }
170
+ async buildBridgePayload(params) {
171
+ return encodeBridgeAction(
172
+ params.token,
173
+ params.amount,
174
+ params.destinationChain,
175
+ params.recipient
176
+ );
177
+ }
178
+ async dispatch(signature, publicKeyX, publicKeyY, targetChain, actionPayload, nonce, signer) {
179
+ void signature;
180
+ void publicKeyX;
181
+ void publicKeyY;
182
+ void targetChain;
183
+ void actionPayload;
184
+ void nonce;
185
+ void signer;
186
+ throw new Error(
187
+ "Direct dispatch not supported on Aptos spoke chains. Actions must be dispatched from the Hub (EVM) chain. This client is for receiving cross-chain messages only."
188
+ );
189
+ }
190
+ /**
191
+ * Dispatch an action via relayer (gasless)
192
+ * Note: On Aptos, this still goes through the Hub chain
193
+ * Aptos is a spoke-only chain in Veridex architecture
194
+ */
195
+ async dispatchGasless(signature, publicKeyX, publicKeyY, targetChain, actionPayload, nonce, relayerUrl) {
196
+ const keyHash = this.computeKeyHash(publicKeyX, publicKeyY);
197
+ const message = this.buildMessage(keyHash, targetChain, actionPayload, nonce);
198
+ const request = {
199
+ messageHash: message,
200
+ r: "0x" + signature.r.toString(16).padStart(64, "0"),
201
+ s: "0x" + signature.s.toString(16).padStart(64, "0"),
202
+ publicKeyX: "0x" + publicKeyX.toString(16).padStart(64, "0"),
203
+ publicKeyY: "0x" + publicKeyY.toString(16).padStart(64, "0"),
204
+ targetChain,
205
+ actionPayload,
206
+ nonce: Number(nonce)
207
+ };
208
+ const response = await fetch(`${relayerUrl}/api/v1/submit`, {
209
+ method: "POST",
210
+ headers: {
211
+ "Content-Type": "application/json"
212
+ },
213
+ body: JSON.stringify(request)
214
+ });
215
+ if (!response.ok) {
216
+ const error = await response.json().catch(() => ({ error: response.statusText }));
217
+ throw new Error(`Relayer submission failed: ${error.error || response.statusText}`);
218
+ }
219
+ const result = await response.json();
220
+ if (!result.success) {
221
+ throw new Error(`Relayer submission failed: ${result.error}`);
222
+ }
223
+ return {
224
+ transactionHash: result.txHash,
225
+ sequence: BigInt(result.sequence || "0"),
226
+ userKeyHash: keyHash,
227
+ targetChain
228
+ };
229
+ }
230
+ async getVaultAddress(userKeyHash) {
231
+ try {
232
+ const vaultAddress = this.computeVaultAddressFromHash(userKeyHash);
233
+ const account = await this.client.getAccount(vaultAddress);
234
+ if (account) {
235
+ return vaultAddress;
236
+ }
237
+ return null;
238
+ } catch (error) {
239
+ if (error?.status === 404) {
240
+ return null;
241
+ }
242
+ console.error("Error getting vault address:", error);
243
+ return null;
244
+ }
245
+ }
246
+ /**
247
+ * Compute vault address using resource account derivation
248
+ * On Aptos, vaults are derived from the module address + user key hash
249
+ */
250
+ computeVaultAddress(userKeyHash) {
251
+ return this.computeVaultAddressFromHash(userKeyHash);
252
+ }
253
+ computeVaultAddressFromHash(userKeyHash) {
254
+ const sourceAddress = this.hexToBytes(this.moduleAddress.replace("0x", ""));
255
+ const seed = this.hexToBytes(userKeyHash.replace("0x", ""));
256
+ const scheme = new Uint8Array([254]);
257
+ const combined = new Uint8Array([...sourceAddress, ...seed, ...scheme]);
258
+ const hash = (0, import_js_sha3.sha3_256)(combined);
259
+ return "0x" + hash;
260
+ }
261
+ /**
262
+ * Convert hex string to Uint8Array (browser-compatible)
263
+ */
264
+ hexToBytes(hex) {
265
+ const bytes = new Uint8Array(hex.length / 2);
266
+ for (let i = 0; i < hex.length; i += 2) {
267
+ bytes[i / 2] = parseInt(hex.substr(i, 2), 16);
268
+ }
269
+ return bytes;
270
+ }
271
+ async vaultExists(userKeyHash) {
272
+ const address = await this.getVaultAddress(userKeyHash);
273
+ return address !== null;
274
+ }
275
+ async createVault(userKeyHash, signer) {
276
+ void userKeyHash;
277
+ void signer;
278
+ throw new Error(
279
+ "Vault creation on Aptos must be done via cross-chain message from Hub. Use the Hub chain client to dispatch a vault creation action targeting Aptos."
280
+ );
281
+ }
282
+ async createVaultSponsored(userKeyHash, sponsorPrivateKey, rpcUrl) {
283
+ void userKeyHash;
284
+ void sponsorPrivateKey;
285
+ void rpcUrl;
286
+ throw new Error(
287
+ "Vault creation on Aptos must be done via cross-chain message from Hub. Use relayer gasless submission to create vault."
288
+ );
289
+ }
290
+ /**
291
+ * Create a vault via the relayer (sponsored/gasless)
292
+ * This is the recommended way to create Aptos vaults
293
+ *
294
+ * The relayer will dispatch a vault creation action from Hub to Aptos spoke
295
+ */
296
+ async createVaultViaRelayer(userKeyHash, relayerUrl) {
297
+ const response = await fetch(`${relayerUrl}/api/v1/aptos/vault`, {
298
+ method: "POST",
299
+ headers: {
300
+ "Content-Type": "application/json"
301
+ },
302
+ body: JSON.stringify({
303
+ userKeyHash,
304
+ chainId: this.config.wormholeChainId
305
+ })
306
+ });
307
+ const result = await response.json();
308
+ if (!response.ok || !result.success) {
309
+ throw new Error(result.error || "Failed to create vault via relayer");
310
+ }
311
+ return {
312
+ address: result.vaultAddress,
313
+ transactionHash: result.transactionHash || "",
314
+ blockNumber: 0,
315
+ gasUsed: 0n,
316
+ alreadyExisted: result.alreadyExists || false,
317
+ sponsoredBy: "relayer"
318
+ };
319
+ }
320
+ /**
321
+ * Get vault info via relayer (includes existence check)
322
+ */
323
+ async getVaultViaRelayer(userKeyHash, relayerUrl) {
324
+ const response = await fetch(
325
+ `${relayerUrl}/api/v1/aptos/vault/${userKeyHash}?chainId=${this.config.wormholeChainId}`
326
+ );
327
+ if (!response.ok) {
328
+ throw new Error("Failed to get vault info from relayer");
329
+ }
330
+ const result = await response.json();
331
+ return {
332
+ vaultAddress: result.vaultAddress,
333
+ exists: result.exists
334
+ };
335
+ }
336
+ async estimateVaultCreationGas(userKeyHash) {
337
+ void userKeyHash;
338
+ return 100000n;
339
+ }
340
+ getFactoryAddress() {
341
+ return void 0;
342
+ }
343
+ getImplementationAddress() {
344
+ return void 0;
345
+ }
346
+ // ========================================================================
347
+ // Balance Methods
348
+ // ========================================================================
349
+ /**
350
+ * Get native APT balance
351
+ */
352
+ async getNativeBalance(address) {
353
+ try {
354
+ const resource = await this.client.getAccountResource(
355
+ address,
356
+ "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>"
357
+ );
358
+ if (resource && resource.data) {
359
+ const data = resource.data;
360
+ return BigInt(data.coin?.value || 0);
361
+ }
362
+ return 0n;
363
+ } catch (error) {
364
+ console.error("Error getting native balance:", error);
365
+ return 0n;
366
+ }
367
+ }
368
+ /**
369
+ * Get fungible asset (FA) or coin balance
370
+ */
371
+ async getTokenBalance(tokenAddress, ownerAddress) {
372
+ try {
373
+ const coinType = tokenAddress.includes("::") ? tokenAddress : `${tokenAddress}::coin::Coin`;
374
+ const resource = await this.client.getAccountResource(
375
+ ownerAddress,
376
+ `0x1::coin::CoinStore<${coinType}>`
377
+ );
378
+ if (resource && resource.data) {
379
+ const data = resource.data;
380
+ return BigInt(data.coin?.value || 0);
381
+ }
382
+ return 0n;
383
+ } catch (error) {
384
+ try {
385
+ console.warn("FA balance query not fully implemented yet");
386
+ return 0n;
387
+ } catch (faError) {
388
+ console.error("Error getting token balance:", error);
389
+ return 0n;
390
+ }
391
+ }
392
+ }
393
+ // ========================================================================
394
+ // Utility Methods
395
+ // ========================================================================
396
+ /**
397
+ * Compute key hash from public key coordinates
398
+ * Matches EVM keccak256(abi.encode(publicKeyX, publicKeyY))
399
+ */
400
+ computeKeyHash(publicKeyX, publicKeyY) {
401
+ const xHex = publicKeyX.toString(16).padStart(64, "0");
402
+ const yHex = publicKeyY.toString(16).padStart(64, "0");
403
+ const xBytes = this.hexToBytes(xHex);
404
+ const yBytes = this.hexToBytes(yHex);
405
+ const combined = new Uint8Array([...xBytes, ...yBytes]);
406
+ const hash = (0, import_js_sha3.sha3_256)(combined);
407
+ return "0x" + hash;
408
+ }
409
+ /**
410
+ * Build message for signing (matches Hub chain format)
411
+ */
412
+ buildMessage(keyHash, targetChain, actionPayload, nonce) {
413
+ const keyHashBytes = this.hexToBytes(keyHash.replace("0x", ""));
414
+ const targetChainBytes = new Uint8Array(2);
415
+ targetChainBytes[0] = targetChain >> 8 & 255;
416
+ targetChainBytes[1] = targetChain & 255;
417
+ const payloadBytes = this.hexToBytes(actionPayload.replace("0x", ""));
418
+ const nonceHex = nonce.toString(16).padStart(64, "0");
419
+ const nonceBytes = this.hexToBytes(nonceHex);
420
+ const combined = new Uint8Array([
421
+ ...keyHashBytes,
422
+ ...targetChainBytes,
423
+ ...payloadBytes,
424
+ ...nonceBytes
425
+ ]);
426
+ const hash = (0, import_js_sha3.sha3_256)(combined);
427
+ return "0x" + hash;
428
+ }
429
+ /**
430
+ * Get Aptos client instance for advanced usage
431
+ */
432
+ getClient() {
433
+ return this.client;
434
+ }
435
+ /**
436
+ * Get module address
437
+ */
438
+ getModuleAddress() {
439
+ return this.moduleAddress;
440
+ }
441
+ /**
442
+ * Get current ledger version
443
+ */
444
+ async getLedgerVersion() {
445
+ const ledgerInfo = await this.client.getLedgerInfo();
446
+ return BigInt(ledgerInfo.ledger_version);
447
+ }
448
+ /**
449
+ * Get transaction by hash
450
+ */
451
+ async getTransaction(txHash) {
452
+ return await this.client.getTransactionByHash(txHash);
453
+ }
454
+ /**
455
+ * Wait for transaction confirmation
456
+ */
457
+ async waitForTransaction(txHash, timeoutSecs = 30) {
458
+ return await this.client.waitForTransactionWithResult(txHash, {
459
+ timeoutSecs,
460
+ checkSuccess: true
461
+ });
462
+ }
463
+ // ============================================================================
464
+ // Social Recovery Methods (Issue #23)
465
+ // ============================================================================
466
+ //
467
+ // Note: Social recovery is managed on the Hub chain (EVM).
468
+ // Aptos spokes receive and execute recovery VAAs broadcast from the Hub.
469
+ // The relayer service handles submitting recovery transactions to Aptos.
470
+ //
471
+ // SDK users should use EVMClient methods for guardian management and
472
+ // recovery initiation on the Hub chain.
473
+ // ============================================================================
474
+ /**
475
+ * Get vault resource for an owner
476
+ *
477
+ * @param ownerKeyHash - Owner's passkey hash (32 bytes as hex)
478
+ * @returns Vault resource data or null if not found
479
+ */
480
+ async getVaultResource(ownerKeyHash) {
481
+ try {
482
+ const vaultAddress = this.computeVaultAddressFromHash(ownerKeyHash);
483
+ const resource = await this.client.getAccountResource(
484
+ vaultAddress,
485
+ `${this.moduleAddress}::vault::Vault`
486
+ );
487
+ if (!resource || !resource.data) {
488
+ return null;
489
+ }
490
+ const data = resource.data;
491
+ return {
492
+ ownerKeyHash: data.owner_key_hash || ownerKeyHash,
493
+ authorizedSigners: data.authorized_signers || [],
494
+ nonce: BigInt(data.nonce || 0)
495
+ };
496
+ } catch (error) {
497
+ console.error("Error getting vault resource:", error);
498
+ return null;
499
+ }
500
+ }
501
+ /**
502
+ * Get authorized signers for a vault
503
+ *
504
+ * @param ownerKeyHash - Owner's passkey hash (32 bytes as hex)
505
+ * @returns Array of authorized signer key hashes
506
+ */
507
+ async getAuthorizedSigners(ownerKeyHash) {
508
+ const vaultResource = await this.getVaultResource(ownerKeyHash);
509
+ return vaultResource?.authorizedSigners || [];
510
+ }
511
+ /**
512
+ * Check if a VAA has been processed (for replay protection)
513
+ *
514
+ * @param vaaHash - VAA hash as hex string
515
+ * @returns Whether the VAA has been processed
516
+ */
517
+ async isVaaProcessed(vaaHash) {
518
+ try {
519
+ const resource = await this.client.getAccountResource(
520
+ this.moduleAddress,
521
+ `${this.moduleAddress}::spoke::ProcessedVAAs`
522
+ );
523
+ if (!resource || !resource.data) {
524
+ return false;
525
+ }
526
+ const data = resource.data;
527
+ const processedVaas = data.processed || [];
528
+ const normalizedHash = vaaHash.toLowerCase().replace("0x", "");
529
+ return processedVaas.some(
530
+ (hash) => hash.toLowerCase().replace("0x", "") === normalizedHash
531
+ );
532
+ } catch (error) {
533
+ console.error("Error checking VAA status:", error);
534
+ return false;
535
+ }
536
+ }
537
+ /**
538
+ * Check if protocol is paused
539
+ *
540
+ * @returns Whether the protocol is paused
541
+ */
542
+ async isProtocolPaused() {
543
+ try {
544
+ const resource = await this.client.getAccountResource(
545
+ this.moduleAddress,
546
+ `${this.moduleAddress}::spoke::Config`
547
+ );
548
+ if (!resource || !resource.data) {
549
+ return false;
550
+ }
551
+ const data = resource.data;
552
+ return data.paused === true;
553
+ } catch (error) {
554
+ console.error("Error checking pause status:", error);
555
+ return false;
556
+ }
557
+ }
558
+ };
559
+ // Annotate the CommonJS export names for ESM import in node:
560
+ 0 && (module.exports = {
561
+ AptosClient
562
+ });
563
+ //# sourceMappingURL=index.js.map