@unicitylabs/sphere-sdk 0.11.2 → 0.11.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.
package/README.md CHANGED
@@ -129,7 +129,30 @@ For manual/advanced provider wiring, see [Custom Providers Configuration](#custo
129
129
  | `deliveryPending` | `true` when the spend is **certified on-chain** but the recipient's **mailbox delivery was deferred** (a full inbox / transient outage). **This is success, not failure** — the token is finalized and the finished blob is journaled and re-delivered automatically. |
130
130
  | `deliveryState` | `'landed'` (delivered) or `'pending-delivery'` (deferred, as above). |
131
131
 
132
- Treat `status === 'completed'` as sent. Use `deliveryPending` only to show a "delivery pending" hint — never as an error. `send()` throws only for genuine failures (e.g. `INVALID_RECIPIENT`, insufficient balance); a stale-but-spent source is self-healed (the next live coin is selected automatically).
132
+ Treat `status === 'completed'` as sent. Use `deliveryPending` only to show a "delivery pending" hint — never as an error. A stale-but-spent source is self-healed (the next live coin is selected automatically).
133
+
134
+ #### Handling `send()` rejections — `CERTIFICATION_UNCONFIRMED` is NOT re-sendable (money-safety)
135
+
136
+ `send()` throws for genuine failures (`INVALID_RECIPIENT`, insufficient balance, a `TransferConflictError` lost race) **and** for one *indeterminate* case you must handle specially: a **`ProofUnconfirmedError`** (`code: 'CERTIFICATION_UNCONFIRMED'`, `mayHaveCertified: true`). It means the spend **may already be on-chain** but the proof fetch was inconclusive — the SDK keeps the intent **open** and completes it later under the **same `transferId`**.
137
+
138
+ - ⚠️ **Never re-issue `send()` on `CERTIFICATION_UNCONFIRMED`.** A fresh `send()` mints a new `transferId` on a *different* source, so the original resumes **and** the retry sends → **the recipient is double-paid.** Treat it as *"sent, pending confirmation."*
139
+ - **Recovery is `resumeOpenIntents()`** — it replays the open intent under the same `transferId` (recovers the proof + delivery, or records the spend if a rival tx won; **never a second spend**). It runs automatically at **session start** (`Sphere.init` / `Sphere.load` / re-sign-in). A **long-running bot** that doesn't re-init should call `sphere.payments.resumeOpenIntents()` on startup and periodically — it returns `{ resumed, conflicted, failed }`.
140
+
141
+ ```ts
142
+ import { isSphereError } from '@unicitylabs/sphere-sdk';
143
+
144
+ try {
145
+ const result = await sphere.payments.send({ recipient: '@bob', amount, coinId });
146
+ // result.status === 'completed' (or result.deliveryPending === true) → sent
147
+ } catch (err) {
148
+ if (isSphereError(err) && err.code === 'CERTIFICATION_UNCONFIRMED') {
149
+ // Possibly already sent on-chain — DO NOT re-send. Resume finishes it
150
+ // (auto at next sign-in, or: await sphere.payments.resumeOpenIntents()).
151
+ } else {
152
+ // genuine failure — safe to surface to the user / retry
153
+ }
154
+ }
155
+ ```
133
156
 
134
157
  > `transferMode` on `TransferRequest` is **deprecated** — accepted for backwards-compat but ignored (v2 has a single engine-driven path).
135
158
 
@@ -504,7 +504,7 @@ function checkCompatibility(input) {
504
504
  }
505
505
 
506
506
  // connect/version.ts
507
- var SDK_VERSION = "0.11.2";
507
+ var SDK_VERSION = "0.11.3";
508
508
 
509
509
  // connect/permissions.ts
510
510
  var PERMISSION_SCOPES = {