@trustware/sdk-staging 1.1.11-staging.2 → 1.1.12-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/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-B1WCJfDI.d.ts → core-B4YDGtJT.d.ts} +3 -3
- package/dist/{core-CeNTuqPz.d.cts → core-Ck7dinYj.d.cts} +3 -3
- package/dist/core.cjs +57 -10
- 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 +57 -10
- package/dist/core.mjs.map +1 -1
- package/dist/index.cjs +124 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.mjs +124 -29
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-DNGk1YkR.d.cts → manager-BZ8gyHGT.d.cts} +1 -1
- package/dist/{manager-Bw8b1wSD.d.ts → manager-D8nQsod2.d.ts} +1 -1
- package/dist/{metadata-Dk4R8_-T.d.cts → metadata-B23D0oO9.d.cts} +1 -1
- package/dist/{metadata-C__KMeuz.d.ts → metadata-BOjEF7oo.d.ts} +1 -1
- package/dist/smart-account.cjs +26 -5
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.d.cts +1 -0
- package/dist/smart-account.d.ts +1 -0
- package/dist/smart-account.mjs +26 -5
- 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 +12 -2
- 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 +12 -2
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +124 -29
- 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 +124 -29
- package/dist/widget.mjs.map +1 -1
- package/package.json +2 -1
package/dist/widget.cjs
CHANGED
|
@@ -567,7 +567,17 @@ var init_config = __esm({
|
|
|
567
567
|
RATE_LIMIT_WAIT_BUDGET_MS = 1e4;
|
|
568
568
|
DEFAULT_FEATURE_FLAGS = {
|
|
569
569
|
tokensPagination: true,
|
|
570
|
-
|
|
570
|
+
// On by default: an address scan covers every configured chain and takes
|
|
571
|
+
// seconds end to end, so streaming turns one long wait into a wallet that
|
|
572
|
+
// fills in as results land — first chunk in ~200ms against a ~2.3s buffered
|
|
573
|
+
// response, measured on a live backend.
|
|
574
|
+
//
|
|
575
|
+
// Safe to default because the path degrades on its own: a backend with
|
|
576
|
+
// BALANCE_STREAM_ENABLED off refuses the stream, and the SDK falls back to
|
|
577
|
+
// the buffered endpoint (emitting balance_stream_fallback), as does any
|
|
578
|
+
// runtime whose fetch has no readable body — React Native, most notably.
|
|
579
|
+
// The cost of defaulting ahead of a backend is one refused request per scan.
|
|
580
|
+
balanceStreaming: true,
|
|
571
581
|
shouldAllowGA4: true,
|
|
572
582
|
swapMode: false,
|
|
573
583
|
swapDefaultDestToken: null,
|
|
@@ -583,7 +593,7 @@ var init_constants = __esm({
|
|
|
583
593
|
"src/constants.ts"() {
|
|
584
594
|
"use strict";
|
|
585
595
|
SDK_NAME = "@trustware/sdk";
|
|
586
|
-
SDK_VERSION = "1.1.
|
|
596
|
+
SDK_VERSION = "1.1.12-staging.2";
|
|
587
597
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
588
598
|
GTM_ID = "GTM-TZDGNCXB";
|
|
589
599
|
API_PREFIX = "/api";
|
|
@@ -631,7 +641,7 @@ function isNotFoundError(err) {
|
|
|
631
641
|
return err instanceof Error && err.message.startsWith("HTTP 404");
|
|
632
642
|
}
|
|
633
643
|
async function validateSdkAccess() {
|
|
634
|
-
const r = await fetch(`${apiBase()}/sdk/validate`, {
|
|
644
|
+
const r = await fetch(`${apiBase()}/v1/sdk/validate`, {
|
|
635
645
|
method: "GET",
|
|
636
646
|
headers: jsonHeaders()
|
|
637
647
|
});
|
|
@@ -2314,6 +2324,16 @@ function mergeBalanceWrappers(current, incoming) {
|
|
|
2314
2324
|
}
|
|
2315
2325
|
return Array.from(merged.values());
|
|
2316
2326
|
}
|
|
2327
|
+
function toSummary(frame, address) {
|
|
2328
|
+
const total = toNumberOrUndefined(frame.total) ?? 0;
|
|
2329
|
+
return {
|
|
2330
|
+
address: toStringOrUndefined(frame.address) ?? address,
|
|
2331
|
+
partial: Boolean(frame.partial),
|
|
2332
|
+
completed: toNumberOrUndefined(frame.completed) ?? 0,
|
|
2333
|
+
total,
|
|
2334
|
+
elapsedMs: toNumberOrUndefined(frame.elapsed)
|
|
2335
|
+
};
|
|
2336
|
+
}
|
|
2317
2337
|
async function parseStreamingBalances(response, address, options = {}) {
|
|
2318
2338
|
if (!response.body) {
|
|
2319
2339
|
throw new Error("balances stream: empty response body");
|
|
@@ -2334,7 +2354,12 @@ async function parseStreamingBalances(response, address, options = {}) {
|
|
|
2334
2354
|
if (!trimmed) continue;
|
|
2335
2355
|
try {
|
|
2336
2356
|
const parsed = JSON.parse(trimmed);
|
|
2337
|
-
if (!parsed.chain_id)
|
|
2357
|
+
if (!parsed.chain_id) {
|
|
2358
|
+
if (parsed.type === "summary") {
|
|
2359
|
+
options.onSummary?.(toSummary(parsed, address));
|
|
2360
|
+
}
|
|
2361
|
+
continue;
|
|
2362
|
+
}
|
|
2338
2363
|
const chunk = normalizeStreamChunk(parsed);
|
|
2339
2364
|
emitBalanceStreamChunk(address, chunk.length);
|
|
2340
2365
|
yield chunk;
|
|
@@ -2353,6 +2378,8 @@ async function parseStreamingBalances(response, address, options = {}) {
|
|
|
2353
2378
|
const chunk = normalizeStreamChunk(parsed);
|
|
2354
2379
|
emitBalanceStreamChunk(address, chunk.length);
|
|
2355
2380
|
yield chunk;
|
|
2381
|
+
} else if (parsed.type === "summary") {
|
|
2382
|
+
options.onSummary?.(toSummary(parsed, address));
|
|
2356
2383
|
}
|
|
2357
2384
|
} catch (error) {
|
|
2358
2385
|
if (options.strict) {
|
|
@@ -2407,7 +2434,7 @@ async function getBalancesByAddress(address, opts) {
|
|
|
2407
2434
|
}
|
|
2408
2435
|
return merged;
|
|
2409
2436
|
}
|
|
2410
|
-
const url = `${apiBase()}/data/balances/${address}`;
|
|
2437
|
+
const url = `${apiBase()}/v1/data/balances/${address}`;
|
|
2411
2438
|
const r = await rateLimitedFetch(url, {
|
|
2412
2439
|
method: "GET",
|
|
2413
2440
|
credentials: "omit",
|
|
@@ -2415,14 +2442,27 @@ async function getBalancesByAddress(address, opts) {
|
|
|
2415
2442
|
});
|
|
2416
2443
|
if (!r.ok) throw new Error(`balances: HTTP ${r.status}`);
|
|
2417
2444
|
const j = await r.json();
|
|
2418
|
-
|
|
2445
|
+
const results = Array.isArray(j) ? j : j.results ?? [];
|
|
2446
|
+
if (opts?.onSummary) {
|
|
2447
|
+
const completed = results.length;
|
|
2448
|
+
opts.onSummary({
|
|
2449
|
+
address,
|
|
2450
|
+
partial: Array.isArray(j) ? false : Boolean(j.partial),
|
|
2451
|
+
completed,
|
|
2452
|
+
total: completed
|
|
2453
|
+
});
|
|
2454
|
+
}
|
|
2455
|
+
return results;
|
|
2456
|
+
}
|
|
2457
|
+
function bufferedOptions(opts) {
|
|
2458
|
+
return { ...opts, stream: false };
|
|
2419
2459
|
}
|
|
2420
2460
|
async function* getBalancesByAddressStream(address, opts = {}) {
|
|
2421
2461
|
if (!TrustwareConfigStore.get().features.balanceStreaming) {
|
|
2422
|
-
yield await getBalancesByAddress(address);
|
|
2462
|
+
yield await getBalancesByAddress(address, bufferedOptions(opts));
|
|
2423
2463
|
return;
|
|
2424
2464
|
}
|
|
2425
|
-
const url = `${apiBase()}/data/balances/${address}?stream=1`;
|
|
2465
|
+
const url = `${apiBase()}/v1/data/balances/${address}?stream=1`;
|
|
2426
2466
|
try {
|
|
2427
2467
|
const response = await rateLimitedFetch(url, {
|
|
2428
2468
|
method: "GET",
|
|
@@ -2438,7 +2478,14 @@ async function* getBalancesByAddressStream(address, opts = {}) {
|
|
|
2438
2478
|
const contentType = response.headers.get("content-type") ?? "";
|
|
2439
2479
|
if (contentType.includes("application/json")) {
|
|
2440
2480
|
const payload = await response.json();
|
|
2441
|
-
|
|
2481
|
+
const results = Array.isArray(payload) ? payload : payload.results ?? [];
|
|
2482
|
+
opts.onSummary?.({
|
|
2483
|
+
address,
|
|
2484
|
+
partial: Array.isArray(payload) ? false : Boolean(payload.partial),
|
|
2485
|
+
completed: results.length,
|
|
2486
|
+
total: results.length
|
|
2487
|
+
});
|
|
2488
|
+
yield results;
|
|
2442
2489
|
return;
|
|
2443
2490
|
}
|
|
2444
2491
|
const stream = await parseStreamingBalances(response, address, opts);
|
|
@@ -2447,7 +2494,7 @@ async function* getBalancesByAddressStream(address, opts = {}) {
|
|
|
2447
2494
|
}
|
|
2448
2495
|
} catch (error) {
|
|
2449
2496
|
emitBalanceStreamFallback(address, error);
|
|
2450
|
-
yield await getBalancesByAddress(address);
|
|
2497
|
+
yield await getBalancesByAddress(address, bufferedOptions(opts));
|
|
2451
2498
|
}
|
|
2452
2499
|
}
|
|
2453
2500
|
async function ensureRegistry() {
|
|
@@ -2978,15 +3025,7 @@ function useTrustwareConfig() {
|
|
|
2978
3025
|
// Shared with the resolver rather than restated, so this placeholder
|
|
2979
3026
|
// can't drift from the real defaults.
|
|
2980
3027
|
retry: { ...DEFAULT_RETRY_CONFIG },
|
|
2981
|
-
features: {
|
|
2982
|
-
tokensPagination: true,
|
|
2983
|
-
balanceStreaming: false,
|
|
2984
|
-
shouldAllowGA4: true,
|
|
2985
|
-
swapMode: false,
|
|
2986
|
-
swapDefaultDestToken: null,
|
|
2987
|
-
swapLockDestToken: false,
|
|
2988
|
-
swapAllowedDestTokens: null
|
|
2989
|
-
}
|
|
3028
|
+
features: { ...DEFAULT_FEATURE_FLAGS }
|
|
2990
3029
|
};
|
|
2991
3030
|
}
|
|
2992
3031
|
});
|
|
@@ -20454,7 +20493,7 @@ var VERSION;
|
|
|
20454
20493
|
var init_version = __esm({
|
|
20455
20494
|
"node_modules/@aa-sdk/core/dist/esm/version.js"() {
|
|
20456
20495
|
"use strict";
|
|
20457
|
-
VERSION = "4.88.
|
|
20496
|
+
VERSION = "4.88.5";
|
|
20458
20497
|
}
|
|
20459
20498
|
});
|
|
20460
20499
|
|
|
@@ -28973,7 +29012,7 @@ var VERSION2;
|
|
|
28973
29012
|
var init_version2 = __esm({
|
|
28974
29013
|
"node_modules/@account-kit/infra/dist/esm/version.js"() {
|
|
28975
29014
|
"use strict";
|
|
28976
|
-
VERSION2 = "4.88.
|
|
29015
|
+
VERSION2 = "4.88.5";
|
|
28977
29016
|
}
|
|
28978
29017
|
});
|
|
28979
29018
|
|
|
@@ -31680,7 +31719,18 @@ async function sendRouteAsUserOperation(params) {
|
|
|
31680
31719
|
);
|
|
31681
31720
|
}
|
|
31682
31721
|
console.debug("[send] UserOp included", { userOpHash, txHash });
|
|
31683
|
-
|
|
31722
|
+
try {
|
|
31723
|
+
void submitReceipt(
|
|
31724
|
+
intentId,
|
|
31725
|
+
txHash,
|
|
31726
|
+
getSponsorshipRequestId(),
|
|
31727
|
+
eoaAddress
|
|
31728
|
+
).catch((err) => {
|
|
31729
|
+
console.debug("[send] receipt submission failed (non-fatal)", err);
|
|
31730
|
+
});
|
|
31731
|
+
} catch (err) {
|
|
31732
|
+
console.debug("[send] receipt submission failed (non-fatal)", err);
|
|
31733
|
+
}
|
|
31684
31734
|
return { userOpHash, txHash, intentId };
|
|
31685
31735
|
}
|
|
31686
31736
|
var NATIVE_ADDRS;
|
|
@@ -33904,10 +33954,6 @@ function useSwapExecution(fromChain) {
|
|
|
33904
33954
|
numericChainId,
|
|
33905
33955
|
{ approvalsEnsured: ownsApprovals }
|
|
33906
33956
|
);
|
|
33907
|
-
try {
|
|
33908
|
-
await submitReceipt(routeResult.intentId, hash);
|
|
33909
|
-
} catch {
|
|
33910
|
-
}
|
|
33911
33957
|
setState((p) => ({
|
|
33912
33958
|
...p,
|
|
33913
33959
|
isSubmitting: false,
|
|
@@ -33916,6 +33962,8 @@ function useSwapExecution(fromChain) {
|
|
|
33916
33962
|
txStatus: "processing"
|
|
33917
33963
|
}));
|
|
33918
33964
|
startPolling(routeResult.intentId, onSuccess, onError);
|
|
33965
|
+
void submitReceipt(routeResult.intentId, hash).catch(() => {
|
|
33966
|
+
});
|
|
33919
33967
|
} catch (err) {
|
|
33920
33968
|
const msg = mapTxError(err);
|
|
33921
33969
|
setState((p) => ({
|
|
@@ -36351,6 +36399,7 @@ function SwapMode({
|
|
|
36351
36399
|
}, [route.loading]);
|
|
36352
36400
|
(0, import_react50.useEffect)(() => {
|
|
36353
36401
|
if (!route.data) return;
|
|
36402
|
+
if (stage !== "home" && stage !== "review") return;
|
|
36354
36403
|
const id = setInterval(() => {
|
|
36355
36404
|
const ts = quoteTimestampRef.current;
|
|
36356
36405
|
if (ts === null) return;
|
|
@@ -36362,7 +36411,11 @@ function SwapMode({
|
|
|
36362
36411
|
}
|
|
36363
36412
|
}, 1e3);
|
|
36364
36413
|
return () => clearInterval(id);
|
|
36365
|
-
}, [route.data]);
|
|
36414
|
+
}, [route.data, stage]);
|
|
36415
|
+
const handleRetryQuote = (0, import_react50.useCallback)(() => {
|
|
36416
|
+
if (!latestFetchParamsRef.current) return;
|
|
36417
|
+
void fetchRef.current(latestFetchParamsRef.current);
|
|
36418
|
+
}, []);
|
|
36366
36419
|
(0, import_react50.useEffect)(() => {
|
|
36367
36420
|
if (stage !== "review") return;
|
|
36368
36421
|
if (!route.data || !walletAddress) return;
|
|
@@ -37891,6 +37944,10 @@ function SwapMode({
|
|
|
37891
37944
|
txStatus: execution.txStatus,
|
|
37892
37945
|
isSubmitting: execution.isSubmitting,
|
|
37893
37946
|
isGasSponsored,
|
|
37947
|
+
hasQuote: !!route.data,
|
|
37948
|
+
isQuoteRefreshing: route.loading,
|
|
37949
|
+
quoteError: route.error,
|
|
37950
|
+
onRetryQuote: handleRetryQuote,
|
|
37894
37951
|
onExecute: () => void handleExecute()
|
|
37895
37952
|
}
|
|
37896
37953
|
)
|
|
@@ -39227,10 +39284,15 @@ function SwapActionArea({
|
|
|
39227
39284
|
txStatus,
|
|
39228
39285
|
isSubmitting,
|
|
39229
39286
|
isGasSponsored,
|
|
39287
|
+
hasQuote,
|
|
39288
|
+
isQuoteRefreshing,
|
|
39289
|
+
quoteError,
|
|
39290
|
+
onRetryQuote,
|
|
39230
39291
|
onExecute
|
|
39231
39292
|
}) {
|
|
39232
39293
|
const needsApproval = allowanceStatus === "needed" && !isGasSponsored;
|
|
39233
39294
|
const isChecking = allowanceStatus === "checking";
|
|
39295
|
+
const quoteUnavailable = !hasQuote && !isQuoteRefreshing && !isSubmitting && txStatus === "idle";
|
|
39234
39296
|
let label;
|
|
39235
39297
|
if (isChecking) {
|
|
39236
39298
|
label = "Checking approval...";
|
|
@@ -39238,12 +39300,14 @@ function SwapActionArea({
|
|
|
39238
39300
|
label = `Approving ${fromTokenSymbol}...`;
|
|
39239
39301
|
} else if (isSubmitting) {
|
|
39240
39302
|
label = "Confirm in wallet...";
|
|
39303
|
+
} else if (isQuoteRefreshing) {
|
|
39304
|
+
label = "Refreshing quote...";
|
|
39241
39305
|
} else if (needsApproval) {
|
|
39242
39306
|
label = `Approve ${fromTokenSymbol}`;
|
|
39243
39307
|
} else {
|
|
39244
39308
|
label = "Swap";
|
|
39245
39309
|
}
|
|
39246
|
-
const isDisabled = isSubmitting || isChecking;
|
|
39310
|
+
const isDisabled = isSubmitting || isChecking || isQuoteRefreshing || !hasQuote;
|
|
39247
39311
|
return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { style: { marginTop: spacing[6] }, children: [
|
|
39248
39312
|
isGasSponsored && !isSubmitting && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
|
|
39249
39313
|
"div",
|
|
@@ -39283,7 +39347,38 @@ function SwapActionArea({
|
|
|
39283
39347
|
]
|
|
39284
39348
|
}
|
|
39285
39349
|
),
|
|
39286
|
-
/* @__PURE__ */ (0, import_jsx_runtime59.
|
|
39350
|
+
quoteUnavailable ? /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
|
|
39351
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
39352
|
+
"p",
|
|
39353
|
+
{
|
|
39354
|
+
style: {
|
|
39355
|
+
fontSize: fontSize.xs,
|
|
39356
|
+
color: colors.destructive,
|
|
39357
|
+
textAlign: "center",
|
|
39358
|
+
marginBottom: spacing[3]
|
|
39359
|
+
},
|
|
39360
|
+
children: quoteError ?? "This quote expired."
|
|
39361
|
+
}
|
|
39362
|
+
),
|
|
39363
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
39364
|
+
"button",
|
|
39365
|
+
{
|
|
39366
|
+
onClick: onRetryQuote,
|
|
39367
|
+
style: {
|
|
39368
|
+
width: "100%",
|
|
39369
|
+
height: "3.5rem",
|
|
39370
|
+
borderRadius: "1.5rem",
|
|
39371
|
+
backgroundColor: colors.primary,
|
|
39372
|
+
color: colors.primaryForeground,
|
|
39373
|
+
fontSize: fontSize.base,
|
|
39374
|
+
fontWeight: fontWeight.semibold,
|
|
39375
|
+
border: 0,
|
|
39376
|
+
cursor: "pointer"
|
|
39377
|
+
},
|
|
39378
|
+
children: "Get a new quote"
|
|
39379
|
+
}
|
|
39380
|
+
)
|
|
39381
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
39287
39382
|
"button",
|
|
39288
39383
|
{
|
|
39289
39384
|
onClick: onExecute,
|