@unicitylabs/sphere-sdk 0.17.2 → 0.17.3

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.
@@ -38,6 +38,7 @@ __export(core_exports, {
38
38
  FIELD_ENVELOPE_MAX_BYTES: () => FIELD_ENVELOPE_MAX_BYTES,
39
39
  FIELD_ENVELOPE_NONCE_BYTES: () => FIELD_ENVELOPE_NONCE_BYTES,
40
40
  FIELD_ENVELOPE_PREFIX: () => FIELD_ENVELOPE_PREFIX,
41
+ NO_PAYMENTS: () => NO_PAYMENTS,
41
42
  PartialSendConflictError: () => PartialSendConflictError,
42
43
  SIGN_MESSAGE_PREFIX: () => SIGN_MESSAGE_PREFIX,
43
44
  Sphere: () => Sphere,
@@ -17061,7 +17062,16 @@ var WalletApiSplitCheckpointStore = class {
17061
17062
  };
17062
17063
 
17063
17064
  // core/payments-v2-wiring.ts
17065
+ var NO_PAYMENTS = "none";
17066
+ function readPaymentsOptOut(walletApi) {
17067
+ if (walletApi === NO_PAYMENTS) return NO_PAYMENTS;
17068
+ throw new SphereError(
17069
+ `walletApi must be a wallet-api transport config or the literal '${NO_PAYMENTS}' (the explicit messaging-only opt-out, #793) \u2014 received ${JSON.stringify(walletApi)}.`,
17070
+ "INVALID_CONFIG"
17071
+ );
17072
+ }
17064
17073
  function resolvePaymentsV2Composition(walletApi, sphereNetwork) {
17074
+ if (typeof walletApi === "string") return readPaymentsOptOut(walletApi);
17065
17075
  const source = walletApi;
17066
17076
  const network = typeof source?.network === "string" && source.network !== "" ? source.network : null;
17067
17077
  if (!source || network === null) {
@@ -17341,7 +17351,11 @@ var Sphere = class _Sphere {
17341
17351
  // The payments vertical (the ONLY money path since the P11 flip)
17342
17352
  /** The ACTIVE address's running vertical — §7: exactly one at a time, ever. */
17343
17353
  _paymentsV2Active = null;
17344
- /** Resolved wallet-api transport composition (network + per-address factory); set at init, fail-closed. */
17354
+ /**
17355
+ * Money composition, set at init. `null` = never resolved (a construction bug),
17356
+ * `NO_PAYMENTS` = the explicit #793 opt-out, an object = a real composition. One
17357
+ * spelling for the last two would read a forgotten resolve as messaging-only.
17358
+ */
17345
17359
  _paymentsV2Composition = null;
17346
17360
  /**
17347
17361
  * §7 lifecycle mutex: every stop/start pair runs strictly serialized, so
@@ -18017,10 +18031,24 @@ var Sphere = class _Sphere {
18017
18031
  get payments() {
18018
18032
  const facade = this._paymentsV2Active?.facade;
18019
18033
  if (!facade) {
18034
+ if (this._paymentsV2Composition === NO_PAYMENTS) {
18035
+ throw new SphereError(
18036
+ "payments is not composed: this Sphere was initialised with `walletApi: 'none'`, the explicit messaging-only composition. Money has no path here \u2014 re-init with a wallet-api transport config to move any.",
18037
+ "PAYMENTS_NOT_COMPOSED"
18038
+ );
18039
+ }
18020
18040
  throw new SphereError("Sphere not initialized", "NOT_INITIALIZED");
18021
18041
  }
18022
18042
  return facade;
18023
18043
  }
18044
+ /**
18045
+ * Whether this Sphere composes money at all (#793) — fixed for the instance's life,
18046
+ * so a messaging-only wallet can branch without a try/catch. Not a liveness check:
18047
+ * `true` still leaves `payments` throwing NOT_INITIALIZED mid-init or mid-switch.
18048
+ */
18049
+ get hasPayments() {
18050
+ return this._paymentsV2Composition !== NO_PAYMENTS;
18051
+ }
18024
18052
  /** Communications module */
18025
18053
  get communications() {
18026
18054
  this.ensureReady();
@@ -20048,6 +20076,7 @@ var Sphere = class _Sphere {
20048
20076
  * breaks initialization.
20049
20077
  */
20050
20078
  async buildTokenEngine(identity) {
20079
+ if (this._paymentsV2Composition === NO_PAYMENTS) return void 0;
20051
20080
  const oracle = this._oracle;
20052
20081
  const privateKey = (identity ?? this._identity)?.privateKey;
20053
20082
  const trustBaseJson = oracle.getTrustBaseJson?.() ?? null;
@@ -20153,6 +20182,7 @@ var Sphere = class _Sphere {
20153
20182
  * setOracleApiKey rebuild is what future operations snapshot.
20154
20183
  */
20155
20184
  async startPaymentsV2Inner(index, identity) {
20185
+ if (this._paymentsV2Composition === NO_PAYMENTS) return;
20156
20186
  if (!this._paymentsV2Composition) {
20157
20187
  throw new SphereError("wallet-api composition required for money", "INVALID_CONFIG");
20158
20188
  }
@@ -20533,6 +20563,7 @@ async function runCustomCheck(name, checkFn, timeoutMs) {
20533
20563
  FIELD_ENVELOPE_MAX_BYTES,
20534
20564
  FIELD_ENVELOPE_NONCE_BYTES,
20535
20565
  FIELD_ENVELOPE_PREFIX,
20566
+ NO_PAYMENTS,
20536
20567
  PartialSendConflictError,
20537
20568
  SIGN_MESSAGE_PREFIX,
20538
20569
  Sphere,