@trustware/sdk-staging 1.1.11-staging.2 → 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.
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 +60 -21
  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 +60 -21
  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 +14 -4
  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 +14 -4
  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 +60 -21
  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 +60 -21
  42. package/dist/widget.mjs.map +1 -1
  43. 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
- balanceStreaming: false,
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.11-staging.2";
596
+ SDK_VERSION = "1.1.12-staging.1";
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) continue;
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
- return Array.isArray(j) ? j : j.results ?? [];
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
- yield Array.isArray(payload) ? payload : payload.results ?? [];
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.4";
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.4";
29015
+ VERSION2 = "4.88.5";
28977
29016
  }
28978
29017
  });
28979
29018