@ninsei-labs/sdk 0.57.2 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +82 -32
- package/THIRD_PARTY_NOTICES.md +7 -4
- package/assets/vendors/MANIFEST.json +1 -9
- package/assets/vendors/sdk/sdk-browser.js +4 -6
- package/engine/core/config.js +5 -24
- package/engine/core/deployments.generated.js +33 -0
- package/engine/core/rfqSource.js +6 -133
- package/engine/core/swap.js +1 -1
- package/engine/evm/index.js +3 -2
- package/engine/evm/session.js +46 -277
- package/engine/monero/address.js +15 -33
- package/engine/monero/keys.js +124 -0
- package/engine/monero/mnemonic.js +104 -0
- package/engine/monero/scan.js +79 -17
- package/engine/monero/wallet.js +31 -68
- package/engine/monero/wordlist.en.js +210 -0
- package/engine/recovery/restore.js +1 -1
- package/engine/sdk/bridge.js +7 -182
- package/engine/ui/walletModal.js +7 -27
- package/index.d.ts +248 -254
- package/package.json +6 -7
- package/src/codes.mjs +12 -0
- package/src/config.mjs +16 -54
- package/src/engine.mjs +3 -0
- package/src/index.mjs +25 -46
- package/src/order.mjs +2 -2
- package/src/public/networks.d.ts +9 -0
- package/src/public/networks.mjs +1 -0
- package/src/public/recovery.d.ts +17 -1
- package/src/public/recovery.mjs +1 -0
- package/src/public/xmr.d.ts +8 -0
- package/src/public/xmr.mjs +1 -1
- package/src/quotePolicy.mjs +58 -0
- package/src/quotes.mjs +30 -753
- package/src/readyWindow.mjs +76 -0
- package/src/record.mjs +4 -0
- package/src/recovery-key.mjs +39 -2
- package/src/recovery.mjs +11 -28
- package/src/relayClaim.mjs +132 -0
- package/src/relayFirmClient.mjs +3 -0
- package/src/relayQuote.mjs +5 -1
- package/src/swap-flow.mjs +49 -5
- package/src/swaps.mjs +530 -317
- package/src/sweep-action.mjs +73 -0
- package/src/sweep.mjs +7 -1
- package/src/version.mjs +1 -1
- package/src/witness-slice.mjs +84 -0
- package/src/xmr-arrival.mjs +378 -9
- package/src/xmrAmountPolicy.mjs +35 -0
- package/assets/vendors/monero/monero-js-browser.js +0 -58
- package/assets/vendors/monero-js/LICENSE +0 -9
- package/assets/vendors/walletconnect/wc-browser.js +0 -6202
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// THE XMR AMOUNT A QUOTE MAY SIGN FOR A REQUESTED AMOUNT.
|
|
2
|
+
//
|
|
3
|
+
// The provider's signed `xmrAmount` is allowed to be BETTER for the client than the requested figure, never worse:
|
|
4
|
+
// ask - the client buys XMR, so the provider may sign at least the requested amount;
|
|
5
|
+
// bid - the client sells XMR, so the provider may sign at most the requested amount.
|
|
6
|
+
// The ETH side stays exact and is checked separately by both callers: it is part of the proof context, not a
|
|
7
|
+
// price that may move with the XMR amount.
|
|
8
|
+
//
|
|
9
|
+
// A value that cannot be read, a negative value and an unknown side are all refused. Returning a boolean here would
|
|
10
|
+
// turn "unreadable" into "equal", so the verdict names the reason.
|
|
11
|
+
export function xmrAmountVerdict({ side, requested, signed } = {}) {
|
|
12
|
+
const parse = (value) => {
|
|
13
|
+
if (value === undefined || value === null || value === "") return null;
|
|
14
|
+
try {
|
|
15
|
+
const amount = BigInt(String(value));
|
|
16
|
+
return amount >= 0n ? amount : null;
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const want = parse(requested);
|
|
22
|
+
const got = parse(signed);
|
|
23
|
+
if (want === null || got === null) return { ok: false, reason: "unreadable" };
|
|
24
|
+
if (side === "ask") {
|
|
25
|
+
return got >= want
|
|
26
|
+
? { ok: true, side, requested: want.toString(), signed: got.toString() }
|
|
27
|
+
: { ok: false, reason: "worse", side, requested: want.toString(), signed: got.toString() };
|
|
28
|
+
}
|
|
29
|
+
if (side === "bid") {
|
|
30
|
+
return got <= want
|
|
31
|
+
? { ok: true, side, requested: want.toString(), signed: got.toString() }
|
|
32
|
+
: { ok: false, reason: "worse", side, requested: want.toString(), signed: got.toString() };
|
|
33
|
+
}
|
|
34
|
+
return { ok: false, reason: "side" };
|
|
35
|
+
}
|