@trustware/sdk-staging 1.1.11-staging.1 → 1.1.11-staging.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/README.md +54 -21
- package/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/{core-BgYLe9Q7.d.ts → core-B1WCJfDI.d.ts} +1 -1
- package/dist/{core-fLSt4qD2.d.cts → core-CeNTuqPz.d.cts} +1 -1
- package/dist/core.cjs +85 -43
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.mjs +83 -42
- package/dist/core.mjs.map +1 -1
- package/dist/index.cjs +107 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.mjs +105 -55
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-BY3NHAks.d.ts → manager-Bw8b1wSD.d.ts} +89 -22
- package/dist/{manager-DT8enQbE.d.cts → manager-DNGk1YkR.d.cts} +89 -22
- package/dist/{metadata-BPvFYMlc.d.ts → metadata-C__KMeuz.d.ts} +1 -1
- package/dist/{metadata-DyxUcKHk.d.cts → metadata-Dk4R8_-T.d.cts} +1 -1
- package/dist/smart-account.cjs +49 -44
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.d.cts +5 -0
- package/dist/smart-account.d.ts +5 -0
- package/dist/smart-account.mjs +49 -44
- package/dist/smart-account.mjs.map +1 -1
- package/dist/wallet.cjs +40 -39
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +3 -3
- package/dist/wallet.d.ts +3 -3
- package/dist/wallet.mjs +40 -39
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +101 -55
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +101 -55
- package/dist/widget.mjs.map +1 -1
- package/package.json +73 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import { T as Trustware } from './core-
|
|
2
|
-
export { a as TrustwareCore, v as validateAddressForChain, b as validateBtcAddress, c as validateCosmosAddress, d as validateEvmAddress, e as validateRouteAddresses, f as validateSeiAddress, g as validateSolanaAddress } from './core-
|
|
3
|
-
import { R as RateLimitInfo, T as TrustwareConfigOptions, i as WalletInterFaceAPI, j as TrustwareError, k as Transaction, l as TrustwareEvent } from './manager-
|
|
4
|
-
export { B as BuildRouteBody, m as BuildRouteResponse, n as BuildRouteResult, o as DEFAULT_AUTO_DETECT_PROVIDER, p as DEFAULT_FEATURE_FLAGS, q as DEFAULT_MESSAGES, r as DEFAULT_RETRY_CONFIG, s as DEFAULT_SLIPPAGE, D as DetectedWallet, E as EIP1193, t as EIP6963ProviderDetail, v as EvmWalletInterface, F as FeatureFlags, I as IdentityStore, P as PostHookRequest, x as
|
|
1
|
+
import { T as Trustware } from './core-CeNTuqPz.cjs';
|
|
2
|
+
export { a as TrustwareCore, v as validateAddressForChain, b as validateBtcAddress, c as validateCosmosAddress, d as validateEvmAddress, e as validateRouteAddresses, f as validateSeiAddress, g as validateSolanaAddress } from './core-CeNTuqPz.cjs';
|
|
3
|
+
import { R as RateLimitInfo, T as TrustwareConfigOptions, i as WalletInterFaceAPI, j as TrustwareError, k as Transaction, l as TrustwareEvent } from './manager-DNGk1YkR.cjs';
|
|
4
|
+
export { B as BuildRouteBody, m as BuildRouteResponse, n as BuildRouteResult, o as DEFAULT_AUTO_DETECT_PROVIDER, p as DEFAULT_FEATURE_FLAGS, q as DEFAULT_MESSAGES, r as DEFAULT_RETRY_CONFIG, s as DEFAULT_SLIPPAGE, D as DetectedWallet, E as EIP1193, t as EIP6963ProviderDetail, v as EvmWalletInterface, F as FeatureFlags, I as IdentityStore, P as PostHookRequest, x as RATE_LIMIT_WAIT_BUDGET_MS, y as ResolvedFeatureFlags, z as ResolvedRetryConfig, A as ResolvedTrustwareConfig, C as ResolvedWalletConnectConfig, G as RetryConfig, H as RouteApproval, J as RouteEstimate, K as RouteIntent, L as RouteParams, M as RoutePlan, N as RouteSponsorship, O as RoutesConfig, Q as SimpleWalletInterface, S as SolanaProviderLike, b as SolanaWalletInterface, U as SponsorshipApproval, V as SwapTokenRef, X as TrustwareTheme, Y as TrustwareWidgetMessages, c as WagmiBridge, d as WagmiConnector, Z as WalletAddressResolution, _ as WalletAddressSource, $ as WalletCategory, a0 as WalletConnectConfig, a1 as WalletEcosystem, a as WalletId, a2 as WalletIdentity, a3 as WalletIdentityAddress, a4 as WalletIdentityChainLike, W as WalletMeta, a5 as assertValidPostHook, a6 as buildWalletIdentityAddress, a7 as createWalletIdentity, a8 as resolveWalletAddressForChain, a9 as upsertWalletIdentityAddress, f as useWalletExternalDisconnect, g as useWalletInfo, h as useWireDetectionIntoManager, w as walletManager } from './manager-DNGk1YkR.cjs';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import React__default from 'react';
|
|
7
7
|
import { C as ChainDef } from './blockchain-BxAFzp0s.cjs';
|
|
8
8
|
export { B as BalanceRow, a as BalanceStreamOptions, b as ChainMeta, c as ChainType, G as GetBalancesOptions, N as NativeCurrency, T as TokenDef, d as TokenMeta, e as TokenPageInfo, f as TokenPageOptions, g as TokenPageResult, h as TokenType, i as TokenWithBalance, W as WalletAddressBalanceWrapper } from './blockchain-BxAFzp0s.cjs';
|
|
9
9
|
import { T as Token, Y as YourTokenData } from './types-DX3HtFcn.cjs';
|
|
10
|
-
export { P as POPULAR_ORDER, W as WALLETS, c as connectDetectedWallet, t as toWalletInterfaceFromDetected, u as useEIP1193, f as useWagmi, g as useWalletDetection } from './metadata-
|
|
10
|
+
export { P as POPULAR_ORDER, W as WALLETS, c as connectDetectedWallet, t as toWalletInterfaceFromDetected, u as useEIP1193, f as useWagmi, g as useWalletDetection } from './metadata-Dk4R8_-T.cjs';
|
|
11
11
|
export { TrustwareWidget } from './widget.cjs';
|
|
12
12
|
export { API_PREFIX, API_ROOT, ASSETS_BASE_URL, GTM_ID, SDK_NAME, SDK_VERSION, WALLETCONNECT_PROJECT_ID } from './constants.cjs';
|
|
13
13
|
|
|
14
14
|
declare class RateLimitError extends Error {
|
|
15
15
|
readonly rateLimitInfo: RateLimitInfo;
|
|
16
|
+
/**
|
|
17
|
+
* true — the response carried no usable Retry-After or X-RateLimit-Reset, so
|
|
18
|
+
* there was no schedule to retry against and the SDK stopped.
|
|
19
|
+
* false — the wait is known and simply longer than the SDK will block for.
|
|
20
|
+
* `rateLimitInfo.retryAfter` holds it; show the user when to return.
|
|
21
|
+
*/
|
|
16
22
|
readonly retriesExhausted: boolean;
|
|
17
23
|
constructor(info: RateLimitInfo, retriesExhausted: boolean);
|
|
18
24
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import { T as Trustware } from './core-
|
|
2
|
-
export { a as TrustwareCore, v as validateAddressForChain, b as validateBtcAddress, c as validateCosmosAddress, d as validateEvmAddress, e as validateRouteAddresses, f as validateSeiAddress, g as validateSolanaAddress } from './core-
|
|
3
|
-
import { R as RateLimitInfo, T as TrustwareConfigOptions, i as WalletInterFaceAPI, j as TrustwareError, k as Transaction, l as TrustwareEvent } from './manager-
|
|
4
|
-
export { B as BuildRouteBody, m as BuildRouteResponse, n as BuildRouteResult, o as DEFAULT_AUTO_DETECT_PROVIDER, p as DEFAULT_FEATURE_FLAGS, q as DEFAULT_MESSAGES, r as DEFAULT_RETRY_CONFIG, s as DEFAULT_SLIPPAGE, D as DetectedWallet, E as EIP1193, t as EIP6963ProviderDetail, v as EvmWalletInterface, F as FeatureFlags, I as IdentityStore, P as PostHookRequest, x as
|
|
1
|
+
import { T as Trustware } from './core-B1WCJfDI.js';
|
|
2
|
+
export { a as TrustwareCore, v as validateAddressForChain, b as validateBtcAddress, c as validateCosmosAddress, d as validateEvmAddress, e as validateRouteAddresses, f as validateSeiAddress, g as validateSolanaAddress } from './core-B1WCJfDI.js';
|
|
3
|
+
import { R as RateLimitInfo, T as TrustwareConfigOptions, i as WalletInterFaceAPI, j as TrustwareError, k as Transaction, l as TrustwareEvent } from './manager-Bw8b1wSD.js';
|
|
4
|
+
export { B as BuildRouteBody, m as BuildRouteResponse, n as BuildRouteResult, o as DEFAULT_AUTO_DETECT_PROVIDER, p as DEFAULT_FEATURE_FLAGS, q as DEFAULT_MESSAGES, r as DEFAULT_RETRY_CONFIG, s as DEFAULT_SLIPPAGE, D as DetectedWallet, E as EIP1193, t as EIP6963ProviderDetail, v as EvmWalletInterface, F as FeatureFlags, I as IdentityStore, P as PostHookRequest, x as RATE_LIMIT_WAIT_BUDGET_MS, y as ResolvedFeatureFlags, z as ResolvedRetryConfig, A as ResolvedTrustwareConfig, C as ResolvedWalletConnectConfig, G as RetryConfig, H as RouteApproval, J as RouteEstimate, K as RouteIntent, L as RouteParams, M as RoutePlan, N as RouteSponsorship, O as RoutesConfig, Q as SimpleWalletInterface, S as SolanaProviderLike, b as SolanaWalletInterface, U as SponsorshipApproval, V as SwapTokenRef, X as TrustwareTheme, Y as TrustwareWidgetMessages, c as WagmiBridge, d as WagmiConnector, Z as WalletAddressResolution, _ as WalletAddressSource, $ as WalletCategory, a0 as WalletConnectConfig, a1 as WalletEcosystem, a as WalletId, a2 as WalletIdentity, a3 as WalletIdentityAddress, a4 as WalletIdentityChainLike, W as WalletMeta, a5 as assertValidPostHook, a6 as buildWalletIdentityAddress, a7 as createWalletIdentity, a8 as resolveWalletAddressForChain, a9 as upsertWalletIdentityAddress, f as useWalletExternalDisconnect, g as useWalletInfo, h as useWireDetectionIntoManager, w as walletManager } from './manager-Bw8b1wSD.js';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import React__default from 'react';
|
|
7
7
|
import { C as ChainDef } from './blockchain-BxAFzp0s.js';
|
|
8
8
|
export { B as BalanceRow, a as BalanceStreamOptions, b as ChainMeta, c as ChainType, G as GetBalancesOptions, N as NativeCurrency, T as TokenDef, d as TokenMeta, e as TokenPageInfo, f as TokenPageOptions, g as TokenPageResult, h as TokenType, i as TokenWithBalance, W as WalletAddressBalanceWrapper } from './blockchain-BxAFzp0s.js';
|
|
9
9
|
import { T as Token, Y as YourTokenData } from './types-BJY9r-mz.js';
|
|
10
|
-
export { P as POPULAR_ORDER, W as WALLETS, c as connectDetectedWallet, t as toWalletInterfaceFromDetected, u as useEIP1193, f as useWagmi, g as useWalletDetection } from './metadata-
|
|
10
|
+
export { P as POPULAR_ORDER, W as WALLETS, c as connectDetectedWallet, t as toWalletInterfaceFromDetected, u as useEIP1193, f as useWagmi, g as useWalletDetection } from './metadata-C__KMeuz.js';
|
|
11
11
|
export { TrustwareWidget } from './widget.js';
|
|
12
12
|
export { API_PREFIX, API_ROOT, ASSETS_BASE_URL, GTM_ID, SDK_NAME, SDK_VERSION, WALLETCONNECT_PROJECT_ID } from './constants.js';
|
|
13
13
|
|
|
14
14
|
declare class RateLimitError extends Error {
|
|
15
15
|
readonly rateLimitInfo: RateLimitInfo;
|
|
16
|
+
/**
|
|
17
|
+
* true — the response carried no usable Retry-After or X-RateLimit-Reset, so
|
|
18
|
+
* there was no schedule to retry against and the SDK stopped.
|
|
19
|
+
* false — the wait is known and simply longer than the SDK will block for.
|
|
20
|
+
* `rateLimitInfo.retryAfter` holds it; show the user when to return.
|
|
21
|
+
*/
|
|
16
22
|
readonly retriesExhausted: boolean;
|
|
17
23
|
constructor(info: RateLimitInfo, retriesExhausted: boolean);
|
|
18
24
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -25,18 +25,16 @@ var init_defaults = __esm({
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
// src/types/config.ts
|
|
28
|
-
var DEFAULT_SLIPPAGE2, DEFAULT_AUTO_DETECT_PROVIDER2, DEFAULT_RETRY_CONFIG, DEFAULT_FEATURE_FLAGS;
|
|
28
|
+
var DEFAULT_SLIPPAGE2, DEFAULT_AUTO_DETECT_PROVIDER2, DEFAULT_RETRY_CONFIG, RATE_LIMIT_WAIT_BUDGET_MS, DEFAULT_FEATURE_FLAGS;
|
|
29
29
|
var init_config = __esm({
|
|
30
30
|
"src/types/config.ts"() {
|
|
31
31
|
"use strict";
|
|
32
32
|
DEFAULT_SLIPPAGE2 = 1;
|
|
33
33
|
DEFAULT_AUTO_DETECT_PROVIDER2 = false;
|
|
34
34
|
DEFAULT_RETRY_CONFIG = {
|
|
35
|
-
autoRetry: true,
|
|
36
|
-
maxRetries: 3,
|
|
37
|
-
baseDelayMs: 1e3,
|
|
38
35
|
approachingThreshold: 5
|
|
39
36
|
};
|
|
37
|
+
RATE_LIMIT_WAIT_BUDGET_MS = 1e4;
|
|
40
38
|
DEFAULT_FEATURE_FLAGS = {
|
|
41
39
|
tokensPagination: true,
|
|
42
40
|
balanceStreaming: false,
|
|
@@ -173,9 +171,6 @@ function resolveConfig(input) {
|
|
|
173
171
|
const theme = input.theme ?? "system";
|
|
174
172
|
const messages = deepMerge(DEFAULT_MESSAGES, input.messages);
|
|
175
173
|
const retry = {
|
|
176
|
-
autoRetry: input.retry?.autoRetry ?? DEFAULT_RETRY_CONFIG.autoRetry,
|
|
177
|
-
maxRetries: input.retry?.maxRetries ?? DEFAULT_RETRY_CONFIG.maxRetries,
|
|
178
|
-
baseDelayMs: input.retry?.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs,
|
|
179
174
|
approachingThreshold: input.retry?.approachingThreshold ?? DEFAULT_RETRY_CONFIG.approachingThreshold,
|
|
180
175
|
onRateLimitInfo: input.retry?.onRateLimitInfo,
|
|
181
176
|
onRateLimited: input.retry?.onRateLimited,
|
|
@@ -487,7 +482,7 @@ var init_constants = __esm({
|
|
|
487
482
|
"src/constants.ts"() {
|
|
488
483
|
"use strict";
|
|
489
484
|
SDK_NAME = "@trustware/sdk";
|
|
490
|
-
SDK_VERSION = "1.1.11-staging.
|
|
485
|
+
SDK_VERSION = "1.1.11-staging.2";
|
|
491
486
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
492
487
|
GTM_ID = "GTM-TZDGNCXB";
|
|
493
488
|
API_PREFIX = "/api";
|
|
@@ -574,50 +569,54 @@ function notifyRateLimitCallbacks(info, isRateLimited, retryCount) {
|
|
|
574
569
|
retry.onRateLimitApproaching(info, retry.approachingThreshold);
|
|
575
570
|
}
|
|
576
571
|
}
|
|
577
|
-
function
|
|
578
|
-
if (
|
|
579
|
-
|
|
572
|
+
function serverDirectedWaitMs(info) {
|
|
573
|
+
if (!info) return null;
|
|
574
|
+
if (typeof info.retryAfter === "number" && info.retryAfter > 0) {
|
|
575
|
+
return info.retryAfter * 1e3;
|
|
580
576
|
}
|
|
581
|
-
|
|
577
|
+
if (typeof info.reset === "number" && info.reset > 0) {
|
|
578
|
+
const untilReset = info.reset * 1e3 - Date.now();
|
|
579
|
+
if (untilReset > 0) return untilReset;
|
|
580
|
+
}
|
|
581
|
+
return null;
|
|
582
582
|
}
|
|
583
583
|
function sleep(ms) {
|
|
584
584
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
585
585
|
}
|
|
586
|
-
async function
|
|
587
|
-
|
|
588
|
-
const cfg = TrustwareConfigStore.get();
|
|
589
|
-
if (!cfg.retry.autoRetry || skipRateLimit) {
|
|
590
|
-
return fetch(url, fetchOptions);
|
|
591
|
-
}
|
|
592
|
-
const { maxRetries, baseDelayMs } = cfg.retry;
|
|
586
|
+
async function withRateLimitRetry(attempt) {
|
|
587
|
+
let waitedMs = 0;
|
|
593
588
|
let retryCount = 0;
|
|
594
589
|
while (true) {
|
|
595
|
-
const response = await
|
|
590
|
+
const response = await attempt();
|
|
596
591
|
const rateLimitInfo = parseRateLimitHeaders(response);
|
|
597
|
-
if (response.status
|
|
592
|
+
if (response.status !== 429) {
|
|
598
593
|
if (rateLimitInfo) {
|
|
599
|
-
notifyRateLimitCallbacks(rateLimitInfo,
|
|
600
|
-
}
|
|
601
|
-
if (retryCount >= maxRetries) {
|
|
602
|
-
throw new RateLimitError(
|
|
603
|
-
rateLimitInfo || { limit: 0, remaining: 0, reset: 0 },
|
|
604
|
-
true
|
|
605
|
-
);
|
|
594
|
+
notifyRateLimitCallbacks(rateLimitInfo, false, 0);
|
|
606
595
|
}
|
|
607
|
-
|
|
608
|
-
baseDelayMs,
|
|
609
|
-
retryCount,
|
|
610
|
-
rateLimitInfo?.retryAfter
|
|
611
|
-
);
|
|
612
|
-
await sleep(delay);
|
|
613
|
-
retryCount++;
|
|
614
|
-
continue;
|
|
596
|
+
return response;
|
|
615
597
|
}
|
|
616
598
|
if (rateLimitInfo) {
|
|
617
|
-
notifyRateLimitCallbacks(rateLimitInfo,
|
|
599
|
+
notifyRateLimitCallbacks(rateLimitInfo, true, retryCount);
|
|
618
600
|
}
|
|
619
|
-
|
|
601
|
+
const waitMs = serverDirectedWaitMs(rateLimitInfo);
|
|
602
|
+
const info = rateLimitInfo || { limit: 0, remaining: 0, reset: 0 };
|
|
603
|
+
if (waitMs === null) {
|
|
604
|
+
throw new RateLimitError(info, true);
|
|
605
|
+
}
|
|
606
|
+
if (waitedMs + waitMs > RATE_LIMIT_WAIT_BUDGET_MS) {
|
|
607
|
+
throw new RateLimitError(info, false);
|
|
608
|
+
}
|
|
609
|
+
await sleep(waitMs);
|
|
610
|
+
waitedMs += waitMs;
|
|
611
|
+
retryCount++;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
async function rateLimitedFetch(url, options = {}) {
|
|
615
|
+
const { skipRateLimit, ...fetchOptions } = options;
|
|
616
|
+
if (skipRateLimit) {
|
|
617
|
+
return fetch(url, fetchOptions);
|
|
620
618
|
}
|
|
619
|
+
return withRateLimitRetry(() => fetch(url, fetchOptions));
|
|
621
620
|
}
|
|
622
621
|
var RateLimitError;
|
|
623
622
|
var init_http = __esm({
|
|
@@ -625,9 +624,11 @@ var init_http = __esm({
|
|
|
625
624
|
"use strict";
|
|
626
625
|
init_constants();
|
|
627
626
|
init_config2();
|
|
627
|
+
init_config();
|
|
628
628
|
RateLimitError = class extends Error {
|
|
629
629
|
constructor(info, retriesExhausted) {
|
|
630
|
-
const
|
|
630
|
+
const seconds = info.retryAfter ?? (info.reset > 0 ? Math.max(0, Math.ceil((info.reset * 1e3 - Date.now()) / 1e3)) : null);
|
|
631
|
+
const message = seconds === null ? "Rate limit exceeded. The server did not say when to retry." : `Rate limit exceeded. Try again in ${seconds} seconds.`;
|
|
631
632
|
super(message);
|
|
632
633
|
this.name = "RateLimitError";
|
|
633
634
|
this.rateLimitInfo = info;
|
|
@@ -4553,7 +4554,18 @@ async function getStatus(intentId) {
|
|
|
4553
4554
|
);
|
|
4554
4555
|
await assertOK(r);
|
|
4555
4556
|
const j = await r.json();
|
|
4556
|
-
return j.data;
|
|
4557
|
+
return normalizeStatusPayload(j.data);
|
|
4558
|
+
}
|
|
4559
|
+
function normalizeStatusPayload(raw) {
|
|
4560
|
+
if (!raw || typeof raw !== "object") return raw;
|
|
4561
|
+
const wire = raw;
|
|
4562
|
+
const out = { ...wire };
|
|
4563
|
+
for (const [snake, camel] of Object.entries(STATUS_WIRE_TO_CAMEL)) {
|
|
4564
|
+
if (out[camel] !== void 0) continue;
|
|
4565
|
+
if (!(snake in wire)) continue;
|
|
4566
|
+
out[camel] = wire[snake];
|
|
4567
|
+
}
|
|
4568
|
+
return out;
|
|
4557
4569
|
}
|
|
4558
4570
|
async function pollStatus(intentId, { intervalMs = 2e3, timeoutMs = 5 * 6e4 } = {}) {
|
|
4559
4571
|
const t0 = Date.now();
|
|
@@ -4564,12 +4576,39 @@ async function pollStatus(intentId, { intervalMs = 2e3, timeoutMs = 5 * 6e4 } =
|
|
|
4564
4576
|
await new Promise((r) => setTimeout(r, intervalMs));
|
|
4565
4577
|
}
|
|
4566
4578
|
}
|
|
4579
|
+
var STATUS_WIRE_TO_CAMEL;
|
|
4567
4580
|
var init_routes = __esm({
|
|
4568
4581
|
"src/core/routes.ts"() {
|
|
4569
4582
|
"use strict";
|
|
4570
4583
|
init_http();
|
|
4571
4584
|
init_store();
|
|
4572
4585
|
init_address();
|
|
4586
|
+
STATUS_WIRE_TO_CAMEL = {
|
|
4587
|
+
intent_id: "intentId",
|
|
4588
|
+
from_address: "fromAddress",
|
|
4589
|
+
to_address: "toAddress",
|
|
4590
|
+
from_chain_id: "fromChainId",
|
|
4591
|
+
to_chain_id: "toChainId",
|
|
4592
|
+
source_tx_hash: "sourceTxHash",
|
|
4593
|
+
dest_tx_hash: "destTxHash",
|
|
4594
|
+
request_id: "requestId",
|
|
4595
|
+
provider_request_id: "providerRequestId",
|
|
4596
|
+
transaction_request: "transactionRequest",
|
|
4597
|
+
status_raw: "statusRaw",
|
|
4598
|
+
route_path: "routePath",
|
|
4599
|
+
route_status: "routeStatus",
|
|
4600
|
+
to_amount_wei: "toAmountWei",
|
|
4601
|
+
from_chain_block: "fromChainBlock",
|
|
4602
|
+
to_chain_block: "toChainBlock",
|
|
4603
|
+
from_chain_tx_url: "fromChainTxUrl",
|
|
4604
|
+
to_chain_tx_url: "toChainTxUrl",
|
|
4605
|
+
gas_status: "gasStatus",
|
|
4606
|
+
is_gmp_transaction: "isGMPTransaction",
|
|
4607
|
+
axelar_transaction_url: "axelarTransactionUrl",
|
|
4608
|
+
create_date: "createdDate",
|
|
4609
|
+
update_date: "updatedDate",
|
|
4610
|
+
time_spent_ms: "timeSpentMs"
|
|
4611
|
+
};
|
|
4573
4612
|
}
|
|
4574
4613
|
});
|
|
4575
4614
|
|
|
@@ -5118,7 +5157,7 @@ async function getBalances(chainRef, address, opts) {
|
|
|
5118
5157
|
if (cached) return cached;
|
|
5119
5158
|
}
|
|
5120
5159
|
const url = `${apiBase()}/v1/data/wallets/${encodeURIComponent(chainKey)}/${trimmedAddress}/balances`;
|
|
5121
|
-
const response = await
|
|
5160
|
+
const response = await rateLimitedFetch(url, {
|
|
5122
5161
|
method: "GET",
|
|
5123
5162
|
credentials: "omit",
|
|
5124
5163
|
headers: jsonHeaders()
|
|
@@ -7621,6 +7660,7 @@ var init_core = __esm({
|
|
|
7621
7660
|
init_store();
|
|
7622
7661
|
init_wallets();
|
|
7623
7662
|
init_routes();
|
|
7663
|
+
init_routes();
|
|
7624
7664
|
init_balances();
|
|
7625
7665
|
init_tx();
|
|
7626
7666
|
init_http();
|
|
@@ -8229,12 +8269,9 @@ function useTrustwareConfig() {
|
|
|
8229
8269
|
title: "Trustware SDK",
|
|
8230
8270
|
description: "Seamlessly bridge assets across chains with Trustware."
|
|
8231
8271
|
},
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
baseDelayMs: 1e3,
|
|
8236
|
-
approachingThreshold: 5
|
|
8237
|
-
},
|
|
8272
|
+
// Shared with the resolver rather than restated, so this placeholder
|
|
8273
|
+
// can't drift from the real defaults.
|
|
8274
|
+
retry: { ...DEFAULT_RETRY_CONFIG },
|
|
8238
8275
|
features: {
|
|
8239
8276
|
tokensPagination: true,
|
|
8240
8277
|
balanceStreaming: false,
|
|
@@ -8259,6 +8296,7 @@ var init_useTrustwareConfig = __esm({
|
|
|
8259
8296
|
"src/hooks/useTrustwareConfig.ts"() {
|
|
8260
8297
|
"use strict";
|
|
8261
8298
|
"use client";
|
|
8299
|
+
init_config();
|
|
8262
8300
|
init_store();
|
|
8263
8301
|
}
|
|
8264
8302
|
});
|
|
@@ -30769,7 +30807,7 @@ import {
|
|
|
30769
30807
|
keccak256 as keccak2566,
|
|
30770
30808
|
stringToHex
|
|
30771
30809
|
} from "viem";
|
|
30772
|
-
async function
|
|
30810
|
+
async function fetchOnceWithTimeout(url, init) {
|
|
30773
30811
|
const controller = new AbortController();
|
|
30774
30812
|
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
30775
30813
|
try {
|
|
@@ -30790,6 +30828,9 @@ async function fetchWithTimeout(url, init) {
|
|
|
30790
30828
|
clearTimeout(timer);
|
|
30791
30829
|
}
|
|
30792
30830
|
}
|
|
30831
|
+
async function fetchWithTimeout(url, init) {
|
|
30832
|
+
return withRateLimitRetry(() => fetchOnceWithTimeout(url, init));
|
|
30833
|
+
}
|
|
30793
30834
|
function extractRevertHex(err) {
|
|
30794
30835
|
if (typeof err.data === "string" && err.data.startsWith("0x"))
|
|
30795
30836
|
return err.data;
|
|
@@ -31289,7 +31330,7 @@ async function estimateRelayFeeInToken(valueWei, fromAmountWei, fromAmountUSD, c
|
|
|
31289
31330
|
tokenUnitsPerDollar = Number(fromAmountWei) / fromUSD;
|
|
31290
31331
|
} else if (fromToken && fromDecimals !== void 0) {
|
|
31291
31332
|
try {
|
|
31292
|
-
const resp = await
|
|
31333
|
+
const resp = await rateLimitedFetch(
|
|
31293
31334
|
`${apiBase()}/v1/price/token?chainId=${cid}&address=${fromToken}`,
|
|
31294
31335
|
{ headers: jsonHeaders() }
|
|
31295
31336
|
);
|
|
@@ -31305,9 +31346,10 @@ async function estimateRelayFeeInToken(valueWei, fromAmountWei, fromAmountUSD, c
|
|
|
31305
31346
|
return 0n;
|
|
31306
31347
|
}
|
|
31307
31348
|
try {
|
|
31308
|
-
const resp = await
|
|
31309
|
-
|
|
31310
|
-
|
|
31349
|
+
const resp = await rateLimitedFetch(
|
|
31350
|
+
`${apiBase()}/v1/price/native?chainId=${cid}`,
|
|
31351
|
+
{ headers: jsonHeaders() }
|
|
31352
|
+
);
|
|
31311
31353
|
if (!resp.ok) throw new Error(`native price HTTP ${resp.status}`);
|
|
31312
31354
|
const json = await resp.json();
|
|
31313
31355
|
const ethPriceUSD = parseFloat(json.data?.priceUSD ?? "0");
|
|
@@ -34047,9 +34089,14 @@ var init_useSwapExecution = __esm({
|
|
|
34047
34089
|
|
|
34048
34090
|
// src/core/forex.ts
|
|
34049
34091
|
async function fetchForexRates(base2 = "USD") {
|
|
34050
|
-
|
|
34051
|
-
|
|
34052
|
-
|
|
34092
|
+
let r;
|
|
34093
|
+
try {
|
|
34094
|
+
r = await rateLimitedFetch(`${apiBase()}/v1/forex?base=${base2}`, {
|
|
34095
|
+
headers: jsonHeaders()
|
|
34096
|
+
});
|
|
34097
|
+
} catch {
|
|
34098
|
+
return {};
|
|
34099
|
+
}
|
|
34053
34100
|
if (!r.ok) return {};
|
|
34054
34101
|
const j = await r.json();
|
|
34055
34102
|
const rates = j?.data?.rates ?? j?.rates ?? j?.data ?? {};
|
|
@@ -40213,6 +40260,7 @@ var init_index = __esm({
|
|
|
40213
40260
|
"src/index.ts"() {
|
|
40214
40261
|
init_core2();
|
|
40215
40262
|
init_http();
|
|
40263
|
+
init_core2();
|
|
40216
40264
|
init_useWalletTokenState();
|
|
40217
40265
|
init_wallets();
|
|
40218
40266
|
init_widget();
|
|
@@ -40237,6 +40285,7 @@ export {
|
|
|
40237
40285
|
GTM_ID,
|
|
40238
40286
|
IdentityStore,
|
|
40239
40287
|
POPULAR_ORDER,
|
|
40288
|
+
RATE_LIMIT_WAIT_BUDGET_MS,
|
|
40240
40289
|
RateLimitError,
|
|
40241
40290
|
SDK_NAME,
|
|
40242
40291
|
SDK_VERSION,
|
|
@@ -40246,6 +40295,7 @@ export {
|
|
|
40246
40295
|
TrustwareWidgetV2 as TrustwareWidget,
|
|
40247
40296
|
WALLETCONNECT_PROJECT_ID,
|
|
40248
40297
|
WALLETS,
|
|
40298
|
+
assertValidPostHook,
|
|
40249
40299
|
buildWalletIdentityAddress,
|
|
40250
40300
|
connectDetectedWallet,
|
|
40251
40301
|
createWalletIdentity,
|