@arkade-os/swap 0.1.5 → 0.1.6

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 (29) hide show
  1. package/dist/advanced.cjs +228 -63
  2. package/dist/advanced.d.cts +6 -6
  3. package/dist/advanced.d.ts +6 -6
  4. package/dist/advanced.js +2 -2
  5. package/dist/{chunk-GJKGPE3S.js → chunk-QFM55KP2.js} +175 -29
  6. package/dist/{chunk-HDCC3JZR.js → chunk-SDPNWPGY.js} +30 -2
  7. package/dist/index.cjs +219 -54
  8. package/dist/index.d.cts +5 -5
  9. package/dist/index.d.ts +5 -5
  10. package/dist/index.js +2 -2
  11. package/dist/{lockupContract-CdXh9yIr.d.ts → lockupContract-CKPFpIt9.d.ts} +1 -1
  12. package/dist/{lockupContract-QfbsjyXG.d.cts → lockupContract-CpJXTjX_.d.cts} +1 -1
  13. package/dist/{offer-BxzPQ6zh.d.cts → offer-Boxive2u.d.cts} +1 -1
  14. package/dist/{offer-Q1lVhrVX.d.ts → offer-Drw1k_jt.d.ts} +1 -1
  15. package/dist/{offerFillPlan-BfcxbVvw.d.cts → offerFillPlan-BxNkWLtw.d.cts} +2 -2
  16. package/dist/{offerFillPlan-C11P2ek2.d.ts → offerFillPlan-D2N4s7Xe.d.ts} +2 -2
  17. package/dist/protocol.cjs +83 -33
  18. package/dist/protocol.d.cts +11 -27
  19. package/dist/protocol.d.ts +11 -27
  20. package/dist/protocol.js +1 -1
  21. package/dist/repositories/realm/index.d.cts +1 -1
  22. package/dist/repositories/realm/index.d.ts +1 -1
  23. package/dist/repositories/sqlite/index.d.cts +1 -1
  24. package/dist/repositories/sqlite/index.d.ts +1 -1
  25. package/dist/{repository-Cut4eEkm.d.cts → repository-DFDNvcZ7.d.cts} +26 -4
  26. package/dist/{repository-BOQ1qYoj.d.ts → repository-Dn1V17T2.d.ts} +26 -4
  27. package/dist/{watch-D15U0QpD.d.ts → watch-D-mc_wfD.d.ts} +1 -1
  28. package/dist/{watch-D4PeBZ3H.d.cts → watch-DFNMY2K-.d.cts} +1 -1
  29. package/package.json +2 -2
@@ -220,9 +220,14 @@ interface LockupSpend {
220
220
  txid?: string;
221
221
  }
222
222
  type LockupFate =
223
- /** At least one output at the lockup is still unspent. Not over. */
223
+ /**
224
+ * At least one output at the lockup is still unspent. Not over. `preimage` is `P`,
225
+ * hash-verified, read off a spent output while another is still live: the lockup is partly
226
+ * claimed and `P` is public. Read only for the receiver.
227
+ */
224
228
  {
225
229
  fate: "open";
230
+ preimage?: Uint8Array;
226
231
  }
227
232
  /** Spent by a witness carrying a preimage that HASHES to the quote's `payment_hash`. */
228
233
  | {
@@ -278,7 +283,9 @@ declare function readLockupFate(indexer: LockupSpendIndexer, input: {
278
283
  /** `sha256(P)`, hex — the quote's `payment_hash`. */
279
284
  paymentHash: string;
280
285
  /** Read for the lockup's receiver, who holds no leaf that recovers a swept output:
281
- * once a claim revealed `P`, swept outputs no longer hold the lockup `open`. */
286
+ * once a claim revealed `P`, swept outputs no longer hold the lockup `open`. It also
287
+ * enables the partly-claimed read: `open.preimage`, `P` found on a spent output while
288
+ * another is still live. */
282
289
  receiver?: boolean;
283
290
  }): Promise<LockupFate>;
284
291
  /**
@@ -629,14 +636,27 @@ interface RfqSwapManagerCallbacks {
629
636
  * any it left behind is never re-claimed.
630
637
  */
631
638
  claimLockup: (swap: ReceiveLockupSwap, vtxos: readonly LockupVtxo[], options: {
632
- /** A claim of ours is already out, so `P` is public and the value gate has
633
- * nothing left to protect; lets a piecemeal funding still be swept. */
639
+ /** `P` is already public on this lockup (a claim of ours, or any spend whose
640
+ * witness hashes to `paymentHash`), so the value gate has nothing left to
641
+ * protect; lets a piecemeal funding still be swept. */
634
642
  partiallyClaimed: boolean;
635
643
  }) => Promise<{
636
644
  txid: string;
637
645
  amount: number;
638
646
  spent?: readonly LockupVtxo[];
639
647
  }>;
648
+ /**
649
+ * The ark txids of the claims of ours the operator accepted but never finalized (see
650
+ * `findPendingClaims`): each has published `P`, yet its sats do not exist until finalized.
651
+ * Needs no keys. Called on every Lightning receive pass; wired with `finalizeClaim`, and
652
+ * without both a revealed `P` settles the swap as before.
653
+ */
654
+ pendingClaims?: (swap: LightningReceiveSwap) => Promise<readonly string[]>;
655
+ /**
656
+ * Finalize them (see `finalizePendingClaim`). Called only after `pendingClaims` named one; a
657
+ * throw ends the pass and is retried on the next one.
658
+ */
659
+ finalizeClaim?: (swap: LightningReceiveSwap) => Promise<void>;
640
660
  /**
641
661
  * Push `refundWithoutReceiver` for every output at the lockup (see
642
662
  * `pushRefundWithoutReceiver`); return `null` for an empty lockup. Never called for a
@@ -1023,6 +1043,8 @@ declare class RfqSwapManager {
1023
1043
  private arm;
1024
1044
  private pollSwap;
1025
1045
  private runPass;
1046
+ /** `none` when no claim of ours is pending; `failed` covers a pending read that failed too. */
1047
+ private finalizeOwnClaim;
1026
1048
  /**
1027
1049
  * The lockup was unilaterally exited: its outputs sit onchain, beyond any offchain
1028
1050
  * spend. `needs_counterparty`, not terminal: it can still end either way onchain. Set
@@ -220,9 +220,14 @@ interface LockupSpend {
220
220
  txid?: string;
221
221
  }
222
222
  type LockupFate =
223
- /** At least one output at the lockup is still unspent. Not over. */
223
+ /**
224
+ * At least one output at the lockup is still unspent. Not over. `preimage` is `P`,
225
+ * hash-verified, read off a spent output while another is still live: the lockup is partly
226
+ * claimed and `P` is public. Read only for the receiver.
227
+ */
224
228
  {
225
229
  fate: "open";
230
+ preimage?: Uint8Array;
226
231
  }
227
232
  /** Spent by a witness carrying a preimage that HASHES to the quote's `payment_hash`. */
228
233
  | {
@@ -278,7 +283,9 @@ declare function readLockupFate(indexer: LockupSpendIndexer, input: {
278
283
  /** `sha256(P)`, hex — the quote's `payment_hash`. */
279
284
  paymentHash: string;
280
285
  /** Read for the lockup's receiver, who holds no leaf that recovers a swept output:
281
- * once a claim revealed `P`, swept outputs no longer hold the lockup `open`. */
286
+ * once a claim revealed `P`, swept outputs no longer hold the lockup `open`. It also
287
+ * enables the partly-claimed read: `open.preimage`, `P` found on a spent output while
288
+ * another is still live. */
282
289
  receiver?: boolean;
283
290
  }): Promise<LockupFate>;
284
291
  /**
@@ -629,14 +636,27 @@ interface RfqSwapManagerCallbacks {
629
636
  * any it left behind is never re-claimed.
630
637
  */
631
638
  claimLockup: (swap: ReceiveLockupSwap, vtxos: readonly LockupVtxo[], options: {
632
- /** A claim of ours is already out, so `P` is public and the value gate has
633
- * nothing left to protect; lets a piecemeal funding still be swept. */
639
+ /** `P` is already public on this lockup (a claim of ours, or any spend whose
640
+ * witness hashes to `paymentHash`), so the value gate has nothing left to
641
+ * protect; lets a piecemeal funding still be swept. */
634
642
  partiallyClaimed: boolean;
635
643
  }) => Promise<{
636
644
  txid: string;
637
645
  amount: number;
638
646
  spent?: readonly LockupVtxo[];
639
647
  }>;
648
+ /**
649
+ * The ark txids of the claims of ours the operator accepted but never finalized (see
650
+ * `findPendingClaims`): each has published `P`, yet its sats do not exist until finalized.
651
+ * Needs no keys. Called on every Lightning receive pass; wired with `finalizeClaim`, and
652
+ * without both a revealed `P` settles the swap as before.
653
+ */
654
+ pendingClaims?: (swap: LightningReceiveSwap) => Promise<readonly string[]>;
655
+ /**
656
+ * Finalize them (see `finalizePendingClaim`). Called only after `pendingClaims` named one; a
657
+ * throw ends the pass and is retried on the next one.
658
+ */
659
+ finalizeClaim?: (swap: LightningReceiveSwap) => Promise<void>;
640
660
  /**
641
661
  * Push `refundWithoutReceiver` for every output at the lockup (see
642
662
  * `pushRefundWithoutReceiver`); return `null` for an empty lockup. Never called for a
@@ -1023,6 +1043,8 @@ declare class RfqSwapManager {
1023
1043
  private arm;
1024
1044
  private pollSwap;
1025
1045
  private runPass;
1046
+ /** `none` when no claim of ours is pending; `failed` covers a pending read that failed too. */
1047
+ private finalizeOwnClaim;
1026
1048
  /**
1027
1049
  * The lockup was unilaterally exited: its outputs sit onchain, beyond any offchain
1028
1050
  * spend. `needs_counterparty`, not terminal: it can still end either way onchain. Set
@@ -1,5 +1,5 @@
1
1
  import { IWallet } from '@arkade-os/sdk';
2
- import { c as AssetSwapStatus, d as AssetSwapRepository, h as AssetSwap } from './repository-BOQ1qYoj.js';
2
+ import { c as AssetSwapStatus, d as AssetSwapRepository, h as AssetSwap } from './repository-Dn1V17T2.js';
3
3
 
4
4
  /**
5
5
  * What this watcher needs to know about an offer swap, narrower than {@link AssetSwap}
@@ -1,5 +1,5 @@
1
1
  import { IWallet } from '@arkade-os/sdk';
2
- import { c as AssetSwapStatus, d as AssetSwapRepository, h as AssetSwap } from './repository-Cut4eEkm.cjs';
2
+ import { c as AssetSwapStatus, d as AssetSwapRepository, h as AssetSwap } from './repository-DFDNvcZ7.cjs';
3
3
 
4
4
  /**
5
5
  * What this watcher needs to know about an offer swap, narrower than {@link AssetSwap}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkade-os/swap",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "description": "Client-side Arkade Intents asset swaps: state a route, get an outcome. Pay a bolt11 invoice, receive over Lightning, exchange assets, or withdraw onchain.",
6
6
  "repository": {
@@ -104,7 +104,7 @@
104
104
  "@scure/base": "2.4.0",
105
105
  "@scure/btc-signer": "2.4.1",
106
106
  "light-bolt11-decoder": "3.2.0",
107
- "@arkade-os/sdk": "0.5.5"
107
+ "@arkade-os/sdk": "0.5.6"
108
108
  },
109
109
  "peerDependencies": {
110
110
  "nostr-tools": "2.24.1"