@ninsei-labs/sdk 0.60.0 → 0.62.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 +57 -0
- package/README.md +81 -18
- package/assets/vendors/MANIFEST.json +1 -1
- package/assets/vendors/sdk/sdk-browser.js +4 -4
- package/engine/atomic/dleq2.js +0 -4
- package/engine/atomic/halfenc.js +6 -10
- package/engine/atomic/halves.js +0 -4
- package/engine/atomic/order.js +0 -4
- package/engine/atomic/orderContext.js +0 -4
- package/engine/atomic/orderHalfCommit.js +0 -4
- package/engine/core/chainSource.js +0 -4
- package/engine/core/clock.js +0 -4
- package/engine/core/config.js +17 -42
- package/engine/core/finality.js +0 -4
- package/engine/core/format.js +1 -5
- package/engine/core/preSignGuards.js +0 -4
- package/engine/core/rfqSource.js +0 -3
- package/engine/core/sellWindow.js +1 -5
- package/engine/core/store.js +11 -7
- package/engine/core/swap.js +3 -7
- package/engine/evm/amounts.js +2 -6
- package/engine/evm/asyncRoute.js +3 -7
- package/engine/evm/auth.js +0 -4
- package/engine/evm/claimGas.js +2 -6
- package/engine/evm/dex.js +1 -5
- package/engine/evm/escrow.js +0 -4
- package/engine/evm/factory.js +1 -5
- package/engine/evm/fees.js +62 -4
- package/engine/evm/funding.js +73 -71
- package/engine/evm/gasReserve.js +10 -4
- package/engine/evm/index.js +7 -11
- package/engine/evm/injected.js +0 -4
- package/engine/evm/permit.js +0 -4
- package/engine/evm/prices.js +3 -4
- package/engine/evm/session.js +1 -5
- package/engine/mock/chain.js +0 -4
- package/engine/monero/address.js +4 -5
- package/engine/monero/arrivalRead.js +15 -2
- package/engine/monero/halvesSweep.js +0 -4
- package/engine/monero/keyImage.js +146 -0
- package/engine/monero/keys.js +1 -0
- package/engine/monero/mnemonic.js +2 -1
- package/engine/monero/node.js +1 -4
- package/engine/monero/scan.js +12 -2
- package/engine/monero/swapKeys.js +0 -4
- package/engine/monero/unlock.js +2 -6
- package/engine/monero/wallet.js +0 -3
- package/engine/recovery/recoveryFile.js +31 -89
- package/engine/recovery/restore.js +0 -4
- package/engine/sdk/bridge.js +24 -58
- package/engine/ui/dom.js +0 -4
- package/engine/ui/walletModal.js +0 -4
- package/index.d.ts +436 -42
- package/package.json +22 -3
- package/src/actions.mjs +72 -6
- package/src/addressGuard.mjs +16 -0
- package/src/codes.mjs +26 -9
- package/src/config.mjs +56 -3
- package/src/decline.mjs +23 -74
- package/src/engine.mjs +17 -26
- package/src/firmRequest.mjs +80 -0
- package/src/index.mjs +17 -28
- package/src/legs/cow.mjs +2 -2
- package/src/legs/evm.mjs +20 -12
- package/src/legs/kyber-spec.mjs +2 -2
- package/src/legs/kyber.mjs +1 -1
- package/src/legs/shape.mjs +1 -1
- package/src/legs/uniswaprelay.mjs +16 -4
- package/src/legs/uniswapx.mjs +29 -7
- package/src/levelsWalkSpec.mjs +1 -1
- package/src/lock.mjs +18 -37
- package/src/provider/envFile.mjs +3 -3
- package/src/provider/sign.mjs +3 -3
- package/src/public/evm.d.ts +84 -0
- package/src/public/evm.mjs +20 -0
- package/src/public/order.mjs +1 -1
- package/src/public/provider.mjs +1 -1
- package/src/public/recovery.d.ts +4 -3
- package/src/public/recovery.mjs +1 -1
- package/src/public/xmr.d.ts +2 -2
- package/src/quoteEip712Spec.mjs +4 -4
- package/src/quotes.mjs +52 -11
- package/src/recovery-key.mjs +7 -3
- package/src/relayClaim.mjs +17 -3
- package/src/relayFirmClient.mjs +4 -0
- package/src/relayQuote.mjs +1 -0
- package/src/sim.mjs +1 -1
- package/src/swap-flow.mjs +28 -41
- package/src/swaps.mjs +217 -123
- package/src/sweep-inputs.mjs +61 -0
- package/src/sweep-reconcile.mjs +71 -0
- package/src/sweep-restore.mjs +38 -9
- package/src/sweep.mjs +164 -10
- package/src/version.mjs +1 -1
- package/src/wallet.mjs +1 -1
- package/src/xmr-arrival.mjs +1053 -57
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninsei-labs/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.62.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
7
7
|
},
|
|
8
|
-
"packageManager": "pnpm@12.
|
|
8
|
+
"packageManager": "pnpm@12.21.0",
|
|
9
9
|
"description": "XMR <-> EVM swap engine: quotes, guards, order steps, recovery (no DOM, no user-facing strings)",
|
|
10
10
|
"license": "(MIT AND LGPL-3.0-only)",
|
|
11
11
|
"type": "module",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"check:pack": "node tools/check.mjs --only=pack",
|
|
22
22
|
"check:pack-teeth": "node tools/run-teeth-isolated.mjs tools/check-pack-teeth.mjs",
|
|
23
23
|
"check:guard-teeth": "node tools/run-teeth-isolated.mjs tools/check-guard-teeth.mjs",
|
|
24
|
+
"check:claim-teeth": "node tools/run-teeth-isolated.mjs tools/check-claim-teeth.mjs",
|
|
24
25
|
"check:secrets": "node tools/check.mjs --only=secrets",
|
|
25
26
|
"check:vendor-bundles": "node tools/check.mjs --only=vendor-bundles",
|
|
26
27
|
"check:dleq-vectors": "node tools/check-dleq-vectors.mjs",
|
|
@@ -37,6 +38,11 @@
|
|
|
37
38
|
"check:terminal-teeth": "node tools/run-teeth-isolated.mjs tools/check-terminal-teeth.mjs",
|
|
38
39
|
"check:sweep": "node tools/sweep-refusal.test.mjs",
|
|
39
40
|
"check:sweep-half": "node tools/check-sweep-half.mjs",
|
|
41
|
+
"check:sweep-relay": "node tools/check-sweep-relay.mjs",
|
|
42
|
+
"check:sweep-sign-guards": "node tools/check-sweep-sign-guards.mjs",
|
|
43
|
+
"check:sweep-inputs": "node tools/check-sweep-inputs.mjs",
|
|
44
|
+
"check:sweep-reconcile": "node tools/check-sweep-reconcile.mjs",
|
|
45
|
+
"check:quote-figures": "node tools/check-quote-figures.mjs",
|
|
40
46
|
"sync:version": "node tools/sync-version.mjs",
|
|
41
47
|
"check:restore": "node tools/check-restore.mjs",
|
|
42
48
|
"check:wallet-factory": "node tools/check-wallet-factory.mjs",
|
|
@@ -47,6 +53,10 @@
|
|
|
47
53
|
"check:arrival-read": "node tools/check-arrival-read.mjs",
|
|
48
54
|
"check:backup-confirmation": "node tools/check-backup-confirmation.mjs",
|
|
49
55
|
"check:key-view": "node tools/check-key-view.mjs",
|
|
56
|
+
"check:key-image": "node tools/check-key-image.mjs",
|
|
57
|
+
"check:key-image-teeth": "node tools/check-key-image-teeth.mjs",
|
|
58
|
+
"check:key-image-oracle": "node tools/check-key-image-oracle.mjs",
|
|
59
|
+
"check:key-image-stand": "node tools/check-key-image-stand.mjs",
|
|
50
60
|
"check:relay-view": "node tools/check-relay-view.mjs",
|
|
51
61
|
"check:relay-terms": "node tools/check-relay-terms.mjs",
|
|
52
62
|
"check:relay-features": "node tools/check-relay-features.mjs",
|
|
@@ -57,6 +67,12 @@
|
|
|
57
67
|
"check:sell-watch": "node tools/check-sell-watch.mjs",
|
|
58
68
|
"check:sell-start": "node tools/check-sell-start.mjs",
|
|
59
69
|
"check:arrival-consensus": "node tools/check-arrival-consensus.mjs",
|
|
70
|
+
"check:arrival-recovery": "node tools/check-arrival-recovery.mjs",
|
|
71
|
+
"check:recovery-read": "node tools/check.mjs --only=recovery-read",
|
|
72
|
+
"check:recovery-read-live": "node tools/check-recovery-read-live.mjs",
|
|
73
|
+
"check:recovery-witness": "node tools/check.mjs --only=recovery-witness",
|
|
74
|
+
"check:recovery-witness-live": "node tools/check-recovery-witness-live.mjs",
|
|
75
|
+
"check:recovery-acceptance": "node tools/check-recovery-acceptance.mjs",
|
|
60
76
|
"check:arrival-shadow": "node tools/check-arrival-shadow.mjs",
|
|
61
77
|
"check:arrival-real": "node tools/check-arrival-real.mjs",
|
|
62
78
|
"check:order-proof": "node tools/check-order-proof.mjs",
|
|
@@ -76,6 +92,7 @@
|
|
|
76
92
|
"check:contract-vectors": "node tools/check-contract-vectors.mjs",
|
|
77
93
|
"check:live-contract": "node tools/check-live-contract.mjs",
|
|
78
94
|
"check:anvil-fork": "node tools/check-anvil-fork.mjs",
|
|
95
|
+
"check:anvil-fee": "node tools/check-anvil-fee.mjs",
|
|
79
96
|
"check:dex": "node tools/check.mjs --only=cow,cow-refusal,kyber,kyber-refusal,uniswapx,uniswapx-refusal,uniswap-relay,uniswap-relay-refusal",
|
|
80
97
|
"check:anvil-uniswap": "node tools/check-anvil-uniswap.mjs",
|
|
81
98
|
"check:atomic-flow": "node tools/check-atomic-flow.mjs",
|
|
@@ -84,6 +101,7 @@
|
|
|
84
101
|
"check:types-consumer": "node node_modules/typescript/bin/tsc -p tools/ts-consumer/tsconfig.json",
|
|
85
102
|
"check:monero-live": "node tools/check-monero-live.mjs",
|
|
86
103
|
"check:native-amount": "node tools/check-native-amount.mjs",
|
|
104
|
+
"check:native-amount-teeth": "node tools/run-teeth-isolated.mjs tools/check-native-amount-teeth.mjs",
|
|
87
105
|
"check:ci-boundary": "node tools/check-ci-boundary.mjs",
|
|
88
106
|
"coverage": "node tools/coverage.mjs"
|
|
89
107
|
},
|
|
@@ -143,7 +161,7 @@
|
|
|
143
161
|
"THIRD_PARTY_NOTICES.md"
|
|
144
162
|
],
|
|
145
163
|
"engines": {
|
|
146
|
-
"node": ">=24.22.
|
|
164
|
+
"node": ">=24.22.3"
|
|
147
165
|
},
|
|
148
166
|
"keywords": [
|
|
149
167
|
"xmr",
|
|
@@ -180,6 +198,7 @@
|
|
|
180
198
|
"sideEffects": false,
|
|
181
199
|
"devDependencies": {
|
|
182
200
|
"esbuild": "0.28.2",
|
|
201
|
+
"monero-ts": "0.11.22",
|
|
183
202
|
"typescript": "7.0.2"
|
|
184
203
|
},
|
|
185
204
|
"allowScripts": {
|
package/src/actions.mjs
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// claiming it is revealing your own half (irreversible), for refunding the same reveal. The transaction still
|
|
10
10
|
// looks successful.
|
|
11
11
|
import { SdkError } from "./errors.mjs";
|
|
12
|
+
import { ERROR_CODES } from "./codes.mjs";
|
|
12
13
|
// THE DEAL FLOW IS NOW A PACKAGE MODULE, NOT AN ENGINE FILE (#32, wave 3): www/js/core/swap-flow.js moved to
|
|
13
14
|
// sdk/src/swap-flow.mjs. The actions therefore call the module directly instead of reaching it through the
|
|
14
15
|
// mirror - there is exactly one implementation, and it lives here.
|
|
@@ -44,13 +45,76 @@ const requestOrFail = (request, extra) => {
|
|
|
44
45
|
return request;
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
//
|
|
48
|
+
// A WALLET ERROR IS NOT A CONTRACT REVERT. EIP-1193 providers report a refusal, a missing permission, another
|
|
49
|
+
// chain or a busy request with numeric codes; the old wrapper turned all of them into `contract-reverted`. The
|
|
50
|
+
// interface then told the person the escrow had refused a transaction it never saw. A real revert is recognised
|
|
51
|
+
// by the receipt, a revert-shaped error, or the message - and only then leaves as `contract-reverted`.
|
|
52
|
+
const codeOfError = (error) => error && (error.code || (error.data && error.data.originalError && error.data.originalError.code));
|
|
53
|
+
const messageOfError = (error) => String((error && error.message) || error || "");
|
|
54
|
+
const isProviderError = (error) => {
|
|
55
|
+
const code = codeOfError(error);
|
|
56
|
+
return typeof code === "number" || (typeof code === "string" && !ERROR_CODES.includes(code));
|
|
57
|
+
};
|
|
58
|
+
const actionFailure = (error, step) => {
|
|
59
|
+
// ERRORS ALREADY NAMED BY THE SDK KEEP THEIR CODE. The flow and the chain guards speak the same vocabulary;
|
|
60
|
+
// wrapping them a second time would erase `why` and turn a named refusal into a generic one.
|
|
61
|
+
if (error instanceof SdkError) throw error;
|
|
62
|
+
if (typeof (error && error.code) === "string" && ERROR_CODES.includes(error.code)) {
|
|
63
|
+
throw new SdkError(error.code, { ...(error.params || {}), step });
|
|
64
|
+
}
|
|
65
|
+
const code = codeOfError(error);
|
|
66
|
+
const message = messageOfError(error);
|
|
67
|
+
const receiptStatus = error && error.receipt && error.receipt.status;
|
|
68
|
+
const explicitReject = code === 4001 || code === "ACTION_REJECTED"
|
|
69
|
+
|| /user rejected|user denied|rejected by user|denied by user|action_rejected/i.test(message);
|
|
70
|
+
// A NAMED REVERT WINS OVER A MESSAGE THAT MENTIONS "revert"; a wallet's own 4001 wins over generic
|
|
71
|
+
// revert-shaped text, so a localized "cannot be reverted" refusal is not blamed on the escrow.
|
|
72
|
+
const namedRevert = code === "contract-reverted" || code === 3
|
|
73
|
+
|| receiptStatus === 0 || receiptStatus === "0x0" || receiptStatus === "0";
|
|
74
|
+
if (namedRevert) throw new SdkError("contract-reverted", { step, why: "revert" });
|
|
75
|
+
// 4001 IS THE PERSON'S DECISION, not a chain answer. A textual rejection is accepted as the same event
|
|
76
|
+
// because some injected providers send no numeric code.
|
|
77
|
+
if (explicitReject) throw new SdkError("wallet-rejected", { step });
|
|
78
|
+
// REVERT DATA ONLY COUNTS AFTER A REFUSAL. A 4001/ACTION_REJECTED error may carry arbitrary provider data;
|
|
79
|
+
// it is still the person's decision, not an escrow answer.
|
|
80
|
+
if ((error && typeof error.data === "string" && error.data.startsWith("0x")) || /execution reverted|revert/i.test(message)) {
|
|
81
|
+
throw new SdkError("contract-reverted", { step, why: "revert" });
|
|
82
|
+
}
|
|
83
|
+
// A DETERMINISTIC WALLET REFUSAL HAS ITS OWN CODE. No gas is a wallet-side state, not a transport failure:
|
|
84
|
+
// retrying the same transaction will fail the same way until the account is funded.
|
|
85
|
+
if (code === "INSUFFICIENT_FUNDS" || /insufficient funds/i.test(message)) {
|
|
86
|
+
throw new SdkError("insufficient-funds", { step });
|
|
87
|
+
}
|
|
88
|
+
// 4902 IS A WALLET THAT DOES NOT KNOW THE CHAIN. It is a wallet-side refusal with its own existing code, not
|
|
89
|
+
// a wrong contract answer.
|
|
90
|
+
if (code === 4902 || /unrecognized chain|not added|unknown chain/i.test(message)) {
|
|
91
|
+
throw new SdkError("wrong-chain", { vm: "evm", step, why: "unknown-chain" });
|
|
92
|
+
}
|
|
93
|
+
// THE WALLET IS NOT USABLE FOR THIS REQUEST. 4100 has no permission for the account, -32002 already has a
|
|
94
|
+
// request open, and a transport failure never reached a node. Keep one wallet-side code and name the reason.
|
|
95
|
+
if (code === 4100) throw new SdkError("wallet-not-connected", { step, why: "unauthorized" });
|
|
96
|
+
if (code === -32002 || /already pending|already processing/i.test(message)) {
|
|
97
|
+
throw new SdkError("wallet-not-connected", { step, why: "request-pending" });
|
|
98
|
+
}
|
|
99
|
+
if (isProviderError(error)) {
|
|
100
|
+
throw new SdkError("wallet-not-connected", { step, why: "transport", providerCode: code ?? null });
|
|
101
|
+
}
|
|
102
|
+
// AN UNCLASSIFIED FAILURE IS NOT A REVERT. The old fallback claimed the escrow refused; that is a statement
|
|
103
|
+
// about the chain we cannot make from an error we did not classify.
|
|
104
|
+
throw new SdkError("unknown", { step, why: "unclassified" });
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// THE SAME CLASSIFIER FOR THE FUNDING PATH. `actionFailure` throws because the actions wrapper wants that shape;
|
|
108
|
+
// funding needs the named error as a value so it can rethrow it after its own pending-record cleanup.
|
|
109
|
+
export const walletError = (error, step) => {
|
|
110
|
+
try { actionFailure(error, step); }
|
|
111
|
+
catch (named) { return named; }
|
|
112
|
+
return new SdkError("unknown", { step, why: "unclassified" });
|
|
113
|
+
};
|
|
114
|
+
|
|
48
115
|
const withCodes = async (step, work) => {
|
|
49
116
|
try { return await work(); }
|
|
50
|
-
catch (error) {
|
|
51
|
-
if (error && typeof error.code === "string") throw error;
|
|
52
|
-
throw new SdkError("contract-reverted", { step });
|
|
53
|
-
}
|
|
117
|
+
catch (error) { actionFailure(error, step); }
|
|
54
118
|
};
|
|
55
119
|
|
|
56
120
|
export function createActions({ call = null, blockTime = null } = {}) {
|
|
@@ -74,7 +138,9 @@ export function createActions({ call = null, blockTime = null } = {}) {
|
|
|
74
138
|
const tx = from ? { to, data, from } : { to, data };
|
|
75
139
|
const result = await provider.request({ method: "eth_call", params: [tx, "latest"] });
|
|
76
140
|
if (typeof result !== "string" || !result.startsWith("0x")) {
|
|
77
|
-
|
|
141
|
+
// A MALFORMED `eth_call` ANSWER IS A NODE FAILURE, NOT A WALLET STATE. `unknown` keeps it out of both
|
|
142
|
+
// `contract-reverted` and the wallet-side codes; the reason names what was wrong.
|
|
143
|
+
throw new SdkError("unknown", { surface: "actions.read", why: "bad-answer" });
|
|
78
144
|
}
|
|
79
145
|
return result;
|
|
80
146
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// ONE ADDRESS CHECK FOR EVERY PATH THAT CAN MOVE MONEY.
|
|
2
|
+
//
|
|
3
|
+
// `checkAddress` answers the shape, the checksum and the network. A caller that forgets it used to be able to send
|
|
4
|
+
// XMR to a malformed address or to another Monero network; `sweep.sign` and `swaps.start` now share this boundary.
|
|
5
|
+
import { SdkError } from "./errors.mjs";
|
|
6
|
+
import { checkAddress } from "../engine/monero/address.js";
|
|
7
|
+
|
|
8
|
+
export async function checkAddressOrThrow(address, network, field) {
|
|
9
|
+
const shape = await checkAddress(address, network ? { expectNetwork: network } : {});
|
|
10
|
+
if (shape.ok === true) return;
|
|
11
|
+
// THE NETWORK IS A FIELD, NOT A SENTENCE. The refusal still carries the human reason for the caller, but the
|
|
12
|
+
// decision uses the actual network reported by `checkAddress`; editing its wording cannot reclassify the error.
|
|
13
|
+
const wrongNetwork = shape.network !== undefined && network !== null
|
|
14
|
+
&& network !== undefined && shape.network !== network;
|
|
15
|
+
throw new SdkError(wrongNetwork ? "wrong-chain" : "bad-input", { field, why: shape.reason || null });
|
|
16
|
+
}
|
package/src/codes.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// CODE TABLES. The single place where the codes are named: they are read by the SDK, by the check and by the README.
|
|
2
2
|
//
|
|
3
3
|
// Why codes and not texts: wording, translations and tone are the interface's business. The core must name a
|
|
4
|
-
// state so that it can be translated and coloured without parsing a string
|
|
4
|
+
// state so that it can be translated and coloured without parsing a string.
|
|
5
5
|
|
|
6
6
|
export const STEP_CODES = [
|
|
7
7
|
"awaiting_funding",
|
|
@@ -13,7 +13,7 @@ export const STEP_CODES = [
|
|
|
13
13
|
"swept",
|
|
14
14
|
];
|
|
15
15
|
|
|
16
|
-
// `declined` IS A TERMINAL STATE OF ITS OWN
|
|
16
|
+
// `declined` IS A TERMINAL STATE OF ITS OWN: the maker refused a funded order, so the whole balance -
|
|
17
17
|
// the fee included - is already back in the depositor's wallet and NO half was revealed. It is told apart from
|
|
18
18
|
// `refunded_eth`, which is the depositor taking the ETH back and DOES reveal a half (src/decline.mjs).
|
|
19
19
|
// `xmr_returned` WAS DECLARED HERE AND IS GONE (it had no writer anywhere): the maker's reclaim of the XMR does
|
|
@@ -51,7 +51,7 @@ export const ERROR_CODES = [
|
|
|
51
51
|
"wrong-account",
|
|
52
52
|
"quote-unavailable",
|
|
53
53
|
"quote-refused",
|
|
54
|
-
// A NODE'S ADDRESS DENYLIST REFUSAL
|
|
54
|
+
// A NODE'S ADDRESS DENYLIST REFUSAL: the maker's node answers {ok:false, code:"denied-address", why}
|
|
55
55
|
// before it prices the order, and that refusal reaches the app under THIS code - WITHOUT the node's `why` text
|
|
56
56
|
// and WITHOUT the address, because the interface shows the person its own neutral message. It is its own code,
|
|
57
57
|
// not "quote-refused": the advice to the interface differs ("this address is barred" vs "the quote was refused").
|
|
@@ -80,7 +80,7 @@ export const ERROR_CODES = [
|
|
|
80
80
|
"quote-key-unknown",
|
|
81
81
|
"quote-provider-mismatch",
|
|
82
82
|
"quote-provider-not-allowed",
|
|
83
|
-
// THE FACTORY THAT WILL VERIFY THE QUOTE AND WHERE ITS FEE GOES
|
|
83
|
+
// THE FACTORY THAT WILL VERIFY THE QUOTE AND WHERE ITS FEE GOES. The factory is taken from
|
|
84
84
|
// the provider's REGISTRY RECORD and its CODE is checked against the interface's known builds (extcodehash):
|
|
85
85
|
// quote-factory-unchecked - no way to read the factory / its code, so the claim stays unproven;
|
|
86
86
|
// quote-factory-unknown - the record names no factory (zero);
|
|
@@ -103,7 +103,7 @@ export const ERROR_CODES = [
|
|
|
103
103
|
// THE CLAIM WAS POSTED BUT NO REAL ANSWER CAME BACK. A timeout, a reset or a body without a usable transaction
|
|
104
104
|
// hash leaves the outcome UNKNOWN: the relay may have sent the claim, and the half is already out of the client.
|
|
105
105
|
// It is NOT `server-unavailable` (which would invite a blind retry) and NOT a success: the caller must read the
|
|
106
|
-
// escrow before doing anything else. `params.why` names the lost part (`answer-lost`, `answer-txid
|
|
106
|
+
// escrow before doing anything else. `params.why` names the lost part (`answer-lost`, `answer-txid`,...).
|
|
107
107
|
"claim-unknown",
|
|
108
108
|
// THE TRANSACTION WAS SENT BUT THE RECEIPT DOES NOT PROVE AN ESCROW: no receipt yet, no expected OrderCreated,
|
|
109
109
|
// or a receipt from another factory. The tx hash is the handle for a retry read; nothing was saved as funded.
|
|
@@ -112,12 +112,12 @@ export const ERROR_CODES = [
|
|
|
112
112
|
// money, not a breakdown and not an empty response: mixing it with other refusals, the interface could not
|
|
113
113
|
// tell "not arrived yet" from "broken".
|
|
114
114
|
"xmr-timeout",
|
|
115
|
-
// XMR IS ON THE ADDRESS BUT BARRED BY THE TRANSACTION'S unlock_time
|
|
115
|
+
// XMR IS ON THE ADDRESS BUT BARRED BY THE TRANSACTION'S unlock_time. Distinct from `xmr-timeout`:
|
|
116
116
|
// that one means "nothing arrived within the wait", this one means "money is there and CANNOT be spent until a
|
|
117
117
|
// height or a date". Marking ready under it would hand the escrow to the maker for funds he cannot be paid from -
|
|
118
118
|
// so the core refuses with its own code, and the `until` boundary travels in params.
|
|
119
119
|
"xmr-locked",
|
|
120
|
-
// THE XMR ARRIVAL CHECK ON TWO NODES
|
|
120
|
+
// THE XMR ARRIVAL CHECK ON TWO NODES. The decision "the XMR arrived" is made by the client, and a
|
|
121
121
|
// single node is a single truth that can lie. Each code names a different reason the button must stay closed:
|
|
122
122
|
// xmr-nodes-disagree - a synced node has no such transaction in that block or a different block hash there;
|
|
123
123
|
// xmr-no-nodes - every node in the list is unreachable, so nothing can be confirmed;
|
|
@@ -135,7 +135,19 @@ export const ERROR_CODES = [
|
|
|
135
135
|
// normal transfer.
|
|
136
136
|
"sweep-fee-too-high",
|
|
137
137
|
"sweep-fee-unknown",
|
|
138
|
-
//
|
|
138
|
+
// THE WITHDRAWAL HAS NO COMPLETE SCAN OR NEEDS MORE THAN ONE TRANSACTION. Signing without a completed restore
|
|
139
|
+
// is a blind spend; a split sweep pays several fees and turns one withdrawal into several transactions.
|
|
140
|
+
"sweep-scan-incomplete",
|
|
141
|
+
"sweep-split",
|
|
142
|
+
// THE SIGNED TRANSACTION AND THE VERIFIED UNSPENT SET MUST NAME THE SAME INPUTS. A signed set that cannot be
|
|
143
|
+
// read is unknown; a set that differs is refused before relay.
|
|
144
|
+
"sweep-inputs-changed",
|
|
145
|
+
"sweep-inputs-unknown",
|
|
146
|
+
// THE WITHDRAWAL WAS SENT BUT THE WALLET DID NOT CONFIRM THE RESULT. A throw or an answer without a transaction
|
|
147
|
+
// id leaves the signed set in the open session. The caller must check the chain before signing again; the same
|
|
148
|
+
// token must not relay that set twice.
|
|
149
|
+
"sweep-relay-unknown",
|
|
150
|
+
// CLAIM GAS FOR THE XMR SELLER. The seller comes from Monero and has no coin on the EVM side to pay
|
|
139
151
|
// for the claim, so the maker may send it - but only when asked for, and only after the core has CONFIRMED the
|
|
140
152
|
// gas actually arrived. The three codes name the three states the interface must not blur together:
|
|
141
153
|
// gas-refused-by-maker - the maker declines to pay the claim gas, and the refusal is shown BEFORE the deal;
|
|
@@ -205,6 +217,11 @@ export const ERROR_META = Object.freeze({
|
|
|
205
217
|
"insufficient-funds": { retryable: false, side: "wallet" },
|
|
206
218
|
"sweep-fee-too-high": { retryable: false, side: "chain" },
|
|
207
219
|
"sweep-fee-unknown": { retryable: true, side: "chain" },
|
|
220
|
+
"sweep-scan-incomplete": { retryable: true, side: "chain" },
|
|
221
|
+
"sweep-split": { retryable: false, side: "wallet" },
|
|
222
|
+
"sweep-inputs-changed": { retryable: false, side: "chain" },
|
|
223
|
+
"sweep-inputs-unknown": { retryable: false, side: "wallet" },
|
|
224
|
+
"sweep-relay-unknown": { retryable: false, side: "chain" },
|
|
208
225
|
"gas-refused-by-maker": { retryable: false, side: "provider" },
|
|
209
226
|
"gas-not-arrived": { retryable: true, side: "chain" },
|
|
210
227
|
"gas-too-little": { retryable: false, side: "provider" },
|
|
@@ -260,7 +277,7 @@ export const KIND_TO_CHECK = {
|
|
|
260
277
|
"t1-not-after-ready-by": "deadline",
|
|
261
278
|
"ready-window-too-short": "deadline",
|
|
262
279
|
"claim-window-too-short": "deadline",
|
|
263
|
-
// A DEADLINE TOO FAR AHEAD
|
|
280
|
+
// A DEADLINE TOO FAR AHEAD: the order's t1 is a year away, and the
|
|
264
281
|
// ETH cannot be returned until then. It shares the `deadline` code with the other two extremes.
|
|
265
282
|
"deadline-too-far": "deadline",
|
|
266
283
|
// escrow state
|
package/src/config.mjs
CHANGED
|
@@ -61,7 +61,7 @@ const chainConfig = (chain) => ({
|
|
|
61
61
|
// refuses an answer whose `cashier` is not this network's vault, and the funding path fills the order terms
|
|
62
62
|
// from the same projection. A projection that drops the field leaves a client built from a network NAME with
|
|
63
63
|
// no vault at all, so every relay quote ends as `no-pinned-cashier` - a defect in the profile, not in the
|
|
64
|
-
// answer
|
|
64
|
+
// answer. Nothing else fills these fields: the projection is the one place both facades read.
|
|
65
65
|
escrow: chain.escrow ? {
|
|
66
66
|
address: chain.escrow.address || null,
|
|
67
67
|
mode: chain.escrow.mode || null,
|
|
@@ -88,7 +88,7 @@ const chainConfig = (chain) => ({
|
|
|
88
88
|
// carry a client for the old node's HTTP surface: those routes were retired, and a client that still names them
|
|
89
89
|
// would silently make every request against a service that no longer exists.
|
|
90
90
|
|
|
91
|
-
// THE MONERO NODES THE ARRIVAL IS CHECKED AGAINST. Defaults are the list verified on 2026-10-02
|
|
91
|
+
// THE MONERO NODES THE ARRIVAL IS CHECKED AGAINST. Defaults are the list verified on 2026-10-02:
|
|
92
92
|
// mainnet - four public nodes of different operators; stagenet - our node and the one independent public node.
|
|
93
93
|
// `ready` opens only when two nodes of DIFFERENT operators agree on the block (see sdk/src/xmr-arrival.mjs), so
|
|
94
94
|
// the list is a list of WITNESSES, not of equal endpoints.
|
|
@@ -107,6 +107,11 @@ export const DEFAULT_XMR_NODES = Object.freeze({
|
|
|
107
107
|
{ url: "https://xmr-stagenet.ninsei.finance", operator: "Ninsei" },
|
|
108
108
|
{ url: "https://stagenet.xmr.kernal.eu:38089", operator: "kernal.eu" },
|
|
109
109
|
],
|
|
110
|
+
// TESTNET AND REGTEST HAVE NO PUBLIC NODES OF OURS. The network is accepted, and the map is present but empty:
|
|
111
|
+
// a caller can name its own list through `nodes` or `addNodes`; an empty list is not a typo and not a fallback to
|
|
112
|
+
// stagenet. Without this key, even a valid testnet node list was refused as `unknown`.
|
|
113
|
+
testnet: [],
|
|
114
|
+
fakechain: [],
|
|
110
115
|
});
|
|
111
116
|
|
|
112
117
|
const nodeEntryOk = (raw) => (typeof raw === "string" && raw)
|
|
@@ -117,7 +122,12 @@ const nodesArrayOk = (a) => Array.isArray(a) && a.every(nodeEntryOk);
|
|
|
117
122
|
const nodesOf = (options, selected) => {
|
|
118
123
|
const custom = options && options.nodes;
|
|
119
124
|
const extra = options && options.addNodes;
|
|
120
|
-
const out = {
|
|
125
|
+
const out = {
|
|
126
|
+
mainnet: [...DEFAULT_XMR_NODES.mainnet],
|
|
127
|
+
stagenet: [...DEFAULT_XMR_NODES.stagenet],
|
|
128
|
+
testnet: [...DEFAULT_XMR_NODES.testnet],
|
|
129
|
+
fakechain: [...DEFAULT_XMR_NODES.fakechain],
|
|
130
|
+
};
|
|
121
131
|
if (custom !== undefined && custom !== null) {
|
|
122
132
|
if (nodesArrayOk(custom)) {
|
|
123
133
|
if (!(selected in out)) fail("bad-input", { field: "nodes", network: selected });
|
|
@@ -178,10 +188,53 @@ const endpointsOf = (raw, options) => {
|
|
|
178
188
|
};
|
|
179
189
|
};
|
|
180
190
|
|
|
191
|
+
export function escrowOverrideOf(settlement) {
|
|
192
|
+
const raw = settlement && settlement.escrow;
|
|
193
|
+
if (raw === undefined || raw === null) return null;
|
|
194
|
+
if (!settlement || settlement.chain !== "local-anvil") {
|
|
195
|
+
fail("bad-input", { field: "settlement.escrow", why: "only-local-anvil" });
|
|
196
|
+
}
|
|
197
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) fail("bad-input", { field: "settlement.escrow" });
|
|
198
|
+
const address = String(raw.address || "");
|
|
199
|
+
if (!/^0x[0-9a-fA-F]{40}$/.test(address)) {
|
|
200
|
+
fail("bad-input", { field: "settlement.escrow.address" });
|
|
201
|
+
}
|
|
202
|
+
const text = (field) => {
|
|
203
|
+
if (raw[field] === undefined || raw[field] === null) return null;
|
|
204
|
+
if (typeof raw[field] !== "string" || !/^0x[0-9a-fA-F]{40}$/.test(raw[field])) {
|
|
205
|
+
fail("bad-input", { field: "settlement.escrow." + field });
|
|
206
|
+
}
|
|
207
|
+
return raw[field];
|
|
208
|
+
};
|
|
209
|
+
if (raw.implementationCodeHash !== undefined && raw.implementationCodeHash !== null) {
|
|
210
|
+
if (typeof raw.implementationCodeHash !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(raw.implementationCodeHash)) {
|
|
211
|
+
fail("bad-input", { field: "settlement.escrow.implementationCodeHash" });
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (raw.deploymentBlock !== undefined && raw.deploymentBlock !== null
|
|
215
|
+
&& (typeof raw.deploymentBlock !== "number" || !Number.isSafeInteger(raw.deploymentBlock) || raw.deploymentBlock < 0)) {
|
|
216
|
+
fail("bad-input", { field: "settlement.escrow.deploymentBlock" });
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
address,
|
|
220
|
+
cashier: text("cashier"),
|
|
221
|
+
registry: text("registry"),
|
|
222
|
+
implementationCodeHash: raw.implementationCodeHash === undefined ? null : raw.implementationCodeHash,
|
|
223
|
+
deploymentBlock: raw.deploymentBlock === undefined || raw.deploymentBlock === null ? null : raw.deploymentBlock,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
181
227
|
export function buildConfig(options) {
|
|
182
228
|
const chains = engine.config.CHAINS.map(chainConfig);
|
|
183
229
|
const chosen = chains.find((c) => c.id === options.settlement.chain) || null;
|
|
184
230
|
if (!chosen) fail("bad-input", { field: "settlement.chain", known: chains.map((c) => c.id) });
|
|
231
|
+
// A LOCAL CHAIN'S ADDRESSES ARE CREATED, NOT CONSTANT. The caller may hand the deployment that its own anvil
|
|
232
|
+
// just produced; the address, cashier and implementation pin then travel with the network into quotes, funding and
|
|
233
|
+
// the arrival read. The override is deliberately local-anvil only: a public network's pins stay reviewed data.
|
|
234
|
+
const override = escrowOverrideOf(options.settlement);
|
|
235
|
+
if (override) {
|
|
236
|
+
chosen.escrow = { ...(chosen.escrow || {}), ...override };
|
|
237
|
+
}
|
|
185
238
|
const rawChain = engine.config.CHAINS.find((c) => c.id === options.settlement.chain) || {};
|
|
186
239
|
const watch = watchOf(options);
|
|
187
240
|
const endpoints = endpointsOf(rawChain, options);
|
package/src/decline.mjs
CHANGED
|
@@ -1,37 +1,17 @@
|
|
|
1
|
-
// THE MAKER'S DECLINE
|
|
1
|
+
// THE MAKER'S DECLINE.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// balance, the fee included, back to the locker. NO half is revealed: there is nothing to recover, and nobody
|
|
6
|
-
// assembles a Monero key from a declined order.
|
|
3
|
+
// A decline is a maker closing a funded order. The escrow sets `refunded`, emits `Declined(claimer)` and returns the
|
|
4
|
+
// balance to the locker. No half is revealed.
|
|
7
5
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// The two are not the same event, though. An ordinary refund is the depositor (or whoever holds their half)
|
|
11
|
-
// taking the ETH back when the maker did not claim; it REVEALS THE DEPOSITOR'S HALF (`HalfRevealed(half, false)`)
|
|
12
|
-
// so the maker can still take their XMR. A decline is the MAKER closing the order in the depositor's favour and
|
|
13
|
-
// reveals nothing. On screen the two want different things said and different buttons hidden, so the SDK tells
|
|
14
|
-
// them apart instead of reporting "refunded" for both.
|
|
6
|
+
// `status()` shows the same `refunded` state as an ordinary refund. The SDK reads the `Declined` event or the node's
|
|
7
|
+
// `declined` status with code `compliance` to tell them apart.
|
|
15
8
|
//
|
|
16
|
-
//
|
|
17
|
-
// 1) THE ESCROW'S `Declined` EVENT (the chain) - `declinedFromLogs`. The escrow has no getter for a decline
|
|
18
|
-
// (there is no `declined()` view), so the event is the on-chain fact that names it; it is read through the
|
|
19
|
-
// same read seam as every other chain read - an `eth_getLogs` over the escrow's address.
|
|
20
|
-
// 2) THE NODE'S SWAP STATUS `declined` WITH THE CODE `compliance` (the wire) - `declinedFromStatus`. Those ARE
|
|
21
|
-
// the two fields the node returns and nothing else, so BOTH are required: the bare word without its code is
|
|
22
|
-
// not the state the node names, and guessing at it would put a category on a refusal that carries none.
|
|
23
|
-
//
|
|
24
|
-
// WHAT IS DELIBERATELY NOT CARRIED: a reason, a category, a provider. The node returns only `compliance` on
|
|
25
|
-
// purpose - it does not name who declined or why - so the SDK reports the state, the node's own single token and
|
|
26
|
-
// which reader saw it, AND NOTHING ELSE (see DECLINE_FIELDS below). The sentence a person reads is the
|
|
27
|
-
// interface's: this package holds no user-facing string, and a decline is no exception.
|
|
9
|
+
// The SDK reports the state, the node's token and the reader. It does not invent a reason, a category or a provider.
|
|
28
10
|
import { SdkError } from "./errors.mjs";
|
|
29
11
|
import { keccak256 } from "./primitives.mjs";
|
|
30
12
|
import * as engine from "./engine.mjs";
|
|
31
13
|
|
|
32
|
-
//
|
|
33
|
-
// does it: keccak256("Declined(address)"). The topic is exported so a caller filters logs with it rather than
|
|
34
|
-
// deriving it a second time - a second copy of the same event would be a second truth about it.
|
|
14
|
+
// The event signature is assembled once and hashed as Solidity does. Callers filter logs with the exported topic.
|
|
35
15
|
export const DECLINE_EVENT_NAME = "Declined";
|
|
36
16
|
export const DECLINE_EVENT_SIGNATURE = () => `${DECLINE_EVENT_NAME}(${["address"].join(",")})`;
|
|
37
17
|
|
|
@@ -42,33 +22,21 @@ const hexOf = (bytes) => {
|
|
|
42
22
|
};
|
|
43
23
|
|
|
44
24
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* escrows deployed before the indexing carry the claimer in data instead, which is why this module matches only
|
|
48
|
-
* topic0 and does not assume a claimer position.
|
|
25
|
+
* The `Declined(address)` topic. The current escrow indexes `claimer` in topic1. Older escrows put the claimer in
|
|
26
|
+
* data, so this module matches topic0 only.
|
|
49
27
|
*/
|
|
50
28
|
export const DECLINED_TOPIC0 = hexOf(keccak256(DECLINE_EVENT_SIGNATURE()));
|
|
51
29
|
|
|
52
|
-
//
|
|
53
|
-
// node's single token, deliberately opaque: it says "a screening decision was taken", not by whom or on what.
|
|
30
|
+
// The node's two fields for a declined swap: `{ status: "declined", code: "compliance" }`. The code is opaque.
|
|
54
31
|
export const DECLINED_STATUS = "declined";
|
|
55
32
|
export const DECLINED_CODE = "compliance";
|
|
56
33
|
|
|
57
|
-
//
|
|
58
|
-
// phrases the sentence itself; the package contributes the state and the code, not the words.
|
|
34
|
+
// The terminal state the interface draws from. The package supplies the state and the code, not the words.
|
|
59
35
|
export const DECLINED_TERMINAL = "declined";
|
|
60
36
|
|
|
61
37
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* `declined` - what happened (true/false);
|
|
65
|
-
* `terminal` - the state the interface draws from (`declined`, or null);
|
|
66
|
-
* `code` - the node's own token, UNCHANGED, or null;
|
|
67
|
-
* `source` - which reader saw it: `event` (the escrow) or `status` (the node). PROVENANCE, NOT A REASON:
|
|
68
|
-
* it says where the SDK learned it, not why the maker refused;
|
|
69
|
-
* `at` - when it was seen (epoch ms), or null;
|
|
70
|
-
* `checked` - whether the chain was read at all. `false` means "not measured", which is NOT "no decline" - a
|
|
71
|
-
* caller that blurs the two would read a maker's refusal as an ordinary refund.
|
|
38
|
+
* The fields of a decline report. Keep this list short. `source` is provenance, not a reason. `checked: false` means
|
|
39
|
+
* the chain was not read, which is not the same as "no decline".
|
|
72
40
|
*/
|
|
73
41
|
export const DECLINE_FIELDS = ["declined", "terminal", "code", "source", "at", "checked"];
|
|
74
42
|
|
|
@@ -92,13 +60,8 @@ export const declineNone = ({ source = null, at = null, checked = true } = {}) =
|
|
|
92
60
|
verdictOf({ declined: false, terminal: null, code: null, source, at, checked });
|
|
93
61
|
|
|
94
62
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* reported as an escrow that declined nothing.
|
|
98
|
-
*
|
|
99
|
-
* Only the FIRST TOPIC is compared (the event's own signature). A log from another address is skipped when the
|
|
100
|
-
* answer carries one and the caller named the escrow; a log without an address is still matched, because the
|
|
101
|
-
* request that produced it was filtered by address and dropping it would hide a real decline.
|
|
63
|
+
* The escrow's `Declined` event. `logs` must be an array. A log from another address is skipped when the caller named
|
|
64
|
+
* the escrow. A log without an address still matches because the read was filtered by address.
|
|
102
65
|
*/
|
|
103
66
|
export function declinedFromLogs(logs, { escrow = null, at = null } = {}) {
|
|
104
67
|
if (!Array.isArray(logs)) throw new SdkError("bad-input", { field: "logs", why: "not-array" });
|
|
@@ -113,13 +76,8 @@ export function declinedFromLogs(logs, { escrow = null, at = null } = {}) {
|
|
|
113
76
|
}
|
|
114
77
|
|
|
115
78
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* `userStatus` (the field the maker API names it by). BOTH fields must be there and must be exactly these tokens;
|
|
119
|
-
* anything else is not the state the node names, and a partial match is NOT a decline.
|
|
120
|
-
*
|
|
121
|
-
* A body that is not an object at all answers `checked: false` - there was nothing to read, which is not the same
|
|
122
|
-
* as having read it and found no decline.
|
|
79
|
+
* The node's status. It accepts `{ status: "declined", code: "compliance" }` at the top level or under `userStatus`.
|
|
80
|
+
* Both fields must match. A body that is not an object answers `checked: false`.
|
|
123
81
|
*/
|
|
124
82
|
export function declinedFromStatus(body, { at = null } = {}) {
|
|
125
83
|
if (!body || typeof body !== "object") return declineNone({ source: "status", at, checked: false });
|
|
@@ -133,10 +91,8 @@ export function declinedFromStatus(body, { at = null } = {}) {
|
|
|
133
91
|
}
|
|
134
92
|
|
|
135
93
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* verdict stays, with `source: null` when neither was read), and a body without the node's two fields does not
|
|
139
|
-
* cancel a chain answer.
|
|
94
|
+
* Both sources. Either one is enough. The chain is read first and the wire second. A body without the node's fields
|
|
95
|
+
* does not cancel a chain answer.
|
|
140
96
|
*/
|
|
141
97
|
export function declineOf({ logs = undefined, status = undefined, escrow = null, at = null } = {}) {
|
|
142
98
|
const fromChain = Array.isArray(logs) ? declinedFromLogs(logs, { escrow, at }) : null;
|
|
@@ -149,14 +105,8 @@ export function declineOf({ logs = undefined, status = undefined, escrow = null,
|
|
|
149
105
|
}
|
|
150
106
|
|
|
151
107
|
/**
|
|
152
|
-
*
|
|
153
|
-
* `
|
|
154
|
-
* follows). It is a READ, not a node substitution: the address is the caller's escrow and the filter is the
|
|
155
|
-
* decline's own topic.
|
|
156
|
-
*
|
|
157
|
-
* `fromBlock` is the caller's: a watch that knows the escrow's birth height scans from there instead of walking
|
|
158
|
-
* the chain's whole history. An answer that is not an array is a REFUSAL - a node that answered something else
|
|
159
|
-
* did not answer "no decline", and a caller must not read it as one.
|
|
108
|
+
* The default log reader: `eth_getLogs` through the page wallet, so the reader and the signer use the same provider.
|
|
109
|
+
* `fromBlock` is the caller's. An answer that is not an array is a refusal, not "no decline".
|
|
160
110
|
*/
|
|
161
111
|
export async function readDeclinedLogs({ address, topics = [DECLINED_TOPIC0], fromBlock = "earliest", toBlock = "latest" } = {}) {
|
|
162
112
|
if (typeof address !== "string" || !/^0x[0-9a-fA-F]{40}$/.test(address)) throw new SdkError("bad-input", { field: "logs.address" });
|
|
@@ -172,9 +122,8 @@ export async function readDeclinedLogs({ address, topics = [DECLINED_TOPIC0], fr
|
|
|
172
122
|
export const logReaderOf = (logs) => (typeof logs === "function" ? logs : readDeclinedLogs);
|
|
173
123
|
|
|
174
124
|
/**
|
|
175
|
-
* A
|
|
176
|
-
*
|
|
177
|
-
* block: scanning too far is slow, scanning too little misses the event.
|
|
125
|
+
* A block boundary as the node wants it. A value that is not a whole, non-negative number falls back to the safe end
|
|
126
|
+
* of the chain. Scanning too far is slow. Scanning too little misses the event.
|
|
178
127
|
*/
|
|
179
128
|
export const blockBoundaryOf = (height, fallback = "earliest") => {
|
|
180
129
|
const value = Number(height);
|