@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.
Files changed (53) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +82 -32
  3. package/THIRD_PARTY_NOTICES.md +7 -4
  4. package/assets/vendors/MANIFEST.json +1 -9
  5. package/assets/vendors/sdk/sdk-browser.js +4 -6
  6. package/engine/core/config.js +5 -24
  7. package/engine/core/deployments.generated.js +33 -0
  8. package/engine/core/rfqSource.js +6 -133
  9. package/engine/core/swap.js +1 -1
  10. package/engine/evm/index.js +3 -2
  11. package/engine/evm/session.js +46 -277
  12. package/engine/monero/address.js +15 -33
  13. package/engine/monero/keys.js +124 -0
  14. package/engine/monero/mnemonic.js +104 -0
  15. package/engine/monero/scan.js +79 -17
  16. package/engine/monero/wallet.js +31 -68
  17. package/engine/monero/wordlist.en.js +210 -0
  18. package/engine/recovery/restore.js +1 -1
  19. package/engine/sdk/bridge.js +7 -182
  20. package/engine/ui/walletModal.js +7 -27
  21. package/index.d.ts +248 -254
  22. package/package.json +6 -7
  23. package/src/codes.mjs +12 -0
  24. package/src/config.mjs +16 -54
  25. package/src/engine.mjs +3 -0
  26. package/src/index.mjs +25 -46
  27. package/src/order.mjs +2 -2
  28. package/src/public/networks.d.ts +9 -0
  29. package/src/public/networks.mjs +1 -0
  30. package/src/public/recovery.d.ts +17 -1
  31. package/src/public/recovery.mjs +1 -0
  32. package/src/public/xmr.d.ts +8 -0
  33. package/src/public/xmr.mjs +1 -1
  34. package/src/quotePolicy.mjs +58 -0
  35. package/src/quotes.mjs +30 -753
  36. package/src/readyWindow.mjs +76 -0
  37. package/src/record.mjs +4 -0
  38. package/src/recovery-key.mjs +39 -2
  39. package/src/recovery.mjs +11 -28
  40. package/src/relayClaim.mjs +132 -0
  41. package/src/relayFirmClient.mjs +3 -0
  42. package/src/relayQuote.mjs +5 -1
  43. package/src/swap-flow.mjs +49 -5
  44. package/src/swaps.mjs +530 -317
  45. package/src/sweep-action.mjs +73 -0
  46. package/src/sweep.mjs +7 -1
  47. package/src/version.mjs +1 -1
  48. package/src/witness-slice.mjs +84 -0
  49. package/src/xmr-arrival.mjs +378 -9
  50. package/src/xmrAmountPolicy.mjs +35 -0
  51. package/assets/vendors/monero/monero-js-browser.js +0 -58
  52. package/assets/vendors/monero-js/LICENSE +0 -9
  53. 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
+ }