@ninsei-labs/sdk 0.57.2 → 0.59.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/CHANGELOG.md +22 -0
- package/README.md +82 -32
- package/THIRD_PARTY_NOTICES.md +7 -4
- package/assets/vendors/MANIFEST.json +1 -9
- package/assets/vendors/sdk/sdk-browser.js +4 -6
- package/engine/core/config.js +5 -24
- package/engine/core/deployments.generated.js +33 -0
- package/engine/core/rfqSource.js +6 -133
- package/engine/core/swap.js +1 -1
- package/engine/evm/index.js +3 -2
- package/engine/evm/session.js +46 -277
- package/engine/monero/address.js +15 -33
- package/engine/monero/keys.js +124 -0
- package/engine/monero/mnemonic.js +104 -0
- package/engine/monero/scan.js +79 -17
- package/engine/monero/wallet.js +31 -68
- package/engine/monero/wordlist.en.js +210 -0
- package/engine/recovery/restore.js +1 -1
- package/engine/sdk/bridge.js +7 -182
- package/engine/ui/walletModal.js +7 -27
- package/index.d.ts +248 -254
- package/package.json +6 -7
- package/src/codes.mjs +12 -0
- package/src/config.mjs +16 -54
- package/src/engine.mjs +3 -0
- package/src/index.mjs +25 -46
- package/src/order.mjs +2 -2
- package/src/public/networks.d.ts +9 -0
- package/src/public/networks.mjs +1 -0
- package/src/public/recovery.d.ts +17 -1
- package/src/public/recovery.mjs +1 -0
- package/src/public/xmr.d.ts +8 -0
- package/src/public/xmr.mjs +1 -1
- package/src/quotePolicy.mjs +58 -0
- package/src/quotes.mjs +30 -753
- package/src/readyWindow.mjs +76 -0
- package/src/record.mjs +4 -0
- package/src/recovery-key.mjs +39 -2
- package/src/recovery.mjs +11 -28
- package/src/relayClaim.mjs +132 -0
- package/src/relayFirmClient.mjs +3 -0
- package/src/relayQuote.mjs +5 -1
- package/src/swap-flow.mjs +49 -5
- package/src/swaps.mjs +530 -317
- package/src/sweep-action.mjs +73 -0
- package/src/sweep.mjs +7 -1
- package/src/version.mjs +1 -1
- package/src/witness-slice.mjs +84 -0
- package/src/xmr-arrival.mjs +378 -9
- package/src/xmrAmountPolicy.mjs +35 -0
- package/assets/vendors/monero/monero-js-browser.js +0 -58
- package/assets/vendors/monero-js/LICENSE +0 -9
- package/assets/vendors/walletconnect/wc-browser.js +0 -6202
package/index.d.ts
CHANGED
|
@@ -35,8 +35,6 @@ export type EvmLogReader = (
|
|
|
35
35
|
) => Promise<readonly EvmLog[]>;
|
|
36
36
|
|
|
37
37
|
export interface NinseiOptions {
|
|
38
|
-
/** The service's HTTP API base. Default is "/api" (the interface proxies it to our server). */
|
|
39
|
-
apiBase?: string;
|
|
40
38
|
/**
|
|
41
39
|
* The settlement network. `chain` is an identifier from `sdk.config.chains` (e.g. "arbitrum-sepolia", "solana").
|
|
42
40
|
* `vm` may be omitted: it is taken from the network registry, and a foreign one cannot be substituted - a network
|
|
@@ -55,7 +53,8 @@ export interface NinseiOptions {
|
|
|
55
53
|
storage?: StorageAdapter;
|
|
56
54
|
/** "live" - real nodes and chain; "sim" - a sandbox (mocks, accelerated time, failure scenarios). */
|
|
57
55
|
mode?: "live" | "sim";
|
|
58
|
-
/** An injected fetch function (SSR, tests, your own transport).
|
|
56
|
+
/** An injected fetch function (SSR, tests, your own transport). It is the client default for relay quotes/claims,
|
|
57
|
+
* Monero height probes and witness checks; a per-call `fetchImpl` still wins. */
|
|
59
58
|
fetch?: FetchLike;
|
|
60
59
|
/** The clock. In "sim" the SDK uses it to accelerate time. */
|
|
61
60
|
now?: () => number;
|
|
@@ -71,7 +70,7 @@ export interface NinseiOptions {
|
|
|
71
70
|
*/
|
|
72
71
|
routing?: { prefer?: readonly string[] };
|
|
73
72
|
/**
|
|
74
|
-
* ADDRESSES
|
|
73
|
+
* READ-ONLY ADDRESSES SUPPLIED FROM OUTSIDE. The default is our explorers and RPC endpoints; the options are for
|
|
75
74
|
* whoever runs the swap themselves. ADDRESSES ARE CONFIGURABLE, NOT CHECKS: the pre-signature guards stay enabled
|
|
76
75
|
* under any configuration.
|
|
77
76
|
*/
|
|
@@ -79,11 +78,6 @@ export interface NinseiOptions {
|
|
|
79
78
|
readonly explorer?: { readonly evmTx?: string; readonly evmAddr?: string; readonly evmName?: string; readonly xmrTx?: string };
|
|
80
79
|
readonly rpc?: { readonly evm?: string; readonly monero?: string };
|
|
81
80
|
};
|
|
82
|
-
/**
|
|
83
|
-
* Renaming API paths by name: { swaps, swap, evmSwaps, orderQuote, orderSell, revealedHalf, swept }.
|
|
84
|
-
* An unknown name is bad-input (a typo must not silently fall back to the default).
|
|
85
|
-
*/
|
|
86
|
-
routes?: Readonly<Record<string, string>>;
|
|
87
81
|
/**
|
|
88
82
|
* READING THE CHAIN FROM OUTSIDE - a seam for whoever runs the SDK outside a browser. By default the chain is read
|
|
89
83
|
* by the page's wallet (the engine's readContract), and in Node there is no such wallet: predict, the order state
|
|
@@ -149,7 +143,7 @@ export interface NinseiOptions {
|
|
|
149
143
|
* THE INTERFACE'S ADDRESS DENYLIST (issue #16) - policy, not proof, next to allowedProviders. Addresses the
|
|
150
144
|
* interface will not trade to or from, compared WITHOUT CASE. The SDK fetches nothing: the interface brings the
|
|
151
145
|
* list in. An empty/absent list means "no check".
|
|
152
|
-
* Before
|
|
146
|
+
* Before a relay quote the order's `locker` is checked (on a purchase the claimer is the node's own address, so
|
|
153
147
|
* it is deliberately not checked), and before `swaps.start` the ACTUAL sender - the address the funding will be
|
|
154
148
|
* sent from (`eth_accounts[0]` read from the wallet adapter at the moment of sending on demand; the person may
|
|
155
149
|
* have switched accounts). A barred address is refused with `address-denied` BEFORE any request. A node's own
|
|
@@ -157,15 +151,6 @@ export interface NinseiOptions {
|
|
|
157
151
|
* address: the interface shows its own neutral message.
|
|
158
152
|
*/
|
|
159
153
|
denylist?: readonly string[];
|
|
160
|
-
/**
|
|
161
|
-
* A PASS TO OUR SERVICE for the "server" step (recording the swap with us). Only a wallet can sign the sign-in
|
|
162
|
-
* message, and the wallet's role in the SDK is an adapter: windows and message signatures remain the interface's,
|
|
163
|
-
* and the core receives a READY pass through the same seam the interface obtains it with today
|
|
164
|
-
* (www/js/evm/auth.js, signIn).
|
|
165
|
-
* A missing option is not an error: the "server" step then names the app's refusal with a code (`server-refused`,
|
|
166
|
-
* 401), rather than going in blind.
|
|
167
|
-
*/
|
|
168
|
-
serverAuth?: () => Promise<string | null> | string | null;
|
|
169
154
|
/**
|
|
170
155
|
* POLLING THE MONERO ADDRESS: the rate and the timeout for the XMR arrival. The defaults come from the engine's
|
|
171
156
|
* settings (the page's rate `API.pollMs`; the timeout - `blockTimeReal x confirmTarget`, that is, the time to
|
|
@@ -251,17 +236,12 @@ export interface SdkConfig {
|
|
|
251
236
|
/** The witness nodes for one Monero network; a network with no nodes answers an empty list. */
|
|
252
237
|
nodesFor(network: string): readonly (XmrNode | string)[];
|
|
253
238
|
readonly assetsBase: string;
|
|
254
|
-
readonly apiBase: string;
|
|
255
239
|
readonly mode: "live" | "sim";
|
|
256
240
|
/** Addresses already resolved: the default from the network registry, the override from the options. */
|
|
257
241
|
readonly endpoints: {
|
|
258
242
|
readonly explorer: { readonly evmTx: string | null; readonly evmAddr: string | null; readonly evmName: string | null; readonly xmrTx: string | null };
|
|
259
243
|
readonly rpc: { readonly evm: string | null; readonly monero: string | null };
|
|
260
244
|
};
|
|
261
|
-
/** Named API paths: name -> template, already with the overrides from the options. */
|
|
262
|
-
readonly routes: Readonly<Record<string, string>>;
|
|
263
|
-
/** Assemble a path by name and params (route("swept", { id })). An unknown name is bad-input. */
|
|
264
|
-
route(name: string, params?: Readonly<Record<string, string>>): string;
|
|
265
245
|
/** The protocol's thresholds (windows, confirmations, limits) - data, not interface constants. */
|
|
266
246
|
readonly limits: {
|
|
267
247
|
readonly minAmount: number | null;
|
|
@@ -269,10 +249,6 @@ export interface SdkConfig {
|
|
|
269
249
|
readonly stepAmount: number | null;
|
|
270
250
|
readonly xmrConfirmTarget: number | null;
|
|
271
251
|
readonly readyLeadWarnSec: number | null;
|
|
272
|
-
/** How often the SDK polls the market (from the engine's settings). */
|
|
273
|
-
readonly quotePollMs: number;
|
|
274
|
-
/** The timeout of a single request to the service. */
|
|
275
|
-
readonly httpTimeoutMs: number;
|
|
276
252
|
/** How often the SDK polls the watch on the Monero address (an engine setting or the `watch` option). */
|
|
277
253
|
readonly watchPollMs: number;
|
|
278
254
|
/** How long the SDK waits for the XMR to arrive before answering with the code `xmr-timeout`. */
|
|
@@ -305,11 +281,18 @@ export interface ChainConfig {
|
|
|
305
281
|
readonly nativeSymbol: string;
|
|
306
282
|
readonly tokens: readonly TokenConfig[];
|
|
307
283
|
readonly dex: { readonly routes: readonly unknown[] } | null;
|
|
308
|
-
/**
|
|
284
|
+
/**
|
|
285
|
+
* The escrow deployment on this network, when there is one. `deploymentBlock` is the block that holds the
|
|
286
|
+
* factory's creation. `cashier`, `registry` and `implementationCodeHash` are the network's pins, carried here
|
|
287
|
+
* so a client built from a network name alone compares a quote against them; a simulated network has nulls.
|
|
288
|
+
*/
|
|
309
289
|
readonly escrow: {
|
|
310
290
|
readonly address: string | null;
|
|
311
291
|
readonly mode: string | null;
|
|
312
292
|
readonly deploymentBlock: number | null;
|
|
293
|
+
readonly registry: string | null;
|
|
294
|
+
readonly cashier: string | null;
|
|
295
|
+
readonly implementationCodeHash: string | null;
|
|
313
296
|
} | null;
|
|
314
297
|
}
|
|
315
298
|
|
|
@@ -435,132 +418,12 @@ export interface Balance {
|
|
|
435
418
|
|
|
436
419
|
// --- Quotes -------------------------------------------------------------------------------------
|
|
437
420
|
|
|
438
|
-
export interface FirmQuoteRequest {
|
|
439
|
-
/** Who gives the quote. Without it there is no one to ask - this is not "the first one at hand". */
|
|
440
|
-
readonly providerId: string;
|
|
441
|
-
/** The order terms: how much, to whom, the deadlines, the salt. The context the signature is bound to is assembled from them. */
|
|
442
|
-
readonly order: Readonly<Record<string, unknown>>;
|
|
443
|
-
/**
|
|
444
|
-
* THE TAKER'S MAKER VIEW HALF, when the order was built from a recovery key. Sent top-level to the node; the quote
|
|
445
|
-
* must echo it, so the joint view key can be rebuilt from the twelve words.
|
|
446
|
-
*/
|
|
447
|
-
readonly viewHalfClaimer?: string;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
421
|
export interface QuotesApi {
|
|
451
|
-
/**
|
|
452
|
-
* Live indicative quotes. Returns an unsubscribe function.
|
|
453
|
-
* A snapshot arrives on every tick and contains only data. The last one to unsubscribe stops the polling.
|
|
454
|
-
*/
|
|
455
|
-
watch(request: QuoteRequest, onSnapshot: (snapshot: QuoteSnapshot) => void): () => void;
|
|
456
|
-
/** The last snapshot without waiting: needed by whoever subscribed later than the first poll. */
|
|
457
|
-
snapshot(): QuoteSnapshot | null;
|
|
458
|
-
/** A binding quote with a TTL. A refusal comes as a code, not text. */
|
|
459
|
-
firm(offer: FirmOffer): Promise<Quote>;
|
|
460
422
|
/**
|
|
461
423
|
* A firm quote through a relay, built from one recovery key. The relay answer is verified against the
|
|
462
424
|
* requested terms and the on-chain registry/factory binding before it is returned.
|
|
463
425
|
*/
|
|
464
426
|
firmRelay(request: FirmRelayOffer): Promise<FirmRelayAnswer>;
|
|
465
|
-
/**
|
|
466
|
-
* A reverse-mode ticket: the maker sells XMR. The request is the node's `request` object; the answer carries the
|
|
467
|
-
* signed order quote and its claim tip, which is checked against the gas price before it is returned.
|
|
468
|
-
*/
|
|
469
|
-
sale(request: Readonly<Record<string, unknown>>): Promise<Readonly<Record<string, unknown>>>;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
export interface QuoteRequest {
|
|
473
|
-
readonly direction: "buy" | "sell";
|
|
474
|
-
/** A token identifier from config ("usdc", "usdt", "dai", ...). For a sell - what the user receives. */
|
|
475
|
-
readonly token?: string;
|
|
476
|
-
/** The size on the user's side: for a buy - how much they pay, for a sell - how much XMR they give. */
|
|
477
|
-
readonly amount?: number;
|
|
478
|
-
/**
|
|
479
|
-
* THE EXPLICIT REQUEST SIZE in units of `unit` (buy - XMR, sell - token). Needed by whoever has already aligned
|
|
480
|
-
* the volume to the provider's grid themselves: the core asks for EXACTLY this number rather than deriving the
|
|
481
|
-
* size from `amount` anew.
|
|
482
|
-
* Not set - the size is derived from `amount`, as before.
|
|
483
|
-
*/
|
|
484
|
-
readonly size?: number;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
export interface QuoteSnapshot {
|
|
488
|
-
readonly direction: "buy" | "sell";
|
|
489
|
-
readonly token: string;
|
|
490
|
-
/** The amount on the user's side, as they entered it: for a buy - in the token, for a sell - in XMR. */
|
|
491
|
-
readonly amount: number | null;
|
|
492
|
-
/** The size asked of the provider, in units of `unit`. The price does not depend on it: it is needed so the
|
|
493
|
-
* provider says whether it takes such a size. */
|
|
494
|
-
readonly size: number;
|
|
495
|
-
/** The unit of the size: XMR for a buy, the token for a sell. */
|
|
496
|
-
readonly unit: string | null;
|
|
497
|
-
/** The best offer's price: non-XMR coins per 1 XMR. null - there is no offer (and then it is not zero). */
|
|
498
|
-
readonly rate: number | null;
|
|
499
|
-
/** How much XMR for this size (buy) or how much XMR the person gives (sell). null - not computed. */
|
|
500
|
-
readonly xmr: number | null;
|
|
501
|
-
/** When the snapshot was received, milliseconds of the epoch. */
|
|
502
|
-
readonly at: number;
|
|
503
|
-
/** The provider node whose price is in the snapshot. */
|
|
504
|
-
readonly providerId: string | null;
|
|
505
|
-
/** The best offer for the requested volume and side, AS THE SERVICE NAMED IT. The core does not recompute it:
|
|
506
|
-
* these are response data by which the interface confirms its own "best" mark by pair and provider. */
|
|
507
|
-
readonly best: QuoteBest | null;
|
|
508
|
-
/** Is the size ready: the node's grid and range are data, not an interface check. */
|
|
509
|
-
readonly sizeOk: boolean;
|
|
510
|
-
/** Why the size is not ready: `bad-size`, `below-min`, `above-max`, `no-offer`. `null` - ready. */
|
|
511
|
-
readonly sizeCode: QuoteSizeCode;
|
|
512
|
-
/** The provider's packet number: liveness of the market is counted by it, not by the clock. */
|
|
513
|
-
readonly seq: number | null;
|
|
514
|
-
/** All offers for this size. Indicative: only `quotes.firm` binds. */
|
|
515
|
-
readonly offers: readonly QuoteOffer[];
|
|
516
|
-
/** Book rows that did not become offers, with the reason as a code: `malformed`, `disabled`, `stale`. */
|
|
517
|
-
readonly refused: readonly QuoteRefusal[];
|
|
518
|
-
/** Reference rates (the price benchmark), as the service returned them. Not a swap offer. */
|
|
519
|
-
readonly references: readonly QuoteReference[];
|
|
520
|
-
/** Are there offers and is the service's response alive. */
|
|
521
|
-
readonly ok: boolean;
|
|
522
|
-
/** Why there is no market: a code, no text. */
|
|
523
|
-
readonly error?: { readonly code: ErrorCode };
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
export type QuoteSizeCode = "bad-size" | "below-min" | "above-max" | "no-offer" | null;
|
|
527
|
-
|
|
528
|
-
/** The best, as the service named it: the pair and the node. The core does not recompute the price. */
|
|
529
|
-
export interface QuoteBest {
|
|
530
|
-
readonly providerId: string;
|
|
531
|
-
readonly pair: string;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
export interface QuoteOffer {
|
|
535
|
-
readonly providerId: string;
|
|
536
|
-
readonly displayName: string | null;
|
|
537
|
-
readonly pair: string;
|
|
538
|
-
readonly asset: string | null;
|
|
539
|
-
readonly currency: string | null;
|
|
540
|
-
readonly rate: number;
|
|
541
|
-
readonly rateQuote: number;
|
|
542
|
-
/** The claim tip in native-token wei; a sale is ranked by the payout AFTER it. */
|
|
543
|
-
readonly claimTip: string;
|
|
544
|
-
readonly min: number | null;
|
|
545
|
-
readonly max: number | null;
|
|
546
|
-
readonly step: number | null;
|
|
547
|
-
readonly ttlMs: number | null;
|
|
548
|
-
readonly at: number | null;
|
|
549
|
-
readonly seq: number | null;
|
|
550
|
-
readonly finality: string | null;
|
|
551
|
-
/** The network of the XMR side and of the settlement side, as the quote named them. Not named - null, not our network. */
|
|
552
|
-
readonly assetNetwork: string | null;
|
|
553
|
-
readonly currencyNetwork: string | null;
|
|
554
|
-
readonly networkStated: boolean;
|
|
555
|
-
/** The networks were filled in by the receiver / not named at all - this is a fact about the quote, not "matched". */
|
|
556
|
-
readonly networksDerived: boolean;
|
|
557
|
-
readonly networksUnnamed: boolean;
|
|
558
|
-
/** The reason named by the provider, as is; the package's signature and key; the age by its own mark. */
|
|
559
|
-
readonly why: string | null;
|
|
560
|
-
readonly signature: string | null;
|
|
561
|
-
readonly keyId: string | null;
|
|
562
|
-
readonly ageMs: number | null;
|
|
563
|
-
readonly networks: { readonly asset: string | null; readonly currency: string | null; readonly stated: boolean };
|
|
564
427
|
}
|
|
565
428
|
|
|
566
429
|
/**
|
|
@@ -638,44 +501,6 @@ export interface RouteRefusalTables {
|
|
|
638
501
|
readonly UNISWAPRELAY_REFUSAL_CODES: readonly RouteRefusalCode[];
|
|
639
502
|
}
|
|
640
503
|
|
|
641
|
-
export interface QuoteRefusal {
|
|
642
|
-
readonly providerId: string;
|
|
643
|
-
readonly displayName: string | null;
|
|
644
|
-
readonly pair: string;
|
|
645
|
-
readonly asset: string | null;
|
|
646
|
-
readonly currency: string | null;
|
|
647
|
-
readonly rate: number | null;
|
|
648
|
-
readonly rateQuote: number | null;
|
|
649
|
-
readonly min: number | null;
|
|
650
|
-
readonly max: number | null;
|
|
651
|
-
readonly step: number | null;
|
|
652
|
-
readonly ttlMs: number | null;
|
|
653
|
-
readonly at: number | null;
|
|
654
|
-
readonly seq: number | null;
|
|
655
|
-
readonly ageMs: number | null;
|
|
656
|
-
readonly assetNetwork: string | null;
|
|
657
|
-
readonly currencyNetwork: string | null;
|
|
658
|
-
readonly networkStated: boolean;
|
|
659
|
-
readonly code: "malformed" | "disabled" | "stale";
|
|
660
|
-
/** The reason named by the provider, as is: this is data, not our wording. */
|
|
661
|
-
readonly why: string | null;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
export interface QuoteReference {
|
|
665
|
-
readonly source: string;
|
|
666
|
-
readonly value: number | null;
|
|
667
|
-
readonly at: number | null;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
export interface FirmOffer {
|
|
671
|
-
/** Who gives the quote. Without it there is no one to ask. */
|
|
672
|
-
readonly providerId: string;
|
|
673
|
-
/** The order terms the signature is bound to. */
|
|
674
|
-
readonly order: Readonly<Record<string, unknown>>;
|
|
675
|
-
/** The taker's maker view half when the order was built from a recovery key. */
|
|
676
|
-
readonly viewHalfClaimer?: string;
|
|
677
|
-
}
|
|
678
|
-
|
|
679
504
|
export interface FirmRelayOffer {
|
|
680
505
|
/** Relay origin, without the `/v1/quote` path. */
|
|
681
506
|
readonly relayUrl: string;
|
|
@@ -702,6 +527,8 @@ export interface FirmRelayAnswer {
|
|
|
702
527
|
readonly orderQuote: Readonly<Record<string, unknown>>;
|
|
703
528
|
/** The exact order terms the quote is bound to. */
|
|
704
529
|
readonly order: Readonly<Record<string, unknown>>;
|
|
530
|
+
/** The node's signed ready window for this side: the wait, the late boundary and the refund lead. */
|
|
531
|
+
readonly readyWindow: ReadyWindow;
|
|
705
532
|
readonly nodeHalf: Readonly<Record<string, unknown>>;
|
|
706
533
|
/** Ready to pass as `swaps.start({ counterparty })`: proof, claimer commitment and maker view half. */
|
|
707
534
|
readonly counterparty: Readonly<Record<string, unknown>>;
|
|
@@ -714,6 +541,10 @@ export interface FirmRelayAnswer {
|
|
|
714
541
|
readonly jointAddress: string;
|
|
715
542
|
/** The escrow address predicted from the signed quote and the depositor's half. */
|
|
716
543
|
readonly escrow: string;
|
|
544
|
+
/** Seconds left when the answer was verified; the host may show this next to the confirm button. */
|
|
545
|
+
readonly remainingSec: number;
|
|
546
|
+
/** The last Unix second at which `swaps.start` can still begin this quote. */
|
|
547
|
+
readonly confirmBySec: number;
|
|
717
548
|
readonly recovery: { readonly kind: "salt-v2"; readonly salt: string };
|
|
718
549
|
/** Everything `swaps.start` can take from the relay; the caller adds its wallet, `receiveTo` and height. */
|
|
719
550
|
readonly startRequest: Readonly<{
|
|
@@ -723,30 +554,32 @@ export interface FirmRelayAnswer {
|
|
|
723
554
|
counterparty: Readonly<Record<string, unknown>>;
|
|
724
555
|
recoveryKey: unknown;
|
|
725
556
|
recoverySalt: string;
|
|
557
|
+
escrow: string;
|
|
726
558
|
}>;
|
|
559
|
+
/** The relay origin that answered. `startSell` stores it for the later no-wallet claim. */
|
|
560
|
+
readonly relayUrl: string;
|
|
727
561
|
readonly relay: string | null;
|
|
728
562
|
readonly offered: number | null;
|
|
729
563
|
readonly forwarded: Readonly<Record<string, unknown>> | null;
|
|
730
564
|
readonly answer: Readonly<Record<string, unknown>>;
|
|
731
565
|
}
|
|
732
566
|
|
|
567
|
+
// --- Ready windows ------------------------------------------------------------------------------
|
|
568
|
+
|
|
733
569
|
/**
|
|
734
|
-
*
|
|
735
|
-
* the
|
|
570
|
+
* The signed `firmWindows` entry the relay answer came with. `readyMinSeconds` and `readyMaxSeconds` bound the
|
|
571
|
+
* quote's readiness horizon; the SDK derives the late-arrival boundary and the refund lead from them instead of
|
|
572
|
+
* keeping its own 1200 s / 20-minute numbers.
|
|
736
573
|
*/
|
|
737
|
-
export interface
|
|
738
|
-
readonly
|
|
739
|
-
readonly
|
|
740
|
-
readonly
|
|
741
|
-
readonly
|
|
742
|
-
readonly
|
|
743
|
-
readonly
|
|
744
|
-
readonly
|
|
745
|
-
readonly
|
|
746
|
-
/** The moment after which the quote must not be signed, milliseconds of the epoch. */
|
|
747
|
-
readonly expiresAt: number;
|
|
748
|
-
readonly receiveTo: string;
|
|
749
|
-
readonly signedPayload: unknown;
|
|
574
|
+
export interface ReadyWindow {
|
|
575
|
+
readonly market: string | null;
|
|
576
|
+
readonly side: string | null;
|
|
577
|
+
readonly xmrNetwork: string | null;
|
|
578
|
+
readonly readyMinSeconds: number;
|
|
579
|
+
readonly readyMaxSeconds: number;
|
|
580
|
+
readonly settlementMinSeconds: number | null;
|
|
581
|
+
readonly settlementMaxSeconds: number | null;
|
|
582
|
+
readonly quoteTtlSeconds: number | null;
|
|
750
583
|
}
|
|
751
584
|
|
|
752
585
|
// --- Pre-signature checks -----------------------------------------------------------------------
|
|
@@ -805,7 +638,7 @@ export type CheckCode =
|
|
|
805
638
|
| "unknown";
|
|
806
639
|
|
|
807
640
|
/** The same as Quote, but a node response body is allowed too: the SDK does not reassemble the signed fields. */
|
|
808
|
-
export type QuoteLike =
|
|
641
|
+
export type QuoteLike = Readonly<Record<string, unknown>> & { readonly signedPayload?: unknown };
|
|
809
642
|
|
|
810
643
|
// --- Swaps --------------------------------------------------------------------------------------
|
|
811
644
|
|
|
@@ -828,6 +661,17 @@ export interface SwapsApi {
|
|
|
828
661
|
startSell(request: SellStartRequest): Promise<SellStart>;
|
|
829
662
|
/** CLAIM THE ETH on a sell from the record: the half and the expectations are the ones stored by `startSell`. */
|
|
830
663
|
sellClaim(request: SellClaimRequest, wallet: WalletAdapter): Promise<unknown>;
|
|
664
|
+
/**
|
|
665
|
+
* CLAIM THE ETH ON A SELL WITHOUT A WALLET. The seller holds XMR and no ETH, so the signed `claimTip` pays the
|
|
666
|
+
* sender. `claimSenders` is the client's ordered list - the relay's own sender first, then the listed makers -
|
|
667
|
+
* sent one at a time through the relay (`POST /v1/claims/{sender}/{escrow}`). Each sender gets a 15-30 s slot; a
|
|
668
|
+
* refusal moves on, a txid or unknown answer is followed by reading the escrow, and only `claimed` on chain is
|
|
669
|
+
* success. When the list is exhausted the result is `claim-yourself` with the time left before `t1`.
|
|
670
|
+
*
|
|
671
|
+
* The deal's maker and its quote-key owner are refused before the half leaves the client. No wallet is created or
|
|
672
|
+
* used and no chain transaction is signed. `relayUrl` may restate the stored origin; a different origin is refused.
|
|
673
|
+
*/
|
|
674
|
+
claimViaRelay(request: RelayClaimRequest): Promise<RelayClaimResult>;
|
|
831
675
|
/**
|
|
832
676
|
* WAIT FOR THE XMR TO ARRIVE at the order's joint address. The polling uses the same request as the page's
|
|
833
677
|
* (GET /swaps/{id}), the rate and the timeout - from `config.limits` and overridable here.
|
|
@@ -859,6 +703,12 @@ export interface SwapsApi {
|
|
|
859
703
|
* never a silent success.
|
|
860
704
|
*/
|
|
861
705
|
verifyArrival(request: XmrArrivalRequest): Promise<XmrArrivalVerdict>;
|
|
706
|
+
/**
|
|
707
|
+
* RUN THE EXACT CHECK AND THE WITNESS-V1 SLICE CHECK SIDE BY SIDE. The exact verdict still decides; this
|
|
708
|
+
* returns both readings and any difference, and changes no swap state. `witnessNodes` must name at least one
|
|
709
|
+
* node with `protocol: "witness-v1"`. It is the staging step before slice-only verification.
|
|
710
|
+
*/
|
|
711
|
+
verifyArrivalShadow(request: XmrArrivalShadowRequest): Promise<XmrArrivalShadowResult>;
|
|
862
712
|
/** Fewer seconds before the ready deadline than the confirmations take - a named refusal (`xmr-too-late`). */
|
|
863
713
|
assertTimeForConfirmations(request: XmrDeadlineRequest): number | null;
|
|
864
714
|
/**
|
|
@@ -867,23 +717,13 @@ export interface SwapsApi {
|
|
|
867
717
|
* without the ready mark, and the early window is gone. The arrival is decided by THE SAME check as the watch
|
|
868
718
|
* (`verifyArrival`). Only a verdict with `absent: true` refunds; a transaction that is seen (`pending` with a txid or
|
|
869
719
|
* height, `one-node`, `arrived`) does not; a failure to check (no nodes, a disagreement) throws its own code and
|
|
870
|
-
* signs nothing. It fires only when less than the
|
|
871
|
-
*
|
|
720
|
+
* signs nothing. It fires only when less than the node's refund lead is left before `readyBy` (the headroom of
|
|
721
|
+
* the signed `readyWindow` stored with the record, overridable with `leadSec`).
|
|
872
722
|
*/
|
|
873
723
|
refundIfXmrMissing(request: AutoRefundRequest, deps?: AutoRefundDeps): Promise<AutoRefundVerdict>;
|
|
874
724
|
/** Unfinished swaps after a page reload. */
|
|
875
725
|
list(): Promise<readonly SwapState[]>;
|
|
876
726
|
get(id: string): Promise<SwapState | null>;
|
|
877
|
-
/**
|
|
878
|
-
* THE SERVICE'S SWAP LIST, MERGED INTO THE LOCAL ONE. The path is the page's (www/js/evm/auth.js,
|
|
879
|
-
* loadServerSwaps: GET /api/evm-swaps), and the merge rule is the ENGINE'S (core/swap.js, addServerSwaps): a
|
|
880
|
-
* local record always wins, the service only adds what this browser does not have, and a record that came
|
|
881
|
-
* from the service is marked `source: "server"`. The pass is obtained by the interface and only presented by
|
|
882
|
-
* the core (the `serverAuth` seam): without it the service's own refusal comes as a code. `added` says how
|
|
883
|
-
* many records the merge brought in - the interface decides by it whether the list changed, instead of
|
|
884
|
-
* guessing.
|
|
885
|
-
*/
|
|
886
|
-
sync(): Promise<SwapSync>;
|
|
887
727
|
/**
|
|
888
728
|
* REMOVE A RECORD FROM THE LOCAL LIST. The record leaves THIS store alone: on the service and in the
|
|
889
729
|
* contract everything stays, so this is a tidy-up of the list, not a cancellation of the swap. `false` means
|
|
@@ -956,17 +796,12 @@ export interface SwapProgressView {
|
|
|
956
796
|
readonly terminal: unknown;
|
|
957
797
|
}
|
|
958
798
|
|
|
959
|
-
/**
|
|
960
|
-
export interface SwapSync {
|
|
961
|
-
readonly ok: true;
|
|
962
|
-
readonly added: number;
|
|
963
|
-
readonly seen: number;
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
/** ONE WITNESS NODE: the address, and whose node it is (two nodes of one operator are one opinion). */
|
|
799
|
+
/** ONE WITNESS NODE: the address, whose node it is, and the optional slice protocol. */
|
|
967
800
|
export interface XmrNode {
|
|
968
801
|
readonly url: string;
|
|
969
802
|
readonly operator?: string;
|
|
803
|
+
/** `witness-v1` when this URL serves `POST /v1/witness/slice`; absent for a standard daemon. */
|
|
804
|
+
readonly protocol?: "witness-v1" | string;
|
|
970
805
|
}
|
|
971
806
|
|
|
972
807
|
/**
|
|
@@ -987,6 +822,45 @@ export interface XmrArrivalRequest {
|
|
|
987
822
|
readonly timeoutMs?: number;
|
|
988
823
|
}
|
|
989
824
|
|
|
825
|
+
/** The slice check's extra input: independent witnesses that serve witness-v1. */
|
|
826
|
+
export interface XmrArrivalShadowRequest extends XmrArrivalRequest {
|
|
827
|
+
readonly witnessNodes: readonly (XmrNode | string)[];
|
|
828
|
+
/** Overrides the network derived from the address; normally left out. */
|
|
829
|
+
readonly network?: string;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
/** What one witness returned from the slice walk. */
|
|
833
|
+
export interface XmrWitnessShadowReading {
|
|
834
|
+
readonly state: "seen" | "pending";
|
|
835
|
+
readonly txid: string | null;
|
|
836
|
+
readonly height: number | null;
|
|
837
|
+
readonly blockHash: string | null;
|
|
838
|
+
readonly amountAtomic: string | null;
|
|
839
|
+
readonly operator?: string;
|
|
840
|
+
readonly url?: string;
|
|
841
|
+
readonly completed: boolean;
|
|
842
|
+
/** Distinct operators whose walk covered the target; two instances of one operator count once. */
|
|
843
|
+
readonly quorum: {
|
|
844
|
+
readonly required: number;
|
|
845
|
+
readonly completed: readonly string[];
|
|
846
|
+
/** On mainnet the Ninsei walker is not one of the two votes; this list excludes it. */
|
|
847
|
+
readonly independent: readonly string[];
|
|
848
|
+
readonly ok: boolean;
|
|
849
|
+
};
|
|
850
|
+
readonly checked: readonly Record<string, unknown>[];
|
|
851
|
+
readonly failed: readonly Record<string, unknown>[];
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/** The exact verdict and the slice reading, side by side. This is not a swap decision. */
|
|
855
|
+
export interface XmrArrivalShadowResult {
|
|
856
|
+
readonly exact: XmrArrivalVerdict | null;
|
|
857
|
+
readonly exactError: { readonly code: string; readonly params: Record<string, unknown> } | null;
|
|
858
|
+
readonly witness: XmrWitnessShadowReading;
|
|
859
|
+
/** True when the two readings agree; null when there is nothing comparable to agree on. */
|
|
860
|
+
readonly agrees: boolean | null;
|
|
861
|
+
readonly problems: readonly string[];
|
|
862
|
+
}
|
|
863
|
+
|
|
990
864
|
/** The XMR state the watch hands to the interface: the fact, the waiting state, or a refusal with a code. */
|
|
991
865
|
export interface XmrArrivalVerdict {
|
|
992
866
|
readonly seen: boolean;
|
|
@@ -1042,8 +916,11 @@ export interface AutoRefundRequest {
|
|
|
1042
916
|
readonly fromHeight?: number | null;
|
|
1043
917
|
readonly txid?: string | null;
|
|
1044
918
|
readonly minConfirmations?: number;
|
|
919
|
+
/** Retained for callers that used to derive the lead locally; the refund no longer reads it. */
|
|
1045
920
|
readonly blockTimeSec?: number;
|
|
1046
|
-
/**
|
|
921
|
+
/** The node's signed window, when it is not read from `swap.readyWindow`. */
|
|
922
|
+
readonly readyWindow?: ReadyWindow;
|
|
923
|
+
/** How long before `readyBy` the refund becomes due. Defaults to the window's own headroom. */
|
|
1047
924
|
readonly leadSec?: number;
|
|
1048
925
|
readonly timeoutMs?: number;
|
|
1049
926
|
readonly nowSec?: number;
|
|
@@ -1070,8 +947,9 @@ export interface AutoRefundVerdict {
|
|
|
1070
947
|
}
|
|
1071
948
|
|
|
1072
949
|
/**
|
|
1073
|
-
* THE OUTCOME OF A START: funds locked, the swap recorded
|
|
950
|
+
* THE OUTCOME OF A START: funds locked, the swap recorded locally, and the joint address returned.
|
|
1074
951
|
* There is NO XMR arrival here YET - the state is named (`step: "xmr-incoming"`), not passed off as completion.
|
|
952
|
+
* No backend watch is opened: the caller watches the chain with `swaps.watch` and its own `verify` inputs.
|
|
1075
953
|
*/
|
|
1076
954
|
export interface SwapStart {
|
|
1077
955
|
readonly id: string | null;
|
|
@@ -1080,32 +958,21 @@ export interface SwapStart {
|
|
|
1080
958
|
/** The order's joint Monero address - the one the XMR arrives at. */
|
|
1081
959
|
readonly address: string;
|
|
1082
960
|
readonly step: "xmr-incoming";
|
|
1083
|
-
readonly server: {
|
|
1084
|
-
readonly marked: boolean;
|
|
1085
|
-
/** The service's response code to the mark. */
|
|
1086
|
-
readonly httpStatus: number;
|
|
1087
|
-
/** What the service said about tying the quote to the escrow (its refusal does not abort the swap). */
|
|
1088
|
-
readonly orderBinding: unknown;
|
|
1089
|
-
};
|
|
1090
|
-
readonly watch: {
|
|
1091
|
-
readonly registered: boolean;
|
|
1092
|
-
readonly httpStatus: number;
|
|
1093
|
-
/** The watch record's identifier at the service: the state is queried by it. */
|
|
1094
|
-
readonly id: string | null;
|
|
1095
|
-
readonly address: string;
|
|
1096
|
-
readonly status: string | null;
|
|
1097
|
-
readonly expectedXmr: number;
|
|
1098
|
-
readonly receivedXmr: number;
|
|
1099
|
-
readonly confirmations: number;
|
|
1100
|
-
readonly txids: readonly string[];
|
|
1101
|
-
};
|
|
1102
961
|
/** The named next step: wait for the arrival. */
|
|
1103
962
|
readonly next: "watch";
|
|
963
|
+
/** The node's signed window, when the start came from a relay answer. */
|
|
964
|
+
readonly readyWindow?: ReadyWindow | null;
|
|
1104
965
|
}
|
|
1105
966
|
|
|
1106
967
|
export interface SellStartRequest {
|
|
1107
968
|
/** The verified `quotes.firmRelay` answer for the bid side. */
|
|
1108
969
|
readonly offer: FirmRelayAnswer;
|
|
970
|
+
/**
|
|
971
|
+
* Optional legacy single sender stored for a no-ETH claim. The ordered list passed to `claimViaRelay` is the
|
|
972
|
+
* authority; this scalar is only a one-element fallback for callers written before the list existed. A sender
|
|
973
|
+
* naming the deal's maker or its quote-key owner is refused.
|
|
974
|
+
*/
|
|
975
|
+
readonly claimSender?: string;
|
|
1109
976
|
/** The twelve-word key; required only when no key is stored yet. */
|
|
1110
977
|
readonly recoveryKey?: string | { readonly mnemonic: string };
|
|
1111
978
|
/** The recovery file's passphrase. In memory; the interface puts it on disk if it deems fit. */
|
|
@@ -1128,6 +995,9 @@ export interface SellStart {
|
|
|
1128
995
|
readonly xmrAmount: string;
|
|
1129
996
|
readonly claimTip: string | null;
|
|
1130
997
|
readonly orderQuote: Readonly<Record<string, unknown>> | null;
|
|
998
|
+
/** The legacy single sender stored by `startSell`, or null when the client supplies the list at claim time. */
|
|
999
|
+
readonly claimSender: string | null;
|
|
1000
|
+
readonly readyWindow: ReadyWindow | null;
|
|
1131
1001
|
readonly resumed: boolean;
|
|
1132
1002
|
readonly next: "send-xmr";
|
|
1133
1003
|
}
|
|
@@ -1140,11 +1010,79 @@ export interface SellClaimRequest {
|
|
|
1140
1010
|
readonly onStep?: (step: unknown) => void;
|
|
1141
1011
|
}
|
|
1142
1012
|
|
|
1013
|
+
/**
|
|
1014
|
+
* THE NO-WALLET CLAIM'S INPUTS. `id` names the sell record made by `startSell`; the escrow, half and signed tip
|
|
1015
|
+
* come from it. `claimSenders` is the client's ordered list: the relay's own sender first, then the listed makers.
|
|
1016
|
+
* Each entry is checked for the deal's maker and its quote-key owner. The old scalar `claimSender` is accepted as a
|
|
1017
|
+
* one-element fallback for callers written before the list. `relayUrl` is optional and may only repeat the origin
|
|
1018
|
+
* stored with the record - a foreign origin is refused.
|
|
1019
|
+
*/
|
|
1020
|
+
export interface RelayClaimRequest {
|
|
1021
|
+
readonly id: string;
|
|
1022
|
+
/** Ordered senders. Tried one at a time; the first that lands a claim on chain wins. */
|
|
1023
|
+
readonly claimSenders?: readonly string[];
|
|
1024
|
+
/** One-element fallback for a caller written before `claimSenders`; may never name the deal's maker. */
|
|
1025
|
+
readonly claimSender?: string;
|
|
1026
|
+
readonly relayUrl?: string;
|
|
1027
|
+
/** One sender's slot; clamped to 15-30 s. Default 20 s. */
|
|
1028
|
+
readonly slotMs?: number;
|
|
1029
|
+
/** How often the escrow is read during a slot. Default 2 s. */
|
|
1030
|
+
readonly pollMs?: number;
|
|
1031
|
+
readonly fetchImpl?: typeof fetch;
|
|
1032
|
+
readonly timeoutMs?: number;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/** One sender's outcome in a list claim. */
|
|
1036
|
+
export interface RelayClaimAttempt {
|
|
1037
|
+
readonly sender: string;
|
|
1038
|
+
readonly outcome: "refused" | "unknown" | "unconfirmed";
|
|
1039
|
+
readonly code?: string | null;
|
|
1040
|
+
readonly params?: Readonly<Record<string, unknown>> | null;
|
|
1041
|
+
readonly txid?: string | null;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
/** The claim has landed: the escrow itself reads `claimed`, not merely a txid answer. */
|
|
1045
|
+
export interface RelayClaimed {
|
|
1046
|
+
readonly state: "claimed";
|
|
1047
|
+
readonly id: string;
|
|
1048
|
+
/** The sender whose slot found the claim; null when the escrow already read claimed before the first POST. */
|
|
1049
|
+
readonly provider: string | null;
|
|
1050
|
+
readonly claimSender: string | null;
|
|
1051
|
+
readonly escrow: string;
|
|
1052
|
+
readonly relayUrl: string;
|
|
1053
|
+
/** The txid when an answer carried one; `null` when the claim was found on chain without it. */
|
|
1054
|
+
readonly txid: string | null;
|
|
1055
|
+
readonly from: string | null;
|
|
1056
|
+
readonly tipWei: string;
|
|
1057
|
+
readonly tried: readonly RelayClaimAttempt[];
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/** No sender landed the claim. The seller must send `sellClaim` before `t1`. */
|
|
1061
|
+
export interface RelayClaimYourself {
|
|
1062
|
+
readonly state: "claim-yourself";
|
|
1063
|
+
readonly reason: "senders-exhausted" | "escrow-refunded";
|
|
1064
|
+
readonly id: string;
|
|
1065
|
+
readonly provider: null;
|
|
1066
|
+
readonly claimSender: null;
|
|
1067
|
+
readonly escrow: string;
|
|
1068
|
+
readonly relayUrl: string;
|
|
1069
|
+
readonly txid: null;
|
|
1070
|
+
readonly from: null;
|
|
1071
|
+
readonly tipWei: string;
|
|
1072
|
+
readonly t1: number | null;
|
|
1073
|
+
readonly secondsLeft: number | null;
|
|
1074
|
+
readonly tried: readonly RelayClaimAttempt[];
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
export type RelayClaimResult = RelayClaimed | RelayClaimYourself;
|
|
1078
|
+
|
|
1143
1079
|
export interface SellWatchRequest {
|
|
1144
1080
|
/** The escrow predicted by the relay adapter. */
|
|
1145
1081
|
readonly escrow: string;
|
|
1146
1082
|
readonly timeoutMs?: number;
|
|
1147
1083
|
readonly pollMs?: number;
|
|
1084
|
+
/** The node's window, if the caller does not rely on the record found by `escrow`. */
|
|
1085
|
+
readonly readyWindow?: ReadyWindow;
|
|
1148
1086
|
}
|
|
1149
1087
|
|
|
1150
1088
|
export interface SellWatchResult {
|
|
@@ -1162,7 +1100,7 @@ export interface SellWatchResult {
|
|
|
1162
1100
|
}
|
|
1163
1101
|
|
|
1164
1102
|
export interface SwapWatchRequest {
|
|
1165
|
-
/** The
|
|
1103
|
+
/** The local swap record identifier. */
|
|
1166
1104
|
readonly id: string;
|
|
1167
1105
|
/** The escrow address for the ready mark (mandatory when `expect` and `wallet` are passed). */
|
|
1168
1106
|
readonly escrow?: string;
|
|
@@ -1186,6 +1124,8 @@ export interface SwapWatchRequest {
|
|
|
1186
1124
|
readonly minConfirmations?: number;
|
|
1187
1125
|
/** The ready deadline in unix seconds; with less time left than the confirmations take it refuses with a code. */
|
|
1188
1126
|
readonly readyBySec?: number;
|
|
1127
|
+
/** The node's window, if the record does not carry one. Required for a client-side arrival check. */
|
|
1128
|
+
readonly readyWindow?: ReadyWindow;
|
|
1189
1129
|
}
|
|
1190
1130
|
|
|
1191
1131
|
/**
|
|
@@ -1238,7 +1178,7 @@ export interface SwapWatch {
|
|
|
1238
1178
|
}
|
|
1239
1179
|
|
|
1240
1180
|
export interface StartRequest {
|
|
1241
|
-
readonly quote:
|
|
1181
|
+
readonly quote: QuoteLike;
|
|
1242
1182
|
/**
|
|
1243
1183
|
* THE ORDER TERMS - the context the DLEQ proof and the firm quote's signature are bound to
|
|
1244
1184
|
* (`orderContext`, fields: chainId, factory, locker, claimer, amount, readyBy, t1, salt). The core ALSO builds our
|
|
@@ -1260,6 +1200,14 @@ export interface StartRequest {
|
|
|
1260
1200
|
* without it (`bad-input { step: "fund-order" }`): the factory takes a signed quote, not bare order terms.
|
|
1261
1201
|
*/
|
|
1262
1202
|
readonly orderQuote?: QuoteLike;
|
|
1203
|
+
/**
|
|
1204
|
+
* OPTIONAL CROSS-CHECK, NOT A REQUIREMENT. A reloaded retry derives this address from the signed quote; when the
|
|
1205
|
+
* caller already has it, the value is compared with that prediction and a different value is refused. A request
|
|
1206
|
+
* without it resumes the same pending record from the quote alone.
|
|
1207
|
+
*/
|
|
1208
|
+
readonly escrow?: string;
|
|
1209
|
+
/** Alias for `escrow` accepted by the same cross-check. */
|
|
1210
|
+
readonly predictedEscrow?: string;
|
|
1263
1211
|
/** The swap direction for the record. Default - `buy`. */
|
|
1264
1212
|
readonly side?: "buy" | "sell";
|
|
1265
1213
|
/** Where to receive: for a purchase - the Monero address, for a sale - the EVM address. */
|
|
@@ -1285,7 +1233,7 @@ export interface StartRequest {
|
|
|
1285
1233
|
restoreHeight?: number;
|
|
1286
1234
|
/** Monero nodes for that one measurement; absent - the configured nodes for the swap's network. */
|
|
1287
1235
|
xmrNodes?: readonly (string | { readonly url: string })[];
|
|
1288
|
-
/** The fetch used for the height measurement (tests); absent - the global fetch. */
|
|
1236
|
+
/** The fetch used for the height measurement (tests); absent - the client's `fetch`, otherwise the global fetch. */
|
|
1289
1237
|
fetchImpl?: typeof fetch;
|
|
1290
1238
|
/**
|
|
1291
1239
|
* Hand the key backup to the interface, ONCE, when this call created the key. `true` - the person saved it;
|
|
@@ -1592,6 +1540,28 @@ export interface SweepFromOrderRequest {
|
|
|
1592
1540
|
readonly passphrase?: string;
|
|
1593
1541
|
}
|
|
1594
1542
|
|
|
1543
|
+
/**
|
|
1544
|
+
* The order expectations the action's slot check compares against the live escrow. `amount`, `readyBy`, `t1`,
|
|
1545
|
+
* `salt` and `factory` travel with the action for the caller's own window and context checks; the slot guard
|
|
1546
|
+
* itself compares the points and commitments.
|
|
1547
|
+
*/
|
|
1548
|
+
export interface SweepActionExpect {
|
|
1549
|
+
readonly chainId: number;
|
|
1550
|
+
readonly factory: string;
|
|
1551
|
+
readonly locker: string;
|
|
1552
|
+
readonly claimer: string;
|
|
1553
|
+
/** The native escrow amount in wei, as a decimal string. */
|
|
1554
|
+
readonly amount: string;
|
|
1555
|
+
readonly readyBy: number;
|
|
1556
|
+
readonly t1: number;
|
|
1557
|
+
readonly salt: string;
|
|
1558
|
+
readonly commitHalfLocker: string;
|
|
1559
|
+
readonly commitHalfClaimer: string;
|
|
1560
|
+
readonly edPointLocker: string;
|
|
1561
|
+
readonly edPointClaimer: string;
|
|
1562
|
+
readonly edViewPointLocker: string;
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1595
1565
|
export interface SweepFromOrderResult {
|
|
1596
1566
|
/** The payload `buildPayload` produced; the same fields a recovery file carries. */
|
|
1597
1567
|
readonly payload: unknown;
|
|
@@ -1599,6 +1569,15 @@ export interface SweepFromOrderResult {
|
|
|
1599
1569
|
readonly contents: string;
|
|
1600
1570
|
/** The joint Monero address built from the key and the order. */
|
|
1601
1571
|
readonly address: string;
|
|
1572
|
+
/** The side of the recovered taker: a locker refunds, a claimer claims. */
|
|
1573
|
+
readonly side: "locker" | "claimer";
|
|
1574
|
+
/** The ETH action the recovered half authorizes. */
|
|
1575
|
+
readonly kind: "refund" | "claim";
|
|
1576
|
+
readonly escrow: string;
|
|
1577
|
+
/** The recovered taker's spend half, ready for `actions.refund` or `actions.claim`. */
|
|
1578
|
+
readonly half: string;
|
|
1579
|
+
readonly claimer: string;
|
|
1580
|
+
readonly expect: SweepActionExpect;
|
|
1602
1581
|
}
|
|
1603
1582
|
|
|
1604
1583
|
export interface SweepPlanRequest {
|
|
@@ -1829,8 +1808,8 @@ export interface RecoveryApi {
|
|
|
1829
1808
|
/** Parse the recovery file. Without the right passphrase - a refusal with a code, not an exception. */
|
|
1830
1809
|
open(file: { readonly contents: string } | string, passphrase?: string): Promise<RecoveredWallet>;
|
|
1831
1810
|
/**
|
|
1832
|
-
* WHICH HEIGHT TO SCAN FROM
|
|
1833
|
-
* the
|
|
1811
|
+
* WHICH HEIGHT TO SCAN FROM. The height written into the file is the only source; no height is a named state -
|
|
1812
|
+
* the person can type one.
|
|
1834
1813
|
*/
|
|
1835
1814
|
restoreHeight(request: RestoreHeightRequest): Promise<RestoreHeightResult>;
|
|
1836
1815
|
}
|
|
@@ -1844,12 +1823,12 @@ export interface RestoreHeightResult {
|
|
|
1844
1823
|
readonly address: string | null;
|
|
1845
1824
|
/** 0 when no source knows a height. */
|
|
1846
1825
|
readonly height: number;
|
|
1847
|
-
readonly source: "
|
|
1826
|
+
readonly source: "file" | "none";
|
|
1848
1827
|
readonly fileHeight: number;
|
|
1849
1828
|
readonly appHeight: number;
|
|
1850
|
-
/** Whether the service was asked
|
|
1829
|
+
/** Whether the retired service was asked. Always false: the SDK no longer carries that route. */
|
|
1851
1830
|
readonly appAsked: boolean;
|
|
1852
|
-
/** When `source` is "none": "
|
|
1831
|
+
/** When `source` is "none": "no-height". Null when a height was found. */
|
|
1853
1832
|
readonly appProblem: string | null;
|
|
1854
1833
|
}
|
|
1855
1834
|
|
|
@@ -1889,7 +1868,7 @@ export type ErrorCode =
|
|
|
1889
1868
|
| "quote-unavailable"
|
|
1890
1869
|
| "quote-refused"
|
|
1891
1870
|
/**
|
|
1892
|
-
* An address on the interface's `denylist` refused BEFORE any request - the order's `locker` before
|
|
1871
|
+
* An address on the interface's `denylist` refused BEFORE any request - the order's `locker` before a relay quote,
|
|
1893
1872
|
* or the actual sender before `swaps.start` (issue #16). Also names the node's own `denied-address` refusal as it
|
|
1894
1873
|
* reaches the app: WITHOUT the node's `why` text and WITHOUT the address, so the interface shows its own message.
|
|
1895
1874
|
*/
|
|
@@ -1903,6 +1882,8 @@ export type ErrorCode =
|
|
|
1903
1882
|
| "quote-field-unbound"
|
|
1904
1883
|
/** The quote's own `validUntil` has passed. */
|
|
1905
1884
|
| "quote-expired"
|
|
1885
|
+
/** The quote arrived with less than the start margin left; ask again before showing a confirmation. */
|
|
1886
|
+
| "quote-too-short"
|
|
1906
1887
|
/** There was no chain read to ask the registry whose key it is: the claim stays unproven. */
|
|
1907
1888
|
| "quote-registry-unchecked"
|
|
1908
1889
|
/** The registry has no provider for this key: nobody owns it. */
|
|
@@ -1927,6 +1908,11 @@ export type ErrorCode =
|
|
|
1927
1908
|
| "server-unavailable"
|
|
1928
1909
|
/** The service answered and did not accept: the connection got through, the request did not (status and reason in params). */
|
|
1929
1910
|
| "server-refused"
|
|
1911
|
+
/**
|
|
1912
|
+
* THE CLAIM WAS POSTED BUT NO REAL ANSWER CAME BACK: a timeout, a reset, or a body without a usable transaction
|
|
1913
|
+
* hash. The relay may have sent the claim; the caller must read the escrow before acting again. Never success.
|
|
1914
|
+
*/
|
|
1915
|
+
| "claim-unknown"
|
|
1930
1916
|
/** The funding transaction was sent, but no status-1 receipt with the expected OrderCreated proves the escrow. */
|
|
1931
1917
|
| "funding-pending"
|
|
1932
1918
|
/** The wait for the XMR to arrive expired: a separate code, because this is a state of the money, not a breakdown. */
|
|
@@ -1943,7 +1929,9 @@ export type ErrorCode =
|
|
|
1943
1929
|
| "xmr-no-nodes"
|
|
1944
1930
|
/** The amount that arrived is below the expected one. */
|
|
1945
1931
|
| "xmr-underpaid"
|
|
1946
|
-
/**
|
|
1932
|
+
/** The view key or spend key does not belong to the address being watched. */
|
|
1933
|
+
| "xmr-address-mismatch"
|
|
1934
|
+
/** The ready deadline cannot fit the confirmations the arrival needs. */
|
|
1947
1935
|
| "xmr-too-late"
|
|
1948
1936
|
| "contract-reverted"
|
|
1949
1937
|
| "insufficient-funds"
|
|
@@ -1971,6 +1959,12 @@ export declare class SdkError extends Error {
|
|
|
1971
1959
|
|
|
1972
1960
|
/** The step codes the SDK works with (`state.step`): the same list as the `StepCode` type. */
|
|
1973
1961
|
export declare const SDK_VERSION: string;
|
|
1962
|
+
/** The minimum remaining lifetime of a quote when a swap starts, in seconds. */
|
|
1963
|
+
export declare const LOCK_START_MARGIN_SEC: number;
|
|
1964
|
+
/** The SDK's own preparation allowance for a buy quote, in addition to the start margin. */
|
|
1965
|
+
export declare const START_PREP_SEC: number;
|
|
1966
|
+
/** The default firm quote lifetime, in seconds. A node may override it; the SDK default stays authoritative. */
|
|
1967
|
+
export declare const DEFAULT_ORDER_QUOTE_TTL_SEC: number;
|
|
1974
1968
|
export declare const STEP_CODES: readonly StepCode[];
|
|
1975
1969
|
/** The check codes a preflight verdict names (`checks[].code`): the same list as the `CheckCode` type. */
|
|
1976
1970
|
export declare const CHECK_CODES: readonly CheckCode[];
|