@arkade-os/swap 0.1.0-rc.13 → 0.1.0-rc.15

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 (53) hide show
  1. package/README.md +11 -0
  2. package/dist/advanced.cjs +1028 -1006
  3. package/dist/advanced.d.cts +145 -279
  4. package/dist/advanced.d.ts +145 -279
  5. package/dist/advanced.js +14 -8
  6. package/dist/{chunk-SC3SAY3X.js → chunk-4WPDXLXH.js} +501 -271
  7. package/dist/chunk-A3SHHRX4.js +104 -0
  8. package/dist/{chunk-KRXPQQJ7.js → chunk-BBP25BWH.js} +198 -218
  9. package/dist/{chunk-ZDFMD4FA.js → chunk-RX3WPV5D.js} +356 -584
  10. package/dist/errors-BcOgFV-F.d.ts +1559 -0
  11. package/dist/errors-n6IHTG-Z.d.cts +1559 -0
  12. package/dist/index.cjs +1406 -1331
  13. package/dist/index.d.cts +69 -186
  14. package/dist/index.d.ts +69 -186
  15. package/dist/index.js +102 -158
  16. package/dist/lockupContract-B_jNbjrG.d.ts +215 -0
  17. package/dist/lockupContract-ZsftgqMc.d.cts +215 -0
  18. package/dist/node/index.cjs +61 -10
  19. package/dist/node/index.d.cts +227 -600
  20. package/dist/node/index.d.ts +227 -600
  21. package/dist/node/index.js +65 -10
  22. package/dist/nostr.cjs +11 -11
  23. package/dist/nostr.d.cts +23 -68
  24. package/dist/nostr.d.ts +23 -68
  25. package/dist/nostr.js +3 -4
  26. package/dist/offer--1zVkNsV.d.ts +261 -0
  27. package/dist/offer-DsP1q6GE.d.cts +261 -0
  28. package/dist/protocol.cjs +747 -1012
  29. package/dist/protocol.d.cts +120 -255
  30. package/dist/protocol.d.ts +120 -255
  31. package/dist/protocol.js +146 -149
  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-BY6GUQiW.d.ts +2233 -0
  41. package/dist/repository-C32GKpR5.d.cts +2233 -0
  42. package/dist/{rfq-BWE8qkV2.d.ts → rfq-60PGpQ_x.d.cts} +178 -408
  43. package/dist/{rfq-BWE8qkV2.d.cts → rfq-60PGpQ_x.d.ts} +178 -408
  44. package/dist/{watch-D8Z78RAV.d.ts → watch-Cejw5cNQ.d.cts} +12 -30
  45. package/dist/{watch-C4ReJR5z.d.cts → watch-D8uzWrHc.d.ts} +12 -30
  46. package/package.json +2 -2
  47. package/dist/chunk-U7VWWTL6.js +0 -66
  48. package/dist/errors-LXMcNhNS.d.ts +0 -2222
  49. package/dist/errors-XUs8r0LT.d.cts +0 -2222
  50. package/dist/lockupContract-BhMebZCb.d.cts +0 -650
  51. package/dist/lockupContract-CAiN97fX.d.ts +0 -650
  52. package/dist/repository-BJLuVFQ0.d.ts +0 -3436
  53. package/dist/repository-DsR3b0JJ.d.cts +0 -3436
@@ -1,20 +1,13 @@
1
1
  import { IWallet } from '@arkade-os/sdk';
2
- import { c as AssetSwapStatus, d as AssetSwapRepository, e as AssetSwap } from './repository-BJLuVFQ0.js';
2
+ import { c as AssetSwapStatus, d as AssetSwapRepository, e as AssetSwap } from './repository-C32GKpR5.cjs';
3
3
 
4
4
  /**
5
- * What this watcher needs to know about an offer swap.
5
+ * What this watcher needs to know about an offer swap, narrower than {@link AssetSwap}
6
+ * so both record families fit: v1 keys on the funding txid, v2 on the quote id (written
7
+ * before funding). `id` is the source's own key; spends match on `fundingTxid` and
8
+ * `swapPkScript`.
6
9
  *
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}.
10
+ * `createdAt` is unix **milliseconds**; see {@link CoveredSwap}.
18
11
  */
19
12
  interface OfferSwapFacts {
20
13
  readonly id: string;
@@ -35,11 +28,8 @@ interface OfferSpendChanges {
35
28
  /**
36
29
  * Where the watcher reads offer records and writes their spends.
37
30
  *
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.
31
+ * `apply` returns `persisted` because a lost write must not retire a script, and the
32
+ * post-update `swaps` so the liveness check needs no third read.
43
33
  */
44
34
  interface OfferSwapSource<S extends OfferSwapFacts = OfferSwapFacts> {
45
35
  list(): Promise<S[]>;
@@ -48,10 +38,7 @@ interface OfferSwapSource<S extends OfferSwapFacts = OfferSwapFacts> {
48
38
  swaps: S[];
49
39
  }>;
50
40
  }
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
- */
41
+ /** A running watcher. `idle()` resolves once in-flight async writes have settled. */
55
42
  interface OfferSwapWatcher {
56
43
  stop(): void;
57
44
  idle(): Promise<void>;
@@ -69,14 +56,9 @@ interface WatchOfferSwapsParams<S extends OfferSwapFacts = OfferSwapFacts> {
69
56
  /**
70
57
  * Subscribe to the wallet's contract events and drive offer swap status.
71
58
  *
72
- * Registration ({@link createOffer}) is what makes this possible: only a
73
- * registered covenant is watched, so only registered offers produce events.
74
- * Offers funded before registration existed stay on the restore scan.
75
- *
76
- * This depends on the wallet's contract event transport. In Node, callers must
77
- * provide an `EventSource` implementation or use a runtime where it is enabled;
78
- * otherwise live updates do not arrive and restore remains the fallback.
79
- *
59
+ * Only covenants registered by {@link createOffer} produce events; older offers stay on
60
+ * the restore scan. In Node, callers must provide an `EventSource` implementation or
61
+ * live updates never arrive.
80
62
  */
81
63
  declare function watchOfferSwaps(params: {
82
64
  wallet: IWallet;
@@ -1,20 +1,13 @@
1
1
  import { IWallet } from '@arkade-os/sdk';
2
- import { c as AssetSwapStatus, d as AssetSwapRepository, e as AssetSwap } from './repository-DsR3b0JJ.cjs';
2
+ import { c as AssetSwapStatus, d as AssetSwapRepository, e as AssetSwap } from './repository-BY6GUQiW.js';
3
3
 
4
4
  /**
5
- * What this watcher needs to know about an offer swap.
5
+ * What this watcher needs to know about an offer swap, narrower than {@link AssetSwap}
6
+ * so both record families fit: v1 keys on the funding txid, v2 on the quote id (written
7
+ * before funding). `id` is the source's own key; spends match on `fundingTxid` and
8
+ * `swapPkScript`.
6
9
  *
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}.
10
+ * `createdAt` is unix **milliseconds**; see {@link CoveredSwap}.
18
11
  */
19
12
  interface OfferSwapFacts {
20
13
  readonly id: string;
@@ -35,11 +28,8 @@ interface OfferSpendChanges {
35
28
  /**
36
29
  * Where the watcher reads offer records and writes their spends.
37
30
  *
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.
31
+ * `apply` returns `persisted` because a lost write must not retire a script, and the
32
+ * post-update `swaps` so the liveness check needs no third read.
43
33
  */
44
34
  interface OfferSwapSource<S extends OfferSwapFacts = OfferSwapFacts> {
45
35
  list(): Promise<S[]>;
@@ -48,10 +38,7 @@ interface OfferSwapSource<S extends OfferSwapFacts = OfferSwapFacts> {
48
38
  swaps: S[];
49
39
  }>;
50
40
  }
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
- */
41
+ /** A running watcher. `idle()` resolves once in-flight async writes have settled. */
55
42
  interface OfferSwapWatcher {
56
43
  stop(): void;
57
44
  idle(): Promise<void>;
@@ -69,14 +56,9 @@ interface WatchOfferSwapsParams<S extends OfferSwapFacts = OfferSwapFacts> {
69
56
  /**
70
57
  * Subscribe to the wallet's contract events and drive offer swap status.
71
58
  *
72
- * Registration ({@link createOffer}) is what makes this possible: only a
73
- * registered covenant is watched, so only registered offers produce events.
74
- * Offers funded before registration existed stay on the restore scan.
75
- *
76
- * This depends on the wallet's contract event transport. In Node, callers must
77
- * provide an `EventSource` implementation or use a runtime where it is enabled;
78
- * otherwise live updates do not arrive and restore remains the fallback.
79
- *
59
+ * Only covenants registered by {@link createOffer} produce events; older offers stay on
60
+ * the restore scan. In Node, callers must provide an `EventSource` implementation or
61
+ * live updates never arrive.
80
62
  */
81
63
  declare function watchOfferSwaps(params: {
82
64
  wallet: IWallet;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkade-os/swap",
3
- "version": "0.1.0-rc.13",
3
+ "version": "0.1.0-rc.15",
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.0.0",
105
105
  "@scure/btc-signer": "2.0.1",
106
106
  "light-bolt11-decoder": "3.2.0",
107
- "@arkade-os/sdk": "0.5.0-rc.10"
107
+ "@arkade-os/sdk": "0.5.0-rc.12"
108
108
  },
109
109
  "peerDependencies": {
110
110
  "nostr-tools": "^2.12.0"
@@ -1,66 +0,0 @@
1
- // src/repository.ts
2
- var marketsCacheKey = (network, registry) => `arkade-intents-markets-${network}-${registry}`;
3
- var InMemoryAssetSwapRepository = class {
4
- version = 5;
5
- swaps = /* @__PURE__ */ new Map();
6
- records = /* @__PURE__ */ new Map();
7
- rfqSwaps = /* @__PURE__ */ new Map();
8
- scanned = /* @__PURE__ */ new Set();
9
- markets = /* @__PURE__ */ new Map();
10
- async saveSwap(swap) {
11
- this.swaps.set(swap.id, swap);
12
- }
13
- async getAllSwaps() {
14
- return [...this.swaps.values()];
15
- }
16
- async saveRfqSwap(record) {
17
- this.rfqSwaps.set(record.rfqId, record);
18
- }
19
- async getRfqSwap(rfqId) {
20
- return this.rfqSwaps.get(rfqId);
21
- }
22
- async getAllRfqSwaps() {
23
- return [...this.rfqSwaps.values()];
24
- }
25
- async removeRfqSwap(rfqId) {
26
- this.rfqSwaps.delete(rfqId);
27
- }
28
- async saveSwapRecord(record) {
29
- this.records.set(record.id, record);
30
- }
31
- async getSwapRecord(id) {
32
- return this.records.get(id);
33
- }
34
- async getAllSwapRecords() {
35
- return [...this.records.values()];
36
- }
37
- async removeSwapRecord(id) {
38
- this.records.delete(id);
39
- }
40
- async getScannedTxids() {
41
- return new Set(this.scanned);
42
- }
43
- async markTxidsScanned(txids) {
44
- for (const txid of txids) this.scanned.add(txid);
45
- }
46
- async getCachedMarkets(network, registry) {
47
- return this.markets.get(marketsCacheKey(network, registry));
48
- }
49
- async saveCachedMarkets(network, registry, entry) {
50
- this.markets.set(marketsCacheKey(network, registry), entry);
51
- }
52
- async clear() {
53
- this.swaps.clear();
54
- this.rfqSwaps.clear();
55
- this.records.clear();
56
- this.scanned.clear();
57
- this.markets.clear();
58
- }
59
- async [Symbol.asyncDispose]() {
60
- }
61
- };
62
-
63
- export {
64
- marketsCacheKey,
65
- InMemoryAssetSwapRepository
66
- };