@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
@@ -0,0 +1,74 @@
1
+ import { IWallet } from '@arkade-os/sdk';
2
+ import { c as AssetSwapStatus, d as AssetSwapRepository, h as AssetSwap } from './repository-DqdLVrVv.cjs';
3
+
4
+ /**
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`.
9
+ *
10
+ * `createdAt` is unix **milliseconds**; see {@link CoveredSwap}.
11
+ */
12
+ interface OfferSwapFacts {
13
+ readonly id: string;
14
+ readonly status: AssetSwapStatus;
15
+ /** The TLV offer, hex — what {@link classifyDepositSpend} needs. */
16
+ readonly offerHex: string;
17
+ readonly swapPkScript: string;
18
+ readonly fundingTxid?: string;
19
+ readonly spentTxid?: string;
20
+ readonly createdAt: number;
21
+ }
22
+ /** The record change a classified spend implies. */
23
+ interface OfferSpendChanges {
24
+ readonly status: AssetSwapStatus;
25
+ readonly spentTxid: string;
26
+ readonly completedAt?: number;
27
+ }
28
+ /**
29
+ * Where the watcher reads offer records and writes their spends.
30
+ *
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.
33
+ */
34
+ interface OfferSwapSource<S extends OfferSwapFacts = OfferSwapFacts> {
35
+ list(): Promise<S[]>;
36
+ apply(swap: S, changes: OfferSpendChanges): Promise<{
37
+ persisted: boolean;
38
+ swaps: S[];
39
+ }>;
40
+ }
41
+ /** A running watcher. `idle()` resolves once in-flight async writes have settled. */
42
+ interface OfferSwapWatcher {
43
+ stop(): void;
44
+ idle(): Promise<void>;
45
+ }
46
+ interface WatchOfferSwapsParams<S extends OfferSwapFacts = OfferSwapFacts> {
47
+ wallet: IWallet;
48
+ /** v1's record source. Ignored when {@link source} is given. */
49
+ repository?: AssetSwapRepository;
50
+ /** Where records are read and spends written. Defaults to
51
+ * {@link assetSwapSource} over `repository`. */
52
+ source?: OfferSwapSource<S>;
53
+ /** Called after a change is persisted. A notification, not a store. */
54
+ onUpdate?: (swap: S) => void;
55
+ }
56
+ /**
57
+ * Subscribe to the wallet's contract events and drive offer swap status.
58
+ *
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.
62
+ */
63
+ declare function watchOfferSwaps(params: {
64
+ wallet: IWallet;
65
+ repository: AssetSwapRepository;
66
+ onUpdate?: (swap: AssetSwap) => void;
67
+ }): Promise<OfferSwapWatcher>;
68
+ declare function watchOfferSwaps<S extends OfferSwapFacts>(params: {
69
+ wallet: IWallet;
70
+ source: OfferSwapSource<S>;
71
+ onUpdate?: (swap: S) => void;
72
+ }): Promise<OfferSwapWatcher>;
73
+
74
+ export { type OfferSpendChanges as O, type WatchOfferSwapsParams as W, type OfferSwapFacts as a, type OfferSwapSource as b, type OfferSwapWatcher as c, watchOfferSwaps as w };
@@ -0,0 +1,74 @@
1
+ import { IWallet } from '@arkade-os/sdk';
2
+ import { c as AssetSwapStatus, d as AssetSwapRepository, h as AssetSwap } from './repository-DmPzpbd7.js';
3
+
4
+ /**
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`.
9
+ *
10
+ * `createdAt` is unix **milliseconds**; see {@link CoveredSwap}.
11
+ */
12
+ interface OfferSwapFacts {
13
+ readonly id: string;
14
+ readonly status: AssetSwapStatus;
15
+ /** The TLV offer, hex — what {@link classifyDepositSpend} needs. */
16
+ readonly offerHex: string;
17
+ readonly swapPkScript: string;
18
+ readonly fundingTxid?: string;
19
+ readonly spentTxid?: string;
20
+ readonly createdAt: number;
21
+ }
22
+ /** The record change a classified spend implies. */
23
+ interface OfferSpendChanges {
24
+ readonly status: AssetSwapStatus;
25
+ readonly spentTxid: string;
26
+ readonly completedAt?: number;
27
+ }
28
+ /**
29
+ * Where the watcher reads offer records and writes their spends.
30
+ *
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.
33
+ */
34
+ interface OfferSwapSource<S extends OfferSwapFacts = OfferSwapFacts> {
35
+ list(): Promise<S[]>;
36
+ apply(swap: S, changes: OfferSpendChanges): Promise<{
37
+ persisted: boolean;
38
+ swaps: S[];
39
+ }>;
40
+ }
41
+ /** A running watcher. `idle()` resolves once in-flight async writes have settled. */
42
+ interface OfferSwapWatcher {
43
+ stop(): void;
44
+ idle(): Promise<void>;
45
+ }
46
+ interface WatchOfferSwapsParams<S extends OfferSwapFacts = OfferSwapFacts> {
47
+ wallet: IWallet;
48
+ /** v1's record source. Ignored when {@link source} is given. */
49
+ repository?: AssetSwapRepository;
50
+ /** Where records are read and spends written. Defaults to
51
+ * {@link assetSwapSource} over `repository`. */
52
+ source?: OfferSwapSource<S>;
53
+ /** Called after a change is persisted. A notification, not a store. */
54
+ onUpdate?: (swap: S) => void;
55
+ }
56
+ /**
57
+ * Subscribe to the wallet's contract events and drive offer swap status.
58
+ *
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.
62
+ */
63
+ declare function watchOfferSwaps(params: {
64
+ wallet: IWallet;
65
+ repository: AssetSwapRepository;
66
+ onUpdate?: (swap: AssetSwap) => void;
67
+ }): Promise<OfferSwapWatcher>;
68
+ declare function watchOfferSwaps<S extends OfferSwapFacts>(params: {
69
+ wallet: IWallet;
70
+ source: OfferSwapSource<S>;
71
+ onUpdate?: (swap: S) => void;
72
+ }): Promise<OfferSwapWatcher>;
73
+
74
+ export { type OfferSpendChanges as O, type WatchOfferSwapsParams as W, type OfferSwapFacts as a, type OfferSwapSource as b, type OfferSwapWatcher as c, watchOfferSwaps as w };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkade-os/swap",
3
- "version": "0.1.0-rc.8",
3
+ "version": "0.1.0",
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": {
@@ -86,7 +86,7 @@
86
86
  "dist"
87
87
  ],
88
88
  "engines": {
89
- "node": ">=22.12.0"
89
+ "node": ">=22.13.0"
90
90
  },
91
91
  "keywords": [
92
92
  "arkade",
@@ -97,17 +97,17 @@
97
97
  "author": "Arkade-OS",
98
98
  "license": "MIT",
99
99
  "dependencies": {
100
- "@arkade-os/solver-discovery": "0.2.3",
100
+ "@arkade-os/solver-discovery": "0.3.0",
101
101
  "@noble/ciphers": "2.1.1",
102
- "@noble/curves": "2.0.1",
103
- "@noble/hashes": "2.0.1",
104
- "@scure/base": "2.0.0",
105
- "@scure/btc-signer": "2.0.1",
102
+ "@noble/curves": "2.4.0",
103
+ "@noble/hashes": "2.4.0",
104
+ "@scure/base": "2.4.0",
105
+ "@scure/btc-signer": "2.4.1",
106
106
  "light-bolt11-decoder": "3.2.0",
107
- "@arkade-os/sdk": "0.5.0-rc.8"
107
+ "@arkade-os/sdk": "0.5.0"
108
108
  },
109
109
  "peerDependencies": {
110
- "nostr-tools": "^2.12.0"
110
+ "nostr-tools": "2.24.1"
111
111
  },
112
112
  "peerDependenciesMeta": {
113
113
  "nostr-tools": {
@@ -120,7 +120,7 @@
120
120
  },
121
121
  "devDependencies": {
122
122
  "fake-indexeddb": "6.2.5",
123
- "nostr-tools": "^2.12.0"
123
+ "nostr-tools": "2.24.1"
124
124
  },
125
125
  "scripts": {
126
126
  "build": "pnpm run build:web && pnpm run build:node",
@@ -131,8 +131,8 @@
131
131
  "lint": "biome format src test",
132
132
  "test": "vitest run --exclude test/e2e",
133
133
  "test:unit": "vitest run --exclude test/e2e",
134
- "test:integration": "vitest run test/e2e --exclude 'test/e2e/rfq*.test.ts'",
135
- "test:integration:rfq": "vitest run test/e2e/rfq",
134
+ "test:integration": "vitest run --no-file-parallelism --exclude \"test/e2e/rfq*.test.ts\" test/e2e/",
135
+ "test:integration:rfq": "vitest run --no-file-parallelism test/e2e/rfq",
136
136
  "smoke:dist": "node scripts/smoke-dist.mjs"
137
137
  }
138
138
  }