@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.
Files changed (43) hide show
  1. package/dist/{blockchain-BxAFzp0s.d.cts → blockchain-DmCPxnxr.d.cts} +25 -1
  2. package/dist/{blockchain-BxAFzp0s.d.ts → blockchain-DmCPxnxr.d.ts} +25 -1
  3. package/dist/constants.cjs +1 -1
  4. package/dist/constants.mjs +1 -1
  5. package/dist/{core-B1WCJfDI.d.ts → core-B4YDGtJT.d.ts} +3 -3
  6. package/dist/{core-CeNTuqPz.d.cts → core-Ck7dinYj.d.cts} +3 -3
  7. package/dist/core.cjs +57 -10
  8. package/dist/core.cjs.map +1 -1
  9. package/dist/core.d.cts +4 -4
  10. package/dist/core.d.ts +4 -4
  11. package/dist/core.mjs +57 -10
  12. package/dist/core.mjs.map +1 -1
  13. package/dist/index.cjs +124 -29
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +8 -8
  16. package/dist/index.d.ts +8 -8
  17. package/dist/index.mjs +124 -29
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/{manager-DNGk1YkR.d.cts → manager-BZ8gyHGT.d.cts} +1 -1
  20. package/dist/{manager-Bw8b1wSD.d.ts → manager-D8nQsod2.d.ts} +1 -1
  21. package/dist/{metadata-Dk4R8_-T.d.cts → metadata-B23D0oO9.d.cts} +1 -1
  22. package/dist/{metadata-C__KMeuz.d.ts → metadata-BOjEF7oo.d.ts} +1 -1
  23. package/dist/smart-account.cjs +26 -5
  24. package/dist/smart-account.cjs.map +1 -1
  25. package/dist/smart-account.d.cts +1 -0
  26. package/dist/smart-account.d.ts +1 -0
  27. package/dist/smart-account.mjs +26 -5
  28. package/dist/smart-account.mjs.map +1 -1
  29. package/dist/{types-BJY9r-mz.d.ts → types-CMmx0S4U.d.ts} +1 -1
  30. package/dist/{types-DX3HtFcn.d.cts → types-DEUb5IZA.d.cts} +1 -1
  31. package/dist/wallet.cjs +12 -2
  32. package/dist/wallet.cjs.map +1 -1
  33. package/dist/wallet.d.cts +4 -4
  34. package/dist/wallet.d.ts +4 -4
  35. package/dist/wallet.mjs +12 -2
  36. package/dist/wallet.mjs.map +1 -1
  37. package/dist/widget.cjs +124 -29
  38. package/dist/widget.cjs.map +1 -1
  39. package/dist/widget.d.cts +2 -2
  40. package/dist/widget.d.ts +2 -2
  41. package/dist/widget.mjs +124 -29
  42. package/dist/widget.mjs.map +1 -1
  43. package/package.json +2 -1
package/dist/widget.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React__default from 'react';
2
- import { N as NavigationStep } from './types-DX3HtFcn.cjs';
3
- import './blockchain-BxAFzp0s.cjs';
2
+ import { N as NavigationStep } from './types-DEUb5IZA.cjs';
3
+ import './blockchain-DmCPxnxr.cjs';
4
4
 
5
5
  type Theme = "light" | "dark" | "system";
6
6
 
package/dist/widget.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React__default from 'react';
2
- import { N as NavigationStep } from './types-BJY9r-mz.js';
3
- import './blockchain-BxAFzp0s.js';
2
+ import { N as NavigationStep } from './types-CMmx0S4U.js';
3
+ import './blockchain-DmCPxnxr.js';
4
4
 
5
5
  type Theme = "light" | "dark" | "system";
6
6
 
package/dist/widget.mjs CHANGED
@@ -545,7 +545,17 @@ var init_config = __esm({
545
545
  RATE_LIMIT_WAIT_BUDGET_MS = 1e4;
546
546
  DEFAULT_FEATURE_FLAGS = {
547
547
  tokensPagination: true,
548
- balanceStreaming: false,
548
+ // On by default: an address scan covers every configured chain and takes
549
+ // seconds end to end, so streaming turns one long wait into a wallet that
550
+ // fills in as results land — first chunk in ~200ms against a ~2.3s buffered
551
+ // response, measured on a live backend.
552
+ //
553
+ // Safe to default because the path degrades on its own: a backend with
554
+ // BALANCE_STREAM_ENABLED off refuses the stream, and the SDK falls back to
555
+ // the buffered endpoint (emitting balance_stream_fallback), as does any
556
+ // runtime whose fetch has no readable body — React Native, most notably.
557
+ // The cost of defaulting ahead of a backend is one refused request per scan.
558
+ balanceStreaming: true,
549
559
  shouldAllowGA4: true,
550
560
  swapMode: false,
551
561
  swapDefaultDestToken: null,
@@ -561,7 +571,7 @@ var init_constants = __esm({
561
571
  "src/constants.ts"() {
562
572
  "use strict";
563
573
  SDK_NAME = "@trustware/sdk";
564
- SDK_VERSION = "1.1.11-staging.2";
574
+ SDK_VERSION = "1.1.12-staging.2";
565
575
  API_ROOT = "https://bv-staging-api.trustware.io";
566
576
  GTM_ID = "GTM-TZDGNCXB";
567
577
  API_PREFIX = "/api";
@@ -609,7 +619,7 @@ function isNotFoundError(err) {
609
619
  return err instanceof Error && err.message.startsWith("HTTP 404");
610
620
  }
611
621
  async function validateSdkAccess() {
612
- const r = await fetch(`${apiBase()}/sdk/validate`, {
622
+ const r = await fetch(`${apiBase()}/v1/sdk/validate`, {
613
623
  method: "GET",
614
624
  headers: jsonHeaders()
615
625
  });
@@ -2292,6 +2302,16 @@ function mergeBalanceWrappers(current, incoming) {
2292
2302
  }
2293
2303
  return Array.from(merged.values());
2294
2304
  }
2305
+ function toSummary(frame, address) {
2306
+ const total = toNumberOrUndefined(frame.total) ?? 0;
2307
+ return {
2308
+ address: toStringOrUndefined(frame.address) ?? address,
2309
+ partial: Boolean(frame.partial),
2310
+ completed: toNumberOrUndefined(frame.completed) ?? 0,
2311
+ total,
2312
+ elapsedMs: toNumberOrUndefined(frame.elapsed)
2313
+ };
2314
+ }
2295
2315
  async function parseStreamingBalances(response, address, options = {}) {
2296
2316
  if (!response.body) {
2297
2317
  throw new Error("balances stream: empty response body");
@@ -2312,7 +2332,12 @@ async function parseStreamingBalances(response, address, options = {}) {
2312
2332
  if (!trimmed) continue;
2313
2333
  try {
2314
2334
  const parsed = JSON.parse(trimmed);
2315
- if (!parsed.chain_id) continue;
2335
+ if (!parsed.chain_id) {
2336
+ if (parsed.type === "summary") {
2337
+ options.onSummary?.(toSummary(parsed, address));
2338
+ }
2339
+ continue;
2340
+ }
2316
2341
  const chunk = normalizeStreamChunk(parsed);
2317
2342
  emitBalanceStreamChunk(address, chunk.length);
2318
2343
  yield chunk;
@@ -2331,6 +2356,8 @@ async function parseStreamingBalances(response, address, options = {}) {
2331
2356
  const chunk = normalizeStreamChunk(parsed);
2332
2357
  emitBalanceStreamChunk(address, chunk.length);
2333
2358
  yield chunk;
2359
+ } else if (parsed.type === "summary") {
2360
+ options.onSummary?.(toSummary(parsed, address));
2334
2361
  }
2335
2362
  } catch (error) {
2336
2363
  if (options.strict) {
@@ -2385,7 +2412,7 @@ async function getBalancesByAddress(address, opts) {
2385
2412
  }
2386
2413
  return merged;
2387
2414
  }
2388
- const url = `${apiBase()}/data/balances/${address}`;
2415
+ const url = `${apiBase()}/v1/data/balances/${address}`;
2389
2416
  const r = await rateLimitedFetch(url, {
2390
2417
  method: "GET",
2391
2418
  credentials: "omit",
@@ -2393,14 +2420,27 @@ async function getBalancesByAddress(address, opts) {
2393
2420
  });
2394
2421
  if (!r.ok) throw new Error(`balances: HTTP ${r.status}`);
2395
2422
  const j = await r.json();
2396
- return Array.isArray(j) ? j : j.results ?? [];
2423
+ const results = Array.isArray(j) ? j : j.results ?? [];
2424
+ if (opts?.onSummary) {
2425
+ const completed = results.length;
2426
+ opts.onSummary({
2427
+ address,
2428
+ partial: Array.isArray(j) ? false : Boolean(j.partial),
2429
+ completed,
2430
+ total: completed
2431
+ });
2432
+ }
2433
+ return results;
2434
+ }
2435
+ function bufferedOptions(opts) {
2436
+ return { ...opts, stream: false };
2397
2437
  }
2398
2438
  async function* getBalancesByAddressStream(address, opts = {}) {
2399
2439
  if (!TrustwareConfigStore.get().features.balanceStreaming) {
2400
- yield await getBalancesByAddress(address);
2440
+ yield await getBalancesByAddress(address, bufferedOptions(opts));
2401
2441
  return;
2402
2442
  }
2403
- const url = `${apiBase()}/data/balances/${address}?stream=1`;
2443
+ const url = `${apiBase()}/v1/data/balances/${address}?stream=1`;
2404
2444
  try {
2405
2445
  const response = await rateLimitedFetch(url, {
2406
2446
  method: "GET",
@@ -2416,7 +2456,14 @@ async function* getBalancesByAddressStream(address, opts = {}) {
2416
2456
  const contentType = response.headers.get("content-type") ?? "";
2417
2457
  if (contentType.includes("application/json")) {
2418
2458
  const payload = await response.json();
2419
- yield Array.isArray(payload) ? payload : payload.results ?? [];
2459
+ const results = Array.isArray(payload) ? payload : payload.results ?? [];
2460
+ opts.onSummary?.({
2461
+ address,
2462
+ partial: Array.isArray(payload) ? false : Boolean(payload.partial),
2463
+ completed: results.length,
2464
+ total: results.length
2465
+ });
2466
+ yield results;
2420
2467
  return;
2421
2468
  }
2422
2469
  const stream = await parseStreamingBalances(response, address, opts);
@@ -2425,7 +2472,7 @@ async function* getBalancesByAddressStream(address, opts = {}) {
2425
2472
  }
2426
2473
  } catch (error) {
2427
2474
  emitBalanceStreamFallback(address, error);
2428
- yield await getBalancesByAddress(address);
2475
+ yield await getBalancesByAddress(address, bufferedOptions(opts));
2429
2476
  }
2430
2477
  }
2431
2478
  async function ensureRegistry() {
@@ -2956,15 +3003,7 @@ function useTrustwareConfig() {
2956
3003
  // Shared with the resolver rather than restated, so this placeholder
2957
3004
  // can't drift from the real defaults.
2958
3005
  retry: { ...DEFAULT_RETRY_CONFIG },
2959
- features: {
2960
- tokensPagination: true,
2961
- balanceStreaming: false,
2962
- shouldAllowGA4: true,
2963
- swapMode: false,
2964
- swapDefaultDestToken: null,
2965
- swapLockDestToken: false,
2966
- swapAllowedDestTokens: null
2967
- }
3006
+ features: { ...DEFAULT_FEATURE_FLAGS }
2968
3007
  };
2969
3008
  }
2970
3009
  });
@@ -20399,7 +20438,7 @@ var VERSION;
20399
20438
  var init_version = __esm({
20400
20439
  "node_modules/@aa-sdk/core/dist/esm/version.js"() {
20401
20440
  "use strict";
20402
- VERSION = "4.88.4";
20441
+ VERSION = "4.88.5";
20403
20442
  }
20404
20443
  });
20405
20444
 
@@ -28908,7 +28947,7 @@ var VERSION2;
28908
28947
  var init_version2 = __esm({
28909
28948
  "node_modules/@account-kit/infra/dist/esm/version.js"() {
28910
28949
  "use strict";
28911
- VERSION2 = "4.88.4";
28950
+ VERSION2 = "4.88.5";
28912
28951
  }
28913
28952
  });
28914
28953
 
@@ -31625,7 +31664,18 @@ async function sendRouteAsUserOperation(params) {
31625
31664
  );
31626
31665
  }
31627
31666
  console.debug("[send] UserOp included", { userOpHash, txHash });
31628
- await submitReceipt(intentId, txHash, getSponsorshipRequestId(), eoaAddress);
31667
+ try {
31668
+ void submitReceipt(
31669
+ intentId,
31670
+ txHash,
31671
+ getSponsorshipRequestId(),
31672
+ eoaAddress
31673
+ ).catch((err) => {
31674
+ console.debug("[send] receipt submission failed (non-fatal)", err);
31675
+ });
31676
+ } catch (err) {
31677
+ console.debug("[send] receipt submission failed (non-fatal)", err);
31678
+ }
31629
31679
  return { userOpHash, txHash, intentId };
31630
31680
  }
31631
31681
  var NATIVE_ADDRS;
@@ -33847,10 +33897,6 @@ function useSwapExecution(fromChain) {
33847
33897
  numericChainId,
33848
33898
  { approvalsEnsured: ownsApprovals }
33849
33899
  );
33850
- try {
33851
- await submitReceipt(routeResult.intentId, hash);
33852
- } catch {
33853
- }
33854
33900
  setState((p) => ({
33855
33901
  ...p,
33856
33902
  isSubmitting: false,
@@ -33859,6 +33905,8 @@ function useSwapExecution(fromChain) {
33859
33905
  txStatus: "processing"
33860
33906
  }));
33861
33907
  startPolling(routeResult.intentId, onSuccess, onError);
33908
+ void submitReceipt(routeResult.intentId, hash).catch(() => {
33909
+ });
33862
33910
  } catch (err) {
33863
33911
  const msg = mapTxError(err);
33864
33912
  setState((p) => ({
@@ -36301,6 +36349,7 @@ function SwapMode({
36301
36349
  }, [route.loading]);
36302
36350
  useEffect34(() => {
36303
36351
  if (!route.data) return;
36352
+ if (stage !== "home" && stage !== "review") return;
36304
36353
  const id = setInterval(() => {
36305
36354
  const ts = quoteTimestampRef.current;
36306
36355
  if (ts === null) return;
@@ -36312,7 +36361,11 @@ function SwapMode({
36312
36361
  }
36313
36362
  }, 1e3);
36314
36363
  return () => clearInterval(id);
36315
- }, [route.data]);
36364
+ }, [route.data, stage]);
36365
+ const handleRetryQuote = useCallback22(() => {
36366
+ if (!latestFetchParamsRef.current) return;
36367
+ void fetchRef.current(latestFetchParamsRef.current);
36368
+ }, []);
36316
36369
  useEffect34(() => {
36317
36370
  if (stage !== "review") return;
36318
36371
  if (!route.data || !walletAddress) return;
@@ -37841,6 +37894,10 @@ function SwapMode({
37841
37894
  txStatus: execution.txStatus,
37842
37895
  isSubmitting: execution.isSubmitting,
37843
37896
  isGasSponsored,
37897
+ hasQuote: !!route.data,
37898
+ isQuoteRefreshing: route.loading,
37899
+ quoteError: route.error,
37900
+ onRetryQuote: handleRetryQuote,
37844
37901
  onExecute: () => void handleExecute()
37845
37902
  }
37846
37903
  )
@@ -39177,10 +39234,15 @@ function SwapActionArea({
39177
39234
  txStatus,
39178
39235
  isSubmitting,
39179
39236
  isGasSponsored,
39237
+ hasQuote,
39238
+ isQuoteRefreshing,
39239
+ quoteError,
39240
+ onRetryQuote,
39180
39241
  onExecute
39181
39242
  }) {
39182
39243
  const needsApproval = allowanceStatus === "needed" && !isGasSponsored;
39183
39244
  const isChecking = allowanceStatus === "checking";
39245
+ const quoteUnavailable = !hasQuote && !isQuoteRefreshing && !isSubmitting && txStatus === "idle";
39184
39246
  let label;
39185
39247
  if (isChecking) {
39186
39248
  label = "Checking approval...";
@@ -39188,12 +39250,14 @@ function SwapActionArea({
39188
39250
  label = `Approving ${fromTokenSymbol}...`;
39189
39251
  } else if (isSubmitting) {
39190
39252
  label = "Confirm in wallet...";
39253
+ } else if (isQuoteRefreshing) {
39254
+ label = "Refreshing quote...";
39191
39255
  } else if (needsApproval) {
39192
39256
  label = `Approve ${fromTokenSymbol}`;
39193
39257
  } else {
39194
39258
  label = "Swap";
39195
39259
  }
39196
- const isDisabled = isSubmitting || isChecking;
39260
+ const isDisabled = isSubmitting || isChecking || isQuoteRefreshing || !hasQuote;
39197
39261
  return /* @__PURE__ */ jsxs47("div", { style: { marginTop: spacing[6] }, children: [
39198
39262
  isGasSponsored && !isSubmitting && /* @__PURE__ */ jsxs47(
39199
39263
  "div",
@@ -39233,7 +39297,38 @@ function SwapActionArea({
39233
39297
  ]
39234
39298
  }
39235
39299
  ),
39236
- /* @__PURE__ */ jsx59(
39300
+ quoteUnavailable ? /* @__PURE__ */ jsxs47(Fragment13, { children: [
39301
+ /* @__PURE__ */ jsx59(
39302
+ "p",
39303
+ {
39304
+ style: {
39305
+ fontSize: fontSize.xs,
39306
+ color: colors.destructive,
39307
+ textAlign: "center",
39308
+ marginBottom: spacing[3]
39309
+ },
39310
+ children: quoteError ?? "This quote expired."
39311
+ }
39312
+ ),
39313
+ /* @__PURE__ */ jsx59(
39314
+ "button",
39315
+ {
39316
+ onClick: onRetryQuote,
39317
+ style: {
39318
+ width: "100%",
39319
+ height: "3.5rem",
39320
+ borderRadius: "1.5rem",
39321
+ backgroundColor: colors.primary,
39322
+ color: colors.primaryForeground,
39323
+ fontSize: fontSize.base,
39324
+ fontWeight: fontWeight.semibold,
39325
+ border: 0,
39326
+ cursor: "pointer"
39327
+ },
39328
+ children: "Get a new quote"
39329
+ }
39330
+ )
39331
+ ] }) : /* @__PURE__ */ jsx59(
39237
39332
  "button",
39238
39333
  {
39239
39334
  onClick: onExecute,