@inversealtruism/cairn-sdk 0.6.0 → 0.8.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.
package/dist/index.cjs CHANGED
@@ -32,7 +32,6 @@ __export(index_exports, {
32
32
  IndexerClient: () => IndexerClient,
33
33
  NamesClient: () => NamesClient,
34
34
  NotInstalledError: () => NotInstalledError,
35
- RegistryClient: () => RegistryClient,
36
35
  SDK_VERSION: () => SDK_VERSION,
37
36
  SubmitInFlightError: () => SubmitInFlightError,
38
37
  UnsupportedMethodError: () => UnsupportedMethodError,
@@ -59,7 +58,7 @@ __export(index_exports, {
59
58
  module.exports = __toCommonJS(index_exports);
60
59
 
61
60
  // src/errors.ts
62
- var SDK_VERSION = "0.6.0";
61
+ var SDK_VERSION = "0.8.0";
63
62
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
64
63
  var CairnError = class extends Error {
65
64
  /** Stable machine code for programmatic branching. */
@@ -502,18 +501,6 @@ var IndexerClient = class {
502
501
  attestations(id) {
503
502
  return this.http.getJson(`/proposal/${encodeURIComponent(id)}/attestations`);
504
503
  }
505
- registryPeers() {
506
- return this.http.getJson("/registry/peers");
507
- }
508
- registryGateways() {
509
- return this.http.getJson("/registry/gateways");
510
- }
511
- identity(handle) {
512
- return this.http.getJson(`/identity/${encodeURIComponent(handle)}`);
513
- }
514
- reverseIdentity(addr) {
515
- return this.http.getJson(`/address/${encodeURIComponent(addr)}/identity`);
516
- }
517
504
  // ---- trust-minimized inclusion ----------------------------------------
518
505
  /**
519
506
  * Verify a tx is included in a block by folding its merkle branch to the root
@@ -708,12 +695,12 @@ function norm(h) {
708
695
  // src/content.ts
709
696
  var import_csd_codec3 = require("@inversealtruism/csd-codec");
710
697
  var ContentClient = class {
711
- sources;
698
+ cairn;
712
699
  constructor(opts) {
713
- this.sources = [];
714
- if (opts.swarm) this.sources.push({ name: "swarm", http: opts.swarm, path: (h) => `/content/${h}` });
715
- if (opts.indexer) this.sources.push({ name: "indexer", http: opts.indexer, path: (h) => `/content/${h}` });
716
- if (opts.cairn) this.sources.push({ name: "cairn", http: opts.cairn, path: (h) => `/content/${h}` });
700
+ if (!opts?.cairn || typeof opts.cairn.getBytes !== "function") {
701
+ throw new TypeError("ContentClient needs a `cairn` Http client (the swarm and indexer sources were removed in 0.7.0)");
702
+ }
703
+ this.cairn = opts.cairn;
717
704
  }
718
705
  /**
719
706
  * Compute the canonical hash + bytes for an object, ready to anchor on-chain.
@@ -737,31 +724,21 @@ var ContentClient = class {
737
724
  }
738
725
  /**
739
726
  * Fetch content by hash and VERIFY it self-certifies (sha256(bytes) == hash).
740
- * Tries each configured source in order; a source that is unreachable, lacks
741
- * the content or serves bytes that don't match the hash is skipped. Returns the
742
- * first verified bytes, or null if no source holds it. Throws
743
- * ContentVerificationError only when no source served verified bytes and at
744
- * least one served mismatching bytes (tampering / wrong object).
727
+ * Returns the verified bytes, or null when the origin does not hold the content
728
+ * or cannot be reached (as 0.6.0 did when every source failed). Throws
729
+ * ContentVerificationError when the origin serves bytes that don't match the hash.
745
730
  */
746
731
  async getBytes(hash) {
747
732
  const h = normalizeHash(hash);
748
- let mismatched = false;
749
- for (const src of this.sources) {
750
- let got = null;
751
- try {
752
- got = await src.http.getBytes(src.path(h));
753
- } catch {
754
- continue;
755
- }
756
- if (!got) continue;
757
- if (!(0, import_csd_codec3.verifyContentBytes)(got.bytes, h)) {
758
- mismatched = true;
759
- continue;
760
- }
761
- return got.bytes;
733
+ let got = null;
734
+ try {
735
+ got = await this.cairn.getBytes(`/content/${h}`);
736
+ } catch {
737
+ return null;
762
738
  }
763
- if (mismatched) throw new ContentVerificationError(h);
764
- return null;
739
+ if (!got) return null;
740
+ if (!(0, import_csd_codec3.verifyContentBytes)(got.bytes, h)) throw new ContentVerificationError(h);
741
+ return got.bytes;
765
742
  }
766
743
  /** Fetch + verify + parse as UTF-8 JSON. Returns null if not found. Throws a CairnError with code
767
744
  * CONTENT_NOT_JSON when the verified bytes are not JSON. */
@@ -785,62 +762,11 @@ function normalizeHash(hash) {
785
762
  return h;
786
763
  }
787
764
 
788
- // src/registry.ts
789
- var import_csd_registry = require("@inversealtruism/csd-registry");
790
- var import_csd_registry2 = require("@inversealtruism/csd-registry");
791
- var RegistryClient = class {
792
- http;
793
- /** Accepts the SDK's hardened Http directly (the Cairn facade path) or the legacy
794
- * { baseUrl, fetch } options (kept for direct constructors; they now get the same
795
- * hardened transport, built internally). */
796
- constructor(src) {
797
- this.http = src instanceof Http ? src : new Http({ baseUrl: src.baseUrl, fetch: src.fetch });
798
- }
799
- /** Discover ranked content/pin gateways (GET /registry/gateways). */
800
- gateways() {
801
- return this.http.getJson("/registry/gateways");
802
- }
803
- /** Discover ranked libp2p peers (GET /registry/peers). */
804
- peers() {
805
- return this.http.getJson("/registry/peers");
806
- }
807
- /**
808
- * Resolve a handle → identity (GET /identity/:handle). Returns null if unresolved.
809
- *
810
- * ⚠ TRUST (CAIRN-SDK-RESOLVE-VERIFIED-FOOTGUN): the returned `verified` flag is the INDEXER's assertion,
811
- * NOT a client-side proof. A hostile/compromised indexer (or a MITM of the read proxy) can return
812
- * `verified:true` for a wrong address. Do NOT use this directly as a payee/login target without either (a)
813
- * recomputing from raw records via `fromRecords.name(...)`, or (b) cross-checking a second independent
814
- * source (the wallet's namespv union cure). Treat `verified` here as a hint, not a guarantee.
815
- */
816
- resolveName(handle) {
817
- return this.getOr404Null(`/identity/${encodeURIComponent(handle)}`);
818
- }
819
- /** Reverse-resolve an address → identity (GET /address/:addr/identity).
820
- * ⚠ Same indexer-trust caveat as resolveName — `verified` is the indexer's claim, not a client proof. */
821
- reverseName(address) {
822
- return this.getOr404Null(`/address/${encodeURIComponent(address)}/identity`);
823
- }
824
- // MF-12: 404 → null (the preserved csd-registry contract for both name resolvers); every other
825
- // failure rethrows the typed HttpError/CairnError the hardened Http raises.
826
- async getOr404Null(path) {
827
- try {
828
- return await this.http.getJson(path);
829
- } catch (e) {
830
- if (e instanceof HttpError && e.status === 404) return null;
831
- return Promise.reject(e);
832
- }
833
- }
834
- /** The deterministic, client-side resolvers (recompute from raw ChainRecord[]). */
835
- get fromRecords() {
836
- return import_csd_registry.fromRecords;
837
- }
838
- };
839
-
840
765
  // src/names.ts
841
766
  var import_cairnx_core = require("@inversealtruism/cairnx-core");
842
767
  var nameOk = (n) => typeof n === "string" && import_cairnx_core.NAME_RE.test(n) && !import_cairnx_core.RESERVED_NAMES.has(n);
843
- var amountOk = (v) => typeof v === "string" && import_cairnx_core.AMOUNT_RE.test(v);
768
+ var amountOk = (v) => (0, import_cairnx_core.parseAmount)(v, { allowZero: true }) !== null;
769
+ var decimalsOk = (d) => Number.isSafeInteger(d) && d >= 0 && d <= import_cairnx_core.MAX_TOKEN_DECIMALS;
844
770
  var heightOk = (v) => Number.isSafeInteger(v) && v >= 0;
845
771
  function nameHistoryProblem(h, name) {
846
772
  if (!h || typeof h !== "object" || Array.isArray(h)) return "not an object";
@@ -857,14 +783,15 @@ function nameHistoryProblem(h, name) {
857
783
  }
858
784
  return null;
859
785
  }
860
- function tokenProblem(t) {
786
+ function tokenProblem(t, ticker) {
861
787
  if (!t || typeof t !== "object") return "not an object";
862
788
  const r = t;
863
789
  if (typeof r.ticker !== "string" || !import_cairnx_core.TICKER_RE.test(r.ticker)) return "bad ticker";
864
- if (!Number.isSafeInteger(r.decimals) || r.decimals < 0) return `bad decimals (${String(r.decimals)})`;
865
- if (!amountOk(r.supply)) return "supply is not a base-unit integer string";
866
- if (!amountOk(r.minted)) return "minted is not a base-unit integer string";
867
- if (r.mintLimit !== void 0 && !amountOk(r.mintLimit)) return "mintLimit is not a base-unit integer string";
790
+ if (ticker !== void 0 && r.ticker !== ticker) return `ticker is ${JSON.stringify(r.ticker)}, expected ${JSON.stringify(ticker)}`;
791
+ if (!decimalsOk(r.decimals)) return `bad decimals (${String(r.decimals)}), not an integer in the consensus range`;
792
+ if (!amountOk(r.supply)) return "supply is not a base-unit integer string within MAX_AMOUNT";
793
+ if (!amountOk(r.minted)) return "minted is not a base-unit integer string within MAX_AMOUNT";
794
+ if (r.mintLimit !== void 0 && !amountOk(r.mintLimit)) return "mintLimit is not a base-unit integer string within MAX_AMOUNT";
868
795
  return null;
869
796
  }
870
797
  var NamesClient = class {
@@ -875,11 +802,17 @@ var NamesClient = class {
875
802
  malformed(path, what) {
876
803
  return new HttpError(200, this.http.url(path), `malformed response: ${what}`);
877
804
  }
878
- async list(path) {
879
- const body = await this.http.getJson(path);
805
+ async list(path, query) {
806
+ const body = await this.http.getJson(path, query);
880
807
  if (!Array.isArray(body)) throw this.malformed(path, "expected an array");
881
808
  return body;
882
809
  }
810
+ /** Rows of a market list with one status, or every row for "all". */
811
+ async byStatus(path, status) {
812
+ if (status === "all") return this.list(path);
813
+ const rows = await this.list(path, { status });
814
+ return rows.filter((r) => r?.status === status);
815
+ }
883
816
  /** Resolve a .csd name for DISPLAY (server-trusted; see the module trust note). null = unknown/invalid name. */
884
817
  async resolve(name) {
885
818
  if (!nameOk(name)) return null;
@@ -950,7 +883,8 @@ var NamesClient = class {
950
883
  });
951
884
  return rows;
952
885
  }
953
- /** One token by ticker. null = unknown/invalid ticker. Throws a typed HttpError on a malformed body. */
886
+ /** One token by ticker. null = unknown/invalid ticker. Throws a typed HttpError on a malformed body or a
887
+ * record for another ticker. */
954
888
  async token(ticker) {
955
889
  if (typeof ticker !== "string" || !import_cairnx_core.TICKER_RE.test(ticker)) return null;
956
890
  const path = `/trade/api/cairnx/token/${ticker}`;
@@ -961,17 +895,19 @@ var NamesClient = class {
961
895
  if (e?.status === 404) return null;
962
896
  throw e;
963
897
  }
964
- const p = tokenProblem(t);
898
+ const p = tokenProblem(t, ticker);
965
899
  if (p) throw this.malformed(path, p);
966
900
  return t;
967
901
  }
968
- /** Open offers (the market's display list). */
969
- offers() {
970
- return this.list(`/trade/api/cairnx/offers`);
902
+ /** Offers with one status, open ones by default (the market's display list). `{ status: "all" }` returns every
903
+ * offer the server holds, filled, cancelled and expired ones included. */
904
+ offers(opts = {}) {
905
+ return this.byStatus(`/trade/api/cairnx/offers`, opts.status ?? "open");
971
906
  }
972
- /** Open bids. */
973
- bids() {
974
- return this.list(`/trade/api/cairnx/bids`);
907
+ /** Bids with one status, open ones by default. `{ status: "all" }` returns every bid the server holds, done,
908
+ * cancelled and expired ones included. */
909
+ bids(opts = {}) {
910
+ return this.byStatus(`/trade/api/cairnx/bids`, opts.status ?? "open");
975
911
  }
976
912
  /** The full canonical CairnX state (large; prefer the scoped reads above). */
977
913
  state() {
@@ -1384,10 +1320,10 @@ async function preverifyOffer(opts) {
1384
1320
  return { ok: false, trust: "verified", reason: "the served offer is missing seller (the rebate recipient) - pass the resolver's full offer object, or omit servedOffer", ...base };
1385
1321
  if (String(so.seller).toLowerCase() !== seller)
1386
1322
  return { ok: false, trust: "verified", reason: "the served seller doesn't match the offer's on-chain author (a lying resolver may be redirecting your payment)", ...base };
1387
- if ((0, import_cairnx_core2.bindOfferTerms)(opts.servedOffer, terms, { give: true, wantType: true }))
1388
- return { ok: false, trust: "verified", reason: "the served terms don't match the offer's on-chain record (fee, rebate, partial sizing, the give, or the want type - a lying resolver could mis-size or re-route the fill, redirecting or burning your payment)", ...base };
1389
1323
  if ((0, import_cairnx_core2.isTokenWant)(offerRec.want) && (String(so?.want?.ticker) !== String(offerRec.want.ticker) || String(so?.want?.amount) !== String(offerRec.want.amount)))
1390
1324
  return { ok: false, trust: "verified", reason: "the served want ticker/amount don't match the offer's on-chain record (a lying resolver could bait-and-switch the token price)", ...base };
1325
+ if ((0, import_cairnx_core2.bindOfferTerms)(opts.servedOffer, terms, { give: true, wantType: true }))
1326
+ return { ok: false, trust: "verified", reason: "the served terms don't match the offer's on-chain record (fee, rebate, partial sizing, the give, or the want type - a lying resolver could mis-size or re-route the fill, redirecting or burning your payment)", ...base };
1391
1327
  }
1392
1328
  if (sumsMismatch) return { ok: false, trust: "verified", reason: sumsMismatch, ...base };
1393
1329
  return { ok: true, trust: "verified", ...base };
@@ -1519,7 +1455,6 @@ var Cairn = class {
1519
1455
  chain;
1520
1456
  index;
1521
1457
  content;
1522
- registry;
1523
1458
  /** .csd names + CairnX market READS (server-trusted display reads; see names.ts trust note). */
1524
1459
  names;
1525
1460
  wallet;
@@ -1543,7 +1478,6 @@ var Cairn = class {
1543
1478
  this.cairnHttp = new Http({ baseUrl: cairn, fetch, timeoutMs });
1544
1479
  this._cairnBase = cairn;
1545
1480
  const indexerHttp = new Http({ baseUrl: indexer, fetch, timeoutMs });
1546
- const swarmHttp = config.baseUrls?.swarm ? new Http({ baseUrl: config.baseUrls.swarm.replace(/\/+$/, ""), fetch, timeoutMs }) : void 0;
1547
1481
  this._spvCp = config.spvCheckpoint ?? DEFAULT_SPV_CHECKPOINT;
1548
1482
  this.chain = new Chain({ rpcUrl: rpc, fetch, timeoutMs });
1549
1483
  this.wallet = config.wallet;
@@ -1552,8 +1486,7 @@ var Cairn = class {
1552
1486
  WebSocketImpl: config.WebSocketImpl,
1553
1487
  headerMerkleAt: (h) => this.verifiedHeaderMerkleAt(h)
1554
1488
  });
1555
- this.content = new ContentClient({ swarm: swarmHttp, indexer: indexerHttp, cairn: this.cairnHttp });
1556
- this.registry = new RegistryClient(indexerHttp);
1489
+ this.content = new ContentClient({ cairn: this.cairnHttp });
1557
1490
  this.names = new NamesClient(this.cairnHttp);
1558
1491
  }
1559
1492
  /**
@@ -1762,7 +1695,6 @@ var Cairn = class {
1762
1695
  IndexerClient,
1763
1696
  NamesClient,
1764
1697
  NotInstalledError,
1765
- RegistryClient,
1766
1698
  SDK_VERSION,
1767
1699
  SubmitInFlightError,
1768
1700
  UnsupportedMethodError,
package/dist/index.d.cts CHANGED
@@ -5,8 +5,7 @@ import { IndexerClient } from './indexer.cjs';
5
5
  export { InclusionResult, IndexEvent, MerkleProof, StreamHandle, StreamHandlers, TrustLevel } from './indexer.cjs';
6
6
  import { ContentClient } from './content.cjs';
7
7
  export { ContentClientOptions, PreparedContent } from './content.cjs';
8
- import { RegistryClient } from './registry.cjs';
9
- import { NameState, MintedProvenOfferTerms } from '@inversealtruism/cairnx-core';
8
+ import { NameState, OfferStatus, BidStatus, MintedProvenOfferTerms } from '@inversealtruism/cairnx-core';
10
9
  export { FillEndorsement, FillOutputPlan, FillPreview, FillSafety, MintedProvenOfferTerms, ProvenOfferTerms, bindOfferTerms, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, previewFill, requiredFillOutputs } from '@inversealtruism/cairnx-core';
11
10
  import { WalletConnection, DetectOptions } from './connect.cjs';
12
11
  export { AttestParams, CairnProvider, ConnectResult, FillParams, ProposeParams, ProviderDetail, ProviderInfo, SealClaimParams, SendParams, SignInResult, SiwcParams, SiwcResult, TxResult, WalletCapabilities, WalletPermission, connect, detectProvider, discoverProviders, getWallet, isInstalled } from './connect.cjs';
@@ -16,9 +15,8 @@ import '@inversealtruism/csd-client';
16
15
  import '@inversealtruism/csd-tx';
17
16
  import '@inversealtruism/csd-codec';
18
17
  import '@inversealtruism/csd-crypto';
19
- import '@inversealtruism/csd-registry';
20
18
 
21
- /** `/cairnx/resolve/:name` — the display-path name→address resolution. */
19
+ /** `/cairnx/resolve/:name`: the display-path name→address resolution. */
22
20
  interface NameResolution {
23
21
  ok: boolean;
24
22
  name: string;
@@ -30,7 +28,7 @@ interface NameResolution {
30
28
  owner?: string;
31
29
  tipHeight?: number;
32
30
  }
33
- /** `/cairnx/name/:name` — full name detail (lease, lock, resting offer, recapture window). */
31
+ /** `/cairnx/name/:name`: full name detail (lease, lock, resting offer, recapture window). */
34
32
  interface NameDetail {
35
33
  name: string;
36
34
  owner: string;
@@ -103,6 +101,8 @@ declare class NamesClient {
103
101
  constructor(http: Http);
104
102
  private malformed;
105
103
  private list;
104
+ /** Rows of a market list with one status, or every row for "all". */
105
+ private byStatus;
106
106
  /** Resolve a .csd name for DISPLAY (server-trusted; see the module trust note). null = unknown/invalid name. */
107
107
  resolve(name: string): Promise<NameResolution | null>;
108
108
  /** Full detail for one name (lease, lock, resting offer, recapture). null = not registered/invalid. */
@@ -118,12 +118,19 @@ declare class NamesClient {
118
118
  names(): Promise<unknown[]>;
119
119
  /** All deployed tokens. Throws a typed HttpError if any row has a malformed ticker, decimals or amount. */
120
120
  tokens(): Promise<TokenInfo[]>;
121
- /** One token by ticker. null = unknown/invalid ticker. Throws a typed HttpError on a malformed body. */
121
+ /** One token by ticker. null = unknown/invalid ticker. Throws a typed HttpError on a malformed body or a
122
+ * record for another ticker. */
122
123
  token(ticker: string): Promise<TokenInfo | null>;
123
- /** Open offers (the market's display list). */
124
- offers(): Promise<unknown[]>;
125
- /** Open bids. */
126
- bids(): Promise<unknown[]>;
124
+ /** Offers with one status, open ones by default (the market's display list). `{ status: "all" }` returns every
125
+ * offer the server holds, filled, cancelled and expired ones included. */
126
+ offers(opts?: {
127
+ status?: OfferStatus | "all";
128
+ }): Promise<unknown[]>;
129
+ /** Bids with one status, open ones by default. `{ status: "all" }` returns every bid the server holds, done,
130
+ * cancelled and expired ones included. */
131
+ bids(opts?: {
132
+ status?: BidStatus | "all";
133
+ }): Promise<unknown[]>;
127
134
  /** The full canonical CairnX state (large; prefer the scoped reads above). */
128
135
  state(): Promise<unknown>;
129
136
  }
@@ -191,7 +198,7 @@ declare function preverifyOffer(opts: {
191
198
 
192
199
  /** Stable machine-readable error codes (branch on these, not the message text). */
193
200
  type CairnErrorCode = "NOT_INSTALLED" | "USER_REJECTED" | "WALLET_LOCKED" | "UNSUPPORTED_METHOD" | "HTTP_ERROR" | "CONTENT_VERIFICATION" | "CONTENT_NOT_JSON" | "ACCOUNT_CHANGED" | "FIRST_PARTY_ONLY" | "RATE_LIMITED" | "APPROVAL_CLOSED" | "FORBIDDEN" | "INTERNAL" | "GHOST_INPUTS_SKIPPED" | "VERIFY_UNAVAILABLE" | "VERIFY_TAMPER" | "INSUFFICIENT" | "TOO_MANY_INPUTS" | "FEE_TOO_LOW" | "FEE_CAP" | "BAD_FEE" | "ZERO_ADDR_REFUSED" | "BAD_OUTPUTS" | "NO_OUTPUTS" | "BAD_REQUEST" | "OFFER_UNKNOWN" | "FILL_UNSAFE" | "FILL_WRONG_TARGET" | "SOURCE_DIVERGENCE" | "SUBMIT_REJECTED" | "SUBMIT_MAYBE_INFLIGHT" | "SUBMIT_DUPLICATE" | "NOTHING_TO_CONSOLIDATE" | "OFFER_SOURCE_CONFLICT" | "FILL_LEGACY_SUNSET" | "VERIFY_HORIZON" | "VERIFY_UNREPRESENTABLE" | "WALLET_UNAVAILABLE" | "REVIEW_REQUIRED" | "UNKNOWN";
194
- declare const SDK_VERSION = "0.6.0";
201
+ declare const SDK_VERSION = "0.8.0";
195
202
  interface CairnErrorOptions {
196
203
  code?: CairnErrorCode;
197
204
  docsPath?: string;
@@ -211,7 +218,7 @@ declare class CairnError extends Error {
211
218
  /** Relative docs path (under the SDK docs base), if any. */
212
219
  readonly docsPath?: string;
213
220
  /** The cairn-sdk version that produced this error. */
214
- readonly version = "0.6.0";
221
+ readonly version = "0.8.0";
215
222
  /**
216
223
  * Whether a dApp may safely AUTO-retry this failure. `false` for fund-safety refusals and user-intent
217
224
  * declines (the default); `true` only for provably transient infra faults where nothing was signed.
@@ -302,12 +309,6 @@ interface CairnBaseUrls {
302
309
  * needs a direct indexer endpoint (set this to a localhost/private indexer URL).
303
310
  */
304
311
  indexer?: string;
305
- /**
306
- * Optional direct csd-swarm gateway base. Not set by default — content is reached
307
- * via the indexer proxy (which fronts the swarm) and the cairn origin, both verified.
308
- * Set this only if you run a public swarm gateway.
309
- */
310
- swarm?: string;
311
312
  }
312
313
  interface CairnConfig {
313
314
  /** Currently only "mainnet". Selects the default base URLs. */
@@ -343,7 +344,6 @@ declare class Cairn {
343
344
  readonly chain: Chain;
344
345
  readonly index: IndexerClient;
345
346
  readonly content: ContentClient;
346
- readonly registry: RegistryClient;
347
347
  /** .csd names + CairnX market READS (server-trusted display reads; see names.ts trust note). */
348
348
  readonly names: NamesClient;
349
349
  wallet?: WalletConnection;
@@ -424,4 +424,4 @@ declare class Cairn {
424
424
  get connected(): boolean;
425
425
  }
426
426
 
427
- export { Cairn, type CairnBaseUrls, type CairnConfig, CairnError, type CairnErrorCode, type CairnErrorOptions, Chain, ContentClient, ContentVerificationError, DEFAULT_SPV_CHECKPOINT, DetectOptions, FetchLike, Http, HttpError, IndexerClient, type NameDetail, type NameHistory, type NameHistoryEntry, type NameResolution, NamesClient, NotInstalledError, type OfferFillCheck, type PrimaryName, RegistryClient, SDK_VERSION, SubmitInFlightError, type TokenInfo, UnsupportedMethodError, UserRejectedError, WalletConnection, WalletLockedError, errorCode, mapProviderError, mapSubmitResultError, preverifyOffer };
427
+ export { Cairn, type CairnBaseUrls, type CairnConfig, CairnError, type CairnErrorCode, type CairnErrorOptions, Chain, ContentClient, ContentVerificationError, DEFAULT_SPV_CHECKPOINT, DetectOptions, FetchLike, Http, HttpError, IndexerClient, type NameDetail, type NameHistory, type NameHistoryEntry, type NameResolution, NamesClient, NotInstalledError, type OfferFillCheck, type PrimaryName, SDK_VERSION, SubmitInFlightError, type TokenInfo, UnsupportedMethodError, UserRejectedError, WalletConnection, WalletLockedError, errorCode, mapProviderError, mapSubmitResultError, preverifyOffer };
package/dist/index.d.ts CHANGED
@@ -5,8 +5,7 @@ import { IndexerClient } from './indexer.js';
5
5
  export { InclusionResult, IndexEvent, MerkleProof, StreamHandle, StreamHandlers, TrustLevel } from './indexer.js';
6
6
  import { ContentClient } from './content.js';
7
7
  export { ContentClientOptions, PreparedContent } from './content.js';
8
- import { RegistryClient } from './registry.js';
9
- import { NameState, MintedProvenOfferTerms } from '@inversealtruism/cairnx-core';
8
+ import { NameState, OfferStatus, BidStatus, MintedProvenOfferTerms } from '@inversealtruism/cairnx-core';
10
9
  export { FillEndorsement, FillOutputPlan, FillPreview, FillSafety, MintedProvenOfferTerms, ProvenOfferTerms, bindOfferTerms, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, previewFill, requiredFillOutputs } from '@inversealtruism/cairnx-core';
11
10
  import { WalletConnection, DetectOptions } from './connect.js';
12
11
  export { AttestParams, CairnProvider, ConnectResult, FillParams, ProposeParams, ProviderDetail, ProviderInfo, SealClaimParams, SendParams, SignInResult, SiwcParams, SiwcResult, TxResult, WalletCapabilities, WalletPermission, connect, detectProvider, discoverProviders, getWallet, isInstalled } from './connect.js';
@@ -16,9 +15,8 @@ import '@inversealtruism/csd-client';
16
15
  import '@inversealtruism/csd-tx';
17
16
  import '@inversealtruism/csd-codec';
18
17
  import '@inversealtruism/csd-crypto';
19
- import '@inversealtruism/csd-registry';
20
18
 
21
- /** `/cairnx/resolve/:name` — the display-path name→address resolution. */
19
+ /** `/cairnx/resolve/:name`: the display-path name→address resolution. */
22
20
  interface NameResolution {
23
21
  ok: boolean;
24
22
  name: string;
@@ -30,7 +28,7 @@ interface NameResolution {
30
28
  owner?: string;
31
29
  tipHeight?: number;
32
30
  }
33
- /** `/cairnx/name/:name` — full name detail (lease, lock, resting offer, recapture window). */
31
+ /** `/cairnx/name/:name`: full name detail (lease, lock, resting offer, recapture window). */
34
32
  interface NameDetail {
35
33
  name: string;
36
34
  owner: string;
@@ -103,6 +101,8 @@ declare class NamesClient {
103
101
  constructor(http: Http);
104
102
  private malformed;
105
103
  private list;
104
+ /** Rows of a market list with one status, or every row for "all". */
105
+ private byStatus;
106
106
  /** Resolve a .csd name for DISPLAY (server-trusted; see the module trust note). null = unknown/invalid name. */
107
107
  resolve(name: string): Promise<NameResolution | null>;
108
108
  /** Full detail for one name (lease, lock, resting offer, recapture). null = not registered/invalid. */
@@ -118,12 +118,19 @@ declare class NamesClient {
118
118
  names(): Promise<unknown[]>;
119
119
  /** All deployed tokens. Throws a typed HttpError if any row has a malformed ticker, decimals or amount. */
120
120
  tokens(): Promise<TokenInfo[]>;
121
- /** One token by ticker. null = unknown/invalid ticker. Throws a typed HttpError on a malformed body. */
121
+ /** One token by ticker. null = unknown/invalid ticker. Throws a typed HttpError on a malformed body or a
122
+ * record for another ticker. */
122
123
  token(ticker: string): Promise<TokenInfo | null>;
123
- /** Open offers (the market's display list). */
124
- offers(): Promise<unknown[]>;
125
- /** Open bids. */
126
- bids(): Promise<unknown[]>;
124
+ /** Offers with one status, open ones by default (the market's display list). `{ status: "all" }` returns every
125
+ * offer the server holds, filled, cancelled and expired ones included. */
126
+ offers(opts?: {
127
+ status?: OfferStatus | "all";
128
+ }): Promise<unknown[]>;
129
+ /** Bids with one status, open ones by default. `{ status: "all" }` returns every bid the server holds, done,
130
+ * cancelled and expired ones included. */
131
+ bids(opts?: {
132
+ status?: BidStatus | "all";
133
+ }): Promise<unknown[]>;
127
134
  /** The full canonical CairnX state (large; prefer the scoped reads above). */
128
135
  state(): Promise<unknown>;
129
136
  }
@@ -191,7 +198,7 @@ declare function preverifyOffer(opts: {
191
198
 
192
199
  /** Stable machine-readable error codes (branch on these, not the message text). */
193
200
  type CairnErrorCode = "NOT_INSTALLED" | "USER_REJECTED" | "WALLET_LOCKED" | "UNSUPPORTED_METHOD" | "HTTP_ERROR" | "CONTENT_VERIFICATION" | "CONTENT_NOT_JSON" | "ACCOUNT_CHANGED" | "FIRST_PARTY_ONLY" | "RATE_LIMITED" | "APPROVAL_CLOSED" | "FORBIDDEN" | "INTERNAL" | "GHOST_INPUTS_SKIPPED" | "VERIFY_UNAVAILABLE" | "VERIFY_TAMPER" | "INSUFFICIENT" | "TOO_MANY_INPUTS" | "FEE_TOO_LOW" | "FEE_CAP" | "BAD_FEE" | "ZERO_ADDR_REFUSED" | "BAD_OUTPUTS" | "NO_OUTPUTS" | "BAD_REQUEST" | "OFFER_UNKNOWN" | "FILL_UNSAFE" | "FILL_WRONG_TARGET" | "SOURCE_DIVERGENCE" | "SUBMIT_REJECTED" | "SUBMIT_MAYBE_INFLIGHT" | "SUBMIT_DUPLICATE" | "NOTHING_TO_CONSOLIDATE" | "OFFER_SOURCE_CONFLICT" | "FILL_LEGACY_SUNSET" | "VERIFY_HORIZON" | "VERIFY_UNREPRESENTABLE" | "WALLET_UNAVAILABLE" | "REVIEW_REQUIRED" | "UNKNOWN";
194
- declare const SDK_VERSION = "0.6.0";
201
+ declare const SDK_VERSION = "0.8.0";
195
202
  interface CairnErrorOptions {
196
203
  code?: CairnErrorCode;
197
204
  docsPath?: string;
@@ -211,7 +218,7 @@ declare class CairnError extends Error {
211
218
  /** Relative docs path (under the SDK docs base), if any. */
212
219
  readonly docsPath?: string;
213
220
  /** The cairn-sdk version that produced this error. */
214
- readonly version = "0.6.0";
221
+ readonly version = "0.8.0";
215
222
  /**
216
223
  * Whether a dApp may safely AUTO-retry this failure. `false` for fund-safety refusals and user-intent
217
224
  * declines (the default); `true` only for provably transient infra faults where nothing was signed.
@@ -302,12 +309,6 @@ interface CairnBaseUrls {
302
309
  * needs a direct indexer endpoint (set this to a localhost/private indexer URL).
303
310
  */
304
311
  indexer?: string;
305
- /**
306
- * Optional direct csd-swarm gateway base. Not set by default — content is reached
307
- * via the indexer proxy (which fronts the swarm) and the cairn origin, both verified.
308
- * Set this only if you run a public swarm gateway.
309
- */
310
- swarm?: string;
311
312
  }
312
313
  interface CairnConfig {
313
314
  /** Currently only "mainnet". Selects the default base URLs. */
@@ -343,7 +344,6 @@ declare class Cairn {
343
344
  readonly chain: Chain;
344
345
  readonly index: IndexerClient;
345
346
  readonly content: ContentClient;
346
- readonly registry: RegistryClient;
347
347
  /** .csd names + CairnX market READS (server-trusted display reads; see names.ts trust note). */
348
348
  readonly names: NamesClient;
349
349
  wallet?: WalletConnection;
@@ -424,4 +424,4 @@ declare class Cairn {
424
424
  get connected(): boolean;
425
425
  }
426
426
 
427
- export { Cairn, type CairnBaseUrls, type CairnConfig, CairnError, type CairnErrorCode, type CairnErrorOptions, Chain, ContentClient, ContentVerificationError, DEFAULT_SPV_CHECKPOINT, DetectOptions, FetchLike, Http, HttpError, IndexerClient, type NameDetail, type NameHistory, type NameHistoryEntry, type NameResolution, NamesClient, NotInstalledError, type OfferFillCheck, type PrimaryName, RegistryClient, SDK_VERSION, SubmitInFlightError, type TokenInfo, UnsupportedMethodError, UserRejectedError, WalletConnection, WalletLockedError, errorCode, mapProviderError, mapSubmitResultError, preverifyOffer };
427
+ export { Cairn, type CairnBaseUrls, type CairnConfig, CairnError, type CairnErrorCode, type CairnErrorOptions, Chain, ContentClient, ContentVerificationError, DEFAULT_SPV_CHECKPOINT, DetectOptions, FetchLike, Http, HttpError, IndexerClient, type NameDetail, type NameHistory, type NameHistoryEntry, type NameResolution, NamesClient, NotInstalledError, type OfferFillCheck, type PrimaryName, SDK_VERSION, SubmitInFlightError, type TokenInfo, UnsupportedMethodError, UserRejectedError, WalletConnection, WalletLockedError, errorCode, mapProviderError, mapSubmitResultError, preverifyOffer };