@arkade-os/swap 0.1.0-rc.2 → 0.1.0-rc.21
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/README.md +52 -2
- package/dist/advanced.cjs +8376 -0
- package/dist/advanced.d.cts +550 -0
- package/dist/advanced.d.ts +550 -0
- package/dist/advanced.js +451 -0
- package/dist/chunk-A3SHHRX4.js +104 -0
- package/dist/chunk-HUQQVBC4.js +4262 -0
- package/dist/{chunk-EOYGUCDM.js → chunk-ITFCQWPG.js} +755 -1382
- package/dist/chunk-PVB7EBAM.js +2517 -0
- package/dist/errors-C3h8ANmE.d.ts +1560 -0
- package/dist/errors-hm7aqnRM.d.cts +1560 -0
- package/dist/index.cjs +4861 -3988
- package/dist/index.d.cts +69 -2812
- package/dist/index.d.ts +69 -2812
- package/dist/index.js +179 -3719
- package/dist/lockupContract-5r5RlgOJ.d.cts +137 -0
- package/dist/lockupContract-5r5RlgOJ.d.ts +137 -0
- package/dist/node/index.cjs +61 -10
- package/dist/node/index.d.cts +249 -591
- package/dist/node/index.d.ts +249 -591
- package/dist/node/index.js +65 -10
- package/dist/nostr.cjs +191 -11
- package/dist/nostr.d.cts +23 -68
- package/dist/nostr.d.ts +23 -68
- package/dist/nostr.js +3 -4
- package/dist/offer-Bd9Yvd8Z.d.ts +261 -0
- package/dist/offer-F88rtL_I.d.cts +261 -0
- package/dist/protocol.cjs +4086 -3706
- package/dist/protocol.d.cts +163 -768
- package/dist/protocol.d.ts +163 -768
- package/dist/protocol.js +190 -173
- package/dist/repositories/realm/index.cjs +55 -11
- package/dist/repositories/realm/index.d.cts +18 -30
- package/dist/repositories/realm/index.d.ts +18 -30
- package/dist/repositories/realm/index.js +49 -12
- package/dist/repositories/sqlite/index.cjs +61 -10
- package/dist/repositories/sqlite/index.d.cts +7 -6
- package/dist/repositories/sqlite/index.d.ts +7 -6
- package/dist/repositories/sqlite/index.js +57 -11
- package/dist/repository-BuYWGAKz.d.cts +2261 -0
- package/dist/repository-DYnRLPt-.d.ts +2261 -0
- package/dist/rfq-60PGpQ_x.d.cts +950 -0
- package/dist/rfq-60PGpQ_x.d.ts +950 -0
- package/dist/watch-BTyiBLSd.d.ts +74 -0
- package/dist/watch-M_KY-5ho.d.cts +74 -0
- package/package.json +20 -10
- package/dist/chunk-LYCMM3VB.js +0 -1357
- package/dist/chunk-U7VWWTL6.js +0 -66
- package/dist/repository-_zU9_pM3.d.cts +0 -3426
- package/dist/repository-kO95noyv.d.ts +0 -3426
- package/dist/rfq-DdBV4JO5.d.cts +0 -1097
- package/dist/rfq-DdBV4JO5.d.ts +0 -1097
- package/dist/watch-CQqvwgwY.d.cts +0 -96
- package/dist/watch-wMbmfN4p.d.ts +0 -96
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { IWallet } from '@arkade-os/sdk';
|
|
2
|
-
import { B as AssetSwapStatus, A as AssetSwapRepository, E as AssetSwap } from './repository-_zU9_pM3.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 };
|
package/dist/watch-wMbmfN4p.d.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { IWallet } from '@arkade-os/sdk';
|
|
2
|
-
import { B as AssetSwapStatus, A as AssetSwapRepository, E as AssetSwap } from './repository-kO95noyv.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 };
|