@inversealtruism/cairn-sdk 0.4.5 → 0.5.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-SWCUE26T.js → chunk-5RGFC2JR.js} +2 -2
- package/dist/{chunk-WZFWAEXL.js → chunk-BL6VFALH.js} +36 -5
- package/dist/{chunk-FX5LLMNP.js → chunk-CZAQNZZG.js} +19 -8
- package/dist/{chunk-J5J4JEJ6.js → chunk-K5MGEYEU.js} +13 -3
- package/dist/{chunk-XW3IFE6K.js → chunk-OE5BEEQY.js} +6 -3
- package/dist/{chunk-LOAOBV36.js → chunk-OSPAN7GX.js} +7 -3
- package/dist/connect.cjs +8 -4
- 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 +13 -6
- package/dist/controller.js +3 -3
- package/dist/index.cjs +220 -229
- package/dist/index.d.cts +52 -22
- package/dist/index.d.ts +52 -22
- 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 +18 -7
- package/dist/react.js +8 -4
- package/dist/registry.cjs +34 -5
- package/dist/registry.js +2 -2
- package/package.json +3 -9
- 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-IGJ46AYP.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, ProvenOfferTerms } from '@inversealtruism/cairnx-core';
|
|
10
|
+
export { FillEndorsement, FillOutputPlan, FillPreview, FillSafety, 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[]>;
|
|
@@ -121,13 +143,21 @@ interface OfferFillCheck {
|
|
|
121
143
|
blockHeight?: number;
|
|
122
144
|
/** B7b (REBIND W3/M1): the PROVEN CSD outputs to build for `pay` (a WHOLE fill of a non-partial offer),
|
|
123
145
|
* 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
|
|
146
|
+
* passed, the served offer carried a `status` and the offer could be sized. Build EXACTLY these; never the
|
|
147
|
+
* resolver-served outputs a lying resolver could redirect. A partial (min-bearing) offer is left unsized
|
|
148
|
+
* (its running paid/delivered is not provable at this corroboration layer; the wallet's fill-SPV is the
|
|
149
|
+
* payment-grade sizer). Liveness is never proven here: the plan is sized only for the status the resolver
|
|
150
|
+
* served, so an offer with no served status gets no plan. */
|
|
127
151
|
outputPlan?: {
|
|
128
152
|
to: string;
|
|
129
153
|
value: bigint;
|
|
130
154
|
}[];
|
|
155
|
+
/** Present when `plannedOutputs` was passed: `true` when they were bound to `outputPlan` (a mismatch
|
|
156
|
+
* refuses with `ok: false`), `false` when there was no proven plan to bind them to (`planReason` says why).
|
|
157
|
+
* `ok: true` with `planBound: false` means your planned outputs were NOT checked. */
|
|
158
|
+
planBound?: boolean;
|
|
159
|
+
/** Why no output plan was sized (set whenever `outputPlan` is absent after `pay` or `plannedOutputs` was passed). */
|
|
160
|
+
planReason?: string;
|
|
131
161
|
}
|
|
132
162
|
|
|
133
163
|
/**
|
|
@@ -159,8 +189,8 @@ declare function preverifyOffer(opts: {
|
|
|
159
189
|
}): Promise<OfferFillCheck>;
|
|
160
190
|
|
|
161
191
|
/** 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" | "UNKNOWN";
|
|
163
|
-
declare const SDK_VERSION = "0.
|
|
192
|
+
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";
|
|
193
|
+
declare const SDK_VERSION = "0.5.0";
|
|
164
194
|
interface CairnErrorOptions {
|
|
165
195
|
code?: CairnErrorCode;
|
|
166
196
|
docsPath?: string;
|
|
@@ -180,7 +210,7 @@ declare class CairnError extends Error {
|
|
|
180
210
|
/** Relative docs path (under the SDK docs base), if any. */
|
|
181
211
|
readonly docsPath?: string;
|
|
182
212
|
/** The cairn-sdk version that produced this error. */
|
|
183
|
-
readonly version = "0.
|
|
213
|
+
readonly version = "0.5.0";
|
|
184
214
|
/**
|
|
185
215
|
* Whether a dApp may safely AUTO-retry this failure. `false` for fund-safety refusals and user-intent
|
|
186
216
|
* declines (the default); `true` only for provably transient infra faults where nothing was signed.
|
|
@@ -260,7 +290,7 @@ declare function mapSubmitResultError(result: {
|
|
|
260
290
|
declare function errorCode(err: unknown): CairnErrorCode;
|
|
261
291
|
|
|
262
292
|
interface CairnBaseUrls {
|
|
263
|
-
/** Cairn
|
|
293
|
+
/** Cairn server (/api/rpc proxy, /api/headers, /content origin, /trade/api names reads). Default https://cairn-substrate.com */
|
|
264
294
|
cairn?: string;
|
|
265
295
|
/** Node RPC base. Default `${cairn}/api/rpc` (the public proxy — no local node needed). */
|
|
266
296
|
rpc?: string;
|
|
@@ -315,7 +345,6 @@ declare class Cairn {
|
|
|
315
345
|
readonly registry: RegistryClient;
|
|
316
346
|
/** .csd names + CairnX market READS (server-trusted display reads; see names.ts trust note). */
|
|
317
347
|
readonly names: NamesClient;
|
|
318
|
-
board: BoardClient;
|
|
319
348
|
wallet?: WalletConnection;
|
|
320
349
|
private readonly cairnHttp;
|
|
321
350
|
private _spvLight;
|
|
@@ -331,12 +360,13 @@ declare class Cairn {
|
|
|
331
360
|
* to the honest "proof-consistent" instead of over-claiming "verified-inclusion". The verified
|
|
332
361
|
* header chain is cached across calls; the first call near tip syncs the post-checkpoint span.
|
|
333
362
|
* MF-03: a STRUCTURAL forward-sync break (a reorg orphaned the cached tip) reseeds ONCE via
|
|
334
|
-
* withSpvReseed.
|
|
335
|
-
*
|
|
336
|
-
*
|
|
363
|
+
* withSpvReseed. A height within SPV_RECHECK_DEPTH of the cached tip is re-checked against the served
|
|
364
|
+
* chain first (recheckCachedHeader), so a block orphaned after it was cached stops backing
|
|
365
|
+
* "verified-inclusion". Deeper heights answer from the cache with no network touch.
|
|
337
366
|
*/
|
|
338
367
|
private verifiedHeaderMerkleAt;
|
|
339
368
|
private withSpvReseed;
|
|
369
|
+
private recheckCachedHeader;
|
|
340
370
|
private seedFreshSpvLight;
|
|
341
371
|
/** The PoW-verifying SPV light client, seeded from the pinned checkpoint and cached across calls
|
|
342
372
|
* (shared by the M3 header-merkle bind and the F13 offer pre-verify). The client is committed to
|
|
@@ -383,8 +413,8 @@ declare class Cairn {
|
|
|
383
413
|
plannedOutputs?: Record<string, bigint | string | number>;
|
|
384
414
|
}): Promise<OfferFillCheck>;
|
|
385
415
|
/**
|
|
386
|
-
* Detect + connect the Cairn Wallet (browser only)
|
|
387
|
-
*
|
|
416
|
+
* Detect + connect the Cairn Wallet (browser only) and attach it as `cairn.wallet`.
|
|
417
|
+
* Resolves to the connected address.
|
|
388
418
|
*/
|
|
389
419
|
connect(opts?: DetectOptions): Promise<string>;
|
|
390
420
|
/** Attach an already-connected wallet (e.g. one you constructed yourself). */
|
|
@@ -393,4 +423,4 @@ declare class Cairn {
|
|
|
393
423
|
get connected(): boolean;
|
|
394
424
|
}
|
|
395
425
|
|
|
396
|
-
export {
|
|
426
|
+
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, ProvenOfferTerms } from '@inversealtruism/cairnx-core';
|
|
10
|
+
export { FillEndorsement, FillOutputPlan, FillPreview, FillSafety, 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[]>;
|
|
@@ -121,13 +143,21 @@ interface OfferFillCheck {
|
|
|
121
143
|
blockHeight?: number;
|
|
122
144
|
/** B7b (REBIND W3/M1): the PROVEN CSD outputs to build for `pay` (a WHOLE fill of a non-partial offer),
|
|
123
145
|
* 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
|
|
146
|
+
* passed, the served offer carried a `status` and the offer could be sized. Build EXACTLY these; never the
|
|
147
|
+
* resolver-served outputs a lying resolver could redirect. A partial (min-bearing) offer is left unsized
|
|
148
|
+
* (its running paid/delivered is not provable at this corroboration layer; the wallet's fill-SPV is the
|
|
149
|
+
* payment-grade sizer). Liveness is never proven here: the plan is sized only for the status the resolver
|
|
150
|
+
* served, so an offer with no served status gets no plan. */
|
|
127
151
|
outputPlan?: {
|
|
128
152
|
to: string;
|
|
129
153
|
value: bigint;
|
|
130
154
|
}[];
|
|
155
|
+
/** Present when `plannedOutputs` was passed: `true` when they were bound to `outputPlan` (a mismatch
|
|
156
|
+
* refuses with `ok: false`), `false` when there was no proven plan to bind them to (`planReason` says why).
|
|
157
|
+
* `ok: true` with `planBound: false` means your planned outputs were NOT checked. */
|
|
158
|
+
planBound?: boolean;
|
|
159
|
+
/** Why no output plan was sized (set whenever `outputPlan` is absent after `pay` or `plannedOutputs` was passed). */
|
|
160
|
+
planReason?: string;
|
|
131
161
|
}
|
|
132
162
|
|
|
133
163
|
/**
|
|
@@ -159,8 +189,8 @@ declare function preverifyOffer(opts: {
|
|
|
159
189
|
}): Promise<OfferFillCheck>;
|
|
160
190
|
|
|
161
191
|
/** 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" | "UNKNOWN";
|
|
163
|
-
declare const SDK_VERSION = "0.
|
|
192
|
+
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";
|
|
193
|
+
declare const SDK_VERSION = "0.5.0";
|
|
164
194
|
interface CairnErrorOptions {
|
|
165
195
|
code?: CairnErrorCode;
|
|
166
196
|
docsPath?: string;
|
|
@@ -180,7 +210,7 @@ declare class CairnError extends Error {
|
|
|
180
210
|
/** Relative docs path (under the SDK docs base), if any. */
|
|
181
211
|
readonly docsPath?: string;
|
|
182
212
|
/** The cairn-sdk version that produced this error. */
|
|
183
|
-
readonly version = "0.
|
|
213
|
+
readonly version = "0.5.0";
|
|
184
214
|
/**
|
|
185
215
|
* Whether a dApp may safely AUTO-retry this failure. `false` for fund-safety refusals and user-intent
|
|
186
216
|
* declines (the default); `true` only for provably transient infra faults where nothing was signed.
|
|
@@ -260,7 +290,7 @@ declare function mapSubmitResultError(result: {
|
|
|
260
290
|
declare function errorCode(err: unknown): CairnErrorCode;
|
|
261
291
|
|
|
262
292
|
interface CairnBaseUrls {
|
|
263
|
-
/** Cairn
|
|
293
|
+
/** Cairn server (/api/rpc proxy, /api/headers, /content origin, /trade/api names reads). Default https://cairn-substrate.com */
|
|
264
294
|
cairn?: string;
|
|
265
295
|
/** Node RPC base. Default `${cairn}/api/rpc` (the public proxy — no local node needed). */
|
|
266
296
|
rpc?: string;
|
|
@@ -315,7 +345,6 @@ declare class Cairn {
|
|
|
315
345
|
readonly registry: RegistryClient;
|
|
316
346
|
/** .csd names + CairnX market READS (server-trusted display reads; see names.ts trust note). */
|
|
317
347
|
readonly names: NamesClient;
|
|
318
|
-
board: BoardClient;
|
|
319
348
|
wallet?: WalletConnection;
|
|
320
349
|
private readonly cairnHttp;
|
|
321
350
|
private _spvLight;
|
|
@@ -331,12 +360,13 @@ declare class Cairn {
|
|
|
331
360
|
* to the honest "proof-consistent" instead of over-claiming "verified-inclusion". The verified
|
|
332
361
|
* header chain is cached across calls; the first call near tip syncs the post-checkpoint span.
|
|
333
362
|
* MF-03: a STRUCTURAL forward-sync break (a reorg orphaned the cached tip) reseeds ONCE via
|
|
334
|
-
* withSpvReseed.
|
|
335
|
-
*
|
|
336
|
-
*
|
|
363
|
+
* withSpvReseed. A height within SPV_RECHECK_DEPTH of the cached tip is re-checked against the served
|
|
364
|
+
* chain first (recheckCachedHeader), so a block orphaned after it was cached stops backing
|
|
365
|
+
* "verified-inclusion". Deeper heights answer from the cache with no network touch.
|
|
337
366
|
*/
|
|
338
367
|
private verifiedHeaderMerkleAt;
|
|
339
368
|
private withSpvReseed;
|
|
369
|
+
private recheckCachedHeader;
|
|
340
370
|
private seedFreshSpvLight;
|
|
341
371
|
/** The PoW-verifying SPV light client, seeded from the pinned checkpoint and cached across calls
|
|
342
372
|
* (shared by the M3 header-merkle bind and the F13 offer pre-verify). The client is committed to
|
|
@@ -383,8 +413,8 @@ declare class Cairn {
|
|
|
383
413
|
plannedOutputs?: Record<string, bigint | string | number>;
|
|
384
414
|
}): Promise<OfferFillCheck>;
|
|
385
415
|
/**
|
|
386
|
-
* Detect + connect the Cairn Wallet (browser only)
|
|
387
|
-
*
|
|
416
|
+
* Detect + connect the Cairn Wallet (browser only) and attach it as `cairn.wallet`.
|
|
417
|
+
* Resolves to the connected address.
|
|
388
418
|
*/
|
|
389
419
|
connect(opts?: DetectOptions): Promise<string>;
|
|
390
420
|
/** Attach an already-connected wallet (e.g. one you constructed yourself). */
|
|
@@ -393,4 +423,4 @@ declare class Cairn {
|
|
|
393
423
|
get connected(): boolean;
|
|
394
424
|
}
|
|
395
425
|
|
|
396
|
-
export {
|
|
426
|
+
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 };
|