@satora/swap 1.3.3 → 1.4.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/dist/index.cjs +69 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +69 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -322,7 +322,8 @@ function deriveSwapActions(input) {
|
|
|
322
322
|
serverChainNow,
|
|
323
323
|
clientRefundLocktime,
|
|
324
324
|
serverRefundLocktime,
|
|
325
|
-
clientFunds = true
|
|
325
|
+
clientFunds = true,
|
|
326
|
+
serverFunds = true
|
|
326
327
|
} = input;
|
|
327
328
|
switch (status) {
|
|
328
329
|
case "pending": {
|
|
@@ -407,6 +408,36 @@ function deriveSwapActions(input) {
|
|
|
407
408
|
return { recommended: "wait", actions: [wait, refund] };
|
|
408
409
|
}
|
|
409
410
|
case "serverfunded": {
|
|
411
|
+
if (!serverFunds) {
|
|
412
|
+
const refundUnlocked2 = clientChainNow >= clientRefundLocktime;
|
|
413
|
+
if (refundUnlocked2) {
|
|
414
|
+
const refund3 = {
|
|
415
|
+
id: "refund_unilateral",
|
|
416
|
+
recommended: true,
|
|
417
|
+
automation: "confirm",
|
|
418
|
+
reason: "Reclaim your deposit."
|
|
419
|
+
};
|
|
420
|
+
return { recommended: "refund_unilateral", actions: [refund3] };
|
|
421
|
+
}
|
|
422
|
+
const wait2 = {
|
|
423
|
+
id: "wait",
|
|
424
|
+
waitingOn: "server_funding",
|
|
425
|
+
recommended: true,
|
|
426
|
+
automation: "auto",
|
|
427
|
+
reason: "Waiting for the Lightning payment to settle."
|
|
428
|
+
};
|
|
429
|
+
const refund2 = {
|
|
430
|
+
id: "refund_unilateral",
|
|
431
|
+
recommended: false,
|
|
432
|
+
automation: "confirm",
|
|
433
|
+
reason: "Refund becomes available once the timelock passes.",
|
|
434
|
+
blockedBy: {
|
|
435
|
+
kind: "timelock_not_expired",
|
|
436
|
+
message: "The refund timelock has not passed yet."
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
return { recommended: "wait", actions: [wait2, refund2] };
|
|
440
|
+
}
|
|
410
441
|
const claimWindowClosed = serverChainNow >= serverRefundLocktime;
|
|
411
442
|
if (!claimWindowClosed) {
|
|
412
443
|
const claim = {
|
|
@@ -1617,8 +1648,10 @@ var HintTracker = class {
|
|
|
1617
1648
|
serverChainNow: now,
|
|
1618
1649
|
clientRefundLocktime: swap.clientRefundLocktime,
|
|
1619
1650
|
serverRefundLocktime: swap.serverRefundLocktime,
|
|
1620
|
-
// Pay-on-Lightning swaps have no client-funded on-chain leg
|
|
1621
|
-
|
|
1651
|
+
// Pay-on-Lightning swaps have no client-funded on-chain leg;
|
|
1652
|
+
// receive-on-Lightning swaps have no server-funded one.
|
|
1653
|
+
clientFunds: swap.clientHtlc !== void 0,
|
|
1654
|
+
serverFunds: swap.serverHtlc !== void 0
|
|
1622
1655
|
});
|
|
1623
1656
|
const previous = this.#lastActions.get(swap.swapId);
|
|
1624
1657
|
if (!force && previous && JSON.stringify(previous) === JSON.stringify(actions))
|
|
@@ -2241,6 +2274,29 @@ function swapToTracked(stored) {
|
|
|
2241
2274
|
// no on-chain client leg
|
|
2242
2275
|
serverRefundLocktime: ms(r.vhtlc_refund_locktime)
|
|
2243
2276
|
};
|
|
2277
|
+
// Client funds the EVM HTLC (evm_expected_sats of the BTC-pegged token);
|
|
2278
|
+
// the server pays the Lightning invoice off-chain and claims the HTLC —
|
|
2279
|
+
// no server leg to watch.
|
|
2280
|
+
case "evm_to_lightning":
|
|
2281
|
+
return {
|
|
2282
|
+
swapId: r.id,
|
|
2283
|
+
clientHtlc: evmLeg({
|
|
2284
|
+
chainId: r.evm_chain_id,
|
|
2285
|
+
htlc: r.evm_htlc_address,
|
|
2286
|
+
hashLock: r.hash_lock,
|
|
2287
|
+
claimAddress: r.server_evm_address,
|
|
2288
|
+
// the server claims the client's EVM HTLC
|
|
2289
|
+
expectedSats: r.evm_expected_sats,
|
|
2290
|
+
token: r.wbtc_address,
|
|
2291
|
+
sender: r.evm_coordinator_address,
|
|
2292
|
+
// the coordinator locks on the client's behalf
|
|
2293
|
+
timelockSec: r.evm_refund_locktime,
|
|
2294
|
+
createdAt: r.created_at
|
|
2295
|
+
}),
|
|
2296
|
+
clientRefundLocktime: ms(r.evm_refund_locktime),
|
|
2297
|
+
serverRefundLocktime: 0
|
|
2298
|
+
// no on-chain server leg
|
|
2299
|
+
};
|
|
2244
2300
|
// Client funds the Arkade VHTLC (source_amount); the server pays the
|
|
2245
2301
|
// Lightning invoice off-chain and claims the VHTLC — no server leg to
|
|
2246
2302
|
// watch.
|
|
@@ -2503,8 +2559,10 @@ var SwapTracker = class {
|
|
|
2503
2559
|
serverChainNow,
|
|
2504
2560
|
clientRefundLocktime: swap.clientRefundLocktime,
|
|
2505
2561
|
serverRefundLocktime: swap.serverRefundLocktime,
|
|
2506
|
-
// Pay-on-Lightning swaps have no client-funded on-chain leg
|
|
2507
|
-
|
|
2562
|
+
// Pay-on-Lightning swaps have no client-funded on-chain leg;
|
|
2563
|
+
// receive-on-Lightning swaps have no server-funded one.
|
|
2564
|
+
clientFunds: swap.clientHtlc !== void 0,
|
|
2565
|
+
serverFunds: swap.serverHtlc !== void 0
|
|
2508
2566
|
}),
|
|
2509
2567
|
// Expose the raw observations so consumers can render progress from
|
|
2510
2568
|
// chain facts (which leg is funded/spent) even when the server is
|
|
@@ -2796,6 +2854,12 @@ var Client = class {
|
|
|
2796
2854
|
);
|
|
2797
2855
|
}
|
|
2798
2856
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
2857
|
+
createEvmToLightningSwap(...args) {
|
|
2858
|
+
return this.#trackAfterCreate(
|
|
2859
|
+
this.#legacy.createEvmToLightningSwap(...args)
|
|
2860
|
+
);
|
|
2861
|
+
}
|
|
2862
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
2799
2863
|
createEvmToArkadeSwapGeneric(...args) {
|
|
2800
2864
|
return this.#trackAfterCreate(
|
|
2801
2865
|
this.#legacy.createEvmToArkadeSwapGeneric(...args)
|