@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/engine/ui/walletModal.js
CHANGED
|
@@ -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
|
|
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
|
-
//
|
|
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
|
|
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
|
|
68
|
-
//
|
|
69
|
-
//
|
|
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({
|
|
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
|