@ninsei-labs/sdk 0.56.1 → 0.58.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 +29 -0
- package/LICENSE-POLICY.md +9 -2
- package/README.md +78 -28
- package/THIRD_PARTY_NOTICES.md +176 -2
- package/assets/vendors/MANIFEST.json +1 -13
- package/assets/vendors/sdk/sdk-browser.js +5 -4
- package/engine/atomic/dleq2.js +116 -15
- package/engine/atomic/order.js +21 -3
- package/engine/core/config.js +20 -46
- package/engine/core/deployments.generated.js +103 -0
- package/engine/core/rfqSource.js +6 -133
- package/engine/core/swap.js +8 -8
- package/engine/evm/asyncRoute.js +1 -1
- package/engine/evm/claimGas.js +2 -1
- package/engine/evm/escrow.js +13 -8
- package/engine/evm/factory.js +11 -6
- package/engine/evm/funding.js +8 -3
- package/engine/evm/index.js +5 -6
- package/engine/evm/session.js +48 -279
- 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 +121 -28
- package/engine/monero/wallet.js +31 -68
- package/engine/monero/wordlist.en.js +210 -0
- package/engine/recovery/restore.js +9 -9
- package/engine/sdk/bridge.js +9 -187
- package/engine/ui/walletModal.js +7 -27
- package/index.d.ts +234 -262
- package/package.json +7 -6
- package/src/actions.mjs +8 -5
- package/src/codes.mjs +17 -0
- package/src/config.mjs +17 -54
- package/src/engine.mjs +9 -6
- package/src/feeEstimate.mjs +11 -4
- package/src/http.mjs +4 -1
- package/src/index.mjs +24 -45
- package/src/legs/kyber.mjs +23 -0
- package/src/lock.mjs +1 -0
- package/src/order.mjs +110 -22
- package/src/primitives.mjs +4 -5
- package/src/probes.mjs +9 -3
- package/src/public/networks.d.ts +45 -0
- package/src/public/networks.mjs +10 -1
- package/src/public/recovery.d.ts +17 -1
- package/src/public/recovery.mjs +1 -0
- package/src/public/xmr.mjs +1 -1
- package/src/quotePolicy.mjs +25 -0
- package/src/quotes.mjs +109 -765
- package/src/readyWindow.mjs +76 -0
- package/src/recovery-key.mjs +71 -16
- package/src/recovery.mjs +11 -28
- package/src/relayClaim.mjs +132 -0
- package/src/relayFeatures.mjs +25 -13
- package/src/relayFirmClient.mjs +36 -7
- package/src/relayQuote.mjs +92 -11
- package/src/relayView.mjs +3 -3
- package/src/swap-flow.mjs +146 -60
- package/src/swaps.mjs +521 -357
- package/src/sweep-action.mjs +73 -0
- package/src/sweep-restore.mjs +8 -4
- package/src/sweep.mjs +12 -2
- package/src/version.mjs +1 -1
- package/src/xmr-arrival.mjs +328 -29
- package/src/xmrAmountPolicy.mjs +35 -0
- package/assets/vendors/atomic/atomic-browser.js +0 -24
- 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/engine/atomic/order-client.js +0 -56
- package/engine/atomic/order-worker.js +0 -156
- package/engine/evm/asyncExec.js +0 -577
- package/engine/evm/asyncLegs.js +0 -308
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
|
|
@@ -49,7 +47,7 @@ export interface NinseiOptions {
|
|
|
49
47
|
* from the node on the CI contour.
|
|
50
48
|
*/
|
|
51
49
|
xmrNetwork: "mainnet" | "stagenet" | "testnet" | "fakechain";
|
|
52
|
-
/** Where to load
|
|
50
|
+
/** Where to load the Monero bundles from. Default "/". */
|
|
53
51
|
assetsBase?: string;
|
|
54
52
|
/** Storage for unfinished swaps and sessions. Default - a localStorage adapter, if present. */
|
|
55
53
|
storage?: StorageAdapter;
|
|
@@ -71,7 +69,7 @@ export interface NinseiOptions {
|
|
|
71
69
|
*/
|
|
72
70
|
routing?: { prefer?: readonly string[] };
|
|
73
71
|
/**
|
|
74
|
-
* ADDRESSES
|
|
72
|
+
* READ-ONLY ADDRESSES SUPPLIED FROM OUTSIDE. The default is our explorers and RPC endpoints; the options are for
|
|
75
73
|
* whoever runs the swap themselves. ADDRESSES ARE CONFIGURABLE, NOT CHECKS: the pre-signature guards stay enabled
|
|
76
74
|
* under any configuration.
|
|
77
75
|
*/
|
|
@@ -79,11 +77,6 @@ export interface NinseiOptions {
|
|
|
79
77
|
readonly explorer?: { readonly evmTx?: string; readonly evmAddr?: string; readonly evmName?: string; readonly xmrTx?: string };
|
|
80
78
|
readonly rpc?: { readonly evm?: string; readonly monero?: string };
|
|
81
79
|
};
|
|
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
80
|
/**
|
|
88
81
|
* READING THE CHAIN FROM OUTSIDE - a seam for whoever runs the SDK outside a browser. By default the chain is read
|
|
89
82
|
* by the page's wallet (the engine's readContract), and in Node there is no such wallet: predict, the order state
|
|
@@ -110,11 +103,14 @@ export interface NinseiOptions {
|
|
|
110
103
|
evmLogs?: EvmLogReader;
|
|
111
104
|
/**
|
|
112
105
|
* READING A SETTLEMENT BLOCK FROM OUTSIDE (`(tag) => block`): the claim-tip check needs the chain's current
|
|
113
|
-
*
|
|
114
|
-
* buy side) never call it.
|
|
106
|
+
* base and priority fees. A missing seam is `quote-tip-unchecked` when a quote carries a non-zero tip; zero tips
|
|
107
|
+
* (the buy side) never call it.
|
|
115
108
|
*/
|
|
116
109
|
evmBlock?: (tag?: string) => Promise<{ readonly baseFeePerGas?: string | number | bigint | null;
|
|
117
|
-
readonly baseFeeWei?: string | number | bigint | null
|
|
110
|
+
readonly baseFeeWei?: string | number | bigint | null;
|
|
111
|
+
readonly priorityFeePerGas?: string | number | bigint | null;
|
|
112
|
+
readonly maxPriorityFeePerGas?: string | number | bigint | null;
|
|
113
|
+
readonly gasPrice?: string | number | bigint | null }>;
|
|
118
114
|
/**
|
|
119
115
|
* THE INTERFACE'S OWN ADMISSION LIST - policy, not proof. The chain (maker registry, providerOf, taken from the
|
|
120
116
|
* quote) proves whose key signed; this says whom THIS interface trades with at all. An array of provider
|
|
@@ -146,7 +142,7 @@ export interface NinseiOptions {
|
|
|
146
142
|
* THE INTERFACE'S ADDRESS DENYLIST (issue #16) - policy, not proof, next to allowedProviders. Addresses the
|
|
147
143
|
* interface will not trade to or from, compared WITHOUT CASE. The SDK fetches nothing: the interface brings the
|
|
148
144
|
* list in. An empty/absent list means "no check".
|
|
149
|
-
* Before
|
|
145
|
+
* Before a relay quote the order's `locker` is checked (on a purchase the claimer is the node's own address, so
|
|
150
146
|
* it is deliberately not checked), and before `swaps.start` the ACTUAL sender - the address the funding will be
|
|
151
147
|
* sent from (`eth_accounts[0]` read from the wallet adapter at the moment of sending on demand; the person may
|
|
152
148
|
* have switched accounts). A barred address is refused with `address-denied` BEFORE any request. A node's own
|
|
@@ -154,15 +150,6 @@ export interface NinseiOptions {
|
|
|
154
150
|
* address: the interface shows its own neutral message.
|
|
155
151
|
*/
|
|
156
152
|
denylist?: readonly string[];
|
|
157
|
-
/**
|
|
158
|
-
* A PASS TO OUR SERVICE for the "server" step (recording the swap with us). Only a wallet can sign the sign-in
|
|
159
|
-
* message, and the wallet's role in the SDK is an adapter: windows and message signatures remain the interface's,
|
|
160
|
-
* and the core receives a READY pass through the same seam the interface obtains it with today
|
|
161
|
-
* (www/js/evm/auth.js, signIn).
|
|
162
|
-
* A missing option is not an error: the "server" step then names the app's refusal with a code (`server-refused`,
|
|
163
|
-
* 401), rather than going in blind.
|
|
164
|
-
*/
|
|
165
|
-
serverAuth?: () => Promise<string | null> | string | null;
|
|
166
153
|
/**
|
|
167
154
|
* POLLING THE MONERO ADDRESS: the rate and the timeout for the XMR arrival. The defaults come from the engine's
|
|
168
155
|
* settings (the page's rate `API.pollMs`; the timeout - `blockTimeReal x confirmTarget`, that is, the time to
|
|
@@ -248,17 +235,12 @@ export interface SdkConfig {
|
|
|
248
235
|
/** The witness nodes for one Monero network; a network with no nodes answers an empty list. */
|
|
249
236
|
nodesFor(network: string): readonly (XmrNode | string)[];
|
|
250
237
|
readonly assetsBase: string;
|
|
251
|
-
readonly apiBase: string;
|
|
252
238
|
readonly mode: "live" | "sim";
|
|
253
239
|
/** Addresses already resolved: the default from the network registry, the override from the options. */
|
|
254
240
|
readonly endpoints: {
|
|
255
241
|
readonly explorer: { readonly evmTx: string | null; readonly evmAddr: string | null; readonly evmName: string | null; readonly xmrTx: string | null };
|
|
256
242
|
readonly rpc: { readonly evm: string | null; readonly monero: string | null };
|
|
257
243
|
};
|
|
258
|
-
/** Named API paths: name -> template, already with the overrides from the options. */
|
|
259
|
-
readonly routes: Readonly<Record<string, string>>;
|
|
260
|
-
/** Assemble a path by name and params (route("swept", { id })). An unknown name is bad-input. */
|
|
261
|
-
route(name: string, params?: Readonly<Record<string, string>>): string;
|
|
262
244
|
/** The protocol's thresholds (windows, confirmations, limits) - data, not interface constants. */
|
|
263
245
|
readonly limits: {
|
|
264
246
|
readonly minAmount: number | null;
|
|
@@ -266,10 +248,6 @@ export interface SdkConfig {
|
|
|
266
248
|
readonly stepAmount: number | null;
|
|
267
249
|
readonly xmrConfirmTarget: number | null;
|
|
268
250
|
readonly readyLeadWarnSec: number | null;
|
|
269
|
-
/** How often the SDK polls the market (from the engine's settings). */
|
|
270
|
-
readonly quotePollMs: number;
|
|
271
|
-
/** The timeout of a single request to the service. */
|
|
272
|
-
readonly httpTimeoutMs: number;
|
|
273
251
|
/** How often the SDK polls the watch on the Monero address (an engine setting or the `watch` option). */
|
|
274
252
|
readonly watchPollMs: number;
|
|
275
253
|
/** How long the SDK waits for the XMR to arrive before answering with the code `xmr-timeout`. */
|
|
@@ -302,11 +280,18 @@ export interface ChainConfig {
|
|
|
302
280
|
readonly nativeSymbol: string;
|
|
303
281
|
readonly tokens: readonly TokenConfig[];
|
|
304
282
|
readonly dex: { readonly routes: readonly unknown[] } | null;
|
|
305
|
-
/**
|
|
283
|
+
/**
|
|
284
|
+
* The escrow deployment on this network, when there is one. `deploymentBlock` is the block that holds the
|
|
285
|
+
* factory's creation. `cashier`, `registry` and `implementationCodeHash` are the network's pins, carried here
|
|
286
|
+
* so a client built from a network name alone compares a quote against them; a simulated network has nulls.
|
|
287
|
+
*/
|
|
306
288
|
readonly escrow: {
|
|
307
289
|
readonly address: string | null;
|
|
308
290
|
readonly mode: string | null;
|
|
309
291
|
readonly deploymentBlock: number | null;
|
|
292
|
+
readonly registry: string | null;
|
|
293
|
+
readonly cashier: string | null;
|
|
294
|
+
readonly implementationCodeHash: string | null;
|
|
310
295
|
} | null;
|
|
311
296
|
}
|
|
312
297
|
|
|
@@ -432,132 +417,12 @@ export interface Balance {
|
|
|
432
417
|
|
|
433
418
|
// --- Quotes -------------------------------------------------------------------------------------
|
|
434
419
|
|
|
435
|
-
export interface FirmQuoteRequest {
|
|
436
|
-
/** Who gives the quote. Without it there is no one to ask - this is not "the first one at hand". */
|
|
437
|
-
readonly providerId: string;
|
|
438
|
-
/** The order terms: how much, to whom, the deadlines, the salt. The context the signature is bound to is assembled from them. */
|
|
439
|
-
readonly order: Readonly<Record<string, unknown>>;
|
|
440
|
-
/**
|
|
441
|
-
* THE TAKER'S MAKER VIEW HALF, when the order was built from a recovery key. Sent top-level to the node; the quote
|
|
442
|
-
* must echo it, so the joint view key can be rebuilt from the twelve words.
|
|
443
|
-
*/
|
|
444
|
-
readonly viewHalfClaimer?: string;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
420
|
export interface QuotesApi {
|
|
448
|
-
/**
|
|
449
|
-
* Live indicative quotes. Returns an unsubscribe function.
|
|
450
|
-
* A snapshot arrives on every tick and contains only data. The last one to unsubscribe stops the polling.
|
|
451
|
-
*/
|
|
452
|
-
watch(request: QuoteRequest, onSnapshot: (snapshot: QuoteSnapshot) => void): () => void;
|
|
453
|
-
/** The last snapshot without waiting: needed by whoever subscribed later than the first poll. */
|
|
454
|
-
snapshot(): QuoteSnapshot | null;
|
|
455
|
-
/** A binding quote with a TTL. A refusal comes as a code, not text. */
|
|
456
|
-
firm(offer: FirmOffer): Promise<Quote>;
|
|
457
421
|
/**
|
|
458
422
|
* A firm quote through a relay, built from one recovery key. The relay answer is verified against the
|
|
459
423
|
* requested terms and the on-chain registry/factory binding before it is returned.
|
|
460
424
|
*/
|
|
461
425
|
firmRelay(request: FirmRelayOffer): Promise<FirmRelayAnswer>;
|
|
462
|
-
/**
|
|
463
|
-
* A reverse-mode ticket: the maker sells XMR. The request is the node's `request` object; the answer carries the
|
|
464
|
-
* signed order quote and its claim tip, which is checked against the gas price before it is returned.
|
|
465
|
-
*/
|
|
466
|
-
sale(request: Readonly<Record<string, unknown>>): Promise<Readonly<Record<string, unknown>>>;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
export interface QuoteRequest {
|
|
470
|
-
readonly direction: "buy" | "sell";
|
|
471
|
-
/** A token identifier from config ("usdc", "usdt", "dai", ...). For a sell - what the user receives. */
|
|
472
|
-
readonly token?: string;
|
|
473
|
-
/** The size on the user's side: for a buy - how much they pay, for a sell - how much XMR they give. */
|
|
474
|
-
readonly amount?: number;
|
|
475
|
-
/**
|
|
476
|
-
* THE EXPLICIT REQUEST SIZE in units of `unit` (buy - XMR, sell - token). Needed by whoever has already aligned
|
|
477
|
-
* the volume to the provider's grid themselves: the core asks for EXACTLY this number rather than deriving the
|
|
478
|
-
* size from `amount` anew.
|
|
479
|
-
* Not set - the size is derived from `amount`, as before.
|
|
480
|
-
*/
|
|
481
|
-
readonly size?: number;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
export interface QuoteSnapshot {
|
|
485
|
-
readonly direction: "buy" | "sell";
|
|
486
|
-
readonly token: string;
|
|
487
|
-
/** The amount on the user's side, as they entered it: for a buy - in the token, for a sell - in XMR. */
|
|
488
|
-
readonly amount: number | null;
|
|
489
|
-
/** The size asked of the provider, in units of `unit`. The price does not depend on it: it is needed so the
|
|
490
|
-
* provider says whether it takes such a size. */
|
|
491
|
-
readonly size: number;
|
|
492
|
-
/** The unit of the size: XMR for a buy, the token for a sell. */
|
|
493
|
-
readonly unit: string | null;
|
|
494
|
-
/** The best offer's price: non-XMR coins per 1 XMR. null - there is no offer (and then it is not zero). */
|
|
495
|
-
readonly rate: number | null;
|
|
496
|
-
/** How much XMR for this size (buy) or how much XMR the person gives (sell). null - not computed. */
|
|
497
|
-
readonly xmr: number | null;
|
|
498
|
-
/** When the snapshot was received, milliseconds of the epoch. */
|
|
499
|
-
readonly at: number;
|
|
500
|
-
/** The provider node whose price is in the snapshot. */
|
|
501
|
-
readonly providerId: string | null;
|
|
502
|
-
/** The best offer for the requested volume and side, AS THE SERVICE NAMED IT. The core does not recompute it:
|
|
503
|
-
* these are response data by which the interface confirms its own "best" mark by pair and provider. */
|
|
504
|
-
readonly best: QuoteBest | null;
|
|
505
|
-
/** Is the size ready: the node's grid and range are data, not an interface check. */
|
|
506
|
-
readonly sizeOk: boolean;
|
|
507
|
-
/** Why the size is not ready: `bad-size`, `below-min`, `above-max`, `no-offer`. `null` - ready. */
|
|
508
|
-
readonly sizeCode: QuoteSizeCode;
|
|
509
|
-
/** The provider's packet number: liveness of the market is counted by it, not by the clock. */
|
|
510
|
-
readonly seq: number | null;
|
|
511
|
-
/** All offers for this size. Indicative: only `quotes.firm` binds. */
|
|
512
|
-
readonly offers: readonly QuoteOffer[];
|
|
513
|
-
/** Book rows that did not become offers, with the reason as a code: `malformed`, `disabled`, `stale`. */
|
|
514
|
-
readonly refused: readonly QuoteRefusal[];
|
|
515
|
-
/** Reference rates (the price benchmark), as the service returned them. Not a swap offer. */
|
|
516
|
-
readonly references: readonly QuoteReference[];
|
|
517
|
-
/** Are there offers and is the service's response alive. */
|
|
518
|
-
readonly ok: boolean;
|
|
519
|
-
/** Why there is no market: a code, no text. */
|
|
520
|
-
readonly error?: { readonly code: ErrorCode };
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
export type QuoteSizeCode = "bad-size" | "below-min" | "above-max" | "no-offer" | null;
|
|
524
|
-
|
|
525
|
-
/** The best, as the service named it: the pair and the node. The core does not recompute the price. */
|
|
526
|
-
export interface QuoteBest {
|
|
527
|
-
readonly providerId: string;
|
|
528
|
-
readonly pair: string;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
export interface QuoteOffer {
|
|
532
|
-
readonly providerId: string;
|
|
533
|
-
readonly displayName: string | null;
|
|
534
|
-
readonly pair: string;
|
|
535
|
-
readonly asset: string | null;
|
|
536
|
-
readonly currency: string | null;
|
|
537
|
-
readonly rate: number;
|
|
538
|
-
readonly rateQuote: number;
|
|
539
|
-
/** The claim tip in native-token wei; a sale is ranked by the payout AFTER it. */
|
|
540
|
-
readonly claimTip: string;
|
|
541
|
-
readonly min: number | null;
|
|
542
|
-
readonly max: number | null;
|
|
543
|
-
readonly step: number | null;
|
|
544
|
-
readonly ttlMs: number | null;
|
|
545
|
-
readonly at: number | null;
|
|
546
|
-
readonly seq: number | null;
|
|
547
|
-
readonly finality: string | null;
|
|
548
|
-
/** The network of the XMR side and of the settlement side, as the quote named them. Not named - null, not our network. */
|
|
549
|
-
readonly assetNetwork: string | null;
|
|
550
|
-
readonly currencyNetwork: string | null;
|
|
551
|
-
readonly networkStated: boolean;
|
|
552
|
-
/** The networks were filled in by the receiver / not named at all - this is a fact about the quote, not "matched". */
|
|
553
|
-
readonly networksDerived: boolean;
|
|
554
|
-
readonly networksUnnamed: boolean;
|
|
555
|
-
/** The reason named by the provider, as is; the package's signature and key; the age by its own mark. */
|
|
556
|
-
readonly why: string | null;
|
|
557
|
-
readonly signature: string | null;
|
|
558
|
-
readonly keyId: string | null;
|
|
559
|
-
readonly ageMs: number | null;
|
|
560
|
-
readonly networks: { readonly asset: string | null; readonly currency: string | null; readonly stated: boolean };
|
|
561
426
|
}
|
|
562
427
|
|
|
563
428
|
/**
|
|
@@ -635,44 +500,6 @@ export interface RouteRefusalTables {
|
|
|
635
500
|
readonly UNISWAPRELAY_REFUSAL_CODES: readonly RouteRefusalCode[];
|
|
636
501
|
}
|
|
637
502
|
|
|
638
|
-
export interface QuoteRefusal {
|
|
639
|
-
readonly providerId: string;
|
|
640
|
-
readonly displayName: string | null;
|
|
641
|
-
readonly pair: string;
|
|
642
|
-
readonly asset: string | null;
|
|
643
|
-
readonly currency: string | null;
|
|
644
|
-
readonly rate: number | null;
|
|
645
|
-
readonly rateQuote: number | null;
|
|
646
|
-
readonly min: number | null;
|
|
647
|
-
readonly max: number | null;
|
|
648
|
-
readonly step: number | null;
|
|
649
|
-
readonly ttlMs: number | null;
|
|
650
|
-
readonly at: number | null;
|
|
651
|
-
readonly seq: number | null;
|
|
652
|
-
readonly ageMs: number | null;
|
|
653
|
-
readonly assetNetwork: string | null;
|
|
654
|
-
readonly currencyNetwork: string | null;
|
|
655
|
-
readonly networkStated: boolean;
|
|
656
|
-
readonly code: "malformed" | "disabled" | "stale";
|
|
657
|
-
/** The reason named by the provider, as is: this is data, not our wording. */
|
|
658
|
-
readonly why: string | null;
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
export interface QuoteReference {
|
|
662
|
-
readonly source: string;
|
|
663
|
-
readonly value: number | null;
|
|
664
|
-
readonly at: number | null;
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
export interface FirmOffer {
|
|
668
|
-
/** Who gives the quote. Without it there is no one to ask. */
|
|
669
|
-
readonly providerId: string;
|
|
670
|
-
/** The order terms the signature is bound to. */
|
|
671
|
-
readonly order: Readonly<Record<string, unknown>>;
|
|
672
|
-
/** The taker's maker view half when the order was built from a recovery key. */
|
|
673
|
-
readonly viewHalfClaimer?: string;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
503
|
export interface FirmRelayOffer {
|
|
677
504
|
/** Relay origin, without the `/v1/quote` path. */
|
|
678
505
|
readonly relayUrl: string;
|
|
@@ -699,6 +526,8 @@ export interface FirmRelayAnswer {
|
|
|
699
526
|
readonly orderQuote: Readonly<Record<string, unknown>>;
|
|
700
527
|
/** The exact order terms the quote is bound to. */
|
|
701
528
|
readonly order: Readonly<Record<string, unknown>>;
|
|
529
|
+
/** The node's signed ready window for this side: the wait, the late boundary and the refund lead. */
|
|
530
|
+
readonly readyWindow: ReadyWindow;
|
|
702
531
|
readonly nodeHalf: Readonly<Record<string, unknown>>;
|
|
703
532
|
/** Ready to pass as `swaps.start({ counterparty })`: proof, claimer commitment and maker view half. */
|
|
704
533
|
readonly counterparty: Readonly<Record<string, unknown>>;
|
|
@@ -712,29 +541,39 @@ export interface FirmRelayAnswer {
|
|
|
712
541
|
/** The escrow address predicted from the signed quote and the depositor's half. */
|
|
713
542
|
readonly escrow: string;
|
|
714
543
|
readonly recovery: { readonly kind: "salt-v2"; readonly salt: string };
|
|
544
|
+
/** Everything `swaps.start` can take from the relay; the caller adds its wallet, `receiveTo` and height. */
|
|
545
|
+
readonly startRequest: Readonly<{
|
|
546
|
+
quote: Readonly<Record<string, unknown>>;
|
|
547
|
+
order: Readonly<Record<string, unknown>>;
|
|
548
|
+
orderQuote: Readonly<Record<string, unknown>>;
|
|
549
|
+
counterparty: Readonly<Record<string, unknown>>;
|
|
550
|
+
recoveryKey: unknown;
|
|
551
|
+
recoverySalt: string;
|
|
552
|
+
}>;
|
|
553
|
+
/** The relay origin that answered. `startSell` stores it for the later no-wallet claim. */
|
|
554
|
+
readonly relayUrl: string;
|
|
715
555
|
readonly relay: string | null;
|
|
716
556
|
readonly offered: number | null;
|
|
717
557
|
readonly forwarded: Readonly<Record<string, unknown>> | null;
|
|
718
558
|
readonly answer: Readonly<Record<string, unknown>>;
|
|
719
559
|
}
|
|
720
560
|
|
|
561
|
+
// --- Ready windows ------------------------------------------------------------------------------
|
|
562
|
+
|
|
721
563
|
/**
|
|
722
|
-
*
|
|
723
|
-
* the
|
|
564
|
+
* The signed `firmWindows` entry the relay answer came with. `readyMinSeconds` and `readyMaxSeconds` bound the
|
|
565
|
+
* quote's readiness horizon; the SDK derives the late-arrival boundary and the refund lead from them instead of
|
|
566
|
+
* keeping its own 1200 s / 20-minute numbers.
|
|
724
567
|
*/
|
|
725
|
-
export interface
|
|
726
|
-
readonly
|
|
727
|
-
readonly
|
|
728
|
-
readonly
|
|
729
|
-
readonly
|
|
730
|
-
readonly
|
|
731
|
-
readonly
|
|
732
|
-
readonly
|
|
733
|
-
readonly
|
|
734
|
-
/** The moment after which the quote must not be signed, milliseconds of the epoch. */
|
|
735
|
-
readonly expiresAt: number;
|
|
736
|
-
readonly receiveTo: string;
|
|
737
|
-
readonly signedPayload: unknown;
|
|
568
|
+
export interface ReadyWindow {
|
|
569
|
+
readonly market: string | null;
|
|
570
|
+
readonly side: string | null;
|
|
571
|
+
readonly xmrNetwork: string | null;
|
|
572
|
+
readonly readyMinSeconds: number;
|
|
573
|
+
readonly readyMaxSeconds: number;
|
|
574
|
+
readonly settlementMinSeconds: number | null;
|
|
575
|
+
readonly settlementMaxSeconds: number | null;
|
|
576
|
+
readonly quoteTtlSeconds: number | null;
|
|
738
577
|
}
|
|
739
578
|
|
|
740
579
|
// --- Pre-signature checks -----------------------------------------------------------------------
|
|
@@ -793,7 +632,7 @@ export type CheckCode =
|
|
|
793
632
|
| "unknown";
|
|
794
633
|
|
|
795
634
|
/** The same as Quote, but a node response body is allowed too: the SDK does not reassemble the signed fields. */
|
|
796
|
-
export type QuoteLike =
|
|
635
|
+
export type QuoteLike = Readonly<Record<string, unknown>> & { readonly signedPayload?: unknown };
|
|
797
636
|
|
|
798
637
|
// --- Swaps --------------------------------------------------------------------------------------
|
|
799
638
|
|
|
@@ -816,6 +655,18 @@ export interface SwapsApi {
|
|
|
816
655
|
startSell(request: SellStartRequest): Promise<SellStart>;
|
|
817
656
|
/** CLAIM THE ETH on a sell from the record: the half and the expectations are the ones stored by `startSell`. */
|
|
818
657
|
sellClaim(request: SellClaimRequest, wallet: WalletAdapter): Promise<unknown>;
|
|
658
|
+
/**
|
|
659
|
+
* CLAIM THE ETH ON A SELL WITHOUT A WALLET. The seller holds XMR and no ETH, so the signed `claimTip` pays the
|
|
660
|
+
* sender. The half goes to the sender the client chose - a listed maker OTHER than the deal's maker - through
|
|
661
|
+
* the relay that answered the quote (`POST /v1/claims/{sender}/{escrow}`). No wallet is created or used and no
|
|
662
|
+
* chain transaction is signed.
|
|
663
|
+
*
|
|
664
|
+
* The sender is stored by `startSell`; a request may supply `claimSender` only when the record has none, and
|
|
665
|
+
* may never name the deal's maker. `relayUrl` may restate the stored origin; a different origin is refused. A
|
|
666
|
+
* node refusal is `quote-refused` with its own code in `params.code`; a lost answer is `claim-unknown` (the
|
|
667
|
+
* claim may have been sent), never success.
|
|
668
|
+
*/
|
|
669
|
+
claimViaRelay(request: RelayClaimRequest): Promise<RelayClaimResult>;
|
|
819
670
|
/**
|
|
820
671
|
* WAIT FOR THE XMR TO ARRIVE at the order's joint address. The polling uses the same request as the page's
|
|
821
672
|
* (GET /swaps/{id}), the rate and the timeout - from `config.limits` and overridable here.
|
|
@@ -847,30 +698,27 @@ export interface SwapsApi {
|
|
|
847
698
|
* never a silent success.
|
|
848
699
|
*/
|
|
849
700
|
verifyArrival(request: XmrArrivalRequest): Promise<XmrArrivalVerdict>;
|
|
701
|
+
/**
|
|
702
|
+
* RUN THE EXACT CHECK AND THE WITNESS-V1 SLICE CHECK SIDE BY SIDE. The exact verdict still decides; this
|
|
703
|
+
* returns both readings and any difference, and changes no swap state. `witnessNodes` must name at least one
|
|
704
|
+
* node with `protocol: "witness-v1"`. It is the staging step before slice-only verification.
|
|
705
|
+
*/
|
|
706
|
+
verifyArrivalShadow(request: XmrArrivalShadowRequest): Promise<XmrArrivalShadowResult>;
|
|
850
707
|
/** Fewer seconds before the ready deadline than the confirmations take - a named refusal (`xmr-too-late`). */
|
|
851
708
|
assertTimeForConfirmations(request: XmrDeadlineRequest): number | null;
|
|
852
709
|
/**
|
|
853
710
|
* THE CLIENT'S OWN EARLY REFUND WHEN THE XMR DID NOT ARRIVE (issue #88). While the interface is open, a depositor
|
|
854
711
|
* who sees no XMR on the joint address takes the ETH back BEFORE `readyBy` - after it the maker may claim even
|
|
855
712
|
* without the ready mark, and the early window is gone. The arrival is decided by THE SAME check as the watch
|
|
856
|
-
* (`verifyArrival`). Only a
|
|
857
|
-
* to check (no nodes, a disagreement) throws its own code and
|
|
858
|
-
*
|
|
713
|
+
* (`verifyArrival`). Only a verdict with `absent: true` refunds; a transaction that is seen (`pending` with a txid or
|
|
714
|
+
* height, `one-node`, `arrived`) does not; a failure to check (no nodes, a disagreement) throws its own code and
|
|
715
|
+
* signs nothing. It fires only when less than the node's refund lead is left before `readyBy` (the headroom of
|
|
716
|
+
* the signed `readyWindow` stored with the record, overridable with `leadSec`).
|
|
859
717
|
*/
|
|
860
718
|
refundIfXmrMissing(request: AutoRefundRequest, deps?: AutoRefundDeps): Promise<AutoRefundVerdict>;
|
|
861
719
|
/** Unfinished swaps after a page reload. */
|
|
862
720
|
list(): Promise<readonly SwapState[]>;
|
|
863
721
|
get(id: string): Promise<SwapState | null>;
|
|
864
|
-
/**
|
|
865
|
-
* THE SERVICE'S SWAP LIST, MERGED INTO THE LOCAL ONE. The path is the page's (www/js/evm/auth.js,
|
|
866
|
-
* loadServerSwaps: GET /api/evm-swaps), and the merge rule is the ENGINE'S (core/swap.js, addServerSwaps): a
|
|
867
|
-
* local record always wins, the service only adds what this browser does not have, and a record that came
|
|
868
|
-
* from the service is marked `source: "server"`. The pass is obtained by the interface and only presented by
|
|
869
|
-
* the core (the `serverAuth` seam): without it the service's own refusal comes as a code. `added` says how
|
|
870
|
-
* many records the merge brought in - the interface decides by it whether the list changed, instead of
|
|
871
|
-
* guessing.
|
|
872
|
-
*/
|
|
873
|
-
sync(): Promise<SwapSync>;
|
|
874
722
|
/**
|
|
875
723
|
* REMOVE A RECORD FROM THE LOCAL LIST. The record leaves THIS store alone: on the service and in the
|
|
876
724
|
* contract everything stays, so this is a tidy-up of the list, not a cancellation of the swap. `false` means
|
|
@@ -943,17 +791,12 @@ export interface SwapProgressView {
|
|
|
943
791
|
readonly terminal: unknown;
|
|
944
792
|
}
|
|
945
793
|
|
|
946
|
-
/**
|
|
947
|
-
export interface SwapSync {
|
|
948
|
-
readonly ok: true;
|
|
949
|
-
readonly added: number;
|
|
950
|
-
readonly seen: number;
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
/** ONE WITNESS NODE: the address, and whose node it is (two nodes of one operator are one opinion). */
|
|
794
|
+
/** ONE WITNESS NODE: the address, whose node it is, and the optional slice protocol. */
|
|
954
795
|
export interface XmrNode {
|
|
955
796
|
readonly url: string;
|
|
956
797
|
readonly operator?: string;
|
|
798
|
+
/** `witness-v1` when this URL serves `POST /v1/witness/slice`; absent for a standard daemon. */
|
|
799
|
+
readonly protocol?: "witness-v1" | string;
|
|
957
800
|
}
|
|
958
801
|
|
|
959
802
|
/**
|
|
@@ -974,10 +817,45 @@ export interface XmrArrivalRequest {
|
|
|
974
817
|
readonly timeoutMs?: number;
|
|
975
818
|
}
|
|
976
819
|
|
|
820
|
+
/** The slice check's extra input: independent witnesses that serve witness-v1. */
|
|
821
|
+
export interface XmrArrivalShadowRequest extends XmrArrivalRequest {
|
|
822
|
+
readonly witnessNodes: readonly (XmrNode | string)[];
|
|
823
|
+
/** Overrides the network derived from the address; normally left out. */
|
|
824
|
+
readonly network?: string;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
/** What one witness returned from the slice walk. */
|
|
828
|
+
export interface XmrWitnessShadowReading {
|
|
829
|
+
readonly state: "seen" | "pending";
|
|
830
|
+
readonly txid: string | null;
|
|
831
|
+
readonly height: number | null;
|
|
832
|
+
readonly blockHash: string | null;
|
|
833
|
+
readonly amountAtomic: string | null;
|
|
834
|
+
readonly operator?: string;
|
|
835
|
+
readonly url?: string;
|
|
836
|
+
readonly completed: boolean;
|
|
837
|
+
readonly checked: readonly Record<string, unknown>[];
|
|
838
|
+
readonly failed: readonly Record<string, unknown>[];
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
/** The exact verdict and the slice reading, side by side. This is not a swap decision. */
|
|
842
|
+
export interface XmrArrivalShadowResult {
|
|
843
|
+
readonly exact: XmrArrivalVerdict | null;
|
|
844
|
+
readonly exactError: { readonly code: string; readonly params: Record<string, unknown> } | null;
|
|
845
|
+
readonly witness: XmrWitnessShadowReading;
|
|
846
|
+
/** True when the two readings agree; null when there is nothing comparable to agree on. */
|
|
847
|
+
readonly agrees: boolean | null;
|
|
848
|
+
readonly problems: readonly string[];
|
|
849
|
+
}
|
|
850
|
+
|
|
977
851
|
/** The XMR state the watch hands to the interface: the fact, the waiting state, or a refusal with a code. */
|
|
978
852
|
export interface XmrArrivalVerdict {
|
|
979
853
|
readonly seen: boolean;
|
|
980
854
|
readonly state: "arrived" | "pending" | "one-node";
|
|
855
|
+
/** True only when a node completed the walk and found no matching transaction. */
|
|
856
|
+
readonly absent?: boolean;
|
|
857
|
+
/** The operators whose completed walk found no matching transaction. */
|
|
858
|
+
readonly completedOperators?: readonly string[];
|
|
981
859
|
readonly txid: string | null;
|
|
982
860
|
readonly height?: number;
|
|
983
861
|
readonly blockHash?: string;
|
|
@@ -1025,8 +903,11 @@ export interface AutoRefundRequest {
|
|
|
1025
903
|
readonly fromHeight?: number | null;
|
|
1026
904
|
readonly txid?: string | null;
|
|
1027
905
|
readonly minConfirmations?: number;
|
|
906
|
+
/** Retained for callers that used to derive the lead locally; the refund no longer reads it. */
|
|
1028
907
|
readonly blockTimeSec?: number;
|
|
1029
|
-
/**
|
|
908
|
+
/** The node's signed window, when it is not read from `swap.readyWindow`. */
|
|
909
|
+
readonly readyWindow?: ReadyWindow;
|
|
910
|
+
/** How long before `readyBy` the refund becomes due. Defaults to the window's own headroom. */
|
|
1030
911
|
readonly leadSec?: number;
|
|
1031
912
|
readonly timeoutMs?: number;
|
|
1032
913
|
readonly nowSec?: number;
|
|
@@ -1043,7 +924,8 @@ export interface AutoRefundDeps {
|
|
|
1043
924
|
/** What the client's own refund decided: refunded, waiting, still time, or the XMR is there. */
|
|
1044
925
|
export interface AutoRefundVerdict {
|
|
1045
926
|
readonly refunded: boolean;
|
|
1046
|
-
readonly state: "refunded" | "waiting" | "claim-window" | "arrived"
|
|
927
|
+
readonly state: "refunded" | "waiting" | "claim-window" | "arrival-pending" | "arrived" |
|
|
928
|
+
"arrival-underpaid" | "arrival-locked";
|
|
1047
929
|
readonly hash?: string | null;
|
|
1048
930
|
readonly leftSec: number;
|
|
1049
931
|
readonly needSec?: number;
|
|
@@ -1052,8 +934,9 @@ export interface AutoRefundVerdict {
|
|
|
1052
934
|
}
|
|
1053
935
|
|
|
1054
936
|
/**
|
|
1055
|
-
* THE OUTCOME OF A START: funds locked, the swap recorded
|
|
937
|
+
* THE OUTCOME OF A START: funds locked, the swap recorded locally, and the joint address returned.
|
|
1056
938
|
* There is NO XMR arrival here YET - the state is named (`step: "xmr-incoming"`), not passed off as completion.
|
|
939
|
+
* No backend watch is opened: the caller watches the chain with `swaps.watch` and its own `verify` inputs.
|
|
1057
940
|
*/
|
|
1058
941
|
export interface SwapStart {
|
|
1059
942
|
readonly id: string | null;
|
|
@@ -1062,34 +945,32 @@ export interface SwapStart {
|
|
|
1062
945
|
/** The order's joint Monero address - the one the XMR arrives at. */
|
|
1063
946
|
readonly address: string;
|
|
1064
947
|
readonly step: "xmr-incoming";
|
|
1065
|
-
readonly server: {
|
|
1066
|
-
readonly marked: boolean;
|
|
1067
|
-
/** The service's response code to the mark. */
|
|
1068
|
-
readonly httpStatus: number;
|
|
1069
|
-
/** What the service said about tying the quote to the escrow (its refusal does not abort the swap). */
|
|
1070
|
-
readonly orderBinding: unknown;
|
|
1071
|
-
};
|
|
1072
|
-
readonly watch: {
|
|
1073
|
-
readonly registered: boolean;
|
|
1074
|
-
readonly httpStatus: number;
|
|
1075
|
-
/** The watch record's identifier at the service: the state is queried by it. */
|
|
1076
|
-
readonly id: string | null;
|
|
1077
|
-
readonly address: string;
|
|
1078
|
-
readonly status: string | null;
|
|
1079
|
-
readonly expectedXmr: number;
|
|
1080
|
-
readonly receivedXmr: number;
|
|
1081
|
-
readonly confirmations: number;
|
|
1082
|
-
readonly txids: readonly string[];
|
|
1083
|
-
};
|
|
1084
948
|
/** The named next step: wait for the arrival. */
|
|
1085
949
|
readonly next: "watch";
|
|
950
|
+
/** The node's signed window, when the start came from a relay answer. */
|
|
951
|
+
readonly readyWindow?: ReadyWindow | null;
|
|
1086
952
|
}
|
|
1087
953
|
|
|
1088
954
|
export interface SellStartRequest {
|
|
1089
955
|
/** The verified `quotes.firmRelay` answer for the bid side. */
|
|
1090
956
|
readonly offer: FirmRelayAnswer;
|
|
957
|
+
/**
|
|
958
|
+
* The sender the client chose for a later no-ETH claim: a listed maker other than the deal's maker. It is
|
|
959
|
+
* stored with the record so a reload claims through the same node; the relay route names it as `provider`.
|
|
960
|
+
* Omitted for a record that will only use the own-wallet path.
|
|
961
|
+
*/
|
|
962
|
+
readonly claimSender?: string;
|
|
1091
963
|
/** The twelve-word key; required only when no key is stored yet. */
|
|
1092
964
|
readonly recoveryKey?: string | { readonly mnemonic: string };
|
|
965
|
+
/** The recovery file's passphrase. In memory; the interface puts it on disk if it deems fit. */
|
|
966
|
+
readonly passphrase?: string;
|
|
967
|
+
/** Asked when the key is new or not yet confirmed. Returning anything but `true` refuses before `send-xmr`. */
|
|
968
|
+
onRecoveryKey?(file: RecoveryFile): Promise<boolean>;
|
|
969
|
+
/**
|
|
970
|
+
* The EVM wallet whose provider supplies the block number and timestamp for the one-block escrow gate.
|
|
971
|
+
* Optional: without it the gate falls back to `latest` and the facade clock. The same wallet that will claim.
|
|
972
|
+
*/
|
|
973
|
+
readonly wallet?: Pick<WalletAdapter, "driver">;
|
|
1093
974
|
}
|
|
1094
975
|
|
|
1095
976
|
export interface SellStart {
|
|
@@ -1101,6 +982,9 @@ export interface SellStart {
|
|
|
1101
982
|
readonly xmrAmount: string;
|
|
1102
983
|
readonly claimTip: string | null;
|
|
1103
984
|
readonly orderQuote: Readonly<Record<string, unknown>> | null;
|
|
985
|
+
/** The no-wallet claim sender stored by `startSell`, or null when only the own-wallet path is available. */
|
|
986
|
+
readonly claimSender: string | null;
|
|
987
|
+
readonly readyWindow: ReadyWindow | null;
|
|
1104
988
|
readonly resumed: boolean;
|
|
1105
989
|
readonly next: "send-xmr";
|
|
1106
990
|
}
|
|
@@ -1113,27 +997,61 @@ export interface SellClaimRequest {
|
|
|
1113
997
|
readonly onStep?: (step: unknown) => void;
|
|
1114
998
|
}
|
|
1115
999
|
|
|
1000
|
+
/**
|
|
1001
|
+
* THE NO-WALLET CLAIM'S INPUTS. `id` names the sell record made by `startSell`; the escrow, half and signed tip
|
|
1002
|
+
* come from it. `claimSender` is the list-member node that will send the claim: it must be a listed maker other than
|
|
1003
|
+
* the deal's maker, and is normally stored by `startSell`. `relayUrl` is optional and may only repeat the origin
|
|
1004
|
+
* stored with the record - a foreign origin is refused.
|
|
1005
|
+
*/
|
|
1006
|
+
export interface RelayClaimRequest {
|
|
1007
|
+
readonly id: string;
|
|
1008
|
+
/** Only for a record made before the sender was stored; it may never name the deal's maker. */
|
|
1009
|
+
readonly claimSender?: string;
|
|
1010
|
+
readonly relayUrl?: string;
|
|
1011
|
+
readonly fetchImpl?: typeof fetch;
|
|
1012
|
+
readonly timeoutMs?: number;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
/** The claim the relay sent for the record. Only a validated on-chain transaction hash is returned here. */
|
|
1016
|
+
export interface RelayClaimResult {
|
|
1017
|
+
readonly id: string;
|
|
1018
|
+
/** The sender the client chose; `claimSender` repeats it for callers that think in that name. */
|
|
1019
|
+
readonly provider: string;
|
|
1020
|
+
readonly claimSender: string;
|
|
1021
|
+
readonly escrow: string;
|
|
1022
|
+
readonly relayUrl: string;
|
|
1023
|
+
readonly txid: string;
|
|
1024
|
+
/** The address that sent the claim transaction (the sender node's sender, not the seller). */
|
|
1025
|
+
readonly from: string;
|
|
1026
|
+
/** The signed tip, in wei, paid out of the claim. */
|
|
1027
|
+
readonly tipWei: string;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1116
1030
|
export interface SellWatchRequest {
|
|
1117
1031
|
/** The escrow predicted by the relay adapter. */
|
|
1118
1032
|
readonly escrow: string;
|
|
1119
1033
|
readonly timeoutMs?: number;
|
|
1120
1034
|
readonly pollMs?: number;
|
|
1035
|
+
/** The node's window, if the caller does not rely on the record found by `escrow`. */
|
|
1036
|
+
readonly readyWindow?: ReadyWindow;
|
|
1121
1037
|
}
|
|
1122
1038
|
|
|
1123
1039
|
export interface SellWatchResult {
|
|
1124
1040
|
readonly escrow: string;
|
|
1125
|
-
readonly state: "ready" | "claimed" | "refunded";
|
|
1041
|
+
readonly state: "ready" | "claim-open" | "claimed" | "refunded";
|
|
1126
1042
|
readonly funded: boolean;
|
|
1127
1043
|
readonly claimed: boolean;
|
|
1128
1044
|
readonly refunded: boolean;
|
|
1129
1045
|
/** `null` for a terminal claim/refund: the ready mark is not part of that answer. */
|
|
1130
1046
|
readonly ready: boolean | null;
|
|
1047
|
+
/** True when the escrow's readyBy has passed and no ready mark or terminal action was seen. */
|
|
1048
|
+
readonly claimOpen: boolean;
|
|
1131
1049
|
readonly balanceWei: string;
|
|
1132
1050
|
readonly waitedMs: number;
|
|
1133
1051
|
}
|
|
1134
1052
|
|
|
1135
1053
|
export interface SwapWatchRequest {
|
|
1136
|
-
/** The
|
|
1054
|
+
/** The local swap record identifier. */
|
|
1137
1055
|
readonly id: string;
|
|
1138
1056
|
/** The escrow address for the ready mark (mandatory when `expect` and `wallet` are passed). */
|
|
1139
1057
|
readonly escrow?: string;
|
|
@@ -1157,6 +1075,8 @@ export interface SwapWatchRequest {
|
|
|
1157
1075
|
readonly minConfirmations?: number;
|
|
1158
1076
|
/** The ready deadline in unix seconds; with less time left than the confirmations take it refuses with a code. */
|
|
1159
1077
|
readonly readyBySec?: number;
|
|
1078
|
+
/** The node's window, if the record does not carry one. Required for a client-side arrival check. */
|
|
1079
|
+
readonly readyWindow?: ReadyWindow;
|
|
1160
1080
|
}
|
|
1161
1081
|
|
|
1162
1082
|
/**
|
|
@@ -1209,7 +1129,7 @@ export interface SwapWatch {
|
|
|
1209
1129
|
}
|
|
1210
1130
|
|
|
1211
1131
|
export interface StartRequest {
|
|
1212
|
-
readonly quote:
|
|
1132
|
+
readonly quote: QuoteLike;
|
|
1213
1133
|
/**
|
|
1214
1134
|
* THE ORDER TERMS - the context the DLEQ proof and the firm quote's signature are bound to
|
|
1215
1135
|
* (`orderContext`, fields: chainId, factory, locker, claimer, amount, readyBy, t1, salt). The core ALSO builds our
|
|
@@ -1274,8 +1194,8 @@ export interface RecoveryFile {
|
|
|
1274
1194
|
export interface SwapState {
|
|
1275
1195
|
readonly id: string;
|
|
1276
1196
|
readonly direction: "buy" | "sell";
|
|
1277
|
-
readonly pay: { readonly token: string; readonly amount: number };
|
|
1278
|
-
readonly get: { readonly xmr: number };
|
|
1197
|
+
readonly pay: { readonly token: string; readonly amount: number | null };
|
|
1198
|
+
readonly get: { readonly xmr: number | null };
|
|
1279
1199
|
/** The current step's code. The texts are the interface's. */
|
|
1280
1200
|
readonly step: StepCode;
|
|
1281
1201
|
/** All steps in the order of passage: what is done, what is running now, what failed. */
|
|
@@ -1332,7 +1252,7 @@ export interface SwapState {
|
|
|
1332
1252
|
/** The swap has a settlement record: the list splits live from settled by THIS flag, not by the phase's text. */
|
|
1333
1253
|
readonly settled: boolean;
|
|
1334
1254
|
/** WHAT HAS ALREADY MOVED: the sum seen at the address and whether the record holds a lock or a secret. */
|
|
1335
|
-
readonly funds: { readonly receivedXmr: number; readonly escrowLocked: boolean };
|
|
1255
|
+
readonly funds: { readonly receivedXmr: number | null; readonly escrowLocked: boolean };
|
|
1336
1256
|
}
|
|
1337
1257
|
|
|
1338
1258
|
export interface StepState {
|
|
@@ -1444,6 +1364,11 @@ export interface SweepRestoreRequest {
|
|
|
1444
1364
|
readonly toHeight: number;
|
|
1445
1365
|
readonly tipHeight: number;
|
|
1446
1366
|
readonly fallback?: boolean;
|
|
1367
|
+
/**
|
|
1368
|
+
* EXPLICIT PERMISSION TO SEND KEY IMAGES TO `nodeUrl` for the spent check. Absent/false: key images never leave
|
|
1369
|
+
* the wallet in the window path, and the result names `spentWhy: "untrusted-node"` with an incomplete scan.
|
|
1370
|
+
*/
|
|
1371
|
+
readonly trustedNode?: boolean;
|
|
1447
1372
|
};
|
|
1448
1373
|
/** The fetch used for `get_block`; absent - the global fetch. */
|
|
1449
1374
|
readonly fetchImpl?: typeof fetch;
|
|
@@ -1558,6 +1483,28 @@ export interface SweepFromOrderRequest {
|
|
|
1558
1483
|
readonly passphrase?: string;
|
|
1559
1484
|
}
|
|
1560
1485
|
|
|
1486
|
+
/**
|
|
1487
|
+
* The order expectations the action's slot check compares against the live escrow. `amount`, `readyBy`, `t1`,
|
|
1488
|
+
* `salt` and `factory` travel with the action for the caller's own window and context checks; the slot guard
|
|
1489
|
+
* itself compares the points and commitments.
|
|
1490
|
+
*/
|
|
1491
|
+
export interface SweepActionExpect {
|
|
1492
|
+
readonly chainId: number;
|
|
1493
|
+
readonly factory: string;
|
|
1494
|
+
readonly locker: string;
|
|
1495
|
+
readonly claimer: string;
|
|
1496
|
+
/** The native escrow amount in wei, as a decimal string. */
|
|
1497
|
+
readonly amount: string;
|
|
1498
|
+
readonly readyBy: number;
|
|
1499
|
+
readonly t1: number;
|
|
1500
|
+
readonly salt: string;
|
|
1501
|
+
readonly commitHalfLocker: string;
|
|
1502
|
+
readonly commitHalfClaimer: string;
|
|
1503
|
+
readonly edPointLocker: string;
|
|
1504
|
+
readonly edPointClaimer: string;
|
|
1505
|
+
readonly edViewPointLocker: string;
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1561
1508
|
export interface SweepFromOrderResult {
|
|
1562
1509
|
/** The payload `buildPayload` produced; the same fields a recovery file carries. */
|
|
1563
1510
|
readonly payload: unknown;
|
|
@@ -1565,6 +1512,15 @@ export interface SweepFromOrderResult {
|
|
|
1565
1512
|
readonly contents: string;
|
|
1566
1513
|
/** The joint Monero address built from the key and the order. */
|
|
1567
1514
|
readonly address: string;
|
|
1515
|
+
/** The side of the recovered taker: a locker refunds, a claimer claims. */
|
|
1516
|
+
readonly side: "locker" | "claimer";
|
|
1517
|
+
/** The ETH action the recovered half authorizes. */
|
|
1518
|
+
readonly kind: "refund" | "claim";
|
|
1519
|
+
readonly escrow: string;
|
|
1520
|
+
/** The recovered taker's spend half, ready for `actions.refund` or `actions.claim`. */
|
|
1521
|
+
readonly half: string;
|
|
1522
|
+
readonly claimer: string;
|
|
1523
|
+
readonly expect: SweepActionExpect;
|
|
1568
1524
|
}
|
|
1569
1525
|
|
|
1570
1526
|
export interface SweepPlanRequest {
|
|
@@ -1795,8 +1751,8 @@ export interface RecoveryApi {
|
|
|
1795
1751
|
/** Parse the recovery file. Without the right passphrase - a refusal with a code, not an exception. */
|
|
1796
1752
|
open(file: { readonly contents: string } | string, passphrase?: string): Promise<RecoveredWallet>;
|
|
1797
1753
|
/**
|
|
1798
|
-
* WHICH HEIGHT TO SCAN FROM
|
|
1799
|
-
* the
|
|
1754
|
+
* WHICH HEIGHT TO SCAN FROM. The height written into the file is the only source; no height is a named state -
|
|
1755
|
+
* the person can type one.
|
|
1800
1756
|
*/
|
|
1801
1757
|
restoreHeight(request: RestoreHeightRequest): Promise<RestoreHeightResult>;
|
|
1802
1758
|
}
|
|
@@ -1810,12 +1766,12 @@ export interface RestoreHeightResult {
|
|
|
1810
1766
|
readonly address: string | null;
|
|
1811
1767
|
/** 0 when no source knows a height. */
|
|
1812
1768
|
readonly height: number;
|
|
1813
|
-
readonly source: "
|
|
1769
|
+
readonly source: "file" | "none";
|
|
1814
1770
|
readonly fileHeight: number;
|
|
1815
1771
|
readonly appHeight: number;
|
|
1816
|
-
/** Whether the service was asked
|
|
1772
|
+
/** Whether the retired service was asked. Always false: the SDK no longer carries that route. */
|
|
1817
1773
|
readonly appAsked: boolean;
|
|
1818
|
-
/** When `source` is "none": "
|
|
1774
|
+
/** When `source` is "none": "no-height". Null when a height was found. */
|
|
1819
1775
|
readonly appProblem: string | null;
|
|
1820
1776
|
}
|
|
1821
1777
|
|
|
@@ -1855,7 +1811,7 @@ export type ErrorCode =
|
|
|
1855
1811
|
| "quote-unavailable"
|
|
1856
1812
|
| "quote-refused"
|
|
1857
1813
|
/**
|
|
1858
|
-
* An address on the interface's `denylist` refused BEFORE any request - the order's `locker` before
|
|
1814
|
+
* An address on the interface's `denylist` refused BEFORE any request - the order's `locker` before a relay quote,
|
|
1859
1815
|
* or the actual sender before `swaps.start` (issue #16). Also names the node's own `denied-address` refusal as it
|
|
1860
1816
|
* reaches the app: WITHOUT the node's `why` text and WITHOUT the address, so the interface shows its own message.
|
|
1861
1817
|
*/
|
|
@@ -1869,6 +1825,8 @@ export type ErrorCode =
|
|
|
1869
1825
|
| "quote-field-unbound"
|
|
1870
1826
|
/** The quote's own `validUntil` has passed. */
|
|
1871
1827
|
| "quote-expired"
|
|
1828
|
+
/** The quote arrived with less than the start margin left; ask again before showing a confirmation. */
|
|
1829
|
+
| "quote-too-short"
|
|
1872
1830
|
/** There was no chain read to ask the registry whose key it is: the claim stays unproven. */
|
|
1873
1831
|
| "quote-registry-unchecked"
|
|
1874
1832
|
/** The registry has no provider for this key: nobody owns it. */
|
|
@@ -1885,12 +1843,19 @@ export type ErrorCode =
|
|
|
1885
1843
|
| "quote-factory-mismatch"
|
|
1886
1844
|
/** The factory's runtime code is not a build this interface knows (`extcodehash`). */
|
|
1887
1845
|
| "quote-factory-code-unknown"
|
|
1846
|
+
/** The signed quote names a cashier other than the network's vault. */
|
|
1847
|
+
| "quote-cashier-mismatch"
|
|
1888
1848
|
| "recovery-declined"
|
|
1889
1849
|
| "recovery-failed"
|
|
1890
1850
|
| "storage-unavailable"
|
|
1891
1851
|
| "server-unavailable"
|
|
1892
1852
|
/** The service answered and did not accept: the connection got through, the request did not (status and reason in params). */
|
|
1893
1853
|
| "server-refused"
|
|
1854
|
+
/**
|
|
1855
|
+
* THE CLAIM WAS POSTED BUT NO REAL ANSWER CAME BACK: a timeout, a reset, or a body without a usable transaction
|
|
1856
|
+
* hash. The relay may have sent the claim; the caller must read the escrow before acting again. Never success.
|
|
1857
|
+
*/
|
|
1858
|
+
| "claim-unknown"
|
|
1894
1859
|
/** The funding transaction was sent, but no status-1 receipt with the expected OrderCreated proves the escrow. */
|
|
1895
1860
|
| "funding-pending"
|
|
1896
1861
|
/** The wait for the XMR to arrive expired: a separate code, because this is a state of the money, not a breakdown. */
|
|
@@ -1907,12 +1872,15 @@ export type ErrorCode =
|
|
|
1907
1872
|
| "xmr-no-nodes"
|
|
1908
1873
|
/** The amount that arrived is below the expected one. */
|
|
1909
1874
|
| "xmr-underpaid"
|
|
1910
|
-
/**
|
|
1875
|
+
/** The view key or spend key does not belong to the address being watched. */
|
|
1876
|
+
| "xmr-address-mismatch"
|
|
1877
|
+
/** The ready deadline cannot fit the confirmations the arrival needs. */
|
|
1911
1878
|
| "xmr-too-late"
|
|
1912
1879
|
| "contract-reverted"
|
|
1913
1880
|
| "insufficient-funds"
|
|
1914
1881
|
/** A wallet/node reported a withdrawal fee above the SDK's ceiling; the transfer is refused. */
|
|
1915
1882
|
| "sweep-fee-too-high"
|
|
1883
|
+
| "sweep-fee-unknown"
|
|
1916
1884
|
/** The maker declines to pay the claim gas; the refusal is shown before the deal (issue #78). */
|
|
1917
1885
|
| "gas-refused-by-maker"
|
|
1918
1886
|
/** The claim gas was ordered but the recipient's balance did not grow. */
|
|
@@ -1934,6 +1902,10 @@ export declare class SdkError extends Error {
|
|
|
1934
1902
|
|
|
1935
1903
|
/** The step codes the SDK works with (`state.step`): the same list as the `StepCode` type. */
|
|
1936
1904
|
export declare const SDK_VERSION: string;
|
|
1905
|
+
/** The minimum remaining lifetime of a quote when a swap starts, in seconds. */
|
|
1906
|
+
export declare const LOCK_START_MARGIN_SEC: number;
|
|
1907
|
+
/** The default firm quote lifetime, in seconds. A node may override it; the SDK default stays authoritative. */
|
|
1908
|
+
export declare const DEFAULT_ORDER_QUOTE_TTL_SEC: number;
|
|
1937
1909
|
export declare const STEP_CODES: readonly StepCode[];
|
|
1938
1910
|
/** The check codes a preflight verdict names (`checks[].code`): the same list as the `CheckCode` type. */
|
|
1939
1911
|
export declare const CHECK_CODES: readonly CheckCode[];
|