@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.
- package/README.md +11 -0
- package/dist/advanced.cjs +1028 -1006
- package/dist/advanced.d.cts +145 -279
- package/dist/advanced.d.ts +145 -279
- package/dist/advanced.js +14 -8
- package/dist/{chunk-SC3SAY3X.js → chunk-4WPDXLXH.js} +501 -271
- package/dist/chunk-A3SHHRX4.js +104 -0
- package/dist/{chunk-KRXPQQJ7.js → chunk-BBP25BWH.js} +198 -218
- package/dist/{chunk-ZDFMD4FA.js → chunk-RX3WPV5D.js} +356 -584
- package/dist/errors-BcOgFV-F.d.ts +1559 -0
- package/dist/errors-n6IHTG-Z.d.cts +1559 -0
- package/dist/index.cjs +1406 -1331
- package/dist/index.d.cts +69 -186
- package/dist/index.d.ts +69 -186
- package/dist/index.js +102 -158
- package/dist/lockupContract-B_jNbjrG.d.ts +215 -0
- package/dist/lockupContract-ZsftgqMc.d.cts +215 -0
- package/dist/node/index.cjs +61 -10
- package/dist/node/index.d.cts +227 -600
- package/dist/node/index.d.ts +227 -600
- package/dist/node/index.js +65 -10
- package/dist/nostr.cjs +11 -11
- package/dist/nostr.d.cts +23 -68
- package/dist/nostr.d.ts +23 -68
- package/dist/nostr.js +3 -4
- package/dist/offer--1zVkNsV.d.ts +261 -0
- package/dist/offer-DsP1q6GE.d.cts +261 -0
- package/dist/protocol.cjs +747 -1012
- package/dist/protocol.d.cts +120 -255
- package/dist/protocol.d.ts +120 -255
- package/dist/protocol.js +146 -149
- 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-BY6GUQiW.d.ts +2233 -0
- package/dist/repository-C32GKpR5.d.cts +2233 -0
- package/dist/{rfq-BWE8qkV2.d.ts → rfq-60PGpQ_x.d.cts} +178 -408
- package/dist/{rfq-BWE8qkV2.d.cts → rfq-60PGpQ_x.d.ts} +178 -408
- package/dist/{watch-D8Z78RAV.d.ts → watch-Cejw5cNQ.d.cts} +12 -30
- package/dist/{watch-C4ReJR5z.d.cts → watch-D8uzWrHc.d.ts} +12 -30
- package/package.json +2 -2
- package/dist/chunk-U7VWWTL6.js +0 -66
- package/dist/errors-LXMcNhNS.d.ts +0 -2222
- package/dist/errors-XUs8r0LT.d.cts +0 -2222
- package/dist/lockupContract-BhMebZCb.d.cts +0 -650
- package/dist/lockupContract-CAiN97fX.d.ts +0 -650
- package/dist/repository-BJLuVFQ0.d.ts +0 -3436
- 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-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
39
|
-
*
|
|
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()`
|
|
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
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
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-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
39
|
-
*
|
|
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()`
|
|
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
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
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.
|
|
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.
|
|
107
|
+
"@arkade-os/sdk": "0.5.0-rc.12"
|
|
108
108
|
},
|
|
109
109
|
"peerDependencies": {
|
|
110
110
|
"nostr-tools": "^2.12.0"
|
package/dist/chunk-U7VWWTL6.js
DELETED
|
@@ -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
|
-
};
|