@veridex/sdk 1.0.0-beta.21 → 1.0.0-beta.23

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