@inversealtruism/cairn-sdk 0.3.0 → 0.3.2

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/board.cjs CHANGED
@@ -27,7 +27,7 @@ var import_csd_codec = require("@inversealtruism/csd-codec");
27
27
  var import_csd_codec2 = require("@inversealtruism/csd-codec");
28
28
 
29
29
  // src/errors.ts
30
- var SDK_VERSION = "0.3.0";
30
+ var SDK_VERSION = "0.3.2";
31
31
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
32
32
  var CairnError = class extends Error {
33
33
  /** Stable machine code for programmatic branching. */
package/dist/board.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  BoardClient
3
- } from "./chunk-NLCF5T2F.js";
4
- import "./chunk-E2Z3XSCW.js";
3
+ } from "./chunk-CZWDA3A5.js";
4
+ import "./chunk-FMXNJQWL.js";
5
5
  export {
6
6
  BoardClient
7
7
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getWallet
3
- } from "./chunk-QV2GIXO7.js";
3
+ } from "./chunk-BN3PFJDY.js";
4
4
 
5
5
  // src/controller.ts
6
6
  var DISCONNECTED = Object.freeze({ status: "disconnected", account: null, error: null });
@@ -3,7 +3,7 @@ import {
3
3
  UnsupportedMethodError,
4
4
  mapProviderError,
5
5
  mapSubmitResultError
6
- } from "./chunk-E2Z3XSCW.js";
6
+ } from "./chunk-FMXNJQWL.js";
7
7
 
8
8
  // src/connect.ts
9
9
  function discoverProviders(opts = {}) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CairnError
3
- } from "./chunk-E2Z3XSCW.js";
3
+ } from "./chunk-FMXNJQWL.js";
4
4
 
5
5
  // src/board.ts
6
6
  import { payloadHash } from "@inversealtruism/csd-codec";
@@ -1,5 +1,5 @@
1
1
  // src/errors.ts
2
- var SDK_VERSION = "0.3.0";
2
+ var SDK_VERSION = "0.3.2";
3
3
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
4
4
  var CairnError = class extends Error {
5
5
  /** Stable machine code for programmatic branching. */
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ContentVerificationError
3
- } from "./chunk-E2Z3XSCW.js";
3
+ } from "./chunk-FMXNJQWL.js";
4
4
 
5
5
  // src/content.ts
6
6
  import { payloadHash, canonicalJson, verifyContentBytes } from "@inversealtruism/csd-codec";
package/dist/connect.cjs CHANGED
@@ -30,7 +30,7 @@ __export(connect_exports, {
30
30
  module.exports = __toCommonJS(connect_exports);
31
31
 
32
32
  // src/errors.ts
33
- var SDK_VERSION = "0.3.0";
33
+ var SDK_VERSION = "0.3.2";
34
34
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
35
35
  var CairnError = class extends Error {
36
36
  /** Stable machine code for programmatic branching. */
package/dist/connect.js CHANGED
@@ -5,8 +5,8 @@ import {
5
5
  discoverProviders,
6
6
  getWallet,
7
7
  isInstalled
8
- } from "./chunk-QV2GIXO7.js";
9
- import "./chunk-E2Z3XSCW.js";
8
+ } from "./chunk-BN3PFJDY.js";
9
+ import "./chunk-FMXNJQWL.js";
10
10
  export {
11
11
  WalletConnection,
12
12
  connect,
package/dist/content.cjs CHANGED
@@ -26,7 +26,7 @@ module.exports = __toCommonJS(content_exports);
26
26
  var import_csd_codec = require("@inversealtruism/csd-codec");
27
27
 
28
28
  // src/errors.ts
29
- var SDK_VERSION = "0.3.0";
29
+ var SDK_VERSION = "0.3.2";
30
30
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
31
31
  var CairnError = class extends Error {
32
32
  /** Stable machine code for programmatic branching. */
package/dist/content.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ContentClient
3
- } from "./chunk-4RDXEW35.js";
4
- import "./chunk-E2Z3XSCW.js";
3
+ } from "./chunk-JKC5K253.js";
4
+ import "./chunk-FMXNJQWL.js";
5
5
  export {
6
6
  ContentClient
7
7
  };
@@ -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.3.0";
28
+ var SDK_VERSION = "0.3.2";
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. */
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  CairnController
3
- } from "./chunk-UMXLWUEF.js";
4
- import "./chunk-QV2GIXO7.js";
5
- import "./chunk-E2Z3XSCW.js";
3
+ } from "./chunk-AGU6K5EZ.js";
4
+ import "./chunk-BN3PFJDY.js";
5
+ import "./chunk-FMXNJQWL.js";
6
6
  export {
7
7
  CairnController
8
8
  };
package/dist/index.cjs CHANGED
@@ -40,12 +40,12 @@ __export(index_exports, {
40
40
  UserRejectedError: () => UserRejectedError,
41
41
  WalletConnection: () => WalletConnection,
42
42
  WalletLockedError: () => WalletLockedError,
43
- bindOfferTerms: () => bindOfferTerms,
43
+ bindOfferTerms: () => import_cairnx_core2.bindOfferTerms,
44
44
  connect: () => connect,
45
45
  detectProvider: () => detectProvider,
46
46
  discoverProviders: () => discoverProviders,
47
47
  errorCode: () => errorCode,
48
- feeBpsAt: () => feeBpsAt,
48
+ feeBpsAt: () => import_cairnx_core2.feeBpsAt,
49
49
  getWallet: () => getWallet,
50
50
  isInstalled: () => isInstalled,
51
51
  mapProviderError: () => mapProviderError,
@@ -55,7 +55,7 @@ __export(index_exports, {
55
55
  module.exports = __toCommonJS(index_exports);
56
56
 
57
57
  // src/errors.ts
58
- var SDK_VERSION = "0.3.0";
58
+ var SDK_VERSION = "0.3.2";
59
59
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
60
60
  var CairnError = class extends Error {
61
61
  /** Stable machine code for programmatic branching. */
@@ -298,8 +298,9 @@ var Http = class {
298
298
  try {
299
299
  const res = await this.raw("GET", path, { query });
300
300
  if (!res.ok) {
301
- const err = new HttpError(res.status, url, await safeText(res));
302
- if (!(res.status >= 500 && attempt < this.retries)) throw err;
301
+ if (!(res.status >= 500 && attempt < this.retries)) throw new HttpError(res.status, url, await safeText(res));
302
+ res.body?.cancel().catch(() => {
303
+ });
303
304
  } else {
304
305
  return this.parseJson(res, new TextDecoder().decode(await readCapped(res, this.maxBytes)), url);
305
306
  }
@@ -935,7 +936,7 @@ var NamesClient = class {
935
936
  async resolve(name) {
936
937
  if (!nameOk(name)) return null;
937
938
  try {
938
- return await this.http.getJson(`/trade/api/cairnx/resolve/${name}`);
939
+ return await this.http.getJson(`/trade/api/cairnx/resolve/${encodeURIComponent(name)}`);
939
940
  } catch (e) {
940
941
  if (e?.status === 404) return null;
941
942
  throw e;
@@ -945,7 +946,7 @@ var NamesClient = class {
945
946
  async name(name) {
946
947
  if (!nameOk(name)) return null;
947
948
  try {
948
- return await this.http.getJson(`/trade/api/cairnx/name/${name}`);
949
+ return await this.http.getJson(`/trade/api/cairnx/name/${encodeURIComponent(name)}`);
949
950
  } catch (e) {
950
951
  if (e?.status === 404) return null;
951
952
  throw e;
@@ -955,7 +956,7 @@ var NamesClient = class {
955
956
  async nameHistory(name) {
956
957
  if (!nameOk(name)) return null;
957
958
  try {
958
- return await this.http.getJson(`/trade/api/cairnx/name-history/${name}`);
959
+ return await this.http.getJson(`/trade/api/cairnx/name-history/${encodeURIComponent(name)}`);
959
960
  } catch (e) {
960
961
  if (e?.status === 404) return null;
961
962
  throw e;
@@ -1238,20 +1239,6 @@ var import_cairnx_core2 = require("@inversealtruism/cairnx-core");
1238
1239
  var ADDR = /^0x[0-9a-f]{40}$/;
1239
1240
  var HASH = /^0x[0-9a-f]{64}$/;
1240
1241
  var COINBASE = "0x" + "00".repeat(32);
1241
- var feeBpsAt = (height) => height >= import_cairnx_core2.V11_HEIGHT ? height >= import_cairnx_core2.V16_HEIGHT ? import_cairnx_core2.FEE_BPS_V16 : import_cairnx_core2.FEE_BPS : 0;
1242
- function bindOfferTerms(servedOffer, t) {
1243
- const o = servedOffer;
1244
- const s = (v) => v === void 0 || v === null ? "" : String(v).toLowerCase();
1245
- if (Number(o?.height) !== t.height) return true;
1246
- if (Number(o?.feeBps) !== t.feeBps) return true;
1247
- if (t.value !== void 0 && String(o?.want?.value) !== t.value) return true;
1248
- if (s(o?.taker) !== s(t.taker)) return true;
1249
- if (s(o?.bid) !== s(t.bid)) return true;
1250
- const om = o?.min;
1251
- if ((om !== void 0 && om !== null) !== (t.min !== void 0)) return true;
1252
- if (t.min !== void 0 && String(om) !== t.min) return true;
1253
- return false;
1254
- }
1255
1242
  async function provenAuthor(client, provenTx) {
1256
1243
  const in0 = provenTx.inputs?.[0];
1257
1244
  if (!in0 || String(in0.prevTxid).toLowerCase() === COINBASE && Number(in0.vout) === 4294967295) return null;
@@ -1311,7 +1298,7 @@ async function preverifyOffer(opts) {
1311
1298
  const payto = w.payto && ADDR.test(String(w.payto).toLowerCase()) ? String(w.payto).toLowerCase() : seller;
1312
1299
  const terms = {
1313
1300
  height: blockHeight,
1314
- feeBps: feeBpsAt(blockHeight),
1301
+ feeBps: (0, import_cairnx_core2.feeBpsAt)(blockHeight),
1315
1302
  value: w.value !== void 0 ? String(w.value) : void 0,
1316
1303
  taker: rec.taker !== void 0 ? String(rec.taker).toLowerCase() : void 0,
1317
1304
  bid: rec.bid !== void 0 ? String(rec.bid).toLowerCase() : void 0,
@@ -1325,7 +1312,7 @@ async function preverifyOffer(opts) {
1325
1312
  return { ok: false, trust: "verified", reason: "the served payment recipient doesn't match the offer's on-chain author/record", ...base };
1326
1313
  if (so?.seller !== void 0 && so?.seller !== null && String(so.seller).toLowerCase() !== seller)
1327
1314
  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 };
1328
- if (bindOfferTerms(opts.servedOffer, terms))
1315
+ if ((0, import_cairnx_core2.bindOfferTerms)(opts.servedOffer, terms))
1329
1316
  return { ok: false, trust: "verified", reason: "the served fee/rebate/partial terms don't match the offer's on-chain record (a lying resolver could mis-size the fill, causing a rejected fill after your payment)", ...base };
1330
1317
  }
1331
1318
  return { ok: true, trust: "verified", ...base };
package/dist/index.d.cts CHANGED
@@ -12,6 +12,7 @@ import { WalletConnection, DetectOptions } from './connect.cjs';
12
12
  export { AttestParams, CairnProvider, ConnectResult, FillParams, ProposeParams, ProviderDetail, ProviderInfo, SealClaimParams, SendParams, SignInResult, SiwcParams, SiwcResult, TxResult, WalletCapabilities, WalletPermission, connect, detectProvider, discoverProviders, getWallet, isInstalled } from './connect.cjs';
13
13
  import { InclusionResult } from '@inversealtruism/csd-light';
14
14
  export { CairnController, CairnControllerOptions, CairnState } from './controller.cjs';
15
+ export { bindOfferTerms, feeBpsAt } from '@inversealtruism/cairnx-core';
15
16
  import '@inversealtruism/csd-client';
16
17
  import '@inversealtruism/csd-tx';
17
18
  import '@inversealtruism/csd-codec';
@@ -127,11 +128,7 @@ interface OfferFillCheck {
127
128
  terms?: ProvenOfferTerms;
128
129
  blockHeight?: number;
129
130
  }
130
- /** The treasury fee rate stamped on an offer at its creation height (resolve.ts: v11 ? (v16 ? 150 : 100) : 0). */
131
- declare const feeBpsAt: (height: number) => number;
132
- /** true iff any fee/rebate/partial-sizing field of the SERVED offer diverges from the merkle-proven terms `t`
133
- * (fail-closed: any divergence => the caller refuses). Byte-identical to cairnx-core `bindOfferTerms`. */
134
- declare function bindOfferTerms(servedOffer: unknown, t: ProvenOfferTerms): boolean;
131
+
135
132
  /**
136
133
  * Pre-verify an offer on-chain before building a `fillOffer` payment. `light` is a PoW-verifying light client
137
134
  * (its `verifyTxInclusion` surfaces the merkle-proven tx + committed appPayloadHash); `client` reads source txs
@@ -151,7 +148,7 @@ declare function preverifyOffer(opts: {
151
148
 
152
149
  /** Stable machine-readable error codes (branch on these, not the message text). */
153
150
  type CairnErrorCode = "NOT_INSTALLED" | "USER_REJECTED" | "WALLET_LOCKED" | "UNSUPPORTED_METHOD" | "HTTP_ERROR" | "CONTENT_VERIFICATION" | "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" | "UNKNOWN";
154
- declare const SDK_VERSION = "0.3.0";
151
+ declare const SDK_VERSION = "0.3.2";
155
152
  interface CairnErrorOptions {
156
153
  code?: CairnErrorCode;
157
154
  docsPath?: string;
@@ -171,7 +168,7 @@ declare class CairnError extends Error {
171
168
  /** Relative docs path (under the SDK docs base), if any. */
172
169
  readonly docsPath?: string;
173
170
  /** The cairn-sdk version that produced this error. */
174
- readonly version = "0.3.0";
171
+ readonly version = "0.3.2";
175
172
  /**
176
173
  * Whether a dApp may safely AUTO-retry this failure. `false` for fund-safety refusals and user-intent
177
174
  * declines (the default); `true` only for provably transient infra faults where nothing was signed.
@@ -349,4 +346,4 @@ declare class Cairn {
349
346
  get connected(): boolean;
350
347
  }
351
348
 
352
- export { BoardClient, Cairn, type CairnBaseUrls, type CairnConfig, CairnError, type CairnErrorCode, type CairnErrorOptions, Chain, ContentClient, ContentVerificationError, DEFAULT_SPV_CHECKPOINT, DetectOptions, FetchLike, Http, HttpError, IndexerClient, type NameDetail, type NameResolution, NamesClient, NotInstalledError, type OfferFillCheck, type PrimaryName, type ProvenOfferTerms, RegistryClient, SDK_VERSION, SubmitInFlightError, type TokenInfo, UnsupportedMethodError, UserRejectedError, WalletConnection, WalletLockedError, bindOfferTerms, errorCode, feeBpsAt, mapProviderError, mapSubmitResultError, preverifyOffer };
349
+ export { BoardClient, Cairn, type CairnBaseUrls, type CairnConfig, CairnError, type CairnErrorCode, type CairnErrorOptions, Chain, ContentClient, ContentVerificationError, DEFAULT_SPV_CHECKPOINT, DetectOptions, FetchLike, Http, HttpError, IndexerClient, type NameDetail, type NameResolution, NamesClient, NotInstalledError, type OfferFillCheck, type PrimaryName, type ProvenOfferTerms, RegistryClient, SDK_VERSION, SubmitInFlightError, type TokenInfo, UnsupportedMethodError, UserRejectedError, WalletConnection, WalletLockedError, errorCode, mapProviderError, mapSubmitResultError, preverifyOffer };
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ import { WalletConnection, DetectOptions } from './connect.js';
12
12
  export { AttestParams, CairnProvider, ConnectResult, FillParams, ProposeParams, ProviderDetail, ProviderInfo, SealClaimParams, SendParams, SignInResult, SiwcParams, SiwcResult, TxResult, WalletCapabilities, WalletPermission, connect, detectProvider, discoverProviders, getWallet, isInstalled } from './connect.js';
13
13
  import { InclusionResult } from '@inversealtruism/csd-light';
14
14
  export { CairnController, CairnControllerOptions, CairnState } from './controller.js';
15
+ export { bindOfferTerms, feeBpsAt } from '@inversealtruism/cairnx-core';
15
16
  import '@inversealtruism/csd-client';
16
17
  import '@inversealtruism/csd-tx';
17
18
  import '@inversealtruism/csd-codec';
@@ -127,11 +128,7 @@ interface OfferFillCheck {
127
128
  terms?: ProvenOfferTerms;
128
129
  blockHeight?: number;
129
130
  }
130
- /** The treasury fee rate stamped on an offer at its creation height (resolve.ts: v11 ? (v16 ? 150 : 100) : 0). */
131
- declare const feeBpsAt: (height: number) => number;
132
- /** true iff any fee/rebate/partial-sizing field of the SERVED offer diverges from the merkle-proven terms `t`
133
- * (fail-closed: any divergence => the caller refuses). Byte-identical to cairnx-core `bindOfferTerms`. */
134
- declare function bindOfferTerms(servedOffer: unknown, t: ProvenOfferTerms): boolean;
131
+
135
132
  /**
136
133
  * Pre-verify an offer on-chain before building a `fillOffer` payment. `light` is a PoW-verifying light client
137
134
  * (its `verifyTxInclusion` surfaces the merkle-proven tx + committed appPayloadHash); `client` reads source txs
@@ -151,7 +148,7 @@ declare function preverifyOffer(opts: {
151
148
 
152
149
  /** Stable machine-readable error codes (branch on these, not the message text). */
153
150
  type CairnErrorCode = "NOT_INSTALLED" | "USER_REJECTED" | "WALLET_LOCKED" | "UNSUPPORTED_METHOD" | "HTTP_ERROR" | "CONTENT_VERIFICATION" | "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" | "UNKNOWN";
154
- declare const SDK_VERSION = "0.3.0";
151
+ declare const SDK_VERSION = "0.3.2";
155
152
  interface CairnErrorOptions {
156
153
  code?: CairnErrorCode;
157
154
  docsPath?: string;
@@ -171,7 +168,7 @@ declare class CairnError extends Error {
171
168
  /** Relative docs path (under the SDK docs base), if any. */
172
169
  readonly docsPath?: string;
173
170
  /** The cairn-sdk version that produced this error. */
174
- readonly version = "0.3.0";
171
+ readonly version = "0.3.2";
175
172
  /**
176
173
  * Whether a dApp may safely AUTO-retry this failure. `false` for fund-safety refusals and user-intent
177
174
  * declines (the default); `true` only for provably transient infra faults where nothing was signed.
@@ -349,4 +346,4 @@ declare class Cairn {
349
346
  get connected(): boolean;
350
347
  }
351
348
 
352
- export { BoardClient, Cairn, type CairnBaseUrls, type CairnConfig, CairnError, type CairnErrorCode, type CairnErrorOptions, Chain, ContentClient, ContentVerificationError, DEFAULT_SPV_CHECKPOINT, DetectOptions, FetchLike, Http, HttpError, IndexerClient, type NameDetail, type NameResolution, NamesClient, NotInstalledError, type OfferFillCheck, type PrimaryName, type ProvenOfferTerms, RegistryClient, SDK_VERSION, SubmitInFlightError, type TokenInfo, UnsupportedMethodError, UserRejectedError, WalletConnection, WalletLockedError, bindOfferTerms, errorCode, feeBpsAt, mapProviderError, mapSubmitResultError, preverifyOffer };
349
+ export { BoardClient, Cairn, type CairnBaseUrls, type CairnConfig, CairnError, type CairnErrorCode, type CairnErrorOptions, Chain, ContentClient, ContentVerificationError, DEFAULT_SPV_CHECKPOINT, DetectOptions, FetchLike, Http, HttpError, IndexerClient, type NameDetail, type NameResolution, NamesClient, NotInstalledError, type OfferFillCheck, type PrimaryName, type ProvenOfferTerms, RegistryClient, SDK_VERSION, SubmitInFlightError, type TokenInfo, UnsupportedMethodError, UserRejectedError, WalletConnection, WalletLockedError, errorCode, mapProviderError, mapSubmitResultError, preverifyOffer };
package/dist/index.js CHANGED
@@ -3,20 +3,20 @@ import {
3
3
  } from "./chunk-BGJZF7S2.js";
4
4
  import {
5
5
  BoardClient
6
- } from "./chunk-NLCF5T2F.js";
6
+ } from "./chunk-CZWDA3A5.js";
7
7
  import {
8
8
  Chain,
9
9
  LightClient
10
10
  } from "./chunk-C452UODV.js";
11
11
  import {
12
12
  ContentClient
13
- } from "./chunk-4RDXEW35.js";
13
+ } from "./chunk-JKC5K253.js";
14
14
  import {
15
15
  IndexerClient
16
16
  } from "./chunk-J5J4JEJ6.js";
17
17
  import {
18
18
  CairnController
19
- } from "./chunk-UMXLWUEF.js";
19
+ } from "./chunk-AGU6K5EZ.js";
20
20
  import {
21
21
  WalletConnection,
22
22
  connect,
@@ -24,7 +24,7 @@ import {
24
24
  discoverProviders,
25
25
  getWallet,
26
26
  isInstalled
27
- } from "./chunk-QV2GIXO7.js";
27
+ } from "./chunk-BN3PFJDY.js";
28
28
  import {
29
29
  CairnError,
30
30
  ContentVerificationError,
@@ -38,7 +38,7 @@ import {
38
38
  errorCode,
39
39
  mapProviderError,
40
40
  mapSubmitResultError
41
- } from "./chunk-E2Z3XSCW.js";
41
+ } from "./chunk-FMXNJQWL.js";
42
42
 
43
43
  // src/http.ts
44
44
  var DEFAULT_MAX_BYTES = 16 * 1024 * 1024;
@@ -145,8 +145,9 @@ var Http = class {
145
145
  try {
146
146
  const res = await this.raw("GET", path, { query });
147
147
  if (!res.ok) {
148
- const err = new HttpError(res.status, url, await safeText(res));
149
- if (!(res.status >= 500 && attempt < this.retries)) throw err;
148
+ if (!(res.status >= 500 && attempt < this.retries)) throw new HttpError(res.status, url, await safeText(res));
149
+ res.body?.cancel().catch(() => {
150
+ });
150
151
  } else {
151
152
  return this.parseJson(res, new TextDecoder().decode(await readCapped(res, this.maxBytes)), url);
152
153
  }
@@ -191,7 +192,7 @@ var NamesClient = class {
191
192
  async resolve(name) {
192
193
  if (!nameOk(name)) return null;
193
194
  try {
194
- return await this.http.getJson(`/trade/api/cairnx/resolve/${name}`);
195
+ return await this.http.getJson(`/trade/api/cairnx/resolve/${encodeURIComponent(name)}`);
195
196
  } catch (e) {
196
197
  if (e?.status === 404) return null;
197
198
  throw e;
@@ -201,7 +202,7 @@ var NamesClient = class {
201
202
  async name(name) {
202
203
  if (!nameOk(name)) return null;
203
204
  try {
204
- return await this.http.getJson(`/trade/api/cairnx/name/${name}`);
205
+ return await this.http.getJson(`/trade/api/cairnx/name/${encodeURIComponent(name)}`);
205
206
  } catch (e) {
206
207
  if (e?.status === 404) return null;
207
208
  throw e;
@@ -211,7 +212,7 @@ var NamesClient = class {
211
212
  async nameHistory(name) {
212
213
  if (!nameOk(name)) return null;
213
214
  try {
214
- return await this.http.getJson(`/trade/api/cairnx/name-history/${name}`);
215
+ return await this.http.getJson(`/trade/api/cairnx/name-history/${encodeURIComponent(name)}`);
215
216
  } catch (e) {
216
217
  if (e?.status === 404) return null;
217
218
  throw e;
@@ -272,24 +273,10 @@ var NamesClient = class {
272
273
  // src/fillverify.ts
273
274
  import { rpcTxToTx } from "@inversealtruism/csd-client";
274
275
  import { txid, payloadHash } from "@inversealtruism/csd-codec";
275
- import { parseRecord, V11_HEIGHT, V16_HEIGHT, FEE_BPS, FEE_BPS_V16 } from "@inversealtruism/cairnx-core";
276
+ import { parseRecord, feeBpsAt, bindOfferTerms } from "@inversealtruism/cairnx-core";
276
277
  var ADDR = /^0x[0-9a-f]{40}$/;
277
278
  var HASH = /^0x[0-9a-f]{64}$/;
278
279
  var COINBASE = "0x" + "00".repeat(32);
279
- var feeBpsAt = (height) => height >= V11_HEIGHT ? height >= V16_HEIGHT ? FEE_BPS_V16 : FEE_BPS : 0;
280
- function bindOfferTerms(servedOffer, t) {
281
- const o = servedOffer;
282
- const s = (v) => v === void 0 || v === null ? "" : String(v).toLowerCase();
283
- if (Number(o?.height) !== t.height) return true;
284
- if (Number(o?.feeBps) !== t.feeBps) return true;
285
- if (t.value !== void 0 && String(o?.want?.value) !== t.value) return true;
286
- if (s(o?.taker) !== s(t.taker)) return true;
287
- if (s(o?.bid) !== s(t.bid)) return true;
288
- const om = o?.min;
289
- if ((om !== void 0 && om !== null) !== (t.min !== void 0)) return true;
290
- if (t.min !== void 0 && String(om) !== t.min) return true;
291
- return false;
292
- }
293
280
  async function provenAuthor(client, provenTx) {
294
281
  const in0 = provenTx.inputs?.[0];
295
282
  if (!in0 || String(in0.prevTxid).toLowerCase() === COINBASE && Number(in0.vout) === 4294967295) return null;
package/dist/react.cjs CHANGED
@@ -26,7 +26,7 @@ __export(react_exports, {
26
26
  module.exports = __toCommonJS(react_exports);
27
27
 
28
28
  // src/errors.ts
29
- var SDK_VERSION = "0.3.0";
29
+ var SDK_VERSION = "0.3.2";
30
30
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
31
31
  var CairnError = class extends Error {
32
32
  /** Stable machine code for programmatic branching. */
package/dist/react.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  CairnController
3
- } from "./chunk-UMXLWUEF.js";
4
- import "./chunk-QV2GIXO7.js";
5
- import "./chunk-E2Z3XSCW.js";
3
+ } from "./chunk-AGU6K5EZ.js";
4
+ import "./chunk-BN3PFJDY.js";
5
+ import "./chunk-FMXNJQWL.js";
6
6
 
7
7
  // src/react.ts
8
8
  function createCairnHooks(React, controllerOrOpts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inversealtruism/cairn-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "The Compute Substrate dApp kit — one cohesive toolkit to connect the Cairn Wallet, read the chain/board, publish self-certifying content, and resolve registries. Composes the published csd-* primitives.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -60,7 +60,7 @@
60
60
  ],
61
61
  "scripts": {
62
62
  "build": "tsup src/index.ts src/connect.ts src/board.ts src/indexer.ts src/content.ts src/registry.ts src/chain.ts src/controller.ts src/react.ts --format esm,cjs --dts --clean",
63
- "test": "tsx test/sdk.test.ts && tsx test/connect.test.ts && tsx test/errors.test.ts && tsx test/controller.test.ts && tsx test/react.test.ts && tsx test/hardening.test.ts && tsx test/spv-checkpoint.test.ts && tsx test/names-b10.test.ts && tsx test/fillverify.test.ts",
63
+ "test": "node test/run.mjs",
64
64
  "test:live": "node examples/read-only.mjs",
65
65
  "build:example": "node scripts/build-example.mjs",
66
66
  "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",