@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.
Files changed (56) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +28 -16
  3. package/assets/vendors/MANIFEST.json +1 -1
  4. package/assets/vendors/sdk/sdk-browser.js +4 -4
  5. package/engine/atomic/dleq2.js +0 -4
  6. package/engine/atomic/halfenc.js +0 -4
  7. package/engine/atomic/halves.js +0 -4
  8. package/engine/atomic/order.js +0 -4
  9. package/engine/atomic/orderContext.js +0 -4
  10. package/engine/atomic/orderHalfCommit.js +0 -4
  11. package/engine/core/chainSource.js +0 -4
  12. package/engine/core/clock.js +0 -4
  13. package/engine/core/config.js +0 -4
  14. package/engine/core/finality.js +0 -4
  15. package/engine/core/format.js +0 -4
  16. package/engine/core/preSignGuards.js +0 -4
  17. package/engine/core/rfqSource.js +0 -3
  18. package/engine/core/sellWindow.js +0 -4
  19. package/engine/core/store.js +0 -4
  20. package/engine/core/swap.js +0 -4
  21. package/engine/evm/amounts.js +0 -4
  22. package/engine/evm/asyncRoute.js +0 -4
  23. package/engine/evm/auth.js +0 -4
  24. package/engine/evm/claimGas.js +2 -6
  25. package/engine/evm/dex.js +0 -4
  26. package/engine/evm/escrow.js +0 -4
  27. package/engine/evm/factory.js +0 -4
  28. package/engine/evm/fees.js +0 -4
  29. package/engine/evm/funding.js +2 -5
  30. package/engine/evm/gasReserve.js +0 -4
  31. package/engine/evm/index.js +5 -9
  32. package/engine/evm/injected.js +0 -4
  33. package/engine/evm/permit.js +0 -4
  34. package/engine/evm/prices.js +0 -4
  35. package/engine/evm/session.js +0 -4
  36. package/engine/mock/chain.js +0 -4
  37. package/engine/monero/address.js +0 -3
  38. package/engine/monero/halvesSweep.js +0 -4
  39. package/engine/monero/node.js +0 -4
  40. package/engine/monero/swapKeys.js +0 -4
  41. package/engine/monero/unlock.js +2 -6
  42. package/engine/monero/wallet.js +0 -3
  43. package/engine/recovery/recoveryFile.js +0 -4
  44. package/engine/recovery/restore.js +0 -4
  45. package/engine/sdk/bridge.js +3 -7
  46. package/engine/ui/dom.js +0 -4
  47. package/engine/ui/walletModal.js +0 -4
  48. package/index.d.ts +24 -23
  49. package/package.json +3 -2
  50. package/src/engine.mjs +17 -26
  51. package/src/public/recovery.d.ts +1 -1
  52. package/src/relayClaim.mjs +17 -3
  53. package/src/swap-flow.mjs +7 -10
  54. package/src/swaps.mjs +157 -70
  55. package/src/version.mjs +1 -1
  56. package/src/xmr-arrival.mjs +14 -16
@@ -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 is not copied here:
18
- // it lives under www/js/monero/unlock.js, is mirrored byte-for-byte into the engine (sdk/engine/monero/unlock.js,
19
- // guarded by tools/check-sdk-engine.mjs) and is read through the engine seam. The block parser is mirrored the
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), mirrored from www/js.
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 lets the walk stop after this slice, not after a block:
534
- // the last witness request is still a fixed slice, never the payout height. Completion is judged by the
535
- // LAST BLOCK the witness actually served, not by the slice index: a witness can stop inside the same
536
- // 20-block window as the target and still be behind it.
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