@inversealtruism/cairn-sdk 0.4.5 → 0.5.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.
@@ -25,7 +25,7 @@ __export(controller_exports, {
25
25
  module.exports = __toCommonJS(controller_exports);
26
26
 
27
27
  // src/errors.ts
28
- var SDK_VERSION = "0.4.5";
28
+ var SDK_VERSION = "0.5.0";
29
29
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
30
30
  var CairnError = class extends Error {
31
31
  /** Stable machine code for programmatic branching. */
@@ -100,7 +100,7 @@ var SubmitInFlightError = class extends CairnError {
100
100
  }
101
101
  };
102
102
  var NATIVE_CODES = /* @__PURE__ */ new Set(["FIRST_PARTY_ONLY", "RATE_LIMITED", "FORBIDDEN", "INTERNAL"]);
103
- var NESTED_TRANSIENT = /* @__PURE__ */ new Set(["VERIFY_UNAVAILABLE", "OFFER_UNKNOWN"]);
103
+ var NESTED_TRANSIENT = /* @__PURE__ */ new Set(["VERIFY_UNAVAILABLE", "OFFER_UNKNOWN", "WALLET_UNAVAILABLE", "REVIEW_REQUIRED"]);
104
104
  var NESTED_TERMINAL = /* @__PURE__ */ new Set([
105
105
  "FILL_UNSAFE",
106
106
  "FILL_WRONG_TARGET",
@@ -118,7 +118,11 @@ var NESTED_TERMINAL = /* @__PURE__ */ new Set([
118
118
  "FEE_TOO_LOW",
119
119
  "ACCOUNT_CHANGED",
120
120
  "GHOST_INPUTS_SKIPPED",
121
- "NOTHING_TO_CONSOLIDATE"
121
+ "NOTHING_TO_CONSOLIDATE",
122
+ "OFFER_SOURCE_CONFLICT",
123
+ "FILL_LEGACY_SUNSET",
124
+ "VERIFY_HORIZON",
125
+ "VERIFY_UNREPRESENTABLE"
122
126
  ]);
123
127
  function mapProviderError(error, code) {
124
128
  if (code === "USER_REJECTED" || code === "APPROVAL_CLOSED") return new UserRejectedError(error);
@@ -344,7 +348,7 @@ var WalletConnection = class {
344
348
  send(params) {
345
349
  return this.call(() => this.provider.send(params), "send").then(unwrapWrite);
346
350
  }
347
- /** Low-level Propose (always prompts). Prefer `cairn.board.propose()` which computes the hash/uri/expiry. */
351
+ /** Low-level Propose (always prompts). The caller computes the payload hash, uri and expiry epoch. */
348
352
  propose(params) {
349
353
  return this.call(() => this.provider.propose(params), "propose").then(unwrapWrite);
350
354
  }
@@ -373,8 +377,9 @@ var DISCONNECTED = Object.freeze({ status: "disconnected", account: null, error:
373
377
  var CairnController = class {
374
378
  state = DISCONNECTED;
375
379
  conn = null;
376
- // MF-15: connect/disconnect generation token. disconnect() bumps it; a connect() whose await straddled
377
- // the bump must never commit "connected" over the torn-down session (a zombie null-connection session).
380
+ // Connect/disconnect generation token. disconnect(), the wallet's `disconnect` event and an empty
381
+ // accountsChanged (lock, account switch, revoke) bump it; a connect() whose await straddled the bump must
382
+ // never commit "connected" over the torn-down session.
378
383
  epoch = 0;
379
384
  listeners = /* @__PURE__ */ new Set();
380
385
  getWalletFn;
@@ -405,6 +410,7 @@ var CairnController = class {
405
410
  }
406
411
  onAccounts = (accounts) => {
407
412
  if (!Array.isArray(accounts) || accounts.length === 0) {
413
+ this.epoch++;
408
414
  this.setState({ status: "disconnected", account: null });
409
415
  return;
410
416
  }
@@ -416,6 +422,7 @@ var CairnController = class {
416
422
  }
417
423
  };
418
424
  onDisconnect = () => {
425
+ this.epoch++;
419
426
  this.setState({ status: "disconnected", account: null });
420
427
  };
421
428
  // Detach the provider listeners (ghost-reconnect fix). Idempotent + best-effort.
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  CairnController
3
- } from "./chunk-XW3IFE6K.js";
4
- import "./chunk-SWCUE26T.js";
5
- import "./chunk-LOAOBV36.js";
3
+ } from "./chunk-OE5BEEQY.js";
4
+ import "./chunk-5RGFC2JR.js";
5
+ import "./chunk-OSPAN7GX.js";
6
6
  export {
7
7
  CairnController
8
8
  };