@unicitylabs/sphere-sdk 0.14.11 → 0.15.0

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 (46) hide show
  1. package/README.md +55 -17
  2. package/dist/connect/index.cjs +17 -17
  3. package/dist/connect/index.cjs.map +1 -1
  4. package/dist/connect/index.js +17 -17
  5. package/dist/connect/index.js.map +1 -1
  6. package/dist/core/index.cjs +69 -84
  7. package/dist/core/index.cjs.map +1 -1
  8. package/dist/core/index.d.cts +5 -14
  9. package/dist/core/index.d.ts +5 -14
  10. package/dist/core/index.js +69 -84
  11. package/dist/core/index.js.map +1 -1
  12. package/dist/impl/browser/connect/index.cjs +10 -3
  13. package/dist/impl/browser/connect/index.cjs.map +1 -1
  14. package/dist/impl/browser/connect/index.js +10 -3
  15. package/dist/impl/browser/connect/index.js.map +1 -1
  16. package/dist/impl/browser/index.cjs.map +1 -1
  17. package/dist/impl/browser/index.js.map +1 -1
  18. package/dist/impl/nodejs/connect/index.cjs +9 -2
  19. package/dist/impl/nodejs/connect/index.cjs.map +1 -1
  20. package/dist/impl/nodejs/connect/index.js +9 -2
  21. package/dist/impl/nodejs/connect/index.js.map +1 -1
  22. package/dist/impl/nodejs/index.cjs.map +1 -1
  23. package/dist/impl/nodejs/index.js.map +1 -1
  24. package/dist/impl/wallet-api-v2/index.cjs +92 -92
  25. package/dist/impl/wallet-api-v2/index.cjs.map +1 -1
  26. package/dist/impl/wallet-api-v2/index.js +92 -92
  27. package/dist/impl/wallet-api-v2/index.js.map +1 -1
  28. package/dist/index.cjs +69 -84
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +6 -11
  31. package/dist/index.d.ts +6 -11
  32. package/dist/index.js +69 -84
  33. package/dist/index.js.map +1 -1
  34. package/dist/modules/payments-v2/index.cjs +116 -174
  35. package/dist/modules/payments-v2/index.cjs.map +1 -1
  36. package/dist/modules/payments-v2/index.d.cts +3 -5
  37. package/dist/modules/payments-v2/index.d.ts +3 -5
  38. package/dist/modules/payments-v2/index.js +114 -173
  39. package/dist/modules/payments-v2/index.js.map +1 -1
  40. package/dist/token-engine/index.cjs +43 -57
  41. package/dist/token-engine/index.cjs.map +1 -1
  42. package/dist/token-engine/index.d.cts +0 -4
  43. package/dist/token-engine/index.d.ts +0 -4
  44. package/dist/token-engine/index.js +43 -57
  45. package/dist/token-engine/index.js.map +1 -1
  46. package/package.json +3 -2
@@ -406,7 +406,7 @@ function checkCompatibility(input) {
406
406
  }
407
407
 
408
408
  // connect/version.ts
409
- var SDK_VERSION = "0.14.11";
409
+ var SDK_VERSION = "0.15.0";
410
410
 
411
411
  // connect/permissions.ts
412
412
  var PERMISSION_SCOPES = {
@@ -491,8 +491,15 @@ var REALTIME_STATUS = {
491
491
  function toLegacyRequest(view, status) {
492
492
  return { ...view, symbol: view.symbol ?? "", status };
493
493
  }
494
+ function paymentsOrNull(sphere) {
495
+ try {
496
+ return sphere.payments;
497
+ } catch {
498
+ return null;
499
+ }
500
+ }
494
501
  function legacyRequestPayload(sphere, update) {
495
- const view = sphere.paymentsV2?.requests.list().find((request) => request.id === update.id);
502
+ const view = paymentsOrNull(sphere)?.requests.list().find((request) => request.id === update.id);
496
503
  if (!view) {
497
504
  return {
498
505
  id: update.id,
@@ -571,7 +578,7 @@ var COMPAT_ATTACHERS = /* @__PURE__ */ new Map([
571
578
  forward({ providerId: "wallet-api", error: "wallet-api connection degraded" });
572
579
  })],
573
580
  ["sync:completed", (sphere, forward) => sphere.on("inventory:updated", () => {
574
- forward({ source: "payments", count: sphere.paymentsV2?.tokens().length ?? 0 });
581
+ forward({ source: "payments", count: paymentsOrNull(sphere)?.tokens().length ?? 0 });
575
582
  })],
576
583
  ["sync:remote-update", remoteUpdateAttacher]
577
584
  ]);
@@ -1323,32 +1330,25 @@ var ConnectHost = class {
1323
1330
  return this.handleUnsubscribe(params.event);
1324
1331
  }
1325
1332
  const sphere = this.requireSphere();
1326
- const v2 = sphere.paymentsV2 ?? null;
1327
1333
  switch (method) {
1328
1334
  case RPC_METHODS.GET_IDENTITY:
1329
1335
  return this.getPublicIdentity();
1330
1336
  case RPC_METHODS.GET_BALANCE:
1331
- return v2 ? v2.assets(params.coinId) : sphere.payments.getBalance(params.coinId);
1332
1337
  case RPC_METHODS.GET_ASSETS:
1333
- return v2 ? v2.assets(params.coinId) : sphere.payments.getAssets(params.coinId);
1338
+ return sphere.payments.assets(params.coinId);
1334
1339
  case RPC_METHODS.GET_FIAT_BALANCE:
1335
- return {
1336
- fiatBalance: v2 ? sumFiatUsd(await v2.assets()) : await sphere.payments.getFiatBalance()
1337
- };
1340
+ return { fiatBalance: sumFiatUsd(await sphere.payments.assets()) };
1338
1341
  case RPC_METHODS.GET_TOKENS:
1339
1342
  return this.stripTokenSdkData(
1340
- v2 ? v2.tokens(params.coinId ? { coinId: params.coinId } : void 0) : sphere.payments.getTokens(
1341
- params.coinId ? { coinId: params.coinId } : void 0
1342
- )
1343
+ sphere.payments.tokens(params.coinId ? { coinId: params.coinId } : void 0)
1343
1344
  );
1344
1345
  case RPC_METHODS.GET_HISTORY: {
1345
- if (!v2) return sphere.payments.getHistory();
1346
1346
  const limit = typeof params.limit === "number" && Number.isFinite(params.limit) ? params.limit : void 0;
1347
- if (limit !== void 0) return (await v2.history({ limit })).entries;
1348
- let page = await v2.history(void 0);
1347
+ if (limit !== void 0) return (await sphere.payments.history({ limit })).entries;
1348
+ let page = await sphere.payments.history(void 0);
1349
1349
  const entries = [...page.entries];
1350
1350
  while (page.more && page.cursor !== null) {
1351
- page = await v2.history({ before: page.cursor });
1351
+ page = await sphere.payments.history({ before: page.cursor });
1352
1352
  entries.push(...page.entries);
1353
1353
  }
1354
1354
  return entries;
@@ -1459,7 +1459,7 @@ var ConnectHost = class {
1459
1459
  return { subscribed: true, event: eventName };
1460
1460
  }
1461
1461
  const sphere = this.requireSphere();
1462
- if (sphere.paymentsV2) {
1462
+ {
1463
1463
  const compatUnsub = attachCompatEvent(
1464
1464
  sphere,
1465
1465
  eventName,