@ninsei-labs/sdk 0.39.3 → 0.40.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 +55 -0
- package/engine/atomic/dleq2.js +86 -111
- package/engine/atomic/halfenc.js +58 -72
- package/engine/atomic/halves.js +31 -53
- package/engine/atomic/order-client.js +15 -16
- package/engine/atomic/order.js +44 -62
- package/engine/atomic/orderContext.js +26 -50
- package/engine/atomic/orderHalfCommit.js +17 -18
- package/engine/core/chainSource.js +54 -69
- package/engine/core/clock.js +11 -12
- package/engine/core/config.js +561 -451
- package/engine/core/finality.js +34 -53
- package/engine/core/format.js +35 -36
- package/engine/core/preSignGuards.js +109 -117
- package/engine/core/rfqSource.js +57 -75
- package/engine/core/sellWindow.js +23 -24
- package/engine/core/store.js +20 -21
- package/engine/core/swap.js +242 -243
- package/engine/evm/amounts.js +50 -51
- package/engine/evm/asyncExec.js +577 -0
- package/engine/evm/asyncLegs.js +308 -0
- package/engine/evm/asyncRoute.js +179 -0
- package/engine/evm/auth.js +41 -48
- package/engine/evm/claimGas.js +28 -47
- package/engine/evm/depositor.js +39 -43
- package/engine/evm/dex.js +266 -267
- package/engine/evm/escrow.js +113 -129
- package/engine/evm/factory.js +71 -77
- package/engine/evm/fees.js +41 -42
- package/engine/evm/funding.js +160 -162
- package/engine/evm/gasReserve.js +67 -36
- package/engine/evm/index.js +46 -53
- package/engine/evm/injected.js +34 -42
- package/engine/evm/permit.js +129 -56
- package/engine/evm/prices.js +30 -45
- package/engine/evm/session.js +188 -189
- package/engine/mock/chain.js +17 -18
- package/engine/monero/address.js +33 -48
- package/engine/monero/halvesSweep.js +25 -43
- package/engine/monero/node.js +14 -15
- package/engine/monero/scan.js +82 -95
- package/engine/monero/swapKeys.js +30 -33
- package/engine/monero/unlock.js +17 -20
- package/engine/monero/wallet.js +32 -42
- package/engine/recovery/recoveryFile.js +154 -161
- package/engine/recovery/restore.js +50 -61
- package/engine/sdk/bridge.js +244 -234
- package/engine/ui/dom.js +4 -5
- package/engine/ui/walletModal.js +20 -31
- package/index.d.ts +8 -0
- package/package.json +1 -1
- package/src/adapters/evm-wallet.mjs +16 -0
- package/src/adapters/monero-wallet.mjs +1 -1
- package/src/adapters/monero.mjs +1 -1
- package/src/adapters/node-test-evm-wallet.mjs +20 -8
- package/src/config.mjs +1 -1
- package/src/engine.mjs +4 -0
- package/src/legs/cow-spec.mjs +254 -0
- package/src/legs/cow.mjs +315 -0
- package/src/legs/evm.mjs +86 -2
- package/src/legs/kyber-spec.mjs +265 -0
- package/src/legs/kyber.mjs +425 -0
- package/src/legs/shape.mjs +35 -0
- package/src/legs/uniswaprelay-spec.mjs +541 -0
- package/src/legs/uniswaprelay.mjs +422 -0
- package/src/legs/uniswapx-spec.mjs +329 -0
- package/src/legs/uniswapx.mjs +362 -0
- package/src/quotes.mjs +1 -1
- package/src/swaps.mjs +1 -1
package/engine/evm/escrow.js
CHANGED
|
@@ -1,182 +1,167 @@
|
|
|
1
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
|
|
3
|
-
// tools/check-sdk-engine.mjs reddens on any drift, so a stale copy cannot ship silently.
|
|
2
|
+
// Edit the source under www/js and regenerate the mirror; a drift guard reddens on any difference.
|
|
4
3
|
// Everything below this header is identical to the source.
|
|
5
4
|
|
|
6
|
-
//
|
|
5
|
+
// Calls to the NinseiSwap escrow contract (one instance = one order).
|
|
7
6
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
// Селекторы вычислены инструментом, не вручную - и это те подписи, которые у контракта ЕСТЬ:
|
|
7
|
+
// There is no EVM library here: the escrow has three state-moving functions (markReady, claim, refund) and a few
|
|
8
|
+
// readers, so calldata is built from a selector and 32-byte words. There is NO FUNDING FUNCTION: an order is born
|
|
9
|
+
// funded in the creation transaction, and the two-step path (create empty, fund by a second call) was removed with
|
|
10
|
+
// it - that path locked money inside a closed order. Hence no fund() selector below.
|
|
11
|
+
// Selectors were computed by a tool, and they are the signatures the contract HAS:
|
|
14
12
|
// cast sig "markReady()" -> 0x1ca087e7
|
|
15
13
|
// cast sig "claim(bytes32)" -> 0xbd66528a
|
|
16
|
-
// cast sig "refund(bytes32)" -> 0x7249fbb6 (refund()
|
|
14
|
+
// cast sig "refund(bytes32)" -> 0x7249fbb6 (no refund() without an argument: the half is mandatory)
|
|
17
15
|
// cast sig "status()" -> 0x200d2ed2
|
|
18
|
-
//
|
|
16
|
+
// They are cross-checked against the Foundry reference (cast sig / cast calldata).
|
|
19
17
|
//
|
|
20
|
-
//
|
|
21
|
-
// HalfRevealed(bytes32 half, bool byClaimer)
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
// 2) status() (:406-408) заведён в контракте именно «фронту и watchtower'у» и отдаёт все четыре
|
|
29
|
-
// величины ОДНИМ вызовом - внесено, забрано, возвращено, остаток - по адресу эскроу, который уже
|
|
30
|
-
// известен из записи сделки. Следить для этого за логами с блока создания не нужно.
|
|
31
|
-
// Событие HalfRevealed при этом несёт признак byClaimer, то есть из него видно и «забрано», и
|
|
32
|
-
// «возвращено»: тому, кто ведёт журнал ордеров, подписка на него полезна. Для чтения состояния
|
|
33
|
-
// конкретного ордера на месте нужен status().
|
|
18
|
+
// EVENTS EXIST - THREE OF THEM:
|
|
19
|
+
// HalfRevealed(bytes32 half, bool byClaimer), OrderTerms(...), Ready(address indexed by), StrayRescued(...)
|
|
20
|
+
// State is still read by calling status(), and the reason is not the absence of events:
|
|
21
|
+
// 1) FUNDING HAS NO EVENT AT ALL: the funded flag is set in the constructor together with OrderTerms, so the
|
|
22
|
+
// first order state never reaches the logs;
|
|
23
|
+
// 2) status() returns all four values - funded, claimed, refunded, balance - in ONE call by escrow address.
|
|
24
|
+
// There is no need to follow logs from the creation block. HalfRevealed carries byClaimer, so it tells both
|
|
25
|
+
// "claimed" and "refunded": useful for whoever keeps an order journal, but status() reads one order on the spot.
|
|
34
26
|
|
|
35
27
|
export const ESCROW_METHODS = {
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
// Ставит её только внёсший, только на зафондированном ордере и только до readyBy (:218-222).
|
|
28
|
+
// NO FUNDING HERE, ON PURPOSE. The old fund() encoded as 0xb60d4288; the contract no longer has it, and its
|
|
29
|
+
// rules moved into order birth: the constructor checks exactly `amount + fee`, paid by the named depositor. A
|
|
30
|
+
// returning line with this selector reddens the ABI check.
|
|
31
|
+
// mark readiness: "I see the XMR". Without it a claim is impossible - the guard against claiming ETH without XMR.
|
|
32
|
+
// Only the depositor sets it, only on a funded order, and only before readyBy.
|
|
42
33
|
markReady: "0x1ca087e7",
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
34
|
+
// claim, presenting YOUR half; its hash (the commitment) was fixed in the order at creation.
|
|
35
|
+
// Anyone may send it - the contract does not check the sender - but the money goes to the recorded claimer, so
|
|
36
|
+
// the caller cannot redirect it.
|
|
46
37
|
claim: "0xbd66528a",
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
// Деньги при этом идут ВСЕГДА внёсшему (:260), а половина публикуется - по ней он заберёт своё XMR.
|
|
38
|
+
// refund after t1, PRESENTING THE DEPOSITOR'S HALF: the contract checks its hash against commitHalfLocker and
|
|
39
|
+
// rejects a foreign half (BadHalf). So "anyone may call" is precise: anyone may SEND the transaction (the
|
|
40
|
+
// watchtower role), but only the holder of the depositor's half can carry it through. The money always goes to
|
|
41
|
+
// the depositor, and the half is published - with it he claims his XMR.
|
|
52
42
|
refund: "0x7249fbb6",
|
|
53
|
-
//
|
|
43
|
+
// state: (funded, claimed, refunded, balance)
|
|
54
44
|
status: "0x200d2ed2",
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
// прежнее - см. derive() в core/swap.js.
|
|
45
|
+
// ONE DEADLINE. Before t1 only the claimer may claim by his half and only with the ready mark; from t1 a claim
|
|
46
|
+
// is forbidden and anyone may refund by presenting the depositor's half. There is no t0() selector: the t0 field
|
|
47
|
+
// does not exist in the contract. Orders created earlier carry their deadline in the deal record, with the old
|
|
48
|
+
// rule - see derive() in core/swap.js.
|
|
60
49
|
t1: "0xfb5343f3",
|
|
61
|
-
//
|
|
50
|
+
// up to this deadline the depositor may mark readiness; strictly before t1
|
|
62
51
|
readyBy: "0x53fc2f40",
|
|
63
|
-
//
|
|
52
|
+
// whether readiness is marked: without it a claim is closed
|
|
64
53
|
ready: "0x6defbf80",
|
|
65
|
-
//
|
|
54
|
+
// the half revealed by settlement: from it the other side assembles the spend key
|
|
66
55
|
revealedHalf: "0x3f267bb6",
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
// ЦЕЛИКОМ, и отдельная сверка точки просмотра больше не нужна. ЦЕНА НАЗВАНА ПРЯМО: слепок у ВСЕХ ордеров
|
|
83
|
-
// другой, значит фабрика и эскроу передеплоиваются, а адреса, записанные где-либо до этого (config.js,
|
|
84
|
-
// networks.json, записи сделок), к новым ордерам не относятся.
|
|
56
|
+
// ORDER POINTS AND COMMITMENTS, read FROM THE ESCROW ITSELF. Needed before signing: the DLEQ proof binds a half
|
|
57
|
+
// to a point but does not stop OTHER points from being put into the order - then the Monero address would be
|
|
58
|
+
// assembled from the wrong halves, and only a comparison of the LIVE CHAIN slots with what the page assembled
|
|
59
|
+
// reveals it. Selectors are `cast sig` over the actual signatures; the ABI check cross-checks the table.
|
|
60
|
+
edPointLocker: "0x8c03382b", // the depositor's spend point: half of the joint address
|
|
61
|
+
edPointClaimer: "0xdd98c465", // and the claimer's spend point: checked against the quote, not taken on trust
|
|
62
|
+
edViewPointLocker: "0x9a06a5fe", // and his view point: without it the Monero address cannot be built
|
|
63
|
+
commitHalfLocker: "0x498b422e", // commitment to the depositor's half: the contract checks refund by it
|
|
64
|
+
commitHalfClaimer: "0x7d4c81f7", // commitment to the claimer's half: the contract checks claim by it
|
|
65
|
+
// order terms in one hash. It ties the recovery file to the on-chain order: by it the file's owner checks the
|
|
66
|
+
// file belongs to THIS escrow and not a look-alike.
|
|
67
|
+
// A FORMER GAP, CLOSED BY DECISION: the depositor's view point used to be OUTSIDE the hash, so it had to be
|
|
68
|
+
// checked separately. Now it is inside, right after the claimer's point as in the OrderTerms event, so the order
|
|
69
|
+
// is checked WHOLE. THE PRICE IS NAMED: every order's hash changes, so the factory and escrow are redeployed,
|
|
70
|
+
// and addresses recorded before that do not refer to the new orders.
|
|
85
71
|
termsHash: "0xb311d9fd",
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
nonce: "0xaffed0e0", // нонс котировки
|
|
72
|
+
// FEE, REGISTRY AND ORIGIN - ALL READ FROM THE ESCROW. The factory no longer has these fields (the router was
|
|
73
|
+
// removed): the rate, amount and recipient of the fee, the registry address, the provider and the signing key
|
|
74
|
+
// come in the signed quote as immutable order fields. Selectors are `cast sig` over the actual signatures.
|
|
75
|
+
fee: "0xddca3f43", // fee amount in wei (computed at order creation)
|
|
76
|
+
feeBps: "0x24a9d853", // rate in basis points (30 = 0.30%)
|
|
77
|
+
feeRecipient: "0x46904840", // who the fee is credited to in the cashier
|
|
78
|
+
feeOnTop: "0x2296cc23", // true - a buy (fee on top), false - a sell (deducted from the payout)
|
|
79
|
+
registry: "0x7b103999", // maker registry address FROM THE ORDER TERMS
|
|
80
|
+
cashier: "0xed740e97", // fee cashier FROM THE ORDER TERMS: the factory does NOT create it
|
|
81
|
+
provider: "0x085d4883", // the provider declared in the quote (checked against the registry)
|
|
82
|
+
quoteKey: "0x391d53ca", // the key the quote was signed with
|
|
83
|
+
validUntil: "0xddac6654", // quote validity (SECONDS)
|
|
84
|
+
nonce: "0xaffed0e0", // quote nonce
|
|
100
85
|
};
|
|
101
86
|
|
|
102
|
-
//
|
|
103
|
-
//
|
|
104
|
-
// call markReady():
|
|
87
|
+
// The escrow has NO dynamic arguments, so every call below is a bare selector. The funding encoder is gone with
|
|
88
|
+
// the function itself (see the note in ESCROW_METHODS).
|
|
89
|
+
// call markReady(): no arguments.
|
|
105
90
|
export function encodeMarkReady() {
|
|
106
91
|
return ESCROW_METHODS.markReady;
|
|
107
92
|
}
|
|
108
93
|
|
|
109
|
-
// call ready()/readyBy()/revealedHalf():
|
|
110
|
-
//
|
|
94
|
+
// call ready()/readyBy()/revealedHalf(): no arguments - their calldata equals the selector, so there are no
|
|
95
|
+
// separate encoders and the selectors live in ESCROW_METHODS above.
|
|
111
96
|
|
|
112
|
-
// call claim(secret):
|
|
113
|
-
// halfClaimer
|
|
114
|
-
//
|
|
115
|
-
//
|
|
97
|
+
// call claim(secret): the secret is bytes32. In the contract it is the CLAIMER'S half (the parameter is named
|
|
98
|
+
// halfClaimer), called a "secret" because it is the preimage of the commitHalfClaimer commitment: the contract
|
|
99
|
+
// compares keccak256 of the presented half with its commitment and nothing more - it does not check the link
|
|
100
|
+
// between the half and the Monero address.
|
|
116
101
|
export function encodeClaim(secret) {
|
|
117
|
-
return ESCROW_METHODS.claim + halfAsThirtyTwoBytes(secret, "
|
|
102
|
+
return ESCROW_METHODS.claim + halfAsThirtyTwoBytes(secret, "secret");
|
|
118
103
|
}
|
|
119
104
|
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
//
|
|
105
|
+
// A HALF IS A NUMBER, NOT A FIXED-LENGTH STRING. In the deal record and the recovery file it is stored as is, and
|
|
106
|
+
// a leading zero is lost: 63 digits instead of 64. The contract needs exactly 32 bytes, so we pad on the left (as
|
|
107
|
+
// the node does in its claim). Without this a refund was impossible in principle: on screen it looked like "the
|
|
108
|
+
// half must be 32 bytes" on a live click of the refund button.
|
|
124
109
|
function halfAsThirtyTwoBytes(value, what) {
|
|
125
110
|
const hex = String(value || "").replace(/^0x/i, "").toLowerCase();
|
|
126
|
-
if (!/^[0-9a-f]{1,64}$/.test(hex)) throw new Error(what + "
|
|
111
|
+
if (!/^[0-9a-f]{1,64}$/.test(hex)) throw new Error(what + " must be a number of up to 32 bytes: " + value);
|
|
127
112
|
return hex.padStart(64, "0");
|
|
128
113
|
}
|
|
129
114
|
|
|
130
|
-
// call refund(bytes32 halfLocker):
|
|
131
|
-
//
|
|
132
|
-
//
|
|
115
|
+
// call refund(bytes32 halfLocker): the DEPOSITOR'S half is presented, not the caller's - the contract checks its
|
|
116
|
+
// hash against commitHalfLocker and rejects a foreign one (BadHalf). The sender is not checked: the half itself
|
|
117
|
+
// grants the right to call.
|
|
133
118
|
export function encodeRefund(halfLocker) {
|
|
134
|
-
return ESCROW_METHODS.refund + halfAsThirtyTwoBytes(halfLocker, "
|
|
119
|
+
return ESCROW_METHODS.refund + halfAsThirtyTwoBytes(halfLocker, "half");
|
|
135
120
|
}
|
|
136
121
|
|
|
137
|
-
// call status():
|
|
122
|
+
// call status(): no arguments.
|
|
138
123
|
export function encodeStatus() {
|
|
139
124
|
return ESCROW_METHODS.status;
|
|
140
125
|
}
|
|
141
126
|
|
|
142
|
-
// call t1():
|
|
127
|
+
// call t1(): no arguments.
|
|
143
128
|
export function encodeT1() {
|
|
144
129
|
return ESCROW_METHODS.t1;
|
|
145
130
|
}
|
|
146
131
|
|
|
147
|
-
// call termsHash():
|
|
132
|
+
// call termsHash(): no arguments.
|
|
148
133
|
export function encodeTermsHash() {
|
|
149
134
|
return ESCROW_METHODS.termsHash;
|
|
150
135
|
}
|
|
151
136
|
|
|
152
|
-
// call
|
|
153
|
-
//
|
|
137
|
+
// call an escrow method WITHOUT arguments by name. Used where there are many reads (the order slots): a function
|
|
138
|
+
// per selector would mean a second table of the same names, free to diverge silently.
|
|
154
139
|
export function encodeRead(name) {
|
|
155
140
|
const sel = ESCROW_METHODS[name];
|
|
156
|
-
if (typeof sel !== "string" || !/^0x[0-9a-f]{8}$/.test(sel)) throw new Error("
|
|
141
|
+
if (typeof sel !== "string" || !/^0x[0-9a-f]{8}$/.test(sel)) throw new Error("no such escrow method: " + name);
|
|
157
142
|
return sel;
|
|
158
143
|
}
|
|
159
144
|
|
|
160
|
-
//
|
|
161
|
-
export function decodeBytes32(returnedHex, what = "
|
|
145
|
+
// Parse a bytes32 answer: one word.
|
|
146
|
+
export function decodeBytes32(returnedHex, what = "value") {
|
|
162
147
|
const hex = String(returnedHex || "").replace(/^0x/, "");
|
|
163
|
-
if (hex.length < 64) throw new Error("
|
|
148
|
+
if (hex.length < 64) throw new Error("short answer " + what + ": " + returnedHex);
|
|
164
149
|
return "0x" + hex.slice(0, 64).toLowerCase();
|
|
165
150
|
}
|
|
166
151
|
|
|
167
|
-
//
|
|
168
|
-
export function decodeUint64(returnedHex, what = "
|
|
152
|
+
// Parse the t1() answer: one word, uint64 inside uint256.
|
|
153
|
+
export function decodeUint64(returnedHex, what = "value") {
|
|
169
154
|
const hex = String(returnedHex || "").replace(/^0x/, "");
|
|
170
|
-
if (hex.length < 64) throw new Error("
|
|
155
|
+
if (hex.length < 64) throw new Error("short answer " + what + ": " + returnedHex);
|
|
171
156
|
const v = BigInt("0x" + hex.slice(0, 64));
|
|
172
|
-
if (v > 18446744073709551615n) throw new Error("
|
|
157
|
+
if (v > 18446744073709551615n) throw new Error("answer " + what + " does not fit in uint64: " + v);
|
|
173
158
|
return Number(v);
|
|
174
159
|
}
|
|
175
160
|
|
|
176
|
-
//
|
|
161
|
+
// Parse the status() answer: four 32-byte words - three flags and the balance.
|
|
177
162
|
export function decodeStatus(returnedHex) {
|
|
178
163
|
const hex = String(returnedHex || "").replace(/^0x/, "");
|
|
179
|
-
if (hex.length < 256) throw new Error("
|
|
164
|
+
if (hex.length < 256) throw new Error("short status() answer: " + returnedHex);
|
|
180
165
|
const word = (i) => hex.slice(i * 64, (i + 1) * 64);
|
|
181
166
|
return {
|
|
182
167
|
isFunded: BigInt("0x" + word(0)) !== 0n,
|
|
@@ -186,23 +171,22 @@ export function decodeStatus(returnedHex) {
|
|
|
186
171
|
};
|
|
187
172
|
}
|
|
188
173
|
|
|
189
|
-
//
|
|
190
|
-
//
|
|
191
|
-
//
|
|
192
|
-
//
|
|
193
|
-
// "
|
|
194
|
-
//
|
|
195
|
-
//
|
|
196
|
-
//
|
|
197
|
-
//
|
|
198
|
-
// контракт защищает деньги, но не защищает от ордера с прошлыми сроками.
|
|
174
|
+
// Which order terms the escrow needs at creation - in one place, so the form and the checks do not diverge.
|
|
175
|
+
// ONE DEADLINE. There is no t0 field: before t1 ETH is claimed by the claimer via his half and only with the
|
|
176
|
+
// ready mark; from t1 a claim is forbidden and anyone may refund by PRESENTING THE DEPOSITOR'S HALF - the
|
|
177
|
+
// watchtower does not have it, so "anyone refunds" reads as "anyone holding the half".
|
|
178
|
+
// The "t1 later than t0" check lost its meaning, but emptiness did not take its place: the deadline must be IN
|
|
179
|
+
// THE FUTURE, else the order is created already closed - no claim is possible and the money hangs until refund.
|
|
180
|
+
// The CONTRACT has no upper bounds and no "future deadlines" rule: the constructor only checks amount != 0 and
|
|
181
|
+
// t1 > readyBy, and deadlines in the past are fine for it. This function holds those bounds - the contract
|
|
182
|
+
// protects the money, not the caller from an order with past deadlines.
|
|
199
183
|
export function orderTerms({ locker, claimer, commitHalfLocker, commitHalfClaimer, edPointLocker, edPointClaimer, amount, readyBy, t1 }) {
|
|
200
184
|
for (const [k, v] of Object.entries({ locker, claimer, commitHalfLocker, commitHalfClaimer, edPointLocker, edPointClaimer, amount })) {
|
|
201
|
-
if (v === undefined || v === null || v === "") throw new Error("
|
|
185
|
+
if (v === undefined || v === null || v === "") throw new Error("order term not set: " + k);
|
|
202
186
|
}
|
|
203
|
-
//
|
|
204
|
-
//
|
|
205
|
-
if (Number(readyBy) <= Math.floor(Date.now() / 1000)) throw new Error("readyBy
|
|
206
|
-
if (Number(t1) <= Number(readyBy)) throw new Error("t1
|
|
187
|
+
// Two deadlines that must NOT coincide: coincidence would restore a window where claim and refund are both
|
|
188
|
+
// valid and gas would decide the dispute. The first is the readiness window, the second the settlement boundary.
|
|
189
|
+
if (Number(readyBy) <= Math.floor(Date.now() / 1000)) throw new Error("readyBy must be in the future: " + readyBy);
|
|
190
|
+
if (Number(t1) <= Number(readyBy)) throw new Error("t1 must be later than readyBy");
|
|
207
191
|
return { locker, claimer, commitHalfLocker, commitHalfClaimer, edPointLocker, edPointClaimer, amount, readyBy, t1 };
|
|
208
192
|
}
|