@trustware/sdk-staging 1.1.11-staging.1 → 1.1.12-staging.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.
- package/README.md +54 -21
- package/dist/{blockchain-BxAFzp0s.d.cts → blockchain-DmCPxnxr.d.cts} +25 -1
- package/dist/{blockchain-BxAFzp0s.d.ts → blockchain-DmCPxnxr.d.ts} +25 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/{core-BgYLe9Q7.d.ts → core-B4YDGtJT.d.ts} +3 -3
- package/dist/{core-fLSt4qD2.d.cts → core-Ck7dinYj.d.cts} +3 -3
- package/dist/core.cjs +141 -52
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +4 -4
- package/dist/core.d.ts +4 -4
- package/dist/core.mjs +139 -51
- package/dist/core.mjs.map +1 -1
- package/dist/index.cjs +166 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -8
- package/dist/index.d.ts +14 -8
- package/dist/index.mjs +164 -75
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-DT8enQbE.d.cts → manager-BZ8gyHGT.d.cts} +90 -23
- package/dist/{manager-BY3NHAks.d.ts → manager-D8nQsod2.d.ts} +90 -23
- package/dist/{metadata-DyxUcKHk.d.cts → metadata-B23D0oO9.d.cts} +1 -1
- package/dist/{metadata-BPvFYMlc.d.ts → metadata-BOjEF7oo.d.ts} +1 -1
- package/dist/smart-account.cjs +62 -47
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.d.cts +6 -0
- package/dist/smart-account.d.ts +6 -0
- package/dist/smart-account.mjs +62 -47
- package/dist/smart-account.mjs.map +1 -1
- package/dist/{types-BJY9r-mz.d.ts → types-CMmx0S4U.d.ts} +1 -1
- package/dist/{types-DX3HtFcn.d.cts → types-DEUb5IZA.d.cts} +1 -1
- package/dist/wallet.cjs +51 -40
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +4 -4
- package/dist/wallet.d.ts +4 -4
- package/dist/wallet.mjs +51 -40
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +160 -75
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.d.cts +2 -2
- package/dist/widget.d.ts +2 -2
- package/dist/widget.mjs +160 -75
- package/dist/widget.mjs.map +1 -1
- package/package.json +74 -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-Ck7dinYj.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-Ck7dinYj.cjs';
|
|
3
|
+
import { R as RateLimitInfo, T as TrustwareConfigOptions, i as WalletInterFaceAPI, j as TrustwareError, k as Transaction, l as TrustwareEvent } from './manager-BZ8gyHGT.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-BZ8gyHGT.cjs';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import React__default from 'react';
|
|
7
|
-
import { C as ChainDef } from './blockchain-
|
|
8
|
-
export { B as BalanceRow, a as BalanceStreamOptions, b as
|
|
9
|
-
import { T as Token, Y as YourTokenData } from './types-
|
|
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-
|
|
7
|
+
import { C as ChainDef } from './blockchain-DmCPxnxr.cjs';
|
|
8
|
+
export { B as BalanceRow, a as BalanceStreamOptions, b as BalanceStreamSummary, c as ChainMeta, d as ChainType, G as GetBalancesOptions, N as NativeCurrency, T as TokenDef, e as TokenMeta, f as TokenPageInfo, g as TokenPageOptions, h as TokenPageResult, i as TokenType, j as TokenWithBalance, W as WalletAddressBalanceWrapper } from './blockchain-DmCPxnxr.cjs';
|
|
9
|
+
import { T as Token, Y as YourTokenData } from './types-DEUb5IZA.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-B23D0oO9.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-B4YDGtJT.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-B4YDGtJT.js';
|
|
3
|
+
import { R as RateLimitInfo, T as TrustwareConfigOptions, i as WalletInterFaceAPI, j as TrustwareError, k as Transaction, l as TrustwareEvent } from './manager-D8nQsod2.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-D8nQsod2.js';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import React__default from 'react';
|
|
7
|
-
import { C as ChainDef } from './blockchain-
|
|
8
|
-
export { B as BalanceRow, a as BalanceStreamOptions, b as
|
|
9
|
-
import { T as Token, Y as YourTokenData } from './types-
|
|
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-
|
|
7
|
+
import { C as ChainDef } from './blockchain-DmCPxnxr.js';
|
|
8
|
+
export { B as BalanceRow, a as BalanceStreamOptions, b as BalanceStreamSummary, c as ChainMeta, d as ChainType, G as GetBalancesOptions, N as NativeCurrency, T as TokenDef, e as TokenMeta, f as TokenPageInfo, g as TokenPageOptions, h as TokenPageResult, i as TokenType, j as TokenWithBalance, W as WalletAddressBalanceWrapper } from './blockchain-DmCPxnxr.js';
|
|
9
|
+
import { T as Token, Y as YourTokenData } from './types-CMmx0S4U.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-BOjEF7oo.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,21 +25,29 @@ 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
|
+
// On by default: an address scan covers every configured chain and takes
|
|
41
|
+
// seconds end to end, so streaming turns one long wait into a wallet that
|
|
42
|
+
// fills in as results land — first chunk in ~200ms against a ~2.3s buffered
|
|
43
|
+
// response, measured on a live backend.
|
|
44
|
+
//
|
|
45
|
+
// Safe to default because the path degrades on its own: a backend with
|
|
46
|
+
// BALANCE_STREAM_ENABLED off refuses the stream, and the SDK falls back to
|
|
47
|
+
// the buffered endpoint (emitting balance_stream_fallback), as does any
|
|
48
|
+
// runtime whose fetch has no readable body — React Native, most notably.
|
|
49
|
+
// The cost of defaulting ahead of a backend is one refused request per scan.
|
|
50
|
+
balanceStreaming: true,
|
|
43
51
|
shouldAllowGA4: true,
|
|
44
52
|
swapMode: false,
|
|
45
53
|
swapDefaultDestToken: null,
|
|
@@ -173,9 +181,6 @@ function resolveConfig(input) {
|
|
|
173
181
|
const theme = input.theme ?? "system";
|
|
174
182
|
const messages = deepMerge(DEFAULT_MESSAGES, input.messages);
|
|
175
183
|
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
184
|
approachingThreshold: input.retry?.approachingThreshold ?? DEFAULT_RETRY_CONFIG.approachingThreshold,
|
|
180
185
|
onRateLimitInfo: input.retry?.onRateLimitInfo,
|
|
181
186
|
onRateLimited: input.retry?.onRateLimited,
|
|
@@ -487,7 +492,7 @@ var init_constants = __esm({
|
|
|
487
492
|
"src/constants.ts"() {
|
|
488
493
|
"use strict";
|
|
489
494
|
SDK_NAME = "@trustware/sdk";
|
|
490
|
-
SDK_VERSION = "1.1.
|
|
495
|
+
SDK_VERSION = "1.1.12-staging.1";
|
|
491
496
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
492
497
|
GTM_ID = "GTM-TZDGNCXB";
|
|
493
498
|
API_PREFIX = "/api";
|
|
@@ -535,7 +540,7 @@ function isNotFoundError(err) {
|
|
|
535
540
|
return err instanceof Error && err.message.startsWith("HTTP 404");
|
|
536
541
|
}
|
|
537
542
|
async function validateSdkAccess() {
|
|
538
|
-
const r = await fetch(`${apiBase()}/sdk/validate`, {
|
|
543
|
+
const r = await fetch(`${apiBase()}/v1/sdk/validate`, {
|
|
539
544
|
method: "GET",
|
|
540
545
|
headers: jsonHeaders()
|
|
541
546
|
});
|
|
@@ -574,50 +579,54 @@ function notifyRateLimitCallbacks(info, isRateLimited, retryCount) {
|
|
|
574
579
|
retry.onRateLimitApproaching(info, retry.approachingThreshold);
|
|
575
580
|
}
|
|
576
581
|
}
|
|
577
|
-
function
|
|
578
|
-
if (
|
|
579
|
-
|
|
582
|
+
function serverDirectedWaitMs(info) {
|
|
583
|
+
if (!info) return null;
|
|
584
|
+
if (typeof info.retryAfter === "number" && info.retryAfter > 0) {
|
|
585
|
+
return info.retryAfter * 1e3;
|
|
580
586
|
}
|
|
581
|
-
|
|
587
|
+
if (typeof info.reset === "number" && info.reset > 0) {
|
|
588
|
+
const untilReset = info.reset * 1e3 - Date.now();
|
|
589
|
+
if (untilReset > 0) return untilReset;
|
|
590
|
+
}
|
|
591
|
+
return null;
|
|
582
592
|
}
|
|
583
593
|
function sleep(ms) {
|
|
584
594
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
585
595
|
}
|
|
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;
|
|
596
|
+
async function withRateLimitRetry(attempt) {
|
|
597
|
+
let waitedMs = 0;
|
|
593
598
|
let retryCount = 0;
|
|
594
599
|
while (true) {
|
|
595
|
-
const response = await
|
|
600
|
+
const response = await attempt();
|
|
596
601
|
const rateLimitInfo = parseRateLimitHeaders(response);
|
|
597
|
-
if (response.status
|
|
602
|
+
if (response.status !== 429) {
|
|
598
603
|
if (rateLimitInfo) {
|
|
599
|
-
notifyRateLimitCallbacks(rateLimitInfo,
|
|
604
|
+
notifyRateLimitCallbacks(rateLimitInfo, false, 0);
|
|
600
605
|
}
|
|
601
|
-
|
|
602
|
-
throw new RateLimitError(
|
|
603
|
-
rateLimitInfo || { limit: 0, remaining: 0, reset: 0 },
|
|
604
|
-
true
|
|
605
|
-
);
|
|
606
|
-
}
|
|
607
|
-
const delay = calculateBackoffDelay(
|
|
608
|
-
baseDelayMs,
|
|
609
|
-
retryCount,
|
|
610
|
-
rateLimitInfo?.retryAfter
|
|
611
|
-
);
|
|
612
|
-
await sleep(delay);
|
|
613
|
-
retryCount++;
|
|
614
|
-
continue;
|
|
606
|
+
return response;
|
|
615
607
|
}
|
|
616
608
|
if (rateLimitInfo) {
|
|
617
|
-
notifyRateLimitCallbacks(rateLimitInfo,
|
|
609
|
+
notifyRateLimitCallbacks(rateLimitInfo, true, retryCount);
|
|
618
610
|
}
|
|
619
|
-
|
|
611
|
+
const waitMs = serverDirectedWaitMs(rateLimitInfo);
|
|
612
|
+
const info = rateLimitInfo || { limit: 0, remaining: 0, reset: 0 };
|
|
613
|
+
if (waitMs === null) {
|
|
614
|
+
throw new RateLimitError(info, true);
|
|
615
|
+
}
|
|
616
|
+
if (waitedMs + waitMs > RATE_LIMIT_WAIT_BUDGET_MS) {
|
|
617
|
+
throw new RateLimitError(info, false);
|
|
618
|
+
}
|
|
619
|
+
await sleep(waitMs);
|
|
620
|
+
waitedMs += waitMs;
|
|
621
|
+
retryCount++;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
async function rateLimitedFetch(url, options = {}) {
|
|
625
|
+
const { skipRateLimit, ...fetchOptions } = options;
|
|
626
|
+
if (skipRateLimit) {
|
|
627
|
+
return fetch(url, fetchOptions);
|
|
620
628
|
}
|
|
629
|
+
return withRateLimitRetry(() => fetch(url, fetchOptions));
|
|
621
630
|
}
|
|
622
631
|
var RateLimitError;
|
|
623
632
|
var init_http = __esm({
|
|
@@ -625,9 +634,11 @@ var init_http = __esm({
|
|
|
625
634
|
"use strict";
|
|
626
635
|
init_constants();
|
|
627
636
|
init_config2();
|
|
637
|
+
init_config();
|
|
628
638
|
RateLimitError = class extends Error {
|
|
629
639
|
constructor(info, retriesExhausted) {
|
|
630
|
-
const
|
|
640
|
+
const seconds = info.retryAfter ?? (info.reset > 0 ? Math.max(0, Math.ceil((info.reset * 1e3 - Date.now()) / 1e3)) : null);
|
|
641
|
+
const message = seconds === null ? "Rate limit exceeded. The server did not say when to retry." : `Rate limit exceeded. Try again in ${seconds} seconds.`;
|
|
631
642
|
super(message);
|
|
632
643
|
this.name = "RateLimitError";
|
|
633
644
|
this.rateLimitInfo = info;
|
|
@@ -4553,7 +4564,18 @@ async function getStatus(intentId) {
|
|
|
4553
4564
|
);
|
|
4554
4565
|
await assertOK(r);
|
|
4555
4566
|
const j = await r.json();
|
|
4556
|
-
return j.data;
|
|
4567
|
+
return normalizeStatusPayload(j.data);
|
|
4568
|
+
}
|
|
4569
|
+
function normalizeStatusPayload(raw) {
|
|
4570
|
+
if (!raw || typeof raw !== "object") return raw;
|
|
4571
|
+
const wire = raw;
|
|
4572
|
+
const out = { ...wire };
|
|
4573
|
+
for (const [snake, camel] of Object.entries(STATUS_WIRE_TO_CAMEL)) {
|
|
4574
|
+
if (out[camel] !== void 0) continue;
|
|
4575
|
+
if (!(snake in wire)) continue;
|
|
4576
|
+
out[camel] = wire[snake];
|
|
4577
|
+
}
|
|
4578
|
+
return out;
|
|
4557
4579
|
}
|
|
4558
4580
|
async function pollStatus(intentId, { intervalMs = 2e3, timeoutMs = 5 * 6e4 } = {}) {
|
|
4559
4581
|
const t0 = Date.now();
|
|
@@ -4564,12 +4586,39 @@ async function pollStatus(intentId, { intervalMs = 2e3, timeoutMs = 5 * 6e4 } =
|
|
|
4564
4586
|
await new Promise((r) => setTimeout(r, intervalMs));
|
|
4565
4587
|
}
|
|
4566
4588
|
}
|
|
4589
|
+
var STATUS_WIRE_TO_CAMEL;
|
|
4567
4590
|
var init_routes = __esm({
|
|
4568
4591
|
"src/core/routes.ts"() {
|
|
4569
4592
|
"use strict";
|
|
4570
4593
|
init_http();
|
|
4571
4594
|
init_store();
|
|
4572
4595
|
init_address();
|
|
4596
|
+
STATUS_WIRE_TO_CAMEL = {
|
|
4597
|
+
intent_id: "intentId",
|
|
4598
|
+
from_address: "fromAddress",
|
|
4599
|
+
to_address: "toAddress",
|
|
4600
|
+
from_chain_id: "fromChainId",
|
|
4601
|
+
to_chain_id: "toChainId",
|
|
4602
|
+
source_tx_hash: "sourceTxHash",
|
|
4603
|
+
dest_tx_hash: "destTxHash",
|
|
4604
|
+
request_id: "requestId",
|
|
4605
|
+
provider_request_id: "providerRequestId",
|
|
4606
|
+
transaction_request: "transactionRequest",
|
|
4607
|
+
status_raw: "statusRaw",
|
|
4608
|
+
route_path: "routePath",
|
|
4609
|
+
route_status: "routeStatus",
|
|
4610
|
+
to_amount_wei: "toAmountWei",
|
|
4611
|
+
from_chain_block: "fromChainBlock",
|
|
4612
|
+
to_chain_block: "toChainBlock",
|
|
4613
|
+
from_chain_tx_url: "fromChainTxUrl",
|
|
4614
|
+
to_chain_tx_url: "toChainTxUrl",
|
|
4615
|
+
gas_status: "gasStatus",
|
|
4616
|
+
is_gmp_transaction: "isGMPTransaction",
|
|
4617
|
+
axelar_transaction_url: "axelarTransactionUrl",
|
|
4618
|
+
create_date: "createdDate",
|
|
4619
|
+
update_date: "updatedDate",
|
|
4620
|
+
time_spent_ms: "timeSpentMs"
|
|
4621
|
+
};
|
|
4573
4622
|
}
|
|
4574
4623
|
});
|
|
4575
4624
|
|
|
@@ -5046,6 +5095,16 @@ function mergeBalanceWrappers(current, incoming) {
|
|
|
5046
5095
|
}
|
|
5047
5096
|
return Array.from(merged.values());
|
|
5048
5097
|
}
|
|
5098
|
+
function toSummary(frame, address) {
|
|
5099
|
+
const total = toNumberOrUndefined(frame.total) ?? 0;
|
|
5100
|
+
return {
|
|
5101
|
+
address: toStringOrUndefined(frame.address) ?? address,
|
|
5102
|
+
partial: Boolean(frame.partial),
|
|
5103
|
+
completed: toNumberOrUndefined(frame.completed) ?? 0,
|
|
5104
|
+
total,
|
|
5105
|
+
elapsedMs: toNumberOrUndefined(frame.elapsed)
|
|
5106
|
+
};
|
|
5107
|
+
}
|
|
5049
5108
|
async function parseStreamingBalances(response, address, options = {}) {
|
|
5050
5109
|
if (!response.body) {
|
|
5051
5110
|
throw new Error("balances stream: empty response body");
|
|
@@ -5066,7 +5125,12 @@ async function parseStreamingBalances(response, address, options = {}) {
|
|
|
5066
5125
|
if (!trimmed) continue;
|
|
5067
5126
|
try {
|
|
5068
5127
|
const parsed = JSON.parse(trimmed);
|
|
5069
|
-
if (!parsed.chain_id)
|
|
5128
|
+
if (!parsed.chain_id) {
|
|
5129
|
+
if (parsed.type === "summary") {
|
|
5130
|
+
options.onSummary?.(toSummary(parsed, address));
|
|
5131
|
+
}
|
|
5132
|
+
continue;
|
|
5133
|
+
}
|
|
5070
5134
|
const chunk = normalizeStreamChunk(parsed);
|
|
5071
5135
|
emitBalanceStreamChunk(address, chunk.length);
|
|
5072
5136
|
yield chunk;
|
|
@@ -5085,6 +5149,8 @@ async function parseStreamingBalances(response, address, options = {}) {
|
|
|
5085
5149
|
const chunk = normalizeStreamChunk(parsed);
|
|
5086
5150
|
emitBalanceStreamChunk(address, chunk.length);
|
|
5087
5151
|
yield chunk;
|
|
5152
|
+
} else if (parsed.type === "summary") {
|
|
5153
|
+
options.onSummary?.(toSummary(parsed, address));
|
|
5088
5154
|
}
|
|
5089
5155
|
} catch (error) {
|
|
5090
5156
|
if (options.strict) {
|
|
@@ -5118,7 +5184,7 @@ async function getBalances(chainRef, address, opts) {
|
|
|
5118
5184
|
if (cached) return cached;
|
|
5119
5185
|
}
|
|
5120
5186
|
const url = `${apiBase()}/v1/data/wallets/${encodeURIComponent(chainKey)}/${trimmedAddress}/balances`;
|
|
5121
|
-
const response = await
|
|
5187
|
+
const response = await rateLimitedFetch(url, {
|
|
5122
5188
|
method: "GET",
|
|
5123
5189
|
credentials: "omit",
|
|
5124
5190
|
headers: jsonHeaders()
|
|
@@ -5139,7 +5205,7 @@ async function getBalancesByAddress(address, opts) {
|
|
|
5139
5205
|
}
|
|
5140
5206
|
return merged;
|
|
5141
5207
|
}
|
|
5142
|
-
const url = `${apiBase()}/data/balances/${address}`;
|
|
5208
|
+
const url = `${apiBase()}/v1/data/balances/${address}`;
|
|
5143
5209
|
const r = await rateLimitedFetch(url, {
|
|
5144
5210
|
method: "GET",
|
|
5145
5211
|
credentials: "omit",
|
|
@@ -5147,14 +5213,27 @@ async function getBalancesByAddress(address, opts) {
|
|
|
5147
5213
|
});
|
|
5148
5214
|
if (!r.ok) throw new Error(`balances: HTTP ${r.status}`);
|
|
5149
5215
|
const j = await r.json();
|
|
5150
|
-
|
|
5216
|
+
const results = Array.isArray(j) ? j : j.results ?? [];
|
|
5217
|
+
if (opts?.onSummary) {
|
|
5218
|
+
const completed = results.length;
|
|
5219
|
+
opts.onSummary({
|
|
5220
|
+
address,
|
|
5221
|
+
partial: Array.isArray(j) ? false : Boolean(j.partial),
|
|
5222
|
+
completed,
|
|
5223
|
+
total: completed
|
|
5224
|
+
});
|
|
5225
|
+
}
|
|
5226
|
+
return results;
|
|
5227
|
+
}
|
|
5228
|
+
function bufferedOptions(opts) {
|
|
5229
|
+
return { ...opts, stream: false };
|
|
5151
5230
|
}
|
|
5152
5231
|
async function* getBalancesByAddressStream(address, opts = {}) {
|
|
5153
5232
|
if (!TrustwareConfigStore.get().features.balanceStreaming) {
|
|
5154
|
-
yield await getBalancesByAddress(address);
|
|
5233
|
+
yield await getBalancesByAddress(address, bufferedOptions(opts));
|
|
5155
5234
|
return;
|
|
5156
5235
|
}
|
|
5157
|
-
const url = `${apiBase()}/data/balances/${address}?stream=1`;
|
|
5236
|
+
const url = `${apiBase()}/v1/data/balances/${address}?stream=1`;
|
|
5158
5237
|
try {
|
|
5159
5238
|
const response = await rateLimitedFetch(url, {
|
|
5160
5239
|
method: "GET",
|
|
@@ -5170,7 +5249,14 @@ async function* getBalancesByAddressStream(address, opts = {}) {
|
|
|
5170
5249
|
const contentType = response.headers.get("content-type") ?? "";
|
|
5171
5250
|
if (contentType.includes("application/json")) {
|
|
5172
5251
|
const payload = await response.json();
|
|
5173
|
-
|
|
5252
|
+
const results = Array.isArray(payload) ? payload : payload.results ?? [];
|
|
5253
|
+
opts.onSummary?.({
|
|
5254
|
+
address,
|
|
5255
|
+
partial: Array.isArray(payload) ? false : Boolean(payload.partial),
|
|
5256
|
+
completed: results.length,
|
|
5257
|
+
total: results.length
|
|
5258
|
+
});
|
|
5259
|
+
yield results;
|
|
5174
5260
|
return;
|
|
5175
5261
|
}
|
|
5176
5262
|
const stream = await parseStreamingBalances(response, address, opts);
|
|
@@ -5179,7 +5265,7 @@ async function* getBalancesByAddressStream(address, opts = {}) {
|
|
|
5179
5265
|
}
|
|
5180
5266
|
} catch (error) {
|
|
5181
5267
|
emitBalanceStreamFallback(address, error);
|
|
5182
|
-
yield await getBalancesByAddress(address);
|
|
5268
|
+
yield await getBalancesByAddress(address, bufferedOptions(opts));
|
|
5183
5269
|
}
|
|
5184
5270
|
}
|
|
5185
5271
|
async function ensureRegistry() {
|
|
@@ -7621,6 +7707,7 @@ var init_core = __esm({
|
|
|
7621
7707
|
init_store();
|
|
7622
7708
|
init_wallets();
|
|
7623
7709
|
init_routes();
|
|
7710
|
+
init_routes();
|
|
7624
7711
|
init_balances();
|
|
7625
7712
|
init_tx();
|
|
7626
7713
|
init_http();
|
|
@@ -8229,21 +8316,10 @@ function useTrustwareConfig() {
|
|
|
8229
8316
|
title: "Trustware SDK",
|
|
8230
8317
|
description: "Seamlessly bridge assets across chains with Trustware."
|
|
8231
8318
|
},
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
|
|
8236
|
-
approachingThreshold: 5
|
|
8237
|
-
},
|
|
8238
|
-
features: {
|
|
8239
|
-
tokensPagination: true,
|
|
8240
|
-
balanceStreaming: false,
|
|
8241
|
-
shouldAllowGA4: true,
|
|
8242
|
-
swapMode: false,
|
|
8243
|
-
swapDefaultDestToken: null,
|
|
8244
|
-
swapLockDestToken: false,
|
|
8245
|
-
swapAllowedDestTokens: null
|
|
8246
|
-
}
|
|
8319
|
+
// Shared with the resolver rather than restated, so this placeholder
|
|
8320
|
+
// can't drift from the real defaults.
|
|
8321
|
+
retry: { ...DEFAULT_RETRY_CONFIG },
|
|
8322
|
+
features: { ...DEFAULT_FEATURE_FLAGS }
|
|
8247
8323
|
};
|
|
8248
8324
|
}
|
|
8249
8325
|
});
|
|
@@ -8259,6 +8335,7 @@ var init_useTrustwareConfig = __esm({
|
|
|
8259
8335
|
"src/hooks/useTrustwareConfig.ts"() {
|
|
8260
8336
|
"use strict";
|
|
8261
8337
|
"use client";
|
|
8338
|
+
init_config();
|
|
8262
8339
|
init_store();
|
|
8263
8340
|
}
|
|
8264
8341
|
});
|
|
@@ -20524,7 +20601,7 @@ var VERSION;
|
|
|
20524
20601
|
var init_version = __esm({
|
|
20525
20602
|
"node_modules/@aa-sdk/core/dist/esm/version.js"() {
|
|
20526
20603
|
"use strict";
|
|
20527
|
-
VERSION = "4.88.
|
|
20604
|
+
VERSION = "4.88.5";
|
|
20528
20605
|
}
|
|
20529
20606
|
});
|
|
20530
20607
|
|
|
@@ -29033,7 +29110,7 @@ var VERSION2;
|
|
|
29033
29110
|
var init_version2 = __esm({
|
|
29034
29111
|
"node_modules/@account-kit/infra/dist/esm/version.js"() {
|
|
29035
29112
|
"use strict";
|
|
29036
|
-
VERSION2 = "4.88.
|
|
29113
|
+
VERSION2 = "4.88.5";
|
|
29037
29114
|
}
|
|
29038
29115
|
});
|
|
29039
29116
|
|
|
@@ -30769,7 +30846,7 @@ import {
|
|
|
30769
30846
|
keccak256 as keccak2566,
|
|
30770
30847
|
stringToHex
|
|
30771
30848
|
} from "viem";
|
|
30772
|
-
async function
|
|
30849
|
+
async function fetchOnceWithTimeout(url, init) {
|
|
30773
30850
|
const controller = new AbortController();
|
|
30774
30851
|
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
30775
30852
|
try {
|
|
@@ -30790,6 +30867,9 @@ async function fetchWithTimeout(url, init) {
|
|
|
30790
30867
|
clearTimeout(timer);
|
|
30791
30868
|
}
|
|
30792
30869
|
}
|
|
30870
|
+
async function fetchWithTimeout(url, init) {
|
|
30871
|
+
return withRateLimitRetry(() => fetchOnceWithTimeout(url, init));
|
|
30872
|
+
}
|
|
30793
30873
|
function extractRevertHex(err) {
|
|
30794
30874
|
if (typeof err.data === "string" && err.data.startsWith("0x"))
|
|
30795
30875
|
return err.data;
|
|
@@ -31289,7 +31369,7 @@ async function estimateRelayFeeInToken(valueWei, fromAmountWei, fromAmountUSD, c
|
|
|
31289
31369
|
tokenUnitsPerDollar = Number(fromAmountWei) / fromUSD;
|
|
31290
31370
|
} else if (fromToken && fromDecimals !== void 0) {
|
|
31291
31371
|
try {
|
|
31292
|
-
const resp = await
|
|
31372
|
+
const resp = await rateLimitedFetch(
|
|
31293
31373
|
`${apiBase()}/v1/price/token?chainId=${cid}&address=${fromToken}`,
|
|
31294
31374
|
{ headers: jsonHeaders() }
|
|
31295
31375
|
);
|
|
@@ -31305,9 +31385,10 @@ async function estimateRelayFeeInToken(valueWei, fromAmountWei, fromAmountUSD, c
|
|
|
31305
31385
|
return 0n;
|
|
31306
31386
|
}
|
|
31307
31387
|
try {
|
|
31308
|
-
const resp = await
|
|
31309
|
-
|
|
31310
|
-
|
|
31388
|
+
const resp = await rateLimitedFetch(
|
|
31389
|
+
`${apiBase()}/v1/price/native?chainId=${cid}`,
|
|
31390
|
+
{ headers: jsonHeaders() }
|
|
31391
|
+
);
|
|
31311
31392
|
if (!resp.ok) throw new Error(`native price HTTP ${resp.status}`);
|
|
31312
31393
|
const json = await resp.json();
|
|
31313
31394
|
const ethPriceUSD = parseFloat(json.data?.priceUSD ?? "0");
|
|
@@ -34047,9 +34128,14 @@ var init_useSwapExecution = __esm({
|
|
|
34047
34128
|
|
|
34048
34129
|
// src/core/forex.ts
|
|
34049
34130
|
async function fetchForexRates(base2 = "USD") {
|
|
34050
|
-
|
|
34051
|
-
|
|
34052
|
-
|
|
34131
|
+
let r;
|
|
34132
|
+
try {
|
|
34133
|
+
r = await rateLimitedFetch(`${apiBase()}/v1/forex?base=${base2}`, {
|
|
34134
|
+
headers: jsonHeaders()
|
|
34135
|
+
});
|
|
34136
|
+
} catch {
|
|
34137
|
+
return {};
|
|
34138
|
+
}
|
|
34053
34139
|
if (!r.ok) return {};
|
|
34054
34140
|
const j = await r.json();
|
|
34055
34141
|
const rates = j?.data?.rates ?? j?.rates ?? j?.data ?? {};
|
|
@@ -40213,6 +40299,7 @@ var init_index = __esm({
|
|
|
40213
40299
|
"src/index.ts"() {
|
|
40214
40300
|
init_core2();
|
|
40215
40301
|
init_http();
|
|
40302
|
+
init_core2();
|
|
40216
40303
|
init_useWalletTokenState();
|
|
40217
40304
|
init_wallets();
|
|
40218
40305
|
init_widget();
|
|
@@ -40237,6 +40324,7 @@ export {
|
|
|
40237
40324
|
GTM_ID,
|
|
40238
40325
|
IdentityStore,
|
|
40239
40326
|
POPULAR_ORDER,
|
|
40327
|
+
RATE_LIMIT_WAIT_BUDGET_MS,
|
|
40240
40328
|
RateLimitError,
|
|
40241
40329
|
SDK_NAME,
|
|
40242
40330
|
SDK_VERSION,
|
|
@@ -40246,6 +40334,7 @@ export {
|
|
|
40246
40334
|
TrustwareWidgetV2 as TrustwareWidget,
|
|
40247
40335
|
WALLETCONNECT_PROJECT_ID,
|
|
40248
40336
|
WALLETS,
|
|
40337
|
+
assertValidPostHook,
|
|
40249
40338
|
buildWalletIdentityAddress,
|
|
40250
40339
|
connectDetectedWallet,
|
|
40251
40340
|
createWalletIdentity,
|