@arkade-os/swap 0.1.3 → 0.1.5
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 +1 -1
- package/dist/advanced.cjs +14 -11
- package/dist/advanced.d.cts +8 -8
- package/dist/advanced.d.ts +8 -8
- package/dist/advanced.js +5 -3
- package/dist/{chunk-2AQYBSF5.js → chunk-7BBQ74BG.js} +13 -13
- package/dist/{chunk-G5QURHVP.js → chunk-GJKGPE3S.js} +3 -3
- package/dist/{chunk-6HKTAZLJ.js → chunk-HDCC3JZR.js} +12 -10
- package/dist/index.cjs +11 -11
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +3 -3
- package/dist/{lockupContract-D-OpxRSX.d.ts → lockupContract-CdXh9yIr.d.ts} +1 -1
- package/dist/{lockupContract-AwSwif9u.d.cts → lockupContract-QfbsjyXG.d.cts} +1 -1
- package/dist/node/index.cjs +37 -37
- package/dist/node/index.js +37 -37
- package/dist/nostr.d.cts +1 -1
- package/dist/nostr.d.ts +1 -1
- package/dist/nostr.js +1 -1
- package/dist/{offer-BEcW5o7V.d.cts → offer-BxzPQ6zh.d.cts} +11 -11
- package/dist/{offer-4Ir1bRQV.d.ts → offer-Q1lVhrVX.d.ts} +11 -11
- package/dist/{offerFillPlan-DvrHfYoH.d.cts → offerFillPlan-BfcxbVvw.d.cts} +18 -13
- package/dist/{offerFillPlan-bsyVMum3.d.ts → offerFillPlan-C11P2ek2.d.ts} +18 -13
- package/dist/protocol.cjs +12 -12
- package/dist/protocol.d.cts +8 -8
- package/dist/protocol.d.ts +8 -8
- package/dist/protocol.js +2 -2
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.cjs +37 -37
- package/dist/repositories/sqlite/index.d.cts +3 -3
- package/dist/repositories/sqlite/index.d.ts +3 -3
- package/dist/repositories/sqlite/index.js +37 -37
- package/dist/{repository-ChRNknNn.d.ts → repository-BOQ1qYoj.d.ts} +7 -7
- package/dist/{repository-BW42Dtct.d.cts → repository-Cut4eEkm.d.cts} +7 -7
- package/dist/{rfq-C0tHOvn6.d.cts → rfq-CP-P0PSL.d.cts} +7 -7
- package/dist/{rfq-C0tHOvn6.d.ts → rfq-CP-P0PSL.d.ts} +7 -7
- package/dist/{watch-B_Q0ddHg.d.ts → watch-D15U0QpD.d.ts} +1 -1
- package/dist/{watch-CpnfqYCE.d.cts → watch-D4PeBZ3H.d.cts} +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { e as AcceptConflict, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, A as AssetAliasTable, B as BuildOfferFillPlanOpts, o as CancelOutcome, q as ClientDisposed, E as CorridorOverrides, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, d as DiscoverySnapshot, K as DiscoverySnapshotUnavailable, N as DriveMode, Q as ExchangeOptions, T as FeeCeiling, W as FillSponsor, X as FillSponsorFare, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a1 as Market, a2 as MarketLeg, a3 as MaxFeeExceeded, a4 as MissingCorridorDep, a5 as NotCancellable, a6 as OFFER_FILL_OWNERS, a7 as OFFER_FILL_TEMPLATE, ad as OperatorUnreachable, af as PayOptions, ag as PayResult, ah as QuoteCheck, ai as QuoteExpired, ak as QuoteVerificationFailed, al as REGISTRY_URL, am as ReceiveArtifact, an as ReceiveOptions, ao as ReceiveRequest, ap as RecoveryResult, aq as RegisteredAsset, ar as RfqAuctionPolicy, av as RfqTransportFactory, ax as SWAP_ERROR_NAMES, ay as SwapClient, az as SwapClientConfig, aC as SwapDriveRefusedError, aD as SwapError, aE as SwapErrorName, aF as SwapFilter, S as SwapPolicy, aG as UnsupportedRoute, aH as VerbDeps, aK as buildOfferFillPlan, aM as canonicalAssetId, aS as createSwapClient, aU as deepFreeze, aV as digestJointGraph, aZ as exchange, b3 as isSwapError,
|
|
2
|
-
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry, a7 as Outcome, ap as Swap, l as QuoteInput, i as RouteResolution, a9 as Quote, as as SwapUpdate, au as Unsubscribe } from './repository-
|
|
3
|
-
export { o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, A as AssetId, v as AssetIdError, w as AssetIdRefusal, x as AssetNamespace, y as AssetOn, z as AssetPart, B as AssetPaymentInput, D as AssetPaymentTerms, E as AssetRef, F as AssetScale, G as AssetSwapId, H as AtomicDecimal, J as AuctionMarketRef, K as AuctionProvenance, M as BITCOIN_RAILS, T as BTC_ASSET_PART, U as BitcoinRail, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, b as CorridorSwapRecord, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, ba as InMemoryAssetSwapRepository, I as Instrument, L as LockupSpendIndexer, a4 as MarketBackend, a5 as MarketRef, N as NetworkRef, O as OfferSwapRecord, a8 as ParsedAssetId, P as PinnedAmount, Q as QuoteId, aa as QuoteLeg, ab as RAILS, R as Rail, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, j as ResolvedEndpoint, am as RestoredMarketRef, bb as RfqSwapState, k as Route, ao as SnapshotRef, bc as SwapContractRegistry, aq as SwapFamily, bd as SwapOperator, ar as SwapRecordCommon, at as TaxiIdentity, av as VerifiedCarrierTerms, aw as arkadeAsset, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, be as isRfqSwapTerminal, aT as issuanceOf, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, b4 as sameAsset, b6 as toAtomicDecimal } from './repository-
|
|
4
|
-
export { C as ChainSource, I as InvoiceFacts, a as RFQ_REFUSAL_ERROR_CODES, b as RfqRefusalDetail, c as RfqRefusalErrorCode, d as RfqRefusalUnit, S as SwapRefusal, T as TxStatus, i as isRfqRefusalErrorCode } from './rfq-
|
|
1
|
+
export { e as AcceptConflict, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, A as AssetAliasTable, B as BuildOfferFillPlanOpts, o as CancelOutcome, q as ClientDisposed, E as CorridorOverrides, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, d as DiscoverySnapshot, K as DiscoverySnapshotUnavailable, N as DriveMode, Q as ExchangeOptions, T as FeeCeiling, W as FillSponsor, X as FillSponsorFare, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a1 as Market, a2 as MarketLeg, a3 as MaxFeeExceeded, a4 as MissingCorridorDep, a5 as NotCancellable, a6 as OFFER_FILL_OWNERS, a7 as OFFER_FILL_TEMPLATE, ad as OperatorUnreachable, af as PayOptions, ag as PayResult, ah as QuoteCheck, ai as QuoteExpired, ak as QuoteVerificationFailed, al as REGISTRY_URL, am as ReceiveArtifact, an as ReceiveOptions, ao as ReceiveRequest, ap as RecoveryResult, aq as RegisteredAsset, ar as RfqAuctionPolicy, av as RfqTransportFactory, ax as SWAP_ERROR_NAMES, ay as SwapClient, az as SwapClientConfig, aC as SwapDriveRefusedError, aD as SwapError, aE as SwapErrorName, aF as SwapFilter, S as SwapPolicy, aG as UnsupportedRoute, aH as VerbDeps, aK as buildOfferFillPlan, aM as canonicalAssetId, aS as createSwapClient, aU as deepFreeze, aV as digestJointGraph, aZ as exchange, b3 as isSwapError, bd as pay, bh as receive, bo as unsignedPsbtBytes, bq as verifyJointGraph, br as verifyOfferFillPlan } from './offerFillPlan-C11P2ek2.js';
|
|
2
|
+
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry, a7 as Outcome, ap as Swap, l as QuoteInput, i as RouteResolution, a9 as Quote, as as SwapUpdate, au as Unsubscribe } from './repository-BOQ1qYoj.js';
|
|
3
|
+
export { o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, A as AssetId, v as AssetIdError, w as AssetIdRefusal, x as AssetNamespace, y as AssetOn, z as AssetPart, B as AssetPaymentInput, D as AssetPaymentTerms, E as AssetRef, F as AssetScale, G as AssetSwapId, H as AtomicDecimal, J as AuctionMarketRef, K as AuctionProvenance, M as BITCOIN_RAILS, T as BTC_ASSET_PART, U as BitcoinRail, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, b as CorridorSwapRecord, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, ba as InMemoryAssetSwapRepository, I as Instrument, L as LockupSpendIndexer, a4 as MarketBackend, a5 as MarketRef, N as NetworkRef, O as OfferSwapRecord, a8 as ParsedAssetId, P as PinnedAmount, Q as QuoteId, aa as QuoteLeg, ab as RAILS, R as Rail, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, j as ResolvedEndpoint, am as RestoredMarketRef, bb as RfqSwapState, k as Route, ao as SnapshotRef, bc as SwapContractRegistry, aq as SwapFamily, bd as SwapOperator, ar as SwapRecordCommon, at as TaxiIdentity, av as VerifiedCarrierTerms, aw as arkadeAsset, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, be as isRfqSwapTerminal, aT as issuanceOf, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, b4 as sameAsset, b6 as toAtomicDecimal } from './repository-BOQ1qYoj.js';
|
|
4
|
+
export { C as ChainSource, I as InvoiceFacts, a as RFQ_REFUSAL_ERROR_CODES, b as RfqRefusalDetail, c as RfqRefusalErrorCode, d as RfqRefusalUnit, S as SwapRefusal, T as TxStatus, i as isRfqRefusalErrorCode } from './rfq-CP-P0PSL.js';
|
|
5
5
|
import { PageRequest, PageResult, PaymentHandle, PaymentRail, RouterPreferences, Wallet, PaymentRouter, PaymentStatus } from '@arkade-os/sdk';
|
|
6
|
-
export { C as CLAIM_PACKET_TYPE, a as ClaimPacketShape, L as LockupRegistrationFailed, S as SEALED_CIPHERTEXT_LENGTH, b as appendArkadeScript, c as claimPacketShape } from './lockupContract-
|
|
6
|
+
export { C as CLAIM_PACKET_TYPE, a as ClaimPacketShape, L as LockupRegistrationFailed, S as SEALED_CIPHERTEXT_LENGTH, b as appendArkadeScript, c as claimPacketShape } from './lockupContract-CdXh9yIr.js';
|
|
7
7
|
import '@arkade-os/solver-discovery';
|
|
8
|
-
import './offer-
|
|
8
|
+
import './offer-Q1lVhrVX.js';
|
|
9
9
|
import 'nostr-tools';
|
|
10
10
|
|
|
11
11
|
/** Browser backend over the SDK's shared IndexedDB manager. */
|
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
unsignedPsbtBytes,
|
|
63
63
|
verifyJointGraph,
|
|
64
64
|
verifyOfferFillPlan
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-HDCC3JZR.js";
|
|
66
66
|
import {
|
|
67
67
|
Amount,
|
|
68
68
|
AmountFormatError,
|
|
@@ -73,7 +73,7 @@ import {
|
|
|
73
73
|
isRfqSwapTerminal,
|
|
74
74
|
quoteIdOfSwapId,
|
|
75
75
|
toAtomicDecimal
|
|
76
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-GJKGPE3S.js";
|
|
77
77
|
import {
|
|
78
78
|
CLAIM_PACKET_TYPE,
|
|
79
79
|
LockupRegistrationFailed,
|
|
@@ -83,7 +83,7 @@ import {
|
|
|
83
83
|
appendArkadeScript,
|
|
84
84
|
claimPacketShape,
|
|
85
85
|
isRfqRefusalErrorCode
|
|
86
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-7BBQ74BG.js";
|
|
87
87
|
import {
|
|
88
88
|
InMemoryAssetSwapRepository,
|
|
89
89
|
assertRfqSwapPageFilter,
|
package/dist/node/index.cjs
CHANGED
|
@@ -108,46 +108,46 @@ var SQLiteAssetSwapRepository = class {
|
|
|
108
108
|
* while `initPromise` stayed resolved and every later statement failed with
|
|
109
109
|
* `no such table`. */
|
|
110
110
|
async init() {
|
|
111
|
-
await this.withTx(async () => {
|
|
112
|
-
await
|
|
111
|
+
await this.withTx(async (tx) => {
|
|
112
|
+
await tx.run(`CREATE TABLE IF NOT EXISTS ${this.swaps} (
|
|
113
113
|
id TEXT PRIMARY KEY,
|
|
114
114
|
status TEXT NOT NULL,
|
|
115
115
|
created_at INTEGER NOT NULL,
|
|
116
116
|
data TEXT NOT NULL
|
|
117
117
|
)`);
|
|
118
|
-
await
|
|
118
|
+
await tx.run(
|
|
119
119
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}asset_swaps_status ON ${this.swaps} (status)`
|
|
120
120
|
);
|
|
121
|
-
await
|
|
121
|
+
await tx.run(
|
|
122
122
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}asset_swaps_created_at ON ${this.swaps} (created_at)`
|
|
123
123
|
);
|
|
124
|
-
await
|
|
124
|
+
await tx.run(`CREATE TABLE IF NOT EXISTS ${this.rfqSwaps} (
|
|
125
125
|
rfq_id TEXT PRIMARY KEY,
|
|
126
126
|
state TEXT NOT NULL,
|
|
127
127
|
updated_at INTEGER NOT NULL,
|
|
128
128
|
data TEXT NOT NULL
|
|
129
129
|
)`);
|
|
130
|
-
await
|
|
130
|
+
await tx.run(
|
|
131
131
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}rfq_updated ON ${this.rfqSwaps} (updated_at, rfq_id)`
|
|
132
132
|
);
|
|
133
|
-
await
|
|
133
|
+
await tx.run(
|
|
134
134
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}rfq_swaps_history ON ${this.rfqSwaps} (state, updated_at, rfq_id)`
|
|
135
135
|
);
|
|
136
|
-
await
|
|
137
|
-
await
|
|
136
|
+
await tx.run(`DROP INDEX IF EXISTS idx_${this.prefix}rfq_swaps_page`);
|
|
137
|
+
await tx.run(
|
|
138
138
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}rfq_swaps_state ON ${this.rfqSwaps} (state)`
|
|
139
139
|
);
|
|
140
|
-
await
|
|
140
|
+
await tx.run(`CREATE TABLE IF NOT EXISTS ${this.swapRecords} (
|
|
141
141
|
id TEXT PRIMARY KEY,
|
|
142
142
|
family TEXT NOT NULL,
|
|
143
143
|
updated_at INTEGER NOT NULL,
|
|
144
144
|
data TEXT NOT NULL
|
|
145
145
|
)`);
|
|
146
|
-
await
|
|
146
|
+
await tx.run(
|
|
147
147
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}swap_records_family ON ${this.swapRecords} (family)`
|
|
148
148
|
);
|
|
149
|
-
await
|
|
150
|
-
await
|
|
149
|
+
await tx.run(`CREATE TABLE IF NOT EXISTS ${this.scanned} (txid TEXT PRIMARY KEY)`);
|
|
150
|
+
await tx.run(
|
|
151
151
|
`CREATE TABLE IF NOT EXISTS ${this.markets} (cache_key TEXT PRIMARY KEY, data TEXT NOT NULL)`
|
|
152
152
|
);
|
|
153
153
|
});
|
|
@@ -155,7 +155,7 @@ var SQLiteAssetSwapRepository = class {
|
|
|
155
155
|
/** Every write, including the single-statement ones. The chain serializes
|
|
156
156
|
* transaction *blocks*, not bare statements: one issued between a
|
|
157
157
|
* neighbour's BEGIN IMMEDIATE and its COMMIT becomes part of that
|
|
158
|
-
* transaction and dies with it. `fn` must
|
|
158
|
+
* transaction and dies with it. `fn` must use its supplied raw executor — no
|
|
159
159
|
* repository method, no `ensureInit` — since `runInTransaction` cannot
|
|
160
160
|
* nest. */
|
|
161
161
|
withTx(fn) {
|
|
@@ -163,8 +163,8 @@ var SQLiteAssetSwapRepository = class {
|
|
|
163
163
|
}
|
|
164
164
|
async saveSwap(swap) {
|
|
165
165
|
await this.ensureInit();
|
|
166
|
-
await this.withTx(async () => {
|
|
167
|
-
await
|
|
166
|
+
await this.withTx(async (tx) => {
|
|
167
|
+
await tx.run(
|
|
168
168
|
`INSERT OR REPLACE INTO ${this.swaps} (id, status, created_at, data)
|
|
169
169
|
VALUES (?, ?, ?, ?)`,
|
|
170
170
|
[swap.id, swap.status, swap.createdAt, JSON.stringify(swap)]
|
|
@@ -176,8 +176,8 @@ var SQLiteAssetSwapRepository = class {
|
|
|
176
176
|
}
|
|
177
177
|
async saveRfqSwap(record) {
|
|
178
178
|
await this.ensureInit();
|
|
179
|
-
await this.withTx(async () => {
|
|
180
|
-
await
|
|
179
|
+
await this.withTx(async (tx) => {
|
|
180
|
+
await tx.run(
|
|
181
181
|
`INSERT OR REPLACE INTO ${this.rfqSwaps} (rfq_id, state, updated_at, data)
|
|
182
182
|
VALUES (?, ?, ?, ?)`,
|
|
183
183
|
[record.rfqId, record.state, record.updatedAt, JSON.stringify(record)]
|
|
@@ -227,14 +227,14 @@ var SQLiteAssetSwapRepository = class {
|
|
|
227
227
|
}
|
|
228
228
|
async removeRfqSwap(rfqId) {
|
|
229
229
|
await this.ensureInit();
|
|
230
|
-
await this.withTx(async () => {
|
|
231
|
-
await
|
|
230
|
+
await this.withTx(async (tx) => {
|
|
231
|
+
await tx.run(`DELETE FROM ${this.rfqSwaps} WHERE rfq_id = ?`, [rfqId]);
|
|
232
232
|
});
|
|
233
233
|
}
|
|
234
234
|
async saveSwapRecord(record) {
|
|
235
235
|
await this.ensureInit();
|
|
236
|
-
await this.withTx(async () => {
|
|
237
|
-
await
|
|
236
|
+
await this.withTx(async (tx) => {
|
|
237
|
+
await tx.run(
|
|
238
238
|
`INSERT OR REPLACE INTO ${this.swapRecords} (id, family, updated_at, data)
|
|
239
239
|
VALUES (?, ?, ?, ?)`,
|
|
240
240
|
[record.id, record.family, record.updatedAt, JSON.stringify(record)]
|
|
@@ -267,8 +267,8 @@ var SQLiteAssetSwapRepository = class {
|
|
|
267
267
|
}
|
|
268
268
|
async removeSwapRecord(id) {
|
|
269
269
|
await this.ensureInit();
|
|
270
|
-
await this.withTx(async () => {
|
|
271
|
-
await
|
|
270
|
+
await this.withTx(async (tx) => {
|
|
271
|
+
await tx.run(`DELETE FROM ${this.swapRecords} WHERE id = ?`, [id]);
|
|
272
272
|
});
|
|
273
273
|
}
|
|
274
274
|
async getScannedTxids() {
|
|
@@ -280,10 +280,10 @@ var SQLiteAssetSwapRepository = class {
|
|
|
280
280
|
await this.ensureInit();
|
|
281
281
|
const all = [...txids];
|
|
282
282
|
if (all.length === 0) return;
|
|
283
|
-
await this.withTx(async () => {
|
|
283
|
+
await this.withTx(async (tx) => {
|
|
284
284
|
for (let i = 0; i < all.length; i += INSERT_CHUNK) {
|
|
285
285
|
const chunk = all.slice(i, i + INSERT_CHUNK);
|
|
286
|
-
await
|
|
286
|
+
await tx.run(
|
|
287
287
|
`INSERT OR IGNORE INTO ${this.scanned} (txid) VALUES ${chunk.map(() => "(?)").join(", ")}`,
|
|
288
288
|
chunk
|
|
289
289
|
);
|
|
@@ -300,11 +300,11 @@ var SQLiteAssetSwapRepository = class {
|
|
|
300
300
|
}
|
|
301
301
|
async saveCachedMarkets(network, registry, entry) {
|
|
302
302
|
await this.ensureInit();
|
|
303
|
-
await this.withTx(async () => {
|
|
304
|
-
await
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
);
|
|
303
|
+
await this.withTx(async (tx) => {
|
|
304
|
+
await tx.run(`INSERT OR REPLACE INTO ${this.markets} (cache_key, data) VALUES (?, ?)`, [
|
|
305
|
+
marketsCacheKey(network, registry),
|
|
306
|
+
JSON.stringify(entry)
|
|
307
|
+
]);
|
|
308
308
|
});
|
|
309
309
|
}
|
|
310
310
|
/** Every table in one transaction: clearing swaps but keeping scanned txids
|
|
@@ -312,12 +312,12 @@ var SQLiteAssetSwapRepository = class {
|
|
|
312
312
|
* partial clear must not be observable. */
|
|
313
313
|
async clear() {
|
|
314
314
|
await this.ensureInit();
|
|
315
|
-
await this.withTx(async () => {
|
|
316
|
-
await
|
|
317
|
-
await
|
|
318
|
-
await
|
|
319
|
-
await
|
|
320
|
-
await
|
|
315
|
+
await this.withTx(async (tx) => {
|
|
316
|
+
await tx.run(`DELETE FROM ${this.swaps}`);
|
|
317
|
+
await tx.run(`DELETE FROM ${this.rfqSwaps}`);
|
|
318
|
+
await tx.run(`DELETE FROM ${this.swapRecords}`);
|
|
319
|
+
await tx.run(`DELETE FROM ${this.scanned}`);
|
|
320
|
+
await tx.run(`DELETE FROM ${this.markets}`);
|
|
321
321
|
});
|
|
322
322
|
}
|
|
323
323
|
async [Symbol.asyncDispose]() {
|
package/dist/node/index.js
CHANGED
|
@@ -86,46 +86,46 @@ var SQLiteAssetSwapRepository = class {
|
|
|
86
86
|
* while `initPromise` stayed resolved and every later statement failed with
|
|
87
87
|
* `no such table`. */
|
|
88
88
|
async init() {
|
|
89
|
-
await this.withTx(async () => {
|
|
90
|
-
await
|
|
89
|
+
await this.withTx(async (tx) => {
|
|
90
|
+
await tx.run(`CREATE TABLE IF NOT EXISTS ${this.swaps} (
|
|
91
91
|
id TEXT PRIMARY KEY,
|
|
92
92
|
status TEXT NOT NULL,
|
|
93
93
|
created_at INTEGER NOT NULL,
|
|
94
94
|
data TEXT NOT NULL
|
|
95
95
|
)`);
|
|
96
|
-
await
|
|
96
|
+
await tx.run(
|
|
97
97
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}asset_swaps_status ON ${this.swaps} (status)`
|
|
98
98
|
);
|
|
99
|
-
await
|
|
99
|
+
await tx.run(
|
|
100
100
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}asset_swaps_created_at ON ${this.swaps} (created_at)`
|
|
101
101
|
);
|
|
102
|
-
await
|
|
102
|
+
await tx.run(`CREATE TABLE IF NOT EXISTS ${this.rfqSwaps} (
|
|
103
103
|
rfq_id TEXT PRIMARY KEY,
|
|
104
104
|
state TEXT NOT NULL,
|
|
105
105
|
updated_at INTEGER NOT NULL,
|
|
106
106
|
data TEXT NOT NULL
|
|
107
107
|
)`);
|
|
108
|
-
await
|
|
108
|
+
await tx.run(
|
|
109
109
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}rfq_updated ON ${this.rfqSwaps} (updated_at, rfq_id)`
|
|
110
110
|
);
|
|
111
|
-
await
|
|
111
|
+
await tx.run(
|
|
112
112
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}rfq_swaps_history ON ${this.rfqSwaps} (state, updated_at, rfq_id)`
|
|
113
113
|
);
|
|
114
|
-
await
|
|
115
|
-
await
|
|
114
|
+
await tx.run(`DROP INDEX IF EXISTS idx_${this.prefix}rfq_swaps_page`);
|
|
115
|
+
await tx.run(
|
|
116
116
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}rfq_swaps_state ON ${this.rfqSwaps} (state)`
|
|
117
117
|
);
|
|
118
|
-
await
|
|
118
|
+
await tx.run(`CREATE TABLE IF NOT EXISTS ${this.swapRecords} (
|
|
119
119
|
id TEXT PRIMARY KEY,
|
|
120
120
|
family TEXT NOT NULL,
|
|
121
121
|
updated_at INTEGER NOT NULL,
|
|
122
122
|
data TEXT NOT NULL
|
|
123
123
|
)`);
|
|
124
|
-
await
|
|
124
|
+
await tx.run(
|
|
125
125
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}swap_records_family ON ${this.swapRecords} (family)`
|
|
126
126
|
);
|
|
127
|
-
await
|
|
128
|
-
await
|
|
127
|
+
await tx.run(`CREATE TABLE IF NOT EXISTS ${this.scanned} (txid TEXT PRIMARY KEY)`);
|
|
128
|
+
await tx.run(
|
|
129
129
|
`CREATE TABLE IF NOT EXISTS ${this.markets} (cache_key TEXT PRIMARY KEY, data TEXT NOT NULL)`
|
|
130
130
|
);
|
|
131
131
|
});
|
|
@@ -133,7 +133,7 @@ var SQLiteAssetSwapRepository = class {
|
|
|
133
133
|
/** Every write, including the single-statement ones. The chain serializes
|
|
134
134
|
* transaction *blocks*, not bare statements: one issued between a
|
|
135
135
|
* neighbour's BEGIN IMMEDIATE and its COMMIT becomes part of that
|
|
136
|
-
* transaction and dies with it. `fn` must
|
|
136
|
+
* transaction and dies with it. `fn` must use its supplied raw executor — no
|
|
137
137
|
* repository method, no `ensureInit` — since `runInTransaction` cannot
|
|
138
138
|
* nest. */
|
|
139
139
|
withTx(fn) {
|
|
@@ -141,8 +141,8 @@ var SQLiteAssetSwapRepository = class {
|
|
|
141
141
|
}
|
|
142
142
|
async saveSwap(swap) {
|
|
143
143
|
await this.ensureInit();
|
|
144
|
-
await this.withTx(async () => {
|
|
145
|
-
await
|
|
144
|
+
await this.withTx(async (tx) => {
|
|
145
|
+
await tx.run(
|
|
146
146
|
`INSERT OR REPLACE INTO ${this.swaps} (id, status, created_at, data)
|
|
147
147
|
VALUES (?, ?, ?, ?)`,
|
|
148
148
|
[swap.id, swap.status, swap.createdAt, JSON.stringify(swap)]
|
|
@@ -154,8 +154,8 @@ var SQLiteAssetSwapRepository = class {
|
|
|
154
154
|
}
|
|
155
155
|
async saveRfqSwap(record) {
|
|
156
156
|
await this.ensureInit();
|
|
157
|
-
await this.withTx(async () => {
|
|
158
|
-
await
|
|
157
|
+
await this.withTx(async (tx) => {
|
|
158
|
+
await tx.run(
|
|
159
159
|
`INSERT OR REPLACE INTO ${this.rfqSwaps} (rfq_id, state, updated_at, data)
|
|
160
160
|
VALUES (?, ?, ?, ?)`,
|
|
161
161
|
[record.rfqId, record.state, record.updatedAt, JSON.stringify(record)]
|
|
@@ -205,14 +205,14 @@ var SQLiteAssetSwapRepository = class {
|
|
|
205
205
|
}
|
|
206
206
|
async removeRfqSwap(rfqId) {
|
|
207
207
|
await this.ensureInit();
|
|
208
|
-
await this.withTx(async () => {
|
|
209
|
-
await
|
|
208
|
+
await this.withTx(async (tx) => {
|
|
209
|
+
await tx.run(`DELETE FROM ${this.rfqSwaps} WHERE rfq_id = ?`, [rfqId]);
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
async saveSwapRecord(record) {
|
|
213
213
|
await this.ensureInit();
|
|
214
|
-
await this.withTx(async () => {
|
|
215
|
-
await
|
|
214
|
+
await this.withTx(async (tx) => {
|
|
215
|
+
await tx.run(
|
|
216
216
|
`INSERT OR REPLACE INTO ${this.swapRecords} (id, family, updated_at, data)
|
|
217
217
|
VALUES (?, ?, ?, ?)`,
|
|
218
218
|
[record.id, record.family, record.updatedAt, JSON.stringify(record)]
|
|
@@ -245,8 +245,8 @@ var SQLiteAssetSwapRepository = class {
|
|
|
245
245
|
}
|
|
246
246
|
async removeSwapRecord(id) {
|
|
247
247
|
await this.ensureInit();
|
|
248
|
-
await this.withTx(async () => {
|
|
249
|
-
await
|
|
248
|
+
await this.withTx(async (tx) => {
|
|
249
|
+
await tx.run(`DELETE FROM ${this.swapRecords} WHERE id = ?`, [id]);
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
252
|
async getScannedTxids() {
|
|
@@ -258,10 +258,10 @@ var SQLiteAssetSwapRepository = class {
|
|
|
258
258
|
await this.ensureInit();
|
|
259
259
|
const all = [...txids];
|
|
260
260
|
if (all.length === 0) return;
|
|
261
|
-
await this.withTx(async () => {
|
|
261
|
+
await this.withTx(async (tx) => {
|
|
262
262
|
for (let i = 0; i < all.length; i += INSERT_CHUNK) {
|
|
263
263
|
const chunk = all.slice(i, i + INSERT_CHUNK);
|
|
264
|
-
await
|
|
264
|
+
await tx.run(
|
|
265
265
|
`INSERT OR IGNORE INTO ${this.scanned} (txid) VALUES ${chunk.map(() => "(?)").join(", ")}`,
|
|
266
266
|
chunk
|
|
267
267
|
);
|
|
@@ -278,11 +278,11 @@ var SQLiteAssetSwapRepository = class {
|
|
|
278
278
|
}
|
|
279
279
|
async saveCachedMarkets(network, registry, entry) {
|
|
280
280
|
await this.ensureInit();
|
|
281
|
-
await this.withTx(async () => {
|
|
282
|
-
await
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
);
|
|
281
|
+
await this.withTx(async (tx) => {
|
|
282
|
+
await tx.run(`INSERT OR REPLACE INTO ${this.markets} (cache_key, data) VALUES (?, ?)`, [
|
|
283
|
+
marketsCacheKey(network, registry),
|
|
284
|
+
JSON.stringify(entry)
|
|
285
|
+
]);
|
|
286
286
|
});
|
|
287
287
|
}
|
|
288
288
|
/** Every table in one transaction: clearing swaps but keeping scanned txids
|
|
@@ -290,12 +290,12 @@ var SQLiteAssetSwapRepository = class {
|
|
|
290
290
|
* partial clear must not be observable. */
|
|
291
291
|
async clear() {
|
|
292
292
|
await this.ensureInit();
|
|
293
|
-
await this.withTx(async () => {
|
|
294
|
-
await
|
|
295
|
-
await
|
|
296
|
-
await
|
|
297
|
-
await
|
|
298
|
-
await
|
|
293
|
+
await this.withTx(async (tx) => {
|
|
294
|
+
await tx.run(`DELETE FROM ${this.swaps}`);
|
|
295
|
+
await tx.run(`DELETE FROM ${this.rfqSwaps}`);
|
|
296
|
+
await tx.run(`DELETE FROM ${this.swapRecords}`);
|
|
297
|
+
await tx.run(`DELETE FROM ${this.scanned}`);
|
|
298
|
+
await tx.run(`DELETE FROM ${this.markets}`);
|
|
299
299
|
});
|
|
300
300
|
}
|
|
301
301
|
async [Symbol.asyncDispose]() {
|
package/dist/nostr.d.cts
CHANGED
package/dist/nostr.d.ts
CHANGED
package/dist/nostr.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { asset, RelativeTimelock,
|
|
2
|
-
import { d as AssetSwapRepository } from './repository-
|
|
1
|
+
import { asset, RelativeTimelock, OperatorInfo, ArkTxInput, Outpoint, IWallet, EmulatorProvider, arkade } from '@arkade-os/sdk';
|
|
2
|
+
import { d as AssetSwapRepository } from './repository-Cut4eEkm.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Coverage: whether an offer's script is in the wallet's watched set. `createOffer` promotes; the
|
|
@@ -43,7 +43,7 @@ interface Offer {
|
|
|
43
43
|
makerPkScript: Uint8Array;
|
|
44
44
|
/** Maker's x-only key (32 bytes) — the cancel path's `user` signer. */
|
|
45
45
|
makerPublicKey: Uint8Array;
|
|
46
|
-
/**
|
|
46
|
+
/** X-only key (32 bytes) of the operator's cosigner that emulates Arkade Script. */
|
|
47
47
|
emulatorPubkey: Uint8Array;
|
|
48
48
|
/** Partial-fill numerator. Reserved wire space in V1: carried through the
|
|
49
49
|
* codec so an offer that sets it decodes, never interpreted here. */
|
|
@@ -90,8 +90,8 @@ declare function decodeOffer(data: Uint8Array): Offer;
|
|
|
90
90
|
*
|
|
91
91
|
* Broadcasts nothing, but registers the covenant before returning the address: a failure now is
|
|
92
92
|
* retryable, whereas after `wallet.send` it would leave a funded deposit unwatched. The unilateral
|
|
93
|
-
* exit closure is built by default (
|
|
94
|
-
* the
|
|
93
|
+
* exit closure is built by default (operator's `unilateralExitDelay`, as solverd does); without it only
|
|
94
|
+
* the operator-cosigned `cancel` gets the deposit out, and an offer never expires.
|
|
95
95
|
*
|
|
96
96
|
* @deprecated Internal to `accept()`; no replacement. Moved off the package root to `@arkade-os/swap/protocol`.
|
|
97
97
|
*/
|
|
@@ -119,11 +119,11 @@ interface OfferParams {
|
|
|
119
119
|
/** Co-signer key override (33-byte compressed hex); see
|
|
120
120
|
* {@link resolveEmulatorPubkey}. */
|
|
121
121
|
emulatorPubkey?: string;
|
|
122
|
-
/** Override the exit closure's delay. Defaults to the
|
|
122
|
+
/** Override the exit closure's delay. Defaults to the operator's own
|
|
123
123
|
* `unilateralExitDelay`, which is the delay solverd uses too. */
|
|
124
124
|
exitDelay?: RelativeTimelock;
|
|
125
125
|
/** Publish without the exit closure, leaving `cancel` — which needs the
|
|
126
|
-
*
|
|
126
|
+
* operator — as the only way back out. See the note on {@link createOffer}. */
|
|
127
127
|
noExit?: boolean;
|
|
128
128
|
/**
|
|
129
129
|
* A live `getArkadeInfo` the caller already made.
|
|
@@ -133,7 +133,7 @@ interface OfferParams {
|
|
|
133
133
|
* live for the reason {@link createOffer} reads live — the info's
|
|
134
134
|
* `signerPubkey` ends up in a covenant leaf.
|
|
135
135
|
*/
|
|
136
|
-
info?:
|
|
136
|
+
info?: OperatorInfo;
|
|
137
137
|
/**
|
|
138
138
|
* The maker position, when the caller already read it.
|
|
139
139
|
*
|
|
@@ -166,15 +166,15 @@ interface DerivedOffer {
|
|
|
166
166
|
/** The covenant's parameters — {@link registerDerivedOffer}'s only input. */
|
|
167
167
|
readonly binding: Readonly<Omit<Offer, "swapPkScript">>;
|
|
168
168
|
/** The live info this covenant is bound to. */
|
|
169
|
-
readonly info:
|
|
169
|
+
readonly info: OperatorInfo;
|
|
170
170
|
readonly operatorPubkey: Uint8Array;
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
173
173
|
* Cancel an offer: spend the swap VTXO back to the user. Returns the ark txid. No path is on a
|
|
174
174
|
* deadline, so an unfilled deposit stays at the swap address until the user cancels.
|
|
175
175
|
*
|
|
176
|
-
* Routes out: `fulfill` (
|
|
177
|
-
* `cancel` (user+
|
|
176
|
+
* Routes out: `fulfill` (operator alone, but constrained to pay `makerWP` at least `wantAmount`),
|
|
177
|
+
* `cancel` (user+operator 2-of-2, no solver involved), `exit` (user alone after a CSV unless `noExit`;
|
|
178
178
|
* reached by unrolling onchain, not here).
|
|
179
179
|
*
|
|
180
180
|
* Cancel races a fill: if `fulfill` spent first this throws "no spendable VTXO at the swap address",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { asset, RelativeTimelock,
|
|
2
|
-
import { d as AssetSwapRepository } from './repository-
|
|
1
|
+
import { asset, RelativeTimelock, OperatorInfo, ArkTxInput, Outpoint, IWallet, EmulatorProvider, arkade } from '@arkade-os/sdk';
|
|
2
|
+
import { d as AssetSwapRepository } from './repository-BOQ1qYoj.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Coverage: whether an offer's script is in the wallet's watched set. `createOffer` promotes; the
|
|
@@ -43,7 +43,7 @@ interface Offer {
|
|
|
43
43
|
makerPkScript: Uint8Array;
|
|
44
44
|
/** Maker's x-only key (32 bytes) — the cancel path's `user` signer. */
|
|
45
45
|
makerPublicKey: Uint8Array;
|
|
46
|
-
/**
|
|
46
|
+
/** X-only key (32 bytes) of the operator's cosigner that emulates Arkade Script. */
|
|
47
47
|
emulatorPubkey: Uint8Array;
|
|
48
48
|
/** Partial-fill numerator. Reserved wire space in V1: carried through the
|
|
49
49
|
* codec so an offer that sets it decodes, never interpreted here. */
|
|
@@ -90,8 +90,8 @@ declare function decodeOffer(data: Uint8Array): Offer;
|
|
|
90
90
|
*
|
|
91
91
|
* Broadcasts nothing, but registers the covenant before returning the address: a failure now is
|
|
92
92
|
* retryable, whereas after `wallet.send` it would leave a funded deposit unwatched. The unilateral
|
|
93
|
-
* exit closure is built by default (
|
|
94
|
-
* the
|
|
93
|
+
* exit closure is built by default (operator's `unilateralExitDelay`, as solverd does); without it only
|
|
94
|
+
* the operator-cosigned `cancel` gets the deposit out, and an offer never expires.
|
|
95
95
|
*
|
|
96
96
|
* @deprecated Internal to `accept()`; no replacement. Moved off the package root to `@arkade-os/swap/protocol`.
|
|
97
97
|
*/
|
|
@@ -119,11 +119,11 @@ interface OfferParams {
|
|
|
119
119
|
/** Co-signer key override (33-byte compressed hex); see
|
|
120
120
|
* {@link resolveEmulatorPubkey}. */
|
|
121
121
|
emulatorPubkey?: string;
|
|
122
|
-
/** Override the exit closure's delay. Defaults to the
|
|
122
|
+
/** Override the exit closure's delay. Defaults to the operator's own
|
|
123
123
|
* `unilateralExitDelay`, which is the delay solverd uses too. */
|
|
124
124
|
exitDelay?: RelativeTimelock;
|
|
125
125
|
/** Publish without the exit closure, leaving `cancel` — which needs the
|
|
126
|
-
*
|
|
126
|
+
* operator — as the only way back out. See the note on {@link createOffer}. */
|
|
127
127
|
noExit?: boolean;
|
|
128
128
|
/**
|
|
129
129
|
* A live `getArkadeInfo` the caller already made.
|
|
@@ -133,7 +133,7 @@ interface OfferParams {
|
|
|
133
133
|
* live for the reason {@link createOffer} reads live — the info's
|
|
134
134
|
* `signerPubkey` ends up in a covenant leaf.
|
|
135
135
|
*/
|
|
136
|
-
info?:
|
|
136
|
+
info?: OperatorInfo;
|
|
137
137
|
/**
|
|
138
138
|
* The maker position, when the caller already read it.
|
|
139
139
|
*
|
|
@@ -166,15 +166,15 @@ interface DerivedOffer {
|
|
|
166
166
|
/** The covenant's parameters — {@link registerDerivedOffer}'s only input. */
|
|
167
167
|
readonly binding: Readonly<Omit<Offer, "swapPkScript">>;
|
|
168
168
|
/** The live info this covenant is bound to. */
|
|
169
|
-
readonly info:
|
|
169
|
+
readonly info: OperatorInfo;
|
|
170
170
|
readonly operatorPubkey: Uint8Array;
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
173
173
|
* Cancel an offer: spend the swap VTXO back to the user. Returns the ark txid. No path is on a
|
|
174
174
|
* deadline, so an unfilled deposit stays at the swap address until the user cancels.
|
|
175
175
|
*
|
|
176
|
-
* Routes out: `fulfill` (
|
|
177
|
-
* `cancel` (user+
|
|
176
|
+
* Routes out: `fulfill` (operator alone, but constrained to pay `makerWP` at least `wantAmount`),
|
|
177
|
+
* `cancel` (user+operator 2-of-2, no solver involved), `exit` (user alone after a CSV unless `noExit`;
|
|
178
178
|
* reached by unrolling onchain, not here).
|
|
179
179
|
*
|
|
180
180
|
* Cancel races a fill: if `fulfill` spent first this throws "no spendable VTXO at the swap address",
|