@inversealtruism/csd-client 0.1.13 → 0.1.15
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 +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/package.json +15 -7
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Typed HTTP RPC client for a Compute Substrate node (or the Cairn proxy / a discovered gateway): tip, block, tx, utxos, proposals, top, domains, mempool, submit, templates.
|
|
4
4
|
|
|
5
|
-
Part of the [Compute Substrate SDK](https://github.com/InverseAltruism/csd-sdk) (L0). Zero `Buffer
|
|
5
|
+
Part of the [Compute Substrate SDK](https://github.com/InverseAltruism/csd-sdk) (L0). Zero `Buffer`, runs in Node, browsers, and MV3 service workers. Deps: `@noble/*` only.
|
|
6
6
|
|
|
7
7
|
```
|
|
8
8
|
npm i @inversealtruism/csd-client
|
package/dist/index.cjs
CHANGED
|
@@ -50,10 +50,10 @@ var CsdClient = class {
|
|
|
50
50
|
const r = await this.f(`${this.base}${path}`, { ...init, signal: AbortSignal.timeout(this.timeoutMs) });
|
|
51
51
|
if (r.status >= 500 && attempt < maxRetries) {
|
|
52
52
|
lastErr = new Error(`HTTP ${r.status}`);
|
|
53
|
-
} else if (!r.ok) throw new Error(`${init?.method ?? "GET"} ${path} \u2192 HTTP ${r.status}`);
|
|
53
|
+
} else if (!r.ok) throw Object.assign(new Error(`${init?.method ?? "GET"} ${path} \u2192 HTTP ${r.status}`), { terminal: r.status < 500 });
|
|
54
54
|
else return await this.readCapped(r, path);
|
|
55
55
|
} catch (e) {
|
|
56
|
-
if (attempt >= maxRetries) throw e;
|
|
56
|
+
if (attempt >= maxRetries || e?.terminal) throw e;
|
|
57
57
|
lastErr = e;
|
|
58
58
|
}
|
|
59
59
|
const cap = Math.min(5e3, 250 * 2 ** attempt);
|
package/dist/index.d.cts
CHANGED
|
@@ -139,7 +139,7 @@ declare class CsdClient {
|
|
|
139
139
|
private post;
|
|
140
140
|
private getOk;
|
|
141
141
|
tip(): Promise<RpcTip>;
|
|
142
|
-
health(): Promise<
|
|
142
|
+
health(): Promise<RpcHealth>;
|
|
143
143
|
blockByHeight(h: number): Promise<RpcBlock>;
|
|
144
144
|
blockByHash(hash: string): Promise<RpcBlock>;
|
|
145
145
|
tx(id: string): Promise<RpcTxInfo>;
|
|
@@ -172,8 +172,8 @@ declare class CsdClient {
|
|
|
172
172
|
submit(nodeJsonTx: unknown): Promise<RpcSubmit>;
|
|
173
173
|
/** As `submit`, but throws on node rejection (`ok:false`) instead of returning a misleading txid. */
|
|
174
174
|
submitOrThrow(nodeJsonTx: unknown): Promise<RpcSubmit>;
|
|
175
|
-
templatePropose(body: unknown): Promise<
|
|
176
|
-
templateAttest(body: unknown): Promise<
|
|
175
|
+
templatePropose(body: unknown): Promise<unknown>;
|
|
176
|
+
templateAttest(body: unknown): Promise<unknown>;
|
|
177
177
|
}
|
|
178
178
|
/** Convert a node /tx or /block tx JSON back into the codec's Tx struct (for re-verification). */
|
|
179
179
|
declare function rpcTxToTx(j: RpcTxJson): Tx;
|
|
@@ -187,7 +187,7 @@ declare function rpcTxToTx(j: RpcTxJson): Tx;
|
|
|
187
187
|
* call this before assembling a spend; csd-tx itself is pure and cannot fetch.
|
|
188
188
|
* (Mirrors the proven cairn-wallet `node.ts` implementation; the wallet's TXB-1 cure made canonical.) */
|
|
189
189
|
declare function verifyInputValues(client: {
|
|
190
|
-
tx(id: string): Promise<
|
|
190
|
+
tx(id: string): Promise<RpcTxInfo>;
|
|
191
191
|
}, inputs: {
|
|
192
192
|
txid: string;
|
|
193
193
|
vout: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -139,7 +139,7 @@ declare class CsdClient {
|
|
|
139
139
|
private post;
|
|
140
140
|
private getOk;
|
|
141
141
|
tip(): Promise<RpcTip>;
|
|
142
|
-
health(): Promise<
|
|
142
|
+
health(): Promise<RpcHealth>;
|
|
143
143
|
blockByHeight(h: number): Promise<RpcBlock>;
|
|
144
144
|
blockByHash(hash: string): Promise<RpcBlock>;
|
|
145
145
|
tx(id: string): Promise<RpcTxInfo>;
|
|
@@ -172,8 +172,8 @@ declare class CsdClient {
|
|
|
172
172
|
submit(nodeJsonTx: unknown): Promise<RpcSubmit>;
|
|
173
173
|
/** As `submit`, but throws on node rejection (`ok:false`) instead of returning a misleading txid. */
|
|
174
174
|
submitOrThrow(nodeJsonTx: unknown): Promise<RpcSubmit>;
|
|
175
|
-
templatePropose(body: unknown): Promise<
|
|
176
|
-
templateAttest(body: unknown): Promise<
|
|
175
|
+
templatePropose(body: unknown): Promise<unknown>;
|
|
176
|
+
templateAttest(body: unknown): Promise<unknown>;
|
|
177
177
|
}
|
|
178
178
|
/** Convert a node /tx or /block tx JSON back into the codec's Tx struct (for re-verification). */
|
|
179
179
|
declare function rpcTxToTx(j: RpcTxJson): Tx;
|
|
@@ -187,7 +187,7 @@ declare function rpcTxToTx(j: RpcTxJson): Tx;
|
|
|
187
187
|
* call this before assembling a spend; csd-tx itself is pure and cannot fetch.
|
|
188
188
|
* (Mirrors the proven cairn-wallet `node.ts` implementation; the wallet's TXB-1 cure made canonical.) */
|
|
189
189
|
declare function verifyInputValues(client: {
|
|
190
|
-
tx(id: string): Promise<
|
|
190
|
+
tx(id: string): Promise<RpcTxInfo>;
|
|
191
191
|
}, inputs: {
|
|
192
192
|
txid: string;
|
|
193
193
|
vout: number;
|
package/dist/index.js
CHANGED
|
@@ -23,10 +23,10 @@ var CsdClient = class {
|
|
|
23
23
|
const r = await this.f(`${this.base}${path}`, { ...init, signal: AbortSignal.timeout(this.timeoutMs) });
|
|
24
24
|
if (r.status >= 500 && attempt < maxRetries) {
|
|
25
25
|
lastErr = new Error(`HTTP ${r.status}`);
|
|
26
|
-
} else if (!r.ok) throw new Error(`${init?.method ?? "GET"} ${path} \u2192 HTTP ${r.status}`);
|
|
26
|
+
} else if (!r.ok) throw Object.assign(new Error(`${init?.method ?? "GET"} ${path} \u2192 HTTP ${r.status}`), { terminal: r.status < 500 });
|
|
27
27
|
else return await this.readCapped(r, path);
|
|
28
28
|
} catch (e) {
|
|
29
|
-
if (attempt >= maxRetries) throw e;
|
|
29
|
+
if (attempt >= maxRetries || e?.terminal) throw e;
|
|
30
30
|
lastErr = e;
|
|
31
31
|
}
|
|
32
32
|
const cap = Math.min(5e3, 250 * 2 ** attempt);
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inversealtruism/csd-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": ">=18"
|
|
6
|
+
},
|
|
4
7
|
"description": "Typed HTTP RPC client for a Compute Substrate node (or the Cairn proxy / a discovered gateway) — tip/block/tx/utxos/proposals/top/domains/mempool/submit/templates.",
|
|
5
8
|
"type": "module",
|
|
6
9
|
"main": "./dist/index.cjs",
|
|
@@ -8,9 +11,14 @@
|
|
|
8
11
|
"types": "./dist/index.d.ts",
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.cts",
|
|
20
|
+
"default": "./dist/index.cjs"
|
|
21
|
+
}
|
|
14
22
|
}
|
|
15
23
|
},
|
|
16
24
|
"files": [
|
|
@@ -19,12 +27,12 @@
|
|
|
19
27
|
"README.md"
|
|
20
28
|
],
|
|
21
29
|
"dependencies": {
|
|
22
|
-
"@inversealtruism/csd-codec": "0.1.
|
|
30
|
+
"@inversealtruism/csd-codec": "0.1.15"
|
|
23
31
|
},
|
|
24
32
|
"license": "MIT",
|
|
25
33
|
"sideEffects": false,
|
|
26
34
|
"devDependencies": {
|
|
27
|
-
"@inversealtruism/csd-vectors": "0.1.
|
|
35
|
+
"@inversealtruism/csd-vectors": "0.1.15"
|
|
28
36
|
},
|
|
29
37
|
"publishConfig": {
|
|
30
38
|
"access": "public"
|
|
@@ -37,6 +45,6 @@
|
|
|
37
45
|
"homepage": "https://cairn-substrate.com",
|
|
38
46
|
"scripts": {
|
|
39
47
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
40
|
-
"test": "tsx test/client.test.ts"
|
|
48
|
+
"test": "tsx test/client.test.ts && tsx test/hostile.test.ts"
|
|
41
49
|
}
|
|
42
50
|
}
|