@ninsei-labs/sdk 0.60.0 → 0.61.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 +28 -16
- 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 +0 -4
- 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 +0 -4
- package/engine/core/finality.js +0 -4
- package/engine/core/format.js +0 -4
- package/engine/core/preSignGuards.js +0 -4
- package/engine/core/rfqSource.js +0 -3
- package/engine/core/sellWindow.js +0 -4
- package/engine/core/store.js +0 -4
- package/engine/core/swap.js +0 -4
- package/engine/evm/amounts.js +0 -4
- package/engine/evm/asyncRoute.js +0 -4
- package/engine/evm/auth.js +0 -4
- package/engine/evm/claimGas.js +2 -6
- package/engine/evm/dex.js +0 -4
- package/engine/evm/escrow.js +0 -4
- package/engine/evm/factory.js +0 -4
- package/engine/evm/fees.js +0 -4
- package/engine/evm/funding.js +2 -5
- package/engine/evm/gasReserve.js +0 -4
- package/engine/evm/index.js +5 -9
- package/engine/evm/injected.js +0 -4
- package/engine/evm/permit.js +0 -4
- package/engine/evm/prices.js +0 -4
- package/engine/evm/session.js +0 -4
- package/engine/mock/chain.js +0 -4
- package/engine/monero/address.js +0 -3
- package/engine/monero/halvesSweep.js +0 -4
- package/engine/monero/node.js +0 -4
- 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 +0 -4
- package/engine/recovery/restore.js +0 -4
- package/engine/sdk/bridge.js +3 -7
- package/engine/ui/dom.js +0 -4
- package/engine/ui/walletModal.js +0 -4
- package/index.d.ts +24 -23
- package/package.json +3 -2
- package/src/engine.mjs +17 -26
- package/src/public/recovery.d.ts +1 -1
- package/src/relayClaim.mjs +17 -3
- package/src/swap-flow.mjs +7 -10
- package/src/swaps.mjs +157 -70
- package/src/version.mjs +1 -1
- package/src/xmr-arrival.mjs +14 -16
package/src/xmr-arrival.mjs
CHANGED
|
@@ -14,10 +14,9 @@
|
|
|
14
14
|
// and the screen says the nodes do not agree. When only one operator has confirmed, the core names that state
|
|
15
15
|
// (`one-node`) instead of waiting silently.
|
|
16
16
|
//
|
|
17
|
-
// WHERE THE RULE LIVES. "Locked by unlock_time is not an arrival" is ONE rule (issue #84). It
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
// same way (www/js/monero/scan.js) - a second copy would be a second truth about money.
|
|
17
|
+
// WHERE THE RULE LIVES. "Locked by unlock_time is not an arrival" is ONE rule (issue #84). It lives in the
|
|
18
|
+
// SDK's engine (engine/monero/unlock.js) and is read through the engine seam. The block parser lives beside it
|
|
19
|
+
// (engine/monero/scan.js) - a second copy would be a second truth about money.
|
|
21
20
|
//
|
|
22
21
|
// PRIVACY. Public nodes are asked for the WHOLE BLOCK (get_block plus /get_transactions over all of the block's
|
|
23
22
|
// hashes), never for a single transaction: otherwise a node links the user's IP to the trade. Requests carry
|
|
@@ -402,7 +401,7 @@ export async function verifyArrival(request) {
|
|
|
402
401
|
const amountAtomic = best.nodes[0].amountAtomic;
|
|
403
402
|
const agreedBy = best.nodes.map((r) => ({ url: r.url, operator: r.operator, blockHash: r.blockHash, confirmations: r.confirmations }));
|
|
404
403
|
|
|
405
|
-
// LOCKED IS NOT AN ARRIVAL, and the rule for that is the shared one (issue #84),
|
|
404
|
+
// LOCKED IS NOT AN ARRIVAL, and the rule for that is the shared one (issue #84), in the SDK engine.
|
|
406
405
|
const locked = best.nodes.find((r) => r.unlock && r.unlock.locked);
|
|
407
406
|
if (locked) {
|
|
408
407
|
const until = locked.unlock;
|
|
@@ -530,14 +529,10 @@ async function locateInSlices(node, { expectedAtomic, address, viewSecret, spend
|
|
|
530
529
|
if (!best || score > best.score || (score === best.score && amountAtomic > best.amountAtomic)) best = candidate;
|
|
531
530
|
}
|
|
532
531
|
}
|
|
533
|
-
// THE WHOLE SLICE WAS READ. A perfect candidate
|
|
534
|
-
// the
|
|
535
|
-
//
|
|
536
|
-
//
|
|
537
|
-
if (best && best.score === 7) {
|
|
538
|
-
completed = slice.to >= target;
|
|
539
|
-
break;
|
|
540
|
-
}
|
|
532
|
+
// THE WHOLE SLICE WAS READ. A perfect candidate does not end the walk: a later slice can contain a newer tip,
|
|
533
|
+
// and the witness must still prove it reached the common target. Completion is judged by the LAST BLOCK the
|
|
534
|
+
// witness actually served, not by the slice index: a witness can stop inside the same 20-block window as the
|
|
535
|
+
// target and still be behind it.
|
|
541
536
|
if (index === last) completed = slice.to >= target;
|
|
542
537
|
}
|
|
543
538
|
return { located: best, completed, servedTop, failure };
|
|
@@ -674,9 +669,6 @@ export async function verifyArrivalShadow(request) {
|
|
|
674
669
|
if (!located) failed.push(...staleWitnesses);
|
|
675
670
|
const completedOperators = [...completedWitnessOperators];
|
|
676
671
|
const independentOperators = completedOperators.filter((operator) => String(operator).toLowerCase() !== "ninsei");
|
|
677
|
-
const required = 2;
|
|
678
|
-
const witnessQuorum = { required, completed: completedOperators, independent: independentOperators,
|
|
679
|
-
ok: (network === "mainnet" ? independentOperators.length : completedOperators.length) >= required };
|
|
680
672
|
|
|
681
673
|
// ONE OPINION PER OPERATOR, THEN COMPARE THE OPINIONS. A second instance of the same operator may repeat the
|
|
682
674
|
// first, but it may not silently contradict it; a different operator that reports another block, amount or
|
|
@@ -718,6 +710,12 @@ export async function verifyArrivalShadow(request) {
|
|
|
718
710
|
const field = observationField(representatives[0], representatives[i]);
|
|
719
711
|
if (field) witnessDisagreements.push({ operators: [representatives[0].operator, representatives[i].operator], field });
|
|
720
712
|
}
|
|
713
|
+
// A QUORUM OF WALKERS IS NOT A QUORUM OF ANSWERS. Compute this after the witness-to-witness comparison: two
|
|
714
|
+
// completed operators that disagree have not agreed on anything, even though each reached the target.
|
|
715
|
+
const required = 2;
|
|
716
|
+
const witnessQuorum = { required, completed: completedOperators, independent: independentOperators,
|
|
717
|
+
ok: (network === "mainnet" ? independentOperators.length : completedOperators.length) >= required
|
|
718
|
+
&& witnessDisagreements.length === 0 };
|
|
721
719
|
const witnessEvidence = { observations: representatives, disagreements: witnessDisagreements };
|
|
722
720
|
|
|
723
721
|
const witness = located
|