@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.
Files changed (73) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE-POLICY.md +9 -2
  3. package/README.md +78 -28
  4. package/THIRD_PARTY_NOTICES.md +176 -2
  5. package/assets/vendors/MANIFEST.json +1 -13
  6. package/assets/vendors/sdk/sdk-browser.js +5 -4
  7. package/engine/atomic/dleq2.js +116 -15
  8. package/engine/atomic/order.js +21 -3
  9. package/engine/core/config.js +20 -46
  10. package/engine/core/deployments.generated.js +103 -0
  11. package/engine/core/rfqSource.js +6 -133
  12. package/engine/core/swap.js +8 -8
  13. package/engine/evm/asyncRoute.js +1 -1
  14. package/engine/evm/claimGas.js +2 -1
  15. package/engine/evm/escrow.js +13 -8
  16. package/engine/evm/factory.js +11 -6
  17. package/engine/evm/funding.js +8 -3
  18. package/engine/evm/index.js +5 -6
  19. package/engine/evm/session.js +48 -279
  20. package/engine/monero/address.js +15 -33
  21. package/engine/monero/keys.js +124 -0
  22. package/engine/monero/mnemonic.js +104 -0
  23. package/engine/monero/scan.js +121 -28
  24. package/engine/monero/wallet.js +31 -68
  25. package/engine/monero/wordlist.en.js +210 -0
  26. package/engine/recovery/restore.js +9 -9
  27. package/engine/sdk/bridge.js +9 -187
  28. package/engine/ui/walletModal.js +7 -27
  29. package/index.d.ts +234 -262
  30. package/package.json +7 -6
  31. package/src/actions.mjs +8 -5
  32. package/src/codes.mjs +17 -0
  33. package/src/config.mjs +17 -54
  34. package/src/engine.mjs +9 -6
  35. package/src/feeEstimate.mjs +11 -4
  36. package/src/http.mjs +4 -1
  37. package/src/index.mjs +24 -45
  38. package/src/legs/kyber.mjs +23 -0
  39. package/src/lock.mjs +1 -0
  40. package/src/order.mjs +110 -22
  41. package/src/primitives.mjs +4 -5
  42. package/src/probes.mjs +9 -3
  43. package/src/public/networks.d.ts +45 -0
  44. package/src/public/networks.mjs +10 -1
  45. package/src/public/recovery.d.ts +17 -1
  46. package/src/public/recovery.mjs +1 -0
  47. package/src/public/xmr.mjs +1 -1
  48. package/src/quotePolicy.mjs +25 -0
  49. package/src/quotes.mjs +109 -765
  50. package/src/readyWindow.mjs +76 -0
  51. package/src/recovery-key.mjs +71 -16
  52. package/src/recovery.mjs +11 -28
  53. package/src/relayClaim.mjs +132 -0
  54. package/src/relayFeatures.mjs +25 -13
  55. package/src/relayFirmClient.mjs +36 -7
  56. package/src/relayQuote.mjs +92 -11
  57. package/src/relayView.mjs +3 -3
  58. package/src/swap-flow.mjs +146 -60
  59. package/src/swaps.mjs +521 -357
  60. package/src/sweep-action.mjs +73 -0
  61. package/src/sweep-restore.mjs +8 -4
  62. package/src/sweep.mjs +12 -2
  63. package/src/version.mjs +1 -1
  64. package/src/xmr-arrival.mjs +328 -29
  65. package/src/xmrAmountPolicy.mjs +35 -0
  66. package/assets/vendors/atomic/atomic-browser.js +0 -24
  67. package/assets/vendors/monero/monero-js-browser.js +0 -58
  68. package/assets/vendors/monero-js/LICENSE +0 -9
  69. package/assets/vendors/walletconnect/wc-browser.js +0 -6202
  70. package/engine/atomic/order-client.js +0 -56
  71. package/engine/atomic/order-worker.js +0 -156
  72. package/engine/evm/asyncExec.js +0 -577
  73. package/engine/evm/asyncLegs.js +0 -308
@@ -2,14 +2,12 @@
2
2
  // Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
3
3
  // Everything below this header is identical to the source.
4
4
 
5
- // A wallet-connect modal: browser-wallet choice and a QR for WalletConnect.
5
+ // A wallet-connect modal for the injected connector: browser-wallet choice only.
6
6
  // The browser-wallet list comes from outside (setChoices); detection is evm/injected.js by EIP-6963. Here is
7
7
  // only rendering: the CSP bans inline styles, so everything goes through dom.h(), and wallet icons are data: URLs.
8
- // NOT the Reown (@reown/appkit) modal: it draws its own inline styles and <style> blocks, both banned by the demo
9
- // CSP, and we did not weaken it for a modal. So we draw the modal ourselves and the QR with a qrcode generator as a data: URL.
10
- // No secrets here: the QR holds the public WalletConnect session URI (wc:...), safe to show like any dapp.
8
+ // The host owns any WalletConnect or QR UI.
11
9
 
12
- import { h, copy } from "./dom.js";
10
+ import { h } from "./dom.js";
13
11
 
14
12
  export function openWalletModal({ title = "Connect a wallet", subtitle = "", hint = "" } = {}) {
15
13
  const refs = {};
@@ -23,11 +21,8 @@ export function openWalletModal({ title = "Connect a wallet", subtitle = "", hin
23
21
  (refs.subtitle = h("div", { class: "ar-modal-sub", text: subtitle })),
24
22
  // The browser-wallet list: empty until detection delivers it (then invisible).
25
23
  (refs.choices = h("div", { class: "ar-modal-choices" })),
26
- (refs.qrBox = h("div", { class: "ar-modal-qr", hidden: true }, [(refs.qr = h("img", { alt: "WalletConnect QR code" }))])),
27
- (refs.uri = h("code", { class: "ar-modal-uri" })),
28
24
  (refs.status = h("div", { class: "ar-modal-status" })),
29
25
  h("div", { class: "ar-modal-actions" }, [
30
- (refs.copyBtn = h("button", { class: "ar-btn-ghost", type: "button", text: "Copy link" })),
31
26
  (refs.cancelBtn = h("button", { class: "ar-btn-ghost", type: "button", text: "Cancel" })),
32
27
  ]),
33
28
  (refs.hint = h("div", { class: "ar-modal-hint", text: hint })),
@@ -39,10 +34,6 @@ export function openWalletModal({ title = "Connect a wallet", subtitle = "", hin
39
34
  const closed = { value: false };
40
35
  let onCancel = null;
41
36
 
42
- // TWO DIFFERENT EXITS FROM THE MODAL, and the difference is fundamental: close() closes it programmatically
43
- // (e.g. the session settled), while cancel() is the user refusing - and THAT is when we must kill the session
44
- // we asked for. They must not be confused: before, a successful connect closed the modal, which fired the
45
- // cancel handler and deleted the just-created session.
46
37
  function close() {
47
38
  if (closed.value) return;
48
39
  closed.value = true;
@@ -57,16 +48,13 @@ export function openWalletModal({ title = "Connect a wallet", subtitle = "", hin
57
48
 
58
49
  refs.closeBtn.addEventListener("click", cancel);
59
50
  refs.cancelBtn.addEventListener("click", cancel);
60
- refs.copyBtn.addEventListener("click", () => {
61
- if (refs.uri.textContent) copy(refs.uri.textContent, "WalletConnect link copied");
62
- });
63
51
  overlay.addEventListener("click", (e) => {
64
52
  if (e.target === overlay) cancel();
65
53
  });
66
54
 
67
- // setChoices([{ key, name, icon, hint, onClick }]) - the browser-wallet list plus WalletConnect. Icons are
68
- // data: URLs only (the wallet itself provides them): external addresses are not allowed by the demo CSP, and
69
- // rightly so - a network image must not influence which wallet is chosen.
55
+ // setChoices([{ key, name, icon, hint, onClick }]) - the browser-wallet list. Icons are data: URLs only
56
+ // (the wallet itself provides them): external addresses are not allowed by the demo CSP, and rightly so -
57
+ // a network image must not influence which wallet is chosen.
70
58
  function setChoices(list) {
71
59
  refs.choices.innerHTML = "";
72
60
  refs.choices.hidden = !list || !list.length;
@@ -80,8 +68,6 @@ export function openWalletModal({ title = "Connect a wallet", subtitle = "", hin
80
68
  item.hint ? h("span", { class: "ar-modal-choice-hint", text: item.hint }) : null,
81
69
  ]),
82
70
  ]);
83
- // The rest of the modal is closed by whoever handled the choice: a browser wallet shows its own window,
84
- // while WalletConnect still needs the QR shown.
85
71
  btn.addEventListener("click", () => {
86
72
  if (closed.value) return;
87
73
  item.onClick();
@@ -99,14 +85,8 @@ export function openWalletModal({ title = "Connect a wallet", subtitle = "", hin
99
85
  setOnCancel(fn) {
100
86
  onCancel = fn;
101
87
  },
102
- update({ qrDataUrl, uri, status, subtitle, hint: hintText, error } = {}) {
88
+ update({ status, subtitle, hint: hintText, error } = {}) {
103
89
  if (closed.value) return;
104
- if (qrDataUrl) {
105
- refs.qr.src = qrDataUrl;
106
- // The frame is shown only when a QR actually exists: before WalletConnect is chosen this is empty.
107
- refs.qrBox.hidden = false;
108
- }
109
- if (uri !== undefined) refs.uri.textContent = uri || "";
110
90
  if (subtitle !== undefined) refs.subtitle.textContent = subtitle || "";
111
91
  if (hintText !== undefined) refs.hint.textContent = hintText || "";
112
92
  // error is more important than status: otherwise a generic "try again" overwrites the error text, and