@ninsei-labs/sdk 0.59.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 +32 -0
- package/README.md +40 -8
- 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/deployments.generated.js +1 -17
- 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 +89 -36
- package/package.json +3 -2
- package/src/engine.mjs +17 -26
- package/src/index.mjs +1 -1
- package/src/predictEscrow.mjs +25 -0
- package/src/public/recovery.d.ts +1 -1
- package/src/quotes.mjs +2 -5
- package/src/relayClaim.mjs +17 -3
- package/src/relayFirmClient.mjs +18 -0
- package/src/swap-flow.mjs +7 -10
- package/src/swaps.mjs +349 -76
- package/src/sweep.mjs +9 -2
- package/src/version.mjs +1 -1
- package/src/xmr-arrival.mjs +61 -41
package/engine/atomic/dleq2.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/atomic/dleq2.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// DLEQ ACROSS CURVES: a proof that one scalar stands behind points on secp256k1 and ed25519.
|
|
6
2
|
// Ported from go-dleq (prove.go, verify.go) to @noble/curves. The upstream project is
|
|
7
3
|
// github.com/athanorlabs/go-dleq at d6fd7c03e213683cbb286d4d5bbba1c7e7e1cfe1 and is licensed LGPL-3.0-only; see
|
package/engine/atomic/halfenc.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/atomic/halfenc.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// Transferring a key half: an encrypted half fit for publishing on chain.
|
|
6
2
|
// WHAT THIS IS. A half x is sent so that: third parties cannot read it (the mask comes from an ECDH shared secret
|
|
7
3
|
// with the recipient); THE RECIPIENT can check that the ciphertext holds the half matching the published point X by
|
package/engine/atomic/halves.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/atomic/halves.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// Half of a Monero key for the XMR <-> EVM atomic swap.
|
|
6
2
|
// The Monero spend key is the sum of two halves: ks = ks_a + ks_b (mod l); spending needs both.
|
|
7
3
|
// One half must work on edwards25519 (Monero) and secp256k1 (EVM), so the scalar stays below the smaller
|
package/engine/atomic/order.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/atomic/order.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// ASSEMBLING ONE ORDER SIDE of an atomic swap: a key half, points, a proof, the encrypted envelope and the
|
|
6
2
|
// contract commitment.
|
|
7
3
|
//
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/atomic/orderContext.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// CANONICAL ORDER CONTEXT - what the DLEQ proof binds to.
|
|
6
2
|
// It is built FROM THE ORDER FIELDS and identically everywhere (app, provider node, any verifier), so a
|
|
7
3
|
// proof can be checked from the on-chain order alone (docs 27, section 11).
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/atomic/orderHalfCommit.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// COMMITMENT TO A HALF - one formula for all sides.
|
|
6
2
|
//
|
|
7
3
|
// WHAT THE CHAIN COMPUTES. `keccak256(x || y)` of the secp256k1 POINT of the half `half*G` - that is, the ADDRESS of that point.
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/core/chainSource.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// DATA SOURCE FOR THE MONERO LEG OF THE SWAP: the demo simulator or the real backend.
|
|
6
2
|
// TWO LEGS, DIFFERENT READINESS. The EVM leg (escrow, claim, refund) is a SIMULATION (no contract yet): every
|
|
7
3
|
// reply is marked mock: true and the UI must show it. The Monero leg (has XMR arrived, how many confirmations)
|
package/engine/core/clock.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/core/clock.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// Demo sim-clock.
|
|
6
2
|
//
|
|
7
3
|
// Idea: real time is compressed by the speed multiplier. speed=60 means one
|
package/engine/core/config.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/core/config.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// VM-neutral deployment pins generated from deployments/<vm>/<network>.json. No address table is copied below.
|
|
6
2
|
import { DEPLOYMENTS, DEPLOYMENT_CHAINS, DEPLOYMENT_VMS, FACTORY_HISTORY, deploymentFor } from "./deployments.generated.js";
|
|
7
3
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// GENERATED FILE - do not edit. Run: node tools/gen-deployment-pins.mjs --write
|
|
2
2
|
// Source: deployments/<vm>/<network>.json, copied from the reviewed contract release manifest.
|
|
3
|
-
// Factory history: deployments/history/<vm>/<network>.json,
|
|
3
|
+
// Factory history: deployments/history/<vm>/<network>.json, mainnet-only retired factories for recovery.
|
|
4
4
|
const freeze = (value) => {
|
|
5
5
|
if (value && typeof value === "object") {
|
|
6
6
|
Object.freeze(value);
|
|
@@ -87,22 +87,6 @@ const DATA = {
|
|
|
87
87
|
};
|
|
88
88
|
const HISTORY_DATA = {
|
|
89
89
|
"arbitrum-sepolia": [
|
|
90
|
-
{
|
|
91
|
-
"address": "0x3ee25f12758ec28e5b3045d16132d89cd0bf341f",
|
|
92
|
-
"deploymentBlock": 318911595,
|
|
93
|
-
"release": {
|
|
94
|
-
"tag": "contracts-testnet-2026.10.21"
|
|
95
|
-
},
|
|
96
|
-
"status": "retired"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"address": "0x69b5a6878b542960af4d239ecc60ad1c9e3e6932",
|
|
100
|
-
"deploymentBlock": 323014007,
|
|
101
|
-
"release": {
|
|
102
|
-
"tag": "contracts-testnet-2026.10.26"
|
|
103
|
-
},
|
|
104
|
-
"status": "retired"
|
|
105
|
-
},
|
|
106
90
|
{
|
|
107
91
|
"address": "0x245d3a4ac4b98d713f6c5130b56cd5d550f8cefe",
|
|
108
92
|
"deploymentBlock": 326005419,
|
package/engine/core/finality.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/core/finality.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// STATE MATURITY PER NETWORK: at which level the chain treats a record as final.
|
|
6
2
|
// One value for all networks is wrong: on base `safe` is ~25 s, on arbitrum ~13 min (measured on live nodes).
|
|
7
3
|
// On bsc, monad and hyperevm the tags are FORMAL: they answer but lag 0-1 block, so reading by `finalized`
|
package/engine/core/format.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/core/format.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// Formatting of numbers, time and addresses.
|
|
6
2
|
|
|
7
3
|
const nf = (min, max) => new Intl.NumberFormat("en-US", { minimumFractionDigits: min, maximumFractionDigits: max });
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/core/preSignGuards.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// PRE-SIGNING GUARDS: AN INADMISSIBLE DEAL DOES NOT START.
|
|
6
2
|
//
|
|
7
3
|
// WHY A SEPARATE MODULE. The guards used to live apart: one in the route registry (the DEX leg's coverage and
|
package/engine/core/rfqSource.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// THE ORDER-QUOTE MIRROR OF www/js/core/rfqSource.js. The SDK copy drops the indicative quote book that the page
|
|
2
|
-
// still uses: the bridge helpers it called are gone. Keep the order-quote path in sync with the source.
|
|
3
|
-
|
|
4
1
|
// THE ORDER QUOTE FOR THE EXECUTOR FALLBACK. This module no longer carries the indicative quote book: the SDK has
|
|
5
2
|
// no book path, and the bridge helpers it called (`sdkBook`, `sdkBookSnapshot`) are gone. What remains is the
|
|
6
3
|
// order quote the executor asks for when it has to fall back to the provider, and its shape check.
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/core/sellWindow.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// XMR SELL WINDOW: ONE RULE FOR TWO SIDES, NOT TWO NUMBERS.
|
|
6
2
|
//
|
|
7
3
|
// WHY A SEPARATE MODULE. The XMR sell window (a person gives XMR, receives the network native coin) has two
|
package/engine/core/store.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/core/store.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// Demo state storage.
|
|
6
2
|
//
|
|
7
3
|
// Why it exists at all: litepaper §5.1.7 - "the tab can be closed, the browser will restore the state". The swap
|
package/engine/core/swap.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/core/swap.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// The demo core: the deal state over time.
|
|
6
2
|
//
|
|
7
3
|
// PRINCIPLE: the state is NOT kept as a "current step". Timestamps and events are kept, and the phase is derived
|
package/engine/evm/amounts.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/evm/amounts.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// Recalculating balances from the contract raw units into human-readable ones.
|
|
6
2
|
//
|
|
7
3
|
// A separate module, because this is money maths and it must be checked without a browser:
|
package/engine/evm/asyncRoute.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/evm/asyncRoute.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// ASYNCHRONOUS ROUTE PROVIDERS BY NETWORK - "IS THERE A PATH FOR A PERSON WITH NO OWN NATIVE COIN".
|
|
6
2
|
//
|
|
7
3
|
// WHY THIS MODULE EXISTS. The declared routes in the registry (www/js/core/config.js: DEX_ROUTES) are ROUTER
|
package/engine/evm/auth.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/evm/auth.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// WALLET-SIGNATURE LOGIN AND THE SERVER-SIDE SWAP LIST.
|
|
6
2
|
// Why: while swap records live only in localStorage, "my list" is tied to the browser. A server-side list
|
|
7
3
|
// fixes that; binding it to the wallet address keeps other people's swaps hidden.
|
package/engine/evm/claimGas.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/evm/claimGas.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// CLAIM GAS FOR THE XMR SELL (claim): ONE SOURCE OF TRUTH FOR THE CLIENT AND THE NODE.
|
|
6
2
|
// In a reverse swap the person gives XMR and claims ETH via `claim` on the settlement chain. They have no ETH,
|
|
7
3
|
// so the node sends the claim gas. The gas rules used to live in TWO places and the numbers differed ~100x, so
|
|
8
4
|
// a person with one gift could not send the claim. Now this module computes both numbers.
|
|
9
|
-
// WHY ONE MODULE
|
|
10
|
-
//
|
|
5
|
+
// WHY ONE MODULE: the formula must be ONE. The SDK owns the EVM engine, and the node imports it from the package;
|
|
6
|
+
// the browser and the node read the same implementation.
|
|
11
7
|
// WHAT IS ONE HERE: the claim gas limit, the fee rule (2 x baseFee + tip) and the GIFT SIZE - the same claim
|
|
12
8
|
// cost plus an EXPLICIT margin for base-fee growth between ticket and claim.
|
|
13
9
|
|
package/engine/evm/dex.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/evm/dex.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// THE DEX LEG: a Uniswap v3 quote read from the chain. READ ONLY: eth_call, not one transaction.
|
|
6
2
|
//
|
|
7
3
|
// WHAT IS REPLACED HERE. The price breakdown used to hold a mock: "Uniswap v3 USDC/WETH 0.05%" and the spread
|
package/engine/evm/escrow.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/evm/escrow.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// Calls to the NinseiSwap escrow contract (one instance = one order).
|
|
6
2
|
//
|
|
7
3
|
// There is no EVM library here: the escrow has three state-moving functions (markReady, claim, refund) and a few
|
package/engine/evm/factory.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/evm/factory.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// Calls to the NinseiSwap escrow factory contract.
|
|
6
2
|
//
|
|
7
3
|
// There are no EVM libraries in the project and we are not adding any. BOTH FACTORY FUNCTIONS NOW TAKE THE
|
package/engine/evm/fees.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/evm/fees.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// The NinseiSwap fee: PART OF THE SIGNED QUOTE (OrderQuote v7), not a contract setting.
|
|
6
2
|
//
|
|
7
3
|
// WHERE THE RATE LIVES. Before, it and the recipient were set by the FACTORY (or router) in immutable fields, and
|
package/engine/evm/funding.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/evm/funding.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// Funding an order in the escrow contract: real transactions, not a simulation.
|
|
6
2
|
//
|
|
7
3
|
// Roles and why:
|
|
@@ -255,7 +251,8 @@ export async function fundOrder({ factory, locker, claimer, commitHalfLocker, co
|
|
|
255
251
|
// point can be funded beside a proof for another, and the claim reveals a half that does not open the address.
|
|
256
252
|
const sameValue = (a, b) => String(a === undefined || a === null ? "" : a).replace(/^0x/i, "").toLowerCase()
|
|
257
253
|
=== String(b === undefined || b === null ? "" : b).replace(/^0x/i, "").toLowerCase();
|
|
258
|
-
for (const name of ["locker", "claimer", "amount", "readyBy", "t1", "salt", "commitHalfClaimer", "edPointClaimer"
|
|
254
|
+
for (const name of ["locker", "claimer", "amount", "readyBy", "t1", "salt", "commitHalfClaimer", "edPointClaimer",
|
|
255
|
+
"commitHalfLocker", "edPointLocker", "edViewPointLocker"]) {
|
|
259
256
|
if (!sameValue(quote[name], terms[name])) {
|
|
260
257
|
throw new Error("the quote and the order terms diverge on field " + name);
|
|
261
258
|
}
|
package/engine/evm/gasReserve.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/evm/gasReserve.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// THE BUYER GAS RESERVE FOR ORDER ACTIONS: THE READINESS MARK AND A POSSIBLE REFUND.
|
|
6
2
|
//
|
|
7
3
|
// THE POINT. In a direct swap the person deposits into the escrow, and after the XMR arrives calls markReady itself
|
package/engine/evm/index.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/evm/index.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// The wallet used by the demo interface.
|
|
6
|
-
// One implementation: the injected EIP-1193 browser wallet (
|
|
2
|
+
// One implementation: the injected EIP-1193 browser wallet (engine/evm/session.js) - the user's real wallet,
|
|
7
3
|
// real balances. Mobile connectors are loaded by the host page and passed in as the same provider.
|
|
8
4
|
// The built-in demo wallet and its mode switch were removed: we are heading to a real product, not a mockup.
|
|
9
5
|
// Still NO transfers: there is no escrow contract yet and the address is mocked (mock/chain.js), so funding
|
|
@@ -37,10 +33,10 @@ export * from "./funding.js";
|
|
|
37
33
|
// protocol code, not two lookalikes.
|
|
38
34
|
export * from "./permit.js";
|
|
39
35
|
// THE ASYNCHRONOUS ROUTE, EXECUTED - through the same engine seam as the decision that chooses it. The page reaches
|
|
40
|
-
// it through the bridge; the SDK
|
|
36
|
+
// it through the bridge; the SDK owns this module.
|
|
41
37
|
export * from "./asyncRoute.js";
|
|
42
|
-
// THE EXECUTOR IS THE PACKAGE'S PROVIDER LAYER (src/legs/cow.mjs and its siblings). The
|
|
43
|
-
//
|
|
38
|
+
// THE EXECUTOR IS THE PACKAGE'S PROVIDER LAYER (src/legs/cow.mjs and its siblings). The old copy that used to
|
|
39
|
+
// execute the route here carried a second submit/status path; it was removed with the order worker.
|
|
44
40
|
|
|
45
41
|
// currentProvider - the wallet provider goes OUT to the SDK core (evm-wallet.mjs) so signing uses the same
|
|
46
42
|
// key as the page. Screens do not need it; they read status()/isConnected().
|
|
@@ -74,7 +70,7 @@ export async function simulateEscrowFunding(tx) {
|
|
|
74
70
|
// Replaces simulateEscrowFunding. The difference is fundamental: the simulation invented a hash, here two
|
|
75
71
|
// real transactions go out - createOrder to the factory and lock(sealedHalf) to the new escrow.
|
|
76
72
|
//
|
|
77
|
-
// Separation is deliberate: cryptography (halves, DLEQ, envelope) lives in
|
|
73
|
+
// Separation is deliberate: cryptography (halves, DLEQ, envelope) lives in engine/atomic/ and does NOT reach
|
|
78
74
|
// here. This function gets the ready sealedCommitment and sealedHalf - exactly what goes to the contract.
|
|
79
75
|
// The caller sets the order of steps: verify the counterparty first, then lock.
|
|
80
76
|
//
|
package/engine/evm/injected.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/evm/injected.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// BROWSER WALLETS: detection by EIP-6963 and connection by EIP-1193.
|
|
6
2
|
// WHY EIP-6963, NOT window.ethereum.isMetaMask. With two extensions installed, window.ethereum is "whoever was
|
|
7
3
|
// last", and guessing by flags gives wrong names and icons. EIP-6963 solves this: a wallet announces itself with
|
package/engine/evm/permit.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/evm/permit.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// TOKEN ALLOWANCE FOR BUYING WITHOUT OWN ETH: what the token supports and what is missing.
|
|
6
2
|
//
|
|
7
3
|
// WHAT IS HERE AND WHAT IS NOT. Only selectors, calldata assembly and an HONEST verdict on whether a signature
|
package/engine/evm/prices.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/evm/prices.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// LIVE MARKET NUMBERS FOR THE EVM LEG: the native price (Chainlink on-chain) and the gas cost (RPC).
|
|
6
2
|
// WHY ON-CHAIN, NOT AN API: the price is a contract call over the same RPC already allowed by the CSP
|
|
7
3
|
// (connect-src), so no new external domain appears, there are no keys or rate limits, and the feed address is
|
package/engine/evm/session.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/evm/session.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// The EVM wallet: state, balances, network switching and the injected connector.
|
|
6
2
|
|
|
7
3
|
// A browser wallet (MetaMask, Rabby, Coinbase...) found by EIP-6963 connects directly over EIP-1193. The SDK
|
package/engine/mock/chain.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/mock/chain.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// Mock chain: the escrow contract on EVM and the Monero leg.
|
|
6
2
|
//
|
|
7
3
|
// There are NO real transactions here. Everything returned is marked mock, and the hashes
|
package/engine/monero/address.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// SDK ENGINE MODULE - the demo's sdk/ mirror copies this file byte for byte (tools/build-sdk-engine.mjs).
|
|
2
|
-
// The page's own www/js module is a separate copy; edit this package source and regenerate the mirror.
|
|
3
|
-
|
|
4
1
|
// Monero address checks and assembly: format + real checksum + network prefixes.
|
|
5
2
|
// A detail easy to get wrong: Monero has its OWN base58 - block-based (8 bytes -> 11 chars, the remainder last).
|
|
6
3
|
// It is NOT compatible with bitcoin-base58, where a leading '1' means a zero byte; here a block is a NUMBER and
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/monero/halvesSweep.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// KEYS FOR SWEEPING FROM A HALVES FILE. One logic for two consumers: the sweep page (sweep.js) and the
|
|
6
2
|
// check, so the two cannot drift.
|
|
7
3
|
// This is the main check of the whole sweep: the contract only verifies that the HASH of the revealed half
|
package/engine/monero/node.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/monero/node.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// The live Monero node: the only real external dependency of the demo.
|
|
6
2
|
//
|
|
7
3
|
// The node address is the MONERO.node constant in www/js/core/config.js - the proxy
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/monero/swapKeys.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// JOINT ADDRESS KEYS FROM HALVES.
|
|
6
2
|
//
|
|
7
3
|
// THERE IS NO FULL SPEND KEY HERE. Neither side generates the swap wallet whole: each gives ITS half and the
|
package/engine/monero/unlock.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/monero/unlock.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// OUTPUT UNLOCK TIME (unlock_time). ONE RULE FOR EVERYONE WHO DECIDES "ARRIVAL IS THERE".
|
|
6
2
|
//
|
|
7
3
|
// A Monero transaction has an unlock_time field. Zero - "the output is open in the normal order". A non-zero
|
|
@@ -13,8 +9,8 @@
|
|
|
13
9
|
// on the "done" mark, while the XMR stayed locked.
|
|
14
10
|
//
|
|
15
11
|
// WHY THE ONE SOURCE LIVES HERE. The rule is read by the backend indexer through the scan module and by the
|
|
16
|
-
// SDK core through the engine
|
|
17
|
-
//
|
|
12
|
+
// SDK core through the engine seam. A second copy would mean a second truth about money, so there is no copy:
|
|
13
|
+
// this module is the one implementation, and both readers use it.
|
|
18
14
|
export const UNLOCK_TIME_BLOCK_MAX = 500_000_000;
|
|
19
15
|
|
|
20
16
|
// Output state by its unlock_time. The return is a NAMED result, not a boolean: the interface must
|
package/engine/monero/wallet.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// SDK ENGINE MODULE - the demo's sdk/ mirror copies this file byte for byte (tools/build-sdk-engine.mjs).
|
|
2
|
-
// The page's own www/js module is a separate copy; edit this package source and regenerate the mirror.
|
|
3
|
-
|
|
4
1
|
// The one-shot Monero wallet of a swap.
|
|
5
2
|
//
|
|
6
3
|
// Keys are derived by the package's own Monero module (engine/monero/keys.js) from @noble/curves; the 25-word
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/recovery/recoveryFile.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// The deal recovery file: real cryptography in the browser (WebCrypto).
|
|
6
2
|
//
|
|
7
3
|
// Litepaper §5: without a saved recovery file a deal is not funded; if the tab is lost, this file is the only way
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/recovery/restore.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// The reverse recovery-file path: file -> wallet that can claim the XMR.
|
|
6
2
|
// The forward path (file generation) is in recoveryFile.js. Here is why the file exists: recovery when the tab is
|
|
7
3
|
// lost. Two rules are pinned by CODE, not by a comment:
|
package/engine/sdk/bridge.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/sdk/bridge.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// THE PAGE-TO-CORE SHIM: THE ONE PLACE WHERE SCREENS KNOW ABOUT THE SDK (sdk/).
|
|
6
2
|
//
|
|
7
3
|
// WHY IT EXISTS. The swap logic lives in the core (sdk/, the @ninsei-labs/sdk package) while the page should do
|
|
@@ -408,7 +404,7 @@ export async function sdkSetDestination(id, address) {
|
|
|
408
404
|
}
|
|
409
405
|
|
|
410
406
|
// THE MONERO ADDRESS NETWORK - A CORE SURFACE (it owns the address format): the shim only exposes it to the screen.
|
|
411
|
-
// The fallback is the same module
|
|
407
|
+
// The fallback is the same address module the SDK uses (engine/monero/address.js): there is no second prefix table.
|
|
412
408
|
export async function sdkAddressNetwork(address) {
|
|
413
409
|
const ctx = await instanceFor(undefined);
|
|
414
410
|
if (ctx) return ctx.sdk.swaps.addressNetwork(address);
|
|
@@ -422,8 +418,8 @@ export async function sdkAddressNetwork(address) {
|
|
|
422
418
|
// the deal digest and the poll tick, reads and polling of the Monero node (the core has no node);
|
|
423
419
|
// * prices, fees, gas and the form's DEX leg - SHOWCASE: the numbers are read from the chain by engine
|
|
424
420
|
// modules, and the screen gets them through the seam, not by a second road into the engine;
|
|
425
|
-
// * networkFromShape/networkLabel - the Monero address shape and its name: the same format module the
|
|
426
|
-
//
|
|
421
|
+
// * networkFromShape/networkLabel - the Monero address shape and its name: the same format module the SDK
|
|
422
|
+
// uses (there is no second prefix table);
|
|
427
423
|
// * createSwap/createReverseSwap/activeSwaps - the RECORD of the demo and reverse deal (the record is kept by
|
|
428
424
|
// the engine; the core exposes its STATE via swaps.list/swaps.progress).
|
|
429
425
|
// * createSwapWallet - THE FORM'S DEAL WALLET (state between screens, ui/formState.js): the page wallet with
|
package/engine/ui/dom.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/ui/dom.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// Tiny DOM helpers. No frameworks: the demo must be readable by eye.
|
|
6
2
|
|
|
7
3
|
export function h(tag, attrs = {}, children = []) {
|
package/engine/ui/walletModal.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// GENERATED FILE - a byte-for-byte copy of the engine module www/js/ui/walletModal.js for the SDK package.
|
|
2
|
-
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
3
|
-
// Everything below this header is identical to the source.
|
|
4
|
-
|
|
5
1
|
// A wallet-connect modal for the injected connector: browser-wallet choice only.
|
|
6
2
|
// The browser-wallet list comes from outside (setChoices); detection is evm/injected.js by EIP-6963. Here is
|
|
7
3
|
// only rendering: the CSP bans inline styles, so everything goes through dom.h(), and wallet icons are data: URLs.
|