@veridex/sdk 1.1.1 → 1.1.2
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.
- package/dist/{EVMClient-DtqvdfUP.d.mts → EVMClient-Bmy9czkE.d.mts} +2 -0
- package/dist/chains/avalanche/index.d.mts +1 -1
- package/dist/chains/avalanche/index.js +59 -11
- package/dist/chains/avalanche/index.js.map +1 -1
- package/dist/chains/avalanche/index.mjs +2 -2
- package/dist/chains/evm/index.d.mts +3 -3
- package/dist/chains/evm/index.js +59 -11
- package/dist/chains/evm/index.js.map +1 -1
- package/dist/chains/evm/index.mjs +1 -1
- package/dist/chains/stacks/index.d.mts +1 -1
- package/dist/chains/starknet/index.d.mts +1 -1
- package/dist/chains/stellar/index.d.mts +312 -0
- package/dist/chains/stellar/index.js +300 -0
- package/dist/chains/stellar/index.js.map +1 -0
- package/dist/chains/stellar/index.mjs +260 -0
- package/dist/chains/stellar/index.mjs.map +1 -0
- package/dist/chains/sui/index.d.mts +1 -1
- package/dist/{chunk-PEGOXMBU.mjs → chunk-AFHWA4CZ.mjs} +2 -2
- package/dist/{chunk-YBN2VC6E.mjs → chunk-DZUNCSI5.mjs} +60 -12
- package/dist/chunk-DZUNCSI5.mjs.map +1 -0
- package/dist/{index-CySMITQ9.d.mts → index-CKKUV4J7.d.mts} +2 -2
- package/dist/index.d.mts +5 -4
- package/dist/index.js +67 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{types-DWx-5jmz.d.mts → types-C564CfsE.d.mts} +21 -1
- package/package.json +8 -1
- package/dist/chunk-YBN2VC6E.mjs.map +0 -1
- /package/dist/{chunk-PEGOXMBU.mjs.map → chunk-AFHWA4CZ.mjs.map} +0 -0
|
@@ -23,6 +23,8 @@ declare class EVMClient implements ChainClient {
|
|
|
23
23
|
private hubContract;
|
|
24
24
|
private factoryContract;
|
|
25
25
|
private cachedImplementation;
|
|
26
|
+
private cachedWormholeAddress;
|
|
27
|
+
private cachedMessageFee;
|
|
26
28
|
constructor(config: EVMClientConfig);
|
|
27
29
|
getConfig(): ChainConfig;
|
|
28
30
|
getNonce(userKeyHash: string): Promise<bigint>;
|
|
@@ -119,7 +119,9 @@ var ERC20_ABI = [
|
|
|
119
119
|
var HUB_ABI = [
|
|
120
120
|
"function dispatch(tuple(bytes authenticatorData, string clientDataJSON, uint256 challengeIndex, uint256 typeIndex, uint256 r, uint256 s) signature, uint256 publicKeyX, uint256 publicKeyY, uint16 targetChain, bytes actionPayload, uint256 nonce) payable returns (uint64 sequence)",
|
|
121
121
|
"function userNonces(bytes32 userKeyHash) view returns (uint256)",
|
|
122
|
-
|
|
122
|
+
// Hub exposes the Wormhole core bridge address; message fee is read from the
|
|
123
|
+
// bridge directly (getMessageFee() was removed from the Hub).
|
|
124
|
+
"function wormhole() view returns (address)",
|
|
123
125
|
"function getVaultAddress(bytes32 userKeyHash) view returns (address)",
|
|
124
126
|
"function vaultExists(bytes32 userKeyHash) view returns (bool)",
|
|
125
127
|
"function createVault(bytes32 userKeyHash) returns (address)",
|
|
@@ -176,6 +178,8 @@ var EVMClient = class {
|
|
|
176
178
|
hubContract;
|
|
177
179
|
factoryContract = null;
|
|
178
180
|
cachedImplementation = null;
|
|
181
|
+
cachedWormholeAddress = null;
|
|
182
|
+
cachedMessageFee = null;
|
|
179
183
|
constructor(config) {
|
|
180
184
|
this.config = {
|
|
181
185
|
name: config.name ?? `EVM Chain ${config.chainId}`,
|
|
@@ -348,8 +352,24 @@ var EVMClient = class {
|
|
|
348
352
|
return Number(count);
|
|
349
353
|
}
|
|
350
354
|
async getMessageFee() {
|
|
351
|
-
const
|
|
352
|
-
|
|
355
|
+
const now = Date.now();
|
|
356
|
+
if (this.cachedMessageFee && this.cachedMessageFee.expiresAt > now) {
|
|
357
|
+
return this.cachedMessageFee.value;
|
|
358
|
+
}
|
|
359
|
+
let wormholeAddress = this.config.contracts.wormholeCoreBridge ?? this.cachedWormholeAddress;
|
|
360
|
+
if (!wormholeAddress) {
|
|
361
|
+
wormholeAddress = await this.hubContract.wormhole();
|
|
362
|
+
this.cachedWormholeAddress = wormholeAddress;
|
|
363
|
+
}
|
|
364
|
+
const wormhole = new import_ethers2.ethers.Contract(
|
|
365
|
+
wormholeAddress,
|
|
366
|
+
["function messageFee() view returns (uint256)"],
|
|
367
|
+
this.provider
|
|
368
|
+
);
|
|
369
|
+
const fee = await wormhole.messageFee();
|
|
370
|
+
const value = BigInt(fee.toString());
|
|
371
|
+
this.cachedMessageFee = { value, expiresAt: now + 3e4 };
|
|
372
|
+
return value;
|
|
353
373
|
}
|
|
354
374
|
async buildTransferPayload(params) {
|
|
355
375
|
return encodeTransferAction(
|
|
@@ -448,13 +468,41 @@ var EVMClient = class {
|
|
|
448
468
|
actionPayload,
|
|
449
469
|
nonce: Number(nonce)
|
|
450
470
|
};
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
471
|
+
const MAX_ATTEMPTS = 3;
|
|
472
|
+
const baseDelayMs = 1e3;
|
|
473
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
474
|
+
let response;
|
|
475
|
+
let lastError;
|
|
476
|
+
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
|
|
477
|
+
try {
|
|
478
|
+
response = await fetch(`${relayerUrl}/api/v1/submit`, {
|
|
479
|
+
method: "POST",
|
|
480
|
+
headers: {
|
|
481
|
+
"Content-Type": "application/json"
|
|
482
|
+
},
|
|
483
|
+
body: JSON.stringify(request)
|
|
484
|
+
});
|
|
485
|
+
const retryable = response.status >= 500 || response.status === 408 || response.status === 429;
|
|
486
|
+
if (!retryable) {
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
if (attempt === MAX_ATTEMPTS) break;
|
|
490
|
+
const retryAfter = response.headers.get("retry-after");
|
|
491
|
+
const explicitDelay = retryAfter ? parseInt(retryAfter, 10) * 1e3 : 0;
|
|
492
|
+
const backoff = explicitDelay > 0 ? explicitDelay : baseDelayMs * 2 ** (attempt - 1) + Math.floor(Math.random() * 200);
|
|
493
|
+
await sleep(backoff);
|
|
494
|
+
} catch (err) {
|
|
495
|
+
lastError = err;
|
|
496
|
+
if (attempt === MAX_ATTEMPTS) break;
|
|
497
|
+
const backoff = baseDelayMs * 2 ** (attempt - 1) + Math.floor(Math.random() * 200);
|
|
498
|
+
await sleep(backoff);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (!response) {
|
|
502
|
+
throw new Error(
|
|
503
|
+
`Relayer submission failed after ${MAX_ATTEMPTS} attempts: ${lastError instanceof Error ? lastError.message : String(lastError)}`
|
|
504
|
+
);
|
|
505
|
+
}
|
|
458
506
|
if (!response.ok) {
|
|
459
507
|
const error = await response.json().catch(() => ({ error: response.statusText }));
|
|
460
508
|
throw new Error(`Relayer submission failed: ${error.error || response.statusText}`);
|
|
@@ -1285,7 +1333,7 @@ var EVMClient = class {
|
|
|
1285
1333
|
async executeTransactionProposal(proposalId, signer) {
|
|
1286
1334
|
const s = signer;
|
|
1287
1335
|
const hub = this.hubContract.connect(s);
|
|
1288
|
-
const fee = await this.
|
|
1336
|
+
const fee = await this.getMessageFee();
|
|
1289
1337
|
const tx = await hub.executeTransactionProposal(proposalId, { value: fee });
|
|
1290
1338
|
const receipt = await tx.wait();
|
|
1291
1339
|
const sequence = this._extractSequenceFromReceipt(receipt);
|