@arkade-os/swap 0.1.0-rc.8 → 0.1.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 (59) hide show
  1. package/README.md +45 -10
  2. package/dist/advanced.cjs +6429 -3083
  3. package/dist/advanced.d.cts +325 -282
  4. package/dist/advanced.d.ts +325 -282
  5. package/dist/advanced.js +343 -34
  6. package/dist/chunk-A3SHHRX4.js +104 -0
  7. package/dist/chunk-FMRAV77W.js +3065 -0
  8. package/dist/{chunk-HV7EIUE2.js → chunk-HRMWBULL.js} +1773 -634
  9. package/dist/chunk-WKJFXXSR.js +3382 -0
  10. package/dist/index.cjs +6868 -3837
  11. package/dist/index.d.cts +71 -243
  12. package/dist/index.d.ts +71 -243
  13. package/dist/index.js +139 -167
  14. package/dist/lockupContract-D7BNjksX.d.ts +148 -0
  15. package/dist/lockupContract-G-9CNRMq.d.cts +148 -0
  16. package/dist/node/index.cjs +61 -10
  17. package/dist/node/index.d.cts +310 -639
  18. package/dist/node/index.d.ts +310 -639
  19. package/dist/node/index.js +65 -10
  20. package/dist/nostr.cjs +428 -49
  21. package/dist/nostr.d.cts +59 -70
  22. package/dist/nostr.d.ts +59 -70
  23. package/dist/nostr.js +268 -36
  24. package/dist/offer-CcJfx5Fj.d.cts +269 -0
  25. package/dist/offer-DdB1M6FZ.d.ts +269 -0
  26. package/dist/offerFillPlan-BII0PW92.d.cts +1642 -0
  27. package/dist/offerFillPlan-CNTLVD7j.d.ts +1642 -0
  28. package/dist/protocol.cjs +5591 -4064
  29. package/dist/protocol.d.cts +258 -355
  30. package/dist/protocol.d.ts +258 -355
  31. package/dist/protocol.js +209 -228
  32. package/dist/repositories/realm/index.cjs +55 -11
  33. package/dist/repositories/realm/index.d.cts +18 -30
  34. package/dist/repositories/realm/index.d.ts +18 -30
  35. package/dist/repositories/realm/index.js +49 -12
  36. package/dist/repositories/sqlite/index.cjs +61 -10
  37. package/dist/repositories/sqlite/index.d.cts +7 -6
  38. package/dist/repositories/sqlite/index.d.ts +7 -6
  39. package/dist/repositories/sqlite/index.js +57 -11
  40. package/dist/repository-DmPzpbd7.d.ts +2342 -0
  41. package/dist/repository-DqdLVrVv.d.cts +2342 -0
  42. package/dist/rfq-C0tHOvn6.d.cts +983 -0
  43. package/dist/rfq-C0tHOvn6.d.ts +983 -0
  44. package/dist/watch-BonYT9af.d.cts +74 -0
  45. package/dist/watch-CmJQDtsy.d.ts +74 -0
  46. package/package.json +12 -12
  47. package/dist/chunk-4PATNGYQ.js +0 -3297
  48. package/dist/chunk-ARYFNDJY.js +0 -1432
  49. package/dist/chunk-U7VWWTL6.js +0 -66
  50. package/dist/errors-CSpOUdCN.d.ts +0 -2216
  51. package/dist/errors-DVn92LQd.d.cts +0 -2216
  52. package/dist/lockupContract-6TYZOBbn.d.ts +0 -490
  53. package/dist/lockupContract-aLCQQiSu.d.cts +0 -490
  54. package/dist/repository-D0gFF_GA.d.cts +0 -3491
  55. package/dist/repository-tDT8p-Nx.d.ts +0 -3491
  56. package/dist/rfq-DhkgiwQ7.d.cts +0 -1126
  57. package/dist/rfq-DhkgiwQ7.d.ts +0 -1126
  58. package/dist/watch-C4cMEeZT.d.cts +0 -96
  59. package/dist/watch-DbWXdpzm.d.ts +0 -96
@@ -1,96 +0,0 @@
1
- import { IWallet } from '@arkade-os/sdk';
2
- import { e as AssetSwapStatus, c as AssetSwapRepository, aW as AssetSwap } from './repository-D0gFF_GA.cjs';
3
-
4
- /**
5
- * What this watcher needs to know about an offer swap.
6
- *
7
- * Structural, and narrower than {@link AssetSwap}, because two record families
8
- * now answer the same question. v1 keys its records on the funding txid — the
9
- * deposit IS the identity, so no record can exist before the money does — while
10
- * the v2 client keys on the quote id and writes the record BEFORE funding, with
11
- * `fundingTxid` a later best-effort write. Projecting the second onto the first
12
- * is impossible for the whole pre-funding window, so the parameter widens
13
- * instead: `id` is whatever key the source stores under, and the spend is
14
- * matched on `fundingTxid` and `swapPkScript`, which both families carry.
15
- *
16
- * `createdAt` is unix **milliseconds**, the unit `coverage.ts` marks issuance
17
- * in; see {@link CoveredSwap}.
18
- */
19
- interface OfferSwapFacts {
20
- readonly id: string;
21
- readonly status: AssetSwapStatus;
22
- /** The TLV offer, hex — what {@link classifyDepositSpend} needs. */
23
- readonly offerHex: string;
24
- readonly swapPkScript: string;
25
- readonly fundingTxid?: string;
26
- readonly spentTxid?: string;
27
- readonly createdAt: number;
28
- }
29
- /** The record change a classified spend implies. */
30
- interface OfferSpendChanges {
31
- readonly status: AssetSwapStatus;
32
- readonly spentTxid: string;
33
- readonly completedAt?: number;
34
- }
35
- /**
36
- * Where the watcher reads offer records and writes their spends.
37
- *
38
- * One seam, two implementations: {@link assetSwapSource} over v1's store, and
39
- * the v2 client's own over its quote-id-keyed record store. `apply` returns
40
- * both halves for the same reason `updateAssetSwapBestEffort` does — a lost
41
- * write must not retire a script, and the post-update view is what the liveness
42
- * check reads without a third round trip.
43
- */
44
- interface OfferSwapSource<S extends OfferSwapFacts = OfferSwapFacts> {
45
- list(): Promise<S[]>;
46
- apply(swap: S, changes: OfferSpendChanges): Promise<{
47
- persisted: boolean;
48
- swaps: S[];
49
- }>;
50
- }
51
- /** A running watcher. `idle()` exists because the writes are async: shutdown
52
- * and tests both need to know when in-flight updates have settled.
53
- *
54
- * @deprecated The drive watches; subscribe with `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`.
55
- */
56
- interface OfferSwapWatcher {
57
- stop(): void;
58
- idle(): Promise<void>;
59
- }
60
- /** @deprecated The drive watches; subscribe with `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`. */
61
- interface WatchOfferSwapsParams<S extends OfferSwapFacts = OfferSwapFacts> {
62
- wallet: IWallet;
63
- /** v1's record source. Ignored when {@link source} is given. */
64
- repository?: AssetSwapRepository;
65
- /** Where records are read and spends written. Defaults to
66
- * {@link assetSwapSource} over `repository`. */
67
- source?: OfferSwapSource<S>;
68
- /** Called after a change is persisted. A notification, not a store. */
69
- onUpdate?: (swap: S) => void;
70
- }
71
- /**
72
- * Subscribe to the wallet's contract events and drive offer swap status.
73
- *
74
- * Registration ({@link createOffer}) is what makes this possible: only a
75
- * registered covenant is watched, so only registered offers produce events.
76
- * Offers funded before registration existed stay on the restore scan.
77
- *
78
- * This depends on the wallet's contract event transport. In Node, callers must
79
- * provide an `EventSource` implementation or use a runtime where it is enabled;
80
- * otherwise live updates do not arrive and restore remains the fallback.
81
- *
82
- * @deprecated The drive watches; subscribe with `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`.
83
- */
84
- declare function watchOfferSwaps(params: {
85
- wallet: IWallet;
86
- repository: AssetSwapRepository;
87
- onUpdate?: (swap: AssetSwap) => void;
88
- }): Promise<OfferSwapWatcher>;
89
- /** @deprecated The drive watches; subscribe with `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`. */
90
- declare function watchOfferSwaps<S extends OfferSwapFacts>(params: {
91
- wallet: IWallet;
92
- source: OfferSwapSource<S>;
93
- onUpdate?: (swap: S) => void;
94
- }): Promise<OfferSwapWatcher>;
95
-
96
- export { type OfferSpendChanges as O, type WatchOfferSwapsParams as W, type OfferSwapFacts as a, type OfferSwapSource as b, type OfferSwapWatcher as c, watchOfferSwaps as w };
@@ -1,96 +0,0 @@
1
- import { IWallet } from '@arkade-os/sdk';
2
- import { e as AssetSwapStatus, c as AssetSwapRepository, aW as AssetSwap } from './repository-tDT8p-Nx.js';
3
-
4
- /**
5
- * What this watcher needs to know about an offer swap.
6
- *
7
- * Structural, and narrower than {@link AssetSwap}, because two record families
8
- * now answer the same question. v1 keys its records on the funding txid — the
9
- * deposit IS the identity, so no record can exist before the money does — while
10
- * the v2 client keys on the quote id and writes the record BEFORE funding, with
11
- * `fundingTxid` a later best-effort write. Projecting the second onto the first
12
- * is impossible for the whole pre-funding window, so the parameter widens
13
- * instead: `id` is whatever key the source stores under, and the spend is
14
- * matched on `fundingTxid` and `swapPkScript`, which both families carry.
15
- *
16
- * `createdAt` is unix **milliseconds**, the unit `coverage.ts` marks issuance
17
- * in; see {@link CoveredSwap}.
18
- */
19
- interface OfferSwapFacts {
20
- readonly id: string;
21
- readonly status: AssetSwapStatus;
22
- /** The TLV offer, hex — what {@link classifyDepositSpend} needs. */
23
- readonly offerHex: string;
24
- readonly swapPkScript: string;
25
- readonly fundingTxid?: string;
26
- readonly spentTxid?: string;
27
- readonly createdAt: number;
28
- }
29
- /** The record change a classified spend implies. */
30
- interface OfferSpendChanges {
31
- readonly status: AssetSwapStatus;
32
- readonly spentTxid: string;
33
- readonly completedAt?: number;
34
- }
35
- /**
36
- * Where the watcher reads offer records and writes their spends.
37
- *
38
- * One seam, two implementations: {@link assetSwapSource} over v1's store, and
39
- * the v2 client's own over its quote-id-keyed record store. `apply` returns
40
- * both halves for the same reason `updateAssetSwapBestEffort` does — a lost
41
- * write must not retire a script, and the post-update view is what the liveness
42
- * check reads without a third round trip.
43
- */
44
- interface OfferSwapSource<S extends OfferSwapFacts = OfferSwapFacts> {
45
- list(): Promise<S[]>;
46
- apply(swap: S, changes: OfferSpendChanges): Promise<{
47
- persisted: boolean;
48
- swaps: S[];
49
- }>;
50
- }
51
- /** A running watcher. `idle()` exists because the writes are async: shutdown
52
- * and tests both need to know when in-flight updates have settled.
53
- *
54
- * @deprecated The drive watches; subscribe with `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`.
55
- */
56
- interface OfferSwapWatcher {
57
- stop(): void;
58
- idle(): Promise<void>;
59
- }
60
- /** @deprecated The drive watches; subscribe with `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`. */
61
- interface WatchOfferSwapsParams<S extends OfferSwapFacts = OfferSwapFacts> {
62
- wallet: IWallet;
63
- /** v1's record source. Ignored when {@link source} is given. */
64
- repository?: AssetSwapRepository;
65
- /** Where records are read and spends written. Defaults to
66
- * {@link assetSwapSource} over `repository`. */
67
- source?: OfferSwapSource<S>;
68
- /** Called after a change is persisted. A notification, not a store. */
69
- onUpdate?: (swap: S) => void;
70
- }
71
- /**
72
- * Subscribe to the wallet's contract events and drive offer swap status.
73
- *
74
- * Registration ({@link createOffer}) is what makes this possible: only a
75
- * registered covenant is watched, so only registered offers produce events.
76
- * Offers funded before registration existed stay on the restore scan.
77
- *
78
- * This depends on the wallet's contract event transport. In Node, callers must
79
- * provide an `EventSource` implementation or use a runtime where it is enabled;
80
- * otherwise live updates do not arrive and restore remains the fallback.
81
- *
82
- * @deprecated The drive watches; subscribe with `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`.
83
- */
84
- declare function watchOfferSwaps(params: {
85
- wallet: IWallet;
86
- repository: AssetSwapRepository;
87
- onUpdate?: (swap: AssetSwap) => void;
88
- }): Promise<OfferSwapWatcher>;
89
- /** @deprecated The drive watches; subscribe with `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`. */
90
- declare function watchOfferSwaps<S extends OfferSwapFacts>(params: {
91
- wallet: IWallet;
92
- source: OfferSwapSource<S>;
93
- onUpdate?: (swap: S) => void;
94
- }): Promise<OfferSwapWatcher>;
95
-
96
- export { type OfferSpendChanges as O, type WatchOfferSwapsParams as W, type OfferSwapFacts as a, type OfferSwapSource as b, type OfferSwapWatcher as c, watchOfferSwaps as w };