@inversealtruism/cairn-sdk 0.4.2 → 0.4.4
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 +1 -1
- package/dist/board.js +2 -2
- package/dist/{chunk-PZEQ4YHR.js → chunk-EAQAJ2JH.js} +1 -1
- package/dist/{chunk-XPTP5W75.js → chunk-KLZ2MABC.js} +1 -1
- package/dist/{chunk-WBU7KDI3.js → chunk-OFB365FB.js} +14 -15
- package/dist/{chunk-REHDMKBF.js → chunk-PHX4NZCI.js} +1 -1
- package/dist/{chunk-VGKXFRHY.js → chunk-UTYGJZAX.js} +1 -1
- package/dist/{chunk-FS2BQWA5.js → chunk-WIJJJEAK.js} +1 -1
- package/dist/connect.cjs +1 -1
- package/dist/connect.js +2 -2
- package/dist/content.cjs +1 -1
- package/dist/content.js +2 -2
- package/dist/controller.cjs +1 -1
- package/dist/controller.js +3 -3
- package/dist/index.cjs +20 -16
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -8
- package/dist/react.cjs +1 -1
- package/dist/react.js +3 -3
- package/dist/registry.cjs +14 -15
- package/dist/registry.js +2 -2
- package/package.json +5 -5
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.4.
|
|
30
|
+
var SDK_VERSION = "0.4.4";
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HttpError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PHX4NZCI.js";
|
|
4
4
|
|
|
5
5
|
// src/registry.ts
|
|
6
6
|
import { fromRecords } from "@inversealtruism/csd-registry";
|
|
@@ -90,7 +90,8 @@ var Http = class {
|
|
|
90
90
|
},
|
|
91
91
|
body: opts?.body !== void 0 ? JSON.stringify(opts.body) : void 0
|
|
92
92
|
});
|
|
93
|
-
|
|
93
|
+
const body = await readCapped(res, this.maxBytes);
|
|
94
|
+
return { res, body };
|
|
94
95
|
} finally {
|
|
95
96
|
clearTimeout(timer);
|
|
96
97
|
}
|
|
@@ -108,13 +109,11 @@ var Http = class {
|
|
|
108
109
|
const url = this.url(path, query);
|
|
109
110
|
for (let attempt = 0; ; attempt++) {
|
|
110
111
|
try {
|
|
111
|
-
const res = await this.raw("GET", path, { query });
|
|
112
|
+
const { res, body } = await this.raw("GET", path, { query });
|
|
112
113
|
if (!res.ok) {
|
|
113
|
-
if (!(res.status >= 500 && attempt < this.retries)) throw new HttpError(res.status, url,
|
|
114
|
-
res.body?.cancel().catch(() => {
|
|
115
|
-
});
|
|
114
|
+
if (!(res.status >= 500 && attempt < this.retries)) throw new HttpError(res.status, url, errText(body));
|
|
116
115
|
} else {
|
|
117
|
-
return this.parseJson(res, new TextDecoder().decode(
|
|
116
|
+
return this.parseJson(res, new TextDecoder().decode(body), url);
|
|
118
117
|
}
|
|
119
118
|
} catch (e) {
|
|
120
119
|
if (e instanceof HttpError && e.status < 500) throw e;
|
|
@@ -125,21 +124,21 @@ var Http = class {
|
|
|
125
124
|
}
|
|
126
125
|
async postJson(path, body, headers) {
|
|
127
126
|
const url = this.url(path);
|
|
128
|
-
const res = await this.raw("POST", path, { body, headers });
|
|
129
|
-
if (!res.ok) throw new HttpError(res.status, url,
|
|
130
|
-
return this.parseJson(res, new TextDecoder().decode(
|
|
127
|
+
const { res, body: respBody } = await this.raw("POST", path, { body, headers });
|
|
128
|
+
if (!res.ok) throw new HttpError(res.status, url, errText(respBody));
|
|
129
|
+
return this.parseJson(res, new TextDecoder().decode(respBody), url);
|
|
131
130
|
}
|
|
132
131
|
/** GET raw bytes (for content retrieval). Returns null on 404. */
|
|
133
132
|
async getBytes(path) {
|
|
134
|
-
const res = await this.raw("GET", path);
|
|
133
|
+
const { res, body } = await this.raw("GET", path);
|
|
135
134
|
if (res.status === 404) return null;
|
|
136
|
-
if (!res.ok) throw new HttpError(res.status, this.url(path),
|
|
137
|
-
return { bytes:
|
|
135
|
+
if (!res.ok) throw new HttpError(res.status, this.url(path), errText(body));
|
|
136
|
+
return { bytes: body, headers: res.headers };
|
|
138
137
|
}
|
|
139
138
|
};
|
|
140
|
-
|
|
139
|
+
function errText(body) {
|
|
141
140
|
try {
|
|
142
|
-
return new TextDecoder().decode(
|
|
141
|
+
return new TextDecoder().decode(body).slice(0, ERR_TEXT_CAP);
|
|
143
142
|
} catch {
|
|
144
143
|
return "";
|
|
145
144
|
}
|
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.4.
|
|
33
|
+
var SDK_VERSION = "0.4.4";
|
|
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
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.4.
|
|
29
|
+
var SDK_VERSION = "0.4.4";
|
|
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
package/dist/controller.cjs
CHANGED
|
@@ -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.
|
|
28
|
+
var SDK_VERSION = "0.4.4";
|
|
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. */
|
package/dist/controller.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -60,7 +60,7 @@ __export(index_exports, {
|
|
|
60
60
|
module.exports = __toCommonJS(index_exports);
|
|
61
61
|
|
|
62
62
|
// src/errors.ts
|
|
63
|
-
var SDK_VERSION = "0.4.
|
|
63
|
+
var SDK_VERSION = "0.4.4";
|
|
64
64
|
var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
|
|
65
65
|
var CairnError = class extends Error {
|
|
66
66
|
/** Stable machine code for programmatic branching. */
|
|
@@ -283,7 +283,8 @@ var Http = class {
|
|
|
283
283
|
},
|
|
284
284
|
body: opts?.body !== void 0 ? JSON.stringify(opts.body) : void 0
|
|
285
285
|
});
|
|
286
|
-
|
|
286
|
+
const body = await readCapped(res, this.maxBytes);
|
|
287
|
+
return { res, body };
|
|
287
288
|
} finally {
|
|
288
289
|
clearTimeout(timer);
|
|
289
290
|
}
|
|
@@ -301,13 +302,11 @@ var Http = class {
|
|
|
301
302
|
const url = this.url(path, query);
|
|
302
303
|
for (let attempt = 0; ; attempt++) {
|
|
303
304
|
try {
|
|
304
|
-
const res = await this.raw("GET", path, { query });
|
|
305
|
+
const { res, body } = await this.raw("GET", path, { query });
|
|
305
306
|
if (!res.ok) {
|
|
306
|
-
if (!(res.status >= 500 && attempt < this.retries)) throw new HttpError(res.status, url,
|
|
307
|
-
res.body?.cancel().catch(() => {
|
|
308
|
-
});
|
|
307
|
+
if (!(res.status >= 500 && attempt < this.retries)) throw new HttpError(res.status, url, errText(body));
|
|
309
308
|
} else {
|
|
310
|
-
return this.parseJson(res, new TextDecoder().decode(
|
|
309
|
+
return this.parseJson(res, new TextDecoder().decode(body), url);
|
|
311
310
|
}
|
|
312
311
|
} catch (e) {
|
|
313
312
|
if (e instanceof HttpError && e.status < 500) throw e;
|
|
@@ -318,21 +317,21 @@ var Http = class {
|
|
|
318
317
|
}
|
|
319
318
|
async postJson(path, body, headers) {
|
|
320
319
|
const url = this.url(path);
|
|
321
|
-
const res = await this.raw("POST", path, { body, headers });
|
|
322
|
-
if (!res.ok) throw new HttpError(res.status, url,
|
|
323
|
-
return this.parseJson(res, new TextDecoder().decode(
|
|
320
|
+
const { res, body: respBody } = await this.raw("POST", path, { body, headers });
|
|
321
|
+
if (!res.ok) throw new HttpError(res.status, url, errText(respBody));
|
|
322
|
+
return this.parseJson(res, new TextDecoder().decode(respBody), url);
|
|
324
323
|
}
|
|
325
324
|
/** GET raw bytes (for content retrieval). Returns null on 404. */
|
|
326
325
|
async getBytes(path) {
|
|
327
|
-
const res = await this.raw("GET", path);
|
|
326
|
+
const { res, body } = await this.raw("GET", path);
|
|
328
327
|
if (res.status === 404) return null;
|
|
329
|
-
if (!res.ok) throw new HttpError(res.status, this.url(path),
|
|
330
|
-
return { bytes:
|
|
328
|
+
if (!res.ok) throw new HttpError(res.status, this.url(path), errText(body));
|
|
329
|
+
return { bytes: body, headers: res.headers };
|
|
331
330
|
}
|
|
332
331
|
};
|
|
333
|
-
|
|
332
|
+
function errText(body) {
|
|
334
333
|
try {
|
|
335
|
-
return new TextDecoder().decode(
|
|
334
|
+
return new TextDecoder().decode(body).slice(0, ERR_TEXT_CAP);
|
|
336
335
|
} catch {
|
|
337
336
|
return "";
|
|
338
337
|
}
|
|
@@ -1371,6 +1370,11 @@ async function preverifyOffer(opts) {
|
|
|
1371
1370
|
const w = rec.want ?? {};
|
|
1372
1371
|
const payto = w.payto && ADDR.test(String(w.payto).toLowerCase()) ? String(w.payto).toLowerCase() : seller;
|
|
1373
1372
|
const terms = (0, import_cairnx_core2.provenOfferTerms)(offerRec, blockHeight);
|
|
1373
|
+
if (payto === import_cairnx_core2.TREASURY_ADDR)
|
|
1374
|
+
return { ok: false, trust: "verified", blockHeight, reason: "the offer's payment recipient is the protocol treasury - the chain rejects it, and a fill would move CSD for nothing" };
|
|
1375
|
+
const provenExpiresEpoch = Number(app.expires_epoch);
|
|
1376
|
+
if (!Number.isSafeInteger(provenExpiresEpoch) || (0, import_cairnx_core2.epochOf)(blockHeight) > provenExpiresEpoch)
|
|
1377
|
+
return { ok: false, trust: "verified", blockHeight, reason: "the offer was already expired when it was mined - the chain rejects it, and a fill would move CSD for nothing" };
|
|
1374
1378
|
let outputPlan;
|
|
1375
1379
|
let sumsMismatch;
|
|
1376
1380
|
if (opts.pay !== void 0 && opts.pay !== null && !(0, import_cairnx_core2.isTokenWant)(offerRec.want) && offerRec.min === void 0) {
|
|
@@ -1522,7 +1526,7 @@ var CairnController = class {
|
|
|
1522
1526
|
};
|
|
1523
1527
|
|
|
1524
1528
|
// src/index.ts
|
|
1525
|
-
var DEFAULT_SPV_CHECKPOINT = { height:
|
|
1529
|
+
var DEFAULT_SPV_CHECKPOINT = { height: 101998, hash: "0x0000000000085295c9e13bbf276a11affb5470059235d1ea85d6334c8b43c49c" };
|
|
1526
1530
|
var DEFAULT_CAIRN = "https://cairn-substrate.com";
|
|
1527
1531
|
var SPV_HTTP_TIMEOUT_MS = 15e3;
|
|
1528
1532
|
var SPV_HTTP_MAX_RETRIES = 4;
|
package/dist/index.d.cts
CHANGED
|
@@ -160,7 +160,7 @@ declare function preverifyOffer(opts: {
|
|
|
160
160
|
|
|
161
161
|
/** Stable machine-readable error codes (branch on these, not the message text). */
|
|
162
162
|
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";
|
|
163
|
-
declare const SDK_VERSION = "0.4.
|
|
163
|
+
declare const SDK_VERSION = "0.4.4";
|
|
164
164
|
interface CairnErrorOptions {
|
|
165
165
|
code?: CairnErrorCode;
|
|
166
166
|
docsPath?: string;
|
|
@@ -180,7 +180,7 @@ declare class CairnError extends Error {
|
|
|
180
180
|
/** Relative docs path (under the SDK docs base), if any. */
|
|
181
181
|
readonly docsPath?: string;
|
|
182
182
|
/** The cairn-sdk version that produced this error. */
|
|
183
|
-
readonly version = "0.4.
|
|
183
|
+
readonly version = "0.4.4";
|
|
184
184
|
/**
|
|
185
185
|
* Whether a dApp may safely AUTO-retry this failure. `false` for fund-safety refusals and user-intent
|
|
186
186
|
* declines (the default); `true` only for provably transient infra faults where nothing was signed.
|
package/dist/index.d.ts
CHANGED
|
@@ -160,7 +160,7 @@ declare function preverifyOffer(opts: {
|
|
|
160
160
|
|
|
161
161
|
/** Stable machine-readable error codes (branch on these, not the message text). */
|
|
162
162
|
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";
|
|
163
|
-
declare const SDK_VERSION = "0.4.
|
|
163
|
+
declare const SDK_VERSION = "0.4.4";
|
|
164
164
|
interface CairnErrorOptions {
|
|
165
165
|
code?: CairnErrorCode;
|
|
166
166
|
docsPath?: string;
|
|
@@ -180,7 +180,7 @@ declare class CairnError extends Error {
|
|
|
180
180
|
/** Relative docs path (under the SDK docs base), if any. */
|
|
181
181
|
readonly docsPath?: string;
|
|
182
182
|
/** The cairn-sdk version that produced this error. */
|
|
183
|
-
readonly version = "0.4.
|
|
183
|
+
readonly version = "0.4.4";
|
|
184
184
|
/**
|
|
185
185
|
* Whether a dApp may safely AUTO-retry this failure. `false` for fund-safety refusals and user-intent
|
|
186
186
|
* declines (the default); `true` only for provably transient infra faults where nothing was signed.
|
package/dist/index.js
CHANGED
|
@@ -2,23 +2,23 @@ import {
|
|
|
2
2
|
Http,
|
|
3
3
|
RegistryClient,
|
|
4
4
|
readCapped
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-OFB365FB.js";
|
|
6
6
|
import {
|
|
7
7
|
BoardClient
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KLZ2MABC.js";
|
|
9
9
|
import {
|
|
10
10
|
Chain,
|
|
11
11
|
LightClient
|
|
12
12
|
} from "./chunk-C452UODV.js";
|
|
13
13
|
import {
|
|
14
14
|
ContentClient
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-EAQAJ2JH.js";
|
|
16
16
|
import {
|
|
17
17
|
IndexerClient
|
|
18
18
|
} from "./chunk-J5J4JEJ6.js";
|
|
19
19
|
import {
|
|
20
20
|
CairnController
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-WIJJJEAK.js";
|
|
22
22
|
import {
|
|
23
23
|
WalletConnection,
|
|
24
24
|
connect,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
discoverProviders,
|
|
27
27
|
getWallet,
|
|
28
28
|
isInstalled
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-UTYGJZAX.js";
|
|
30
30
|
import {
|
|
31
31
|
CairnError,
|
|
32
32
|
ContentVerificationError,
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
errorCode,
|
|
41
41
|
mapProviderError,
|
|
42
42
|
mapSubmitResultError
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-PHX4NZCI.js";
|
|
44
44
|
|
|
45
45
|
// src/names.ts
|
|
46
46
|
import { NAME_RE, RESERVED_NAMES } from "@inversealtruism/cairnx-core";
|
|
@@ -146,7 +146,9 @@ import {
|
|
|
146
146
|
fillEndorsement,
|
|
147
147
|
fillIsSafe,
|
|
148
148
|
requiredFillOutputs,
|
|
149
|
-
previewFill
|
|
149
|
+
previewFill,
|
|
150
|
+
TREASURY_ADDR,
|
|
151
|
+
epochOf
|
|
150
152
|
} from "@inversealtruism/cairnx-core";
|
|
151
153
|
var ADDR = /^0x[0-9a-f]{40}$/;
|
|
152
154
|
var HASH = /^0x[0-9a-f]{64}$/;
|
|
@@ -229,6 +231,11 @@ async function preverifyOffer(opts) {
|
|
|
229
231
|
const w = rec.want ?? {};
|
|
230
232
|
const payto = w.payto && ADDR.test(String(w.payto).toLowerCase()) ? String(w.payto).toLowerCase() : seller;
|
|
231
233
|
const terms = provenOfferTerms(offerRec, blockHeight);
|
|
234
|
+
if (payto === TREASURY_ADDR)
|
|
235
|
+
return { ok: false, trust: "verified", blockHeight, reason: "the offer's payment recipient is the protocol treasury - the chain rejects it, and a fill would move CSD for nothing" };
|
|
236
|
+
const provenExpiresEpoch = Number(app.expires_epoch);
|
|
237
|
+
if (!Number.isSafeInteger(provenExpiresEpoch) || epochOf(blockHeight) > provenExpiresEpoch)
|
|
238
|
+
return { ok: false, trust: "verified", blockHeight, reason: "the offer was already expired when it was mined - the chain rejects it, and a fill would move CSD for nothing" };
|
|
232
239
|
let outputPlan;
|
|
233
240
|
let sumsMismatch;
|
|
234
241
|
if (opts.pay !== void 0 && opts.pay !== null && !isTokenWant(offerRec.want) && offerRec.min === void 0) {
|
|
@@ -279,7 +286,7 @@ async function preverifyOffer(opts) {
|
|
|
279
286
|
}
|
|
280
287
|
|
|
281
288
|
// src/index.ts
|
|
282
|
-
var DEFAULT_SPV_CHECKPOINT = { height:
|
|
289
|
+
var DEFAULT_SPV_CHECKPOINT = { height: 101998, hash: "0x0000000000085295c9e13bbf276a11affb5470059235d1ea85d6334c8b43c49c" };
|
|
283
290
|
var DEFAULT_CAIRN = "https://cairn-substrate.com";
|
|
284
291
|
var SPV_HTTP_TIMEOUT_MS = 15e3;
|
|
285
292
|
var SPV_HTTP_MAX_RETRIES = 4;
|
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.4.
|
|
29
|
+
var SDK_VERSION = "0.4.4";
|
|
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-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-WIJJJEAK.js";
|
|
4
|
+
import "./chunk-UTYGJZAX.js";
|
|
5
|
+
import "./chunk-PHX4NZCI.js";
|
|
6
6
|
|
|
7
7
|
// src/react.ts
|
|
8
8
|
function createCairnHooks(React, controllerOrOpts) {
|
package/dist/registry.cjs
CHANGED
|
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(registry_exports);
|
|
|
36
36
|
var import_csd_registry = require("@inversealtruism/csd-registry");
|
|
37
37
|
|
|
38
38
|
// src/errors.ts
|
|
39
|
-
var SDK_VERSION = "0.4.
|
|
39
|
+
var SDK_VERSION = "0.4.4";
|
|
40
40
|
var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
|
|
41
41
|
var CairnError = class extends Error {
|
|
42
42
|
/** Stable machine code for programmatic branching. */
|
|
@@ -177,7 +177,8 @@ var Http = class {
|
|
|
177
177
|
},
|
|
178
178
|
body: opts?.body !== void 0 ? JSON.stringify(opts.body) : void 0
|
|
179
179
|
});
|
|
180
|
-
|
|
180
|
+
const body = await readCapped(res, this.maxBytes);
|
|
181
|
+
return { res, body };
|
|
181
182
|
} finally {
|
|
182
183
|
clearTimeout(timer);
|
|
183
184
|
}
|
|
@@ -195,13 +196,11 @@ var Http = class {
|
|
|
195
196
|
const url = this.url(path, query);
|
|
196
197
|
for (let attempt = 0; ; attempt++) {
|
|
197
198
|
try {
|
|
198
|
-
const res = await this.raw("GET", path, { query });
|
|
199
|
+
const { res, body } = await this.raw("GET", path, { query });
|
|
199
200
|
if (!res.ok) {
|
|
200
|
-
if (!(res.status >= 500 && attempt < this.retries)) throw new HttpError(res.status, url,
|
|
201
|
-
res.body?.cancel().catch(() => {
|
|
202
|
-
});
|
|
201
|
+
if (!(res.status >= 500 && attempt < this.retries)) throw new HttpError(res.status, url, errText(body));
|
|
203
202
|
} else {
|
|
204
|
-
return this.parseJson(res, new TextDecoder().decode(
|
|
203
|
+
return this.parseJson(res, new TextDecoder().decode(body), url);
|
|
205
204
|
}
|
|
206
205
|
} catch (e) {
|
|
207
206
|
if (e instanceof HttpError && e.status < 500) throw e;
|
|
@@ -212,21 +211,21 @@ var Http = class {
|
|
|
212
211
|
}
|
|
213
212
|
async postJson(path, body, headers) {
|
|
214
213
|
const url = this.url(path);
|
|
215
|
-
const res = await this.raw("POST", path, { body, headers });
|
|
216
|
-
if (!res.ok) throw new HttpError(res.status, url,
|
|
217
|
-
return this.parseJson(res, new TextDecoder().decode(
|
|
214
|
+
const { res, body: respBody } = await this.raw("POST", path, { body, headers });
|
|
215
|
+
if (!res.ok) throw new HttpError(res.status, url, errText(respBody));
|
|
216
|
+
return this.parseJson(res, new TextDecoder().decode(respBody), url);
|
|
218
217
|
}
|
|
219
218
|
/** GET raw bytes (for content retrieval). Returns null on 404. */
|
|
220
219
|
async getBytes(path) {
|
|
221
|
-
const res = await this.raw("GET", path);
|
|
220
|
+
const { res, body } = await this.raw("GET", path);
|
|
222
221
|
if (res.status === 404) return null;
|
|
223
|
-
if (!res.ok) throw new HttpError(res.status, this.url(path),
|
|
224
|
-
return { bytes:
|
|
222
|
+
if (!res.ok) throw new HttpError(res.status, this.url(path), errText(body));
|
|
223
|
+
return { bytes: body, headers: res.headers };
|
|
225
224
|
}
|
|
226
225
|
};
|
|
227
|
-
|
|
226
|
+
function errText(body) {
|
|
228
227
|
try {
|
|
229
|
-
return new TextDecoder().decode(
|
|
228
|
+
return new TextDecoder().decode(body).slice(0, ERR_TEXT_CAP);
|
|
230
229
|
} catch {
|
|
231
230
|
return "";
|
|
232
231
|
}
|
package/dist/registry.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inversealtruism/cairn-sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
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",
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
"README.md"
|
|
60
60
|
],
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@inversealtruism/cairnx-core": "0.1.
|
|
63
|
-
"@inversealtruism/csd-client": "0.1.
|
|
62
|
+
"@inversealtruism/cairnx-core": "0.1.42",
|
|
63
|
+
"@inversealtruism/csd-client": "0.1.16",
|
|
64
64
|
"@inversealtruism/csd-codec": "0.1.16",
|
|
65
65
|
"@inversealtruism/csd-crypto": "0.1.15",
|
|
66
|
-
"@inversealtruism/csd-light": "0.1.
|
|
66
|
+
"@inversealtruism/csd-light": "0.1.21",
|
|
67
67
|
"@inversealtruism/csd-registry": "0.1.17",
|
|
68
|
-
"@inversealtruism/csd-tx": "0.1.
|
|
68
|
+
"@inversealtruism/csd-tx": "0.1.18"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@inversealtruism/csd-siwc": "0.1.16",
|