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