@inversealtruism/cairn-sdk 0.4.6 → 0.6.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/README.md +13 -21
- package/dist/{chunk-ZFVE6MU7.js → chunk-2A4AJBO5.js} +1 -1
- package/dist/{chunk-2HP3ZXBO.js → chunk-67QBDZPW.js} +36 -5
- package/dist/{chunk-FWTPXLGV.js → chunk-BMH2MACB.js} +2 -2
- package/dist/{chunk-J5J4JEJ6.js → chunk-K5MGEYEU.js} +13 -3
- package/dist/{chunk-OB33SSGA.js → chunk-MLNW2RQB.js} +6 -3
- package/dist/{chunk-E4YQRWZZ.js → chunk-QEYBWBXC.js} +19 -8
- package/dist/connect.cjs +2 -2
- package/dist/connect.d.cts +2 -2
- package/dist/connect.d.ts +2 -2
- package/dist/connect.js +2 -2
- package/dist/content.cjs +18 -8
- package/dist/content.d.cts +8 -5
- package/dist/content.d.ts +8 -5
- package/dist/content.js +2 -2
- package/dist/controller.cjs +7 -4
- package/dist/controller.js +3 -3
- package/dist/index.cjs +214 -227
- package/dist/index.d.cts +54 -23
- package/dist/index.d.ts +54 -23
- package/dist/index.js +144 -53
- package/dist/indexer.cjs +13 -3
- package/dist/indexer.d.cts +3 -0
- package/dist/indexer.d.ts +3 -0
- package/dist/indexer.js +1 -1
- package/dist/react.cjs +12 -5
- package/dist/react.js +8 -4
- package/dist/registry.cjs +34 -5
- package/dist/registry.js +2 -2
- package/package.json +11 -17
- package/dist/board.cjs +0 -231
- package/dist/board.d.cts +0 -151
- package/dist/board.d.ts +0 -151
- package/dist/board.js +0 -7
- package/dist/chunk-E2MA75S3.js +0 -163
package/dist/index.d.cts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { H as Http, F as FetchLike } from './http-C9C4L4hz.cjs';
|
|
2
2
|
export { a as HttpOptions } from './http-C9C4L4hz.cjs';
|
|
3
3
|
import { Chain } from './chain.cjs';
|
|
4
|
-
import { BoardClient } from './board.cjs';
|
|
5
|
-
export { BoardItemContent, BoardWindow, ProposeInput, ProposeResult, RankedItem, SupportInput } from './board.cjs';
|
|
6
4
|
import { IndexerClient } from './indexer.cjs';
|
|
7
5
|
export { InclusionResult, IndexEvent, MerkleProof, StreamHandle, StreamHandlers, TrustLevel } from './indexer.cjs';
|
|
8
6
|
import { ContentClient } from './content.cjs';
|
|
9
7
|
export { ContentClientOptions, PreparedContent } from './content.cjs';
|
|
10
8
|
import { RegistryClient } from './registry.cjs';
|
|
9
|
+
import { NameState, MintedProvenOfferTerms } from '@inversealtruism/cairnx-core';
|
|
10
|
+
export { FillEndorsement, FillOutputPlan, FillPreview, FillSafety, MintedProvenOfferTerms, ProvenOfferTerms, bindOfferTerms, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, previewFill, requiredFillOutputs } from '@inversealtruism/cairnx-core';
|
|
11
11
|
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
|
-
import { ProvenOfferTerms } from '@inversealtruism/cairnx-core';
|
|
14
|
-
export { FillEndorsement, FillOutputPlan, FillPreview, FillSafety, ProvenOfferTerms, bindOfferTerms, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, previewFill, requiredFillOutputs } from '@inversealtruism/cairnx-core';
|
|
15
13
|
import { InclusionResult } from '@inversealtruism/csd-light';
|
|
16
14
|
export { CairnController, CairnControllerOptions, CairnState } from './controller.cjs';
|
|
17
15
|
import '@inversealtruism/csd-client';
|
|
@@ -75,6 +73,27 @@ interface PrimaryName {
|
|
|
75
73
|
address: string;
|
|
76
74
|
name?: string | null;
|
|
77
75
|
}
|
|
76
|
+
/** One `/cairnx/name-history` event: the txid a wallet fetches and merkle-verifies. `kind` is diagnostic only. */
|
|
77
|
+
interface NameHistoryEntry {
|
|
78
|
+
txid: string;
|
|
79
|
+
height: number;
|
|
80
|
+
pos: number;
|
|
81
|
+
kind: string;
|
|
82
|
+
}
|
|
83
|
+
/** `/cairnx/name-history/:name`: the server's current claim plus the UNTRUSTED txid hints a verifier replays. */
|
|
84
|
+
interface NameHistory {
|
|
85
|
+
ok: boolean;
|
|
86
|
+
name: string;
|
|
87
|
+
tipHeight: number;
|
|
88
|
+
/** the server's forward resolution (what a verifier recomputes and must match) */
|
|
89
|
+
resolve: Omit<NameResolution, "ok">;
|
|
90
|
+
/** the server's full name record */
|
|
91
|
+
record?: NameState;
|
|
92
|
+
events: NameHistoryEntry[];
|
|
93
|
+
/** `false`: replaying only `events` cannot prove this name's owner (see `caveat`); never treat a match as verified. */
|
|
94
|
+
scopedReplaySufficient: boolean;
|
|
95
|
+
caveat?: string;
|
|
96
|
+
}
|
|
78
97
|
/**
|
|
79
98
|
* Read client for the CairnX convention (names + token market) over a Cairn front door.
|
|
80
99
|
* Construct via the main `Cairn` class (`cairn.names`); all methods are read-only.
|
|
@@ -82,21 +101,24 @@ interface PrimaryName {
|
|
|
82
101
|
declare class NamesClient {
|
|
83
102
|
private readonly http;
|
|
84
103
|
constructor(http: Http);
|
|
104
|
+
private malformed;
|
|
105
|
+
private list;
|
|
85
106
|
/** Resolve a .csd name for DISPLAY (server-trusted; see the module trust note). null = unknown/invalid name. */
|
|
86
107
|
resolve(name: string): Promise<NameResolution | null>;
|
|
87
108
|
/** Full detail for one name (lease, lock, resting offer, recapture). null = not registered/invalid. */
|
|
88
109
|
name(name: string): Promise<NameDetail | null>;
|
|
89
|
-
/** The event history of one name (registrations, transfers, sets, renewals)
|
|
90
|
-
|
|
110
|
+
/** The event history of one name (registrations, transfers, sets, renewals) with the server's current
|
|
111
|
+
* claim. null = invalid or unregistered name. Throws a typed HttpError on a malformed body. */
|
|
112
|
+
nameHistory(name: string): Promise<NameHistory | null>;
|
|
91
113
|
/** Reverse lookup: an address's chosen primary .csd name (null name = none set). */
|
|
92
114
|
primary(addr: string): Promise<PrimaryName | null>;
|
|
93
115
|
/** All names an address owns (plus its primary), as served by `/cairnx/address/:addr`. */
|
|
94
116
|
namesOf(addr: string): Promise<unknown | null>;
|
|
95
117
|
/** All registered names (display list; short-edge-cached server-side). */
|
|
96
118
|
names(): Promise<unknown[]>;
|
|
97
|
-
/** All deployed tokens. */
|
|
119
|
+
/** All deployed tokens. Throws a typed HttpError if any row has a malformed ticker, decimals or amount. */
|
|
98
120
|
tokens(): Promise<TokenInfo[]>;
|
|
99
|
-
/** One token by ticker. null = unknown/invalid ticker. */
|
|
121
|
+
/** One token by ticker. null = unknown/invalid ticker. Throws a typed HttpError on a malformed body. */
|
|
100
122
|
token(ticker: string): Promise<TokenInfo | null>;
|
|
101
123
|
/** Open offers (the market's display list). */
|
|
102
124
|
offers(): Promise<unknown[]>;
|
|
@@ -117,17 +139,26 @@ interface OfferFillCheck {
|
|
|
117
139
|
transient?: boolean;
|
|
118
140
|
payto?: string;
|
|
119
141
|
seller?: string;
|
|
120
|
-
|
|
142
|
+
/** Minted by cairnx-core's `provenOfferTerms`, so it can be passed back to `bindOfferTerms` without the opt-out. */
|
|
143
|
+
terms?: MintedProvenOfferTerms;
|
|
121
144
|
blockHeight?: number;
|
|
122
145
|
/** B7b (REBIND W3/M1): the PROVEN CSD outputs to build for `pay` (a WHOLE fill of a non-partial offer),
|
|
123
146
|
* sized from the merkle-proven offer by the single-sourced `fillOutputPlan`. Present only when `pay` was
|
|
124
|
-
* passed and the offer could be sized. Build EXACTLY these; never the
|
|
125
|
-
* resolver could redirect. A partial (min-bearing) offer is left unsized
|
|
126
|
-
* not provable at this corroboration layer; the wallet's fill-SPV is the
|
|
147
|
+
* passed, the served offer carried a `status` and the offer could be sized. Build EXACTLY these; never the
|
|
148
|
+
* resolver-served outputs a lying resolver could redirect. A partial (min-bearing) offer is left unsized
|
|
149
|
+
* (its running paid/delivered is not provable at this corroboration layer; the wallet's fill-SPV is the
|
|
150
|
+
* payment-grade sizer). Liveness is never proven here: the plan is sized only for the status the resolver
|
|
151
|
+
* served, so an offer with no served status gets no plan. */
|
|
127
152
|
outputPlan?: {
|
|
128
153
|
to: string;
|
|
129
154
|
value: bigint;
|
|
130
155
|
}[];
|
|
156
|
+
/** Present when `plannedOutputs` was passed: `true` when they were bound to `outputPlan` (a mismatch
|
|
157
|
+
* refuses with `ok: false`), `false` when there was no proven plan to bind them to (`planReason` says why).
|
|
158
|
+
* `ok: true` with `planBound: false` means your planned outputs were NOT checked. */
|
|
159
|
+
planBound?: boolean;
|
|
160
|
+
/** Why no output plan was sized (set whenever `outputPlan` is absent after `pay` or `plannedOutputs` was passed). */
|
|
161
|
+
planReason?: string;
|
|
131
162
|
}
|
|
132
163
|
|
|
133
164
|
/**
|
|
@@ -159,8 +190,8 @@ declare function preverifyOffer(opts: {
|
|
|
159
190
|
}): Promise<OfferFillCheck>;
|
|
160
191
|
|
|
161
192
|
/** Stable machine-readable error codes (branch on these, not the message text). */
|
|
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" | "OFFER_SOURCE_CONFLICT" | "FILL_LEGACY_SUNSET" | "VERIFY_HORIZON" | "VERIFY_UNREPRESENTABLE" | "WALLET_UNAVAILABLE" | "REVIEW_REQUIRED" | "UNKNOWN";
|
|
163
|
-
declare const SDK_VERSION = "0.
|
|
193
|
+
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";
|
|
164
195
|
interface CairnErrorOptions {
|
|
165
196
|
code?: CairnErrorCode;
|
|
166
197
|
docsPath?: string;
|
|
@@ -180,7 +211,7 @@ declare class CairnError extends Error {
|
|
|
180
211
|
/** Relative docs path (under the SDK docs base), if any. */
|
|
181
212
|
readonly docsPath?: string;
|
|
182
213
|
/** The cairn-sdk version that produced this error. */
|
|
183
|
-
readonly version = "0.
|
|
214
|
+
readonly version = "0.6.0";
|
|
184
215
|
/**
|
|
185
216
|
* Whether a dApp may safely AUTO-retry this failure. `false` for fund-safety refusals and user-intent
|
|
186
217
|
* declines (the default); `true` only for provably transient infra faults where nothing was signed.
|
|
@@ -260,7 +291,7 @@ declare function mapSubmitResultError(result: {
|
|
|
260
291
|
declare function errorCode(err: unknown): CairnErrorCode;
|
|
261
292
|
|
|
262
293
|
interface CairnBaseUrls {
|
|
263
|
-
/** Cairn
|
|
294
|
+
/** Cairn server (/api/rpc proxy, /api/headers, /content origin, /trade/api names reads). Default https://cairn-substrate.com */
|
|
264
295
|
cairn?: string;
|
|
265
296
|
/** Node RPC base. Default `${cairn}/api/rpc` (the public proxy — no local node needed). */
|
|
266
297
|
rpc?: string;
|
|
@@ -315,7 +346,6 @@ declare class Cairn {
|
|
|
315
346
|
readonly registry: RegistryClient;
|
|
316
347
|
/** .csd names + CairnX market READS (server-trusted display reads; see names.ts trust note). */
|
|
317
348
|
readonly names: NamesClient;
|
|
318
|
-
board: BoardClient;
|
|
319
349
|
wallet?: WalletConnection;
|
|
320
350
|
private readonly cairnHttp;
|
|
321
351
|
private _spvLight;
|
|
@@ -331,12 +361,13 @@ declare class Cairn {
|
|
|
331
361
|
* to the honest "proof-consistent" instead of over-claiming "verified-inclusion". The verified
|
|
332
362
|
* header chain is cached across calls; the first call near tip syncs the post-checkpoint span.
|
|
333
363
|
* MF-03: a STRUCTURAL forward-sync break (a reorg orphaned the cached tip) reseeds ONCE via
|
|
334
|
-
* withSpvReseed.
|
|
335
|
-
*
|
|
336
|
-
*
|
|
364
|
+
* withSpvReseed. A height within SPV_RECHECK_DEPTH of the cached tip is re-checked against the served
|
|
365
|
+
* chain first (recheckCachedHeader), so a block orphaned after it was cached stops backing
|
|
366
|
+
* "verified-inclusion". Deeper heights answer from the cache with no network touch.
|
|
337
367
|
*/
|
|
338
368
|
private verifiedHeaderMerkleAt;
|
|
339
369
|
private withSpvReseed;
|
|
370
|
+
private recheckCachedHeader;
|
|
340
371
|
private seedFreshSpvLight;
|
|
341
372
|
/** The PoW-verifying SPV light client, seeded from the pinned checkpoint and cached across calls
|
|
342
373
|
* (shared by the M3 header-merkle bind and the F13 offer pre-verify). The client is committed to
|
|
@@ -383,8 +414,8 @@ declare class Cairn {
|
|
|
383
414
|
plannedOutputs?: Record<string, bigint | string | number>;
|
|
384
415
|
}): Promise<OfferFillCheck>;
|
|
385
416
|
/**
|
|
386
|
-
* Detect + connect the Cairn Wallet (browser only)
|
|
387
|
-
*
|
|
417
|
+
* Detect + connect the Cairn Wallet (browser only) and attach it as `cairn.wallet`.
|
|
418
|
+
* Resolves to the connected address.
|
|
388
419
|
*/
|
|
389
420
|
connect(opts?: DetectOptions): Promise<string>;
|
|
390
421
|
/** Attach an already-connected wallet (e.g. one you constructed yourself). */
|
|
@@ -393,4 +424,4 @@ declare class Cairn {
|
|
|
393
424
|
get connected(): boolean;
|
|
394
425
|
}
|
|
395
426
|
|
|
396
|
-
export {
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { H as Http, F as FetchLike } from './http-C9C4L4hz.js';
|
|
2
2
|
export { a as HttpOptions } from './http-C9C4L4hz.js';
|
|
3
3
|
import { Chain } from './chain.js';
|
|
4
|
-
import { BoardClient } from './board.js';
|
|
5
|
-
export { BoardItemContent, BoardWindow, ProposeInput, ProposeResult, RankedItem, SupportInput } from './board.js';
|
|
6
4
|
import { IndexerClient } from './indexer.js';
|
|
7
5
|
export { InclusionResult, IndexEvent, MerkleProof, StreamHandle, StreamHandlers, TrustLevel } from './indexer.js';
|
|
8
6
|
import { ContentClient } from './content.js';
|
|
9
7
|
export { ContentClientOptions, PreparedContent } from './content.js';
|
|
10
8
|
import { RegistryClient } from './registry.js';
|
|
9
|
+
import { NameState, MintedProvenOfferTerms } from '@inversealtruism/cairnx-core';
|
|
10
|
+
export { FillEndorsement, FillOutputPlan, FillPreview, FillSafety, MintedProvenOfferTerms, ProvenOfferTerms, bindOfferTerms, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, previewFill, requiredFillOutputs } from '@inversealtruism/cairnx-core';
|
|
11
11
|
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
|
-
import { ProvenOfferTerms } from '@inversealtruism/cairnx-core';
|
|
14
|
-
export { FillEndorsement, FillOutputPlan, FillPreview, FillSafety, ProvenOfferTerms, bindOfferTerms, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, previewFill, requiredFillOutputs } from '@inversealtruism/cairnx-core';
|
|
15
13
|
import { InclusionResult } from '@inversealtruism/csd-light';
|
|
16
14
|
export { CairnController, CairnControllerOptions, CairnState } from './controller.js';
|
|
17
15
|
import '@inversealtruism/csd-client';
|
|
@@ -75,6 +73,27 @@ interface PrimaryName {
|
|
|
75
73
|
address: string;
|
|
76
74
|
name?: string | null;
|
|
77
75
|
}
|
|
76
|
+
/** One `/cairnx/name-history` event: the txid a wallet fetches and merkle-verifies. `kind` is diagnostic only. */
|
|
77
|
+
interface NameHistoryEntry {
|
|
78
|
+
txid: string;
|
|
79
|
+
height: number;
|
|
80
|
+
pos: number;
|
|
81
|
+
kind: string;
|
|
82
|
+
}
|
|
83
|
+
/** `/cairnx/name-history/:name`: the server's current claim plus the UNTRUSTED txid hints a verifier replays. */
|
|
84
|
+
interface NameHistory {
|
|
85
|
+
ok: boolean;
|
|
86
|
+
name: string;
|
|
87
|
+
tipHeight: number;
|
|
88
|
+
/** the server's forward resolution (what a verifier recomputes and must match) */
|
|
89
|
+
resolve: Omit<NameResolution, "ok">;
|
|
90
|
+
/** the server's full name record */
|
|
91
|
+
record?: NameState;
|
|
92
|
+
events: NameHistoryEntry[];
|
|
93
|
+
/** `false`: replaying only `events` cannot prove this name's owner (see `caveat`); never treat a match as verified. */
|
|
94
|
+
scopedReplaySufficient: boolean;
|
|
95
|
+
caveat?: string;
|
|
96
|
+
}
|
|
78
97
|
/**
|
|
79
98
|
* Read client for the CairnX convention (names + token market) over a Cairn front door.
|
|
80
99
|
* Construct via the main `Cairn` class (`cairn.names`); all methods are read-only.
|
|
@@ -82,21 +101,24 @@ interface PrimaryName {
|
|
|
82
101
|
declare class NamesClient {
|
|
83
102
|
private readonly http;
|
|
84
103
|
constructor(http: Http);
|
|
104
|
+
private malformed;
|
|
105
|
+
private list;
|
|
85
106
|
/** Resolve a .csd name for DISPLAY (server-trusted; see the module trust note). null = unknown/invalid name. */
|
|
86
107
|
resolve(name: string): Promise<NameResolution | null>;
|
|
87
108
|
/** Full detail for one name (lease, lock, resting offer, recapture). null = not registered/invalid. */
|
|
88
109
|
name(name: string): Promise<NameDetail | null>;
|
|
89
|
-
/** The event history of one name (registrations, transfers, sets, renewals)
|
|
90
|
-
|
|
110
|
+
/** The event history of one name (registrations, transfers, sets, renewals) with the server's current
|
|
111
|
+
* claim. null = invalid or unregistered name. Throws a typed HttpError on a malformed body. */
|
|
112
|
+
nameHistory(name: string): Promise<NameHistory | null>;
|
|
91
113
|
/** Reverse lookup: an address's chosen primary .csd name (null name = none set). */
|
|
92
114
|
primary(addr: string): Promise<PrimaryName | null>;
|
|
93
115
|
/** All names an address owns (plus its primary), as served by `/cairnx/address/:addr`. */
|
|
94
116
|
namesOf(addr: string): Promise<unknown | null>;
|
|
95
117
|
/** All registered names (display list; short-edge-cached server-side). */
|
|
96
118
|
names(): Promise<unknown[]>;
|
|
97
|
-
/** All deployed tokens. */
|
|
119
|
+
/** All deployed tokens. Throws a typed HttpError if any row has a malformed ticker, decimals or amount. */
|
|
98
120
|
tokens(): Promise<TokenInfo[]>;
|
|
99
|
-
/** One token by ticker. null = unknown/invalid ticker. */
|
|
121
|
+
/** One token by ticker. null = unknown/invalid ticker. Throws a typed HttpError on a malformed body. */
|
|
100
122
|
token(ticker: string): Promise<TokenInfo | null>;
|
|
101
123
|
/** Open offers (the market's display list). */
|
|
102
124
|
offers(): Promise<unknown[]>;
|
|
@@ -117,17 +139,26 @@ interface OfferFillCheck {
|
|
|
117
139
|
transient?: boolean;
|
|
118
140
|
payto?: string;
|
|
119
141
|
seller?: string;
|
|
120
|
-
|
|
142
|
+
/** Minted by cairnx-core's `provenOfferTerms`, so it can be passed back to `bindOfferTerms` without the opt-out. */
|
|
143
|
+
terms?: MintedProvenOfferTerms;
|
|
121
144
|
blockHeight?: number;
|
|
122
145
|
/** B7b (REBIND W3/M1): the PROVEN CSD outputs to build for `pay` (a WHOLE fill of a non-partial offer),
|
|
123
146
|
* sized from the merkle-proven offer by the single-sourced `fillOutputPlan`. Present only when `pay` was
|
|
124
|
-
* passed and the offer could be sized. Build EXACTLY these; never the
|
|
125
|
-
* resolver could redirect. A partial (min-bearing) offer is left unsized
|
|
126
|
-
* not provable at this corroboration layer; the wallet's fill-SPV is the
|
|
147
|
+
* passed, the served offer carried a `status` and the offer could be sized. Build EXACTLY these; never the
|
|
148
|
+
* resolver-served outputs a lying resolver could redirect. A partial (min-bearing) offer is left unsized
|
|
149
|
+
* (its running paid/delivered is not provable at this corroboration layer; the wallet's fill-SPV is the
|
|
150
|
+
* payment-grade sizer). Liveness is never proven here: the plan is sized only for the status the resolver
|
|
151
|
+
* served, so an offer with no served status gets no plan. */
|
|
127
152
|
outputPlan?: {
|
|
128
153
|
to: string;
|
|
129
154
|
value: bigint;
|
|
130
155
|
}[];
|
|
156
|
+
/** Present when `plannedOutputs` was passed: `true` when they were bound to `outputPlan` (a mismatch
|
|
157
|
+
* refuses with `ok: false`), `false` when there was no proven plan to bind them to (`planReason` says why).
|
|
158
|
+
* `ok: true` with `planBound: false` means your planned outputs were NOT checked. */
|
|
159
|
+
planBound?: boolean;
|
|
160
|
+
/** Why no output plan was sized (set whenever `outputPlan` is absent after `pay` or `plannedOutputs` was passed). */
|
|
161
|
+
planReason?: string;
|
|
131
162
|
}
|
|
132
163
|
|
|
133
164
|
/**
|
|
@@ -159,8 +190,8 @@ declare function preverifyOffer(opts: {
|
|
|
159
190
|
}): Promise<OfferFillCheck>;
|
|
160
191
|
|
|
161
192
|
/** Stable machine-readable error codes (branch on these, not the message text). */
|
|
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" | "OFFER_SOURCE_CONFLICT" | "FILL_LEGACY_SUNSET" | "VERIFY_HORIZON" | "VERIFY_UNREPRESENTABLE" | "WALLET_UNAVAILABLE" | "REVIEW_REQUIRED" | "UNKNOWN";
|
|
163
|
-
declare const SDK_VERSION = "0.
|
|
193
|
+
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";
|
|
164
195
|
interface CairnErrorOptions {
|
|
165
196
|
code?: CairnErrorCode;
|
|
166
197
|
docsPath?: string;
|
|
@@ -180,7 +211,7 @@ declare class CairnError extends Error {
|
|
|
180
211
|
/** Relative docs path (under the SDK docs base), if any. */
|
|
181
212
|
readonly docsPath?: string;
|
|
182
213
|
/** The cairn-sdk version that produced this error. */
|
|
183
|
-
readonly version = "0.
|
|
214
|
+
readonly version = "0.6.0";
|
|
184
215
|
/**
|
|
185
216
|
* Whether a dApp may safely AUTO-retry this failure. `false` for fund-safety refusals and user-intent
|
|
186
217
|
* declines (the default); `true` only for provably transient infra faults where nothing was signed.
|
|
@@ -260,7 +291,7 @@ declare function mapSubmitResultError(result: {
|
|
|
260
291
|
declare function errorCode(err: unknown): CairnErrorCode;
|
|
261
292
|
|
|
262
293
|
interface CairnBaseUrls {
|
|
263
|
-
/** Cairn
|
|
294
|
+
/** Cairn server (/api/rpc proxy, /api/headers, /content origin, /trade/api names reads). Default https://cairn-substrate.com */
|
|
264
295
|
cairn?: string;
|
|
265
296
|
/** Node RPC base. Default `${cairn}/api/rpc` (the public proxy — no local node needed). */
|
|
266
297
|
rpc?: string;
|
|
@@ -315,7 +346,6 @@ declare class Cairn {
|
|
|
315
346
|
readonly registry: RegistryClient;
|
|
316
347
|
/** .csd names + CairnX market READS (server-trusted display reads; see names.ts trust note). */
|
|
317
348
|
readonly names: NamesClient;
|
|
318
|
-
board: BoardClient;
|
|
319
349
|
wallet?: WalletConnection;
|
|
320
350
|
private readonly cairnHttp;
|
|
321
351
|
private _spvLight;
|
|
@@ -331,12 +361,13 @@ declare class Cairn {
|
|
|
331
361
|
* to the honest "proof-consistent" instead of over-claiming "verified-inclusion". The verified
|
|
332
362
|
* header chain is cached across calls; the first call near tip syncs the post-checkpoint span.
|
|
333
363
|
* MF-03: a STRUCTURAL forward-sync break (a reorg orphaned the cached tip) reseeds ONCE via
|
|
334
|
-
* withSpvReseed.
|
|
335
|
-
*
|
|
336
|
-
*
|
|
364
|
+
* withSpvReseed. A height within SPV_RECHECK_DEPTH of the cached tip is re-checked against the served
|
|
365
|
+
* chain first (recheckCachedHeader), so a block orphaned after it was cached stops backing
|
|
366
|
+
* "verified-inclusion". Deeper heights answer from the cache with no network touch.
|
|
337
367
|
*/
|
|
338
368
|
private verifiedHeaderMerkleAt;
|
|
339
369
|
private withSpvReseed;
|
|
370
|
+
private recheckCachedHeader;
|
|
340
371
|
private seedFreshSpvLight;
|
|
341
372
|
/** The PoW-verifying SPV light client, seeded from the pinned checkpoint and cached across calls
|
|
342
373
|
* (shared by the M3 header-merkle bind and the F13 offer pre-verify). The client is committed to
|
|
@@ -383,8 +414,8 @@ declare class Cairn {
|
|
|
383
414
|
plannedOutputs?: Record<string, bigint | string | number>;
|
|
384
415
|
}): Promise<OfferFillCheck>;
|
|
385
416
|
/**
|
|
386
|
-
* Detect + connect the Cairn Wallet (browser only)
|
|
387
|
-
*
|
|
417
|
+
* Detect + connect the Cairn Wallet (browser only) and attach it as `cairn.wallet`.
|
|
418
|
+
* Resolves to the connected address.
|
|
388
419
|
*/
|
|
389
420
|
connect(opts?: DetectOptions): Promise<string>;
|
|
390
421
|
/** Attach an already-connected wallet (e.g. one you constructed yourself). */
|
|
@@ -393,4 +424,4 @@ declare class Cairn {
|
|
|
393
424
|
get connected(): boolean;
|
|
394
425
|
}
|
|
395
426
|
|
|
396
|
-
export {
|
|
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 };
|