@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.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/dist/advanced.cjs +14 -11
  3. package/dist/advanced.d.cts +8 -8
  4. package/dist/advanced.d.ts +8 -8
  5. package/dist/advanced.js +5 -3
  6. package/dist/{chunk-2AQYBSF5.js → chunk-7BBQ74BG.js} +13 -13
  7. package/dist/{chunk-G5QURHVP.js → chunk-GJKGPE3S.js} +3 -3
  8. package/dist/{chunk-6HKTAZLJ.js → chunk-HDCC3JZR.js} +12 -10
  9. package/dist/index.cjs +11 -11
  10. package/dist/index.d.cts +6 -6
  11. package/dist/index.d.ts +6 -6
  12. package/dist/index.js +3 -3
  13. package/dist/{lockupContract-D-OpxRSX.d.ts → lockupContract-CdXh9yIr.d.ts} +1 -1
  14. package/dist/{lockupContract-AwSwif9u.d.cts → lockupContract-QfbsjyXG.d.cts} +1 -1
  15. package/dist/node/index.cjs +37 -37
  16. package/dist/node/index.js +37 -37
  17. package/dist/nostr.d.cts +1 -1
  18. package/dist/nostr.d.ts +1 -1
  19. package/dist/nostr.js +1 -1
  20. package/dist/{offer-BEcW5o7V.d.cts → offer-BxzPQ6zh.d.cts} +11 -11
  21. package/dist/{offer-4Ir1bRQV.d.ts → offer-Q1lVhrVX.d.ts} +11 -11
  22. package/dist/{offerFillPlan-DvrHfYoH.d.cts → offerFillPlan-BfcxbVvw.d.cts} +18 -13
  23. package/dist/{offerFillPlan-bsyVMum3.d.ts → offerFillPlan-C11P2ek2.d.ts} +18 -13
  24. package/dist/protocol.cjs +12 -12
  25. package/dist/protocol.d.cts +8 -8
  26. package/dist/protocol.d.ts +8 -8
  27. package/dist/protocol.js +2 -2
  28. package/dist/repositories/realm/index.d.cts +2 -2
  29. package/dist/repositories/realm/index.d.ts +2 -2
  30. package/dist/repositories/sqlite/index.cjs +37 -37
  31. package/dist/repositories/sqlite/index.d.cts +3 -3
  32. package/dist/repositories/sqlite/index.d.ts +3 -3
  33. package/dist/repositories/sqlite/index.js +37 -37
  34. package/dist/{repository-ChRNknNn.d.ts → repository-BOQ1qYoj.d.ts} +7 -7
  35. package/dist/{repository-BW42Dtct.d.cts → repository-Cut4eEkm.d.cts} +7 -7
  36. package/dist/{rfq-C0tHOvn6.d.cts → rfq-CP-P0PSL.d.cts} +7 -7
  37. package/dist/{rfq-C0tHOvn6.d.ts → rfq-CP-P0PSL.d.ts} +7 -7
  38. package/dist/{watch-B_Q0ddHg.d.ts → watch-D15U0QpD.d.ts} +1 -1
  39. package/dist/{watch-CpnfqYCE.d.cts → watch-D4PeBZ3H.d.cts} +1 -1
  40. 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, bc as pay, bg as receive, bn as unsignedPsbtBytes, bp as verifyJointGraph, bq as verifyOfferFillPlan } from './offerFillPlan-bsyVMum3.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-ChRNknNn.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-ChRNknNn.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-C0tHOvn6.js';
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-D-OpxRSX.js';
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-4Ir1bRQV.js';
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-6HKTAZLJ.js";
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-G5QURHVP.js";
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-2AQYBSF5.js";
86
+ } from "./chunk-7BBQ74BG.js";
87
87
  import {
88
88
  InMemoryAssetSwapRepository,
89
89
  assertRfqSwapPageFilter,
@@ -1,4 +1,4 @@
1
- import { C as CoverageRegistrationOptions } from './offer-4Ir1bRQV.js';
1
+ import { C as CoverageRegistrationOptions } from './offer-Q1lVhrVX.js';
2
2
  import { VHTLC, IContractManager } from '@arkade-os/sdk';
3
3
 
4
4
  interface SealedClaimPacket {
@@ -1,4 +1,4 @@
1
- import { C as CoverageRegistrationOptions } from './offer-BEcW5o7V.cjs';
1
+ import { C as CoverageRegistrationOptions } from './offer-BxzPQ6zh.cjs';
2
2
  import { VHTLC, IContractManager } from '@arkade-os/sdk';
3
3
 
4
4
  interface SealedClaimPacket {
@@ -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 this.db.run(`CREATE TABLE IF NOT EXISTS ${this.swaps} (
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 this.db.run(
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 this.db.run(
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 this.db.run(`CREATE TABLE IF NOT EXISTS ${this.rfqSwaps} (
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 this.db.run(
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 this.db.run(
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 this.db.run(`DROP INDEX IF EXISTS idx_${this.prefix}rfq_swaps_page`);
137
- await this.db.run(
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 this.db.run(`CREATE TABLE IF NOT EXISTS ${this.swapRecords} (
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 this.db.run(
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 this.db.run(`CREATE TABLE IF NOT EXISTS ${this.scanned} (txid TEXT PRIMARY KEY)`);
150
- await this.db.run(
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 issue only raw db calls — no
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 this.db.run(
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 this.db.run(
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 this.db.run(`DELETE FROM ${this.rfqSwaps} WHERE rfq_id = ?`, [rfqId]);
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 this.db.run(
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 this.db.run(`DELETE FROM ${this.swapRecords} WHERE id = ?`, [id]);
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 this.db.run(
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 this.db.run(
305
- `INSERT OR REPLACE INTO ${this.markets} (cache_key, data) VALUES (?, ?)`,
306
- [marketsCacheKey(network, registry), JSON.stringify(entry)]
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 this.db.run(`DELETE FROM ${this.swaps}`);
317
- await this.db.run(`DELETE FROM ${this.rfqSwaps}`);
318
- await this.db.run(`DELETE FROM ${this.swapRecords}`);
319
- await this.db.run(`DELETE FROM ${this.scanned}`);
320
- await this.db.run(`DELETE FROM ${this.markets}`);
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]() {
@@ -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 this.db.run(`CREATE TABLE IF NOT EXISTS ${this.swaps} (
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 this.db.run(
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 this.db.run(
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 this.db.run(`CREATE TABLE IF NOT EXISTS ${this.rfqSwaps} (
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 this.db.run(
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 this.db.run(
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 this.db.run(`DROP INDEX IF EXISTS idx_${this.prefix}rfq_swaps_page`);
115
- await this.db.run(
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 this.db.run(`CREATE TABLE IF NOT EXISTS ${this.swapRecords} (
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 this.db.run(
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 this.db.run(`CREATE TABLE IF NOT EXISTS ${this.scanned} (txid TEXT PRIMARY KEY)`);
128
- await this.db.run(
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 issue only raw db calls — no
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 this.db.run(
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 this.db.run(
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 this.db.run(`DELETE FROM ${this.rfqSwaps} WHERE rfq_id = ?`, [rfqId]);
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 this.db.run(
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 this.db.run(`DELETE FROM ${this.swapRecords} WHERE id = ?`, [id]);
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 this.db.run(
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 this.db.run(
283
- `INSERT OR REPLACE INTO ${this.markets} (cache_key, data) VALUES (?, ?)`,
284
- [marketsCacheKey(network, registry), JSON.stringify(entry)]
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 this.db.run(`DELETE FROM ${this.swaps}`);
295
- await this.db.run(`DELETE FROM ${this.rfqSwaps}`);
296
- await this.db.run(`DELETE FROM ${this.swapRecords}`);
297
- await this.db.run(`DELETE FROM ${this.scanned}`);
298
- await this.db.run(`DELETE FROM ${this.markets}`);
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
@@ -1,5 +1,5 @@
1
1
  import { TransportCardFetcher } from '@arkade-os/solver-discovery';
2
- import { e as RfqTransport } from './rfq-C0tHOvn6.cjs';
2
+ import { e as RfqTransport } from './rfq-CP-P0PSL.cjs';
3
3
  import { SimplePool } from 'nostr-tools';
4
4
  import '@arkade-os/sdk';
5
5
 
package/dist/nostr.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TransportCardFetcher } from '@arkade-os/solver-discovery';
2
- import { e as RfqTransport } from './rfq-C0tHOvn6.js';
2
+ import { e as RfqTransport } from './rfq-CP-P0PSL.js';
3
3
  import { SimplePool } from 'nostr-tools';
4
4
  import '@arkade-os/sdk';
5
5
 
package/dist/nostr.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  expectQuote,
3
3
  pairOf
4
- } from "./chunk-2AQYBSF5.js";
4
+ } from "./chunk-7BBQ74BG.js";
5
5
  import "./chunk-A3SHHRX4.js";
6
6
 
7
7
  // src/nostr.ts
@@ -1,5 +1,5 @@
1
- import { asset, RelativeTimelock, ArkadeInfo, ArkTxInput, Outpoint, IWallet, EmulatorProvider, arkade } from '@arkade-os/sdk';
2
- import { d as AssetSwapRepository } from './repository-BW42Dtct.cjs';
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
- /** Covenant co-signer (emulator) x-only key (32 bytes). */
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 (server's `unilateralExitDelay`, as solverd does); without it only
94
- * the server-co-signed `cancel` gets the deposit out, and an offer never expires.
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 server's own
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
- * server — as the only way back out. See the note on {@link createOffer}. */
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?: ArkadeInfo;
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: ArkadeInfo;
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` (server alone, but constrained to pay `makerWP` at least `wantAmount`),
177
- * `cancel` (user+server 2-of-2, no solver involved), `exit` (user alone after a CSV unless `noExit`;
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, ArkadeInfo, ArkTxInput, Outpoint, IWallet, EmulatorProvider, arkade } from '@arkade-os/sdk';
2
- import { d as AssetSwapRepository } from './repository-ChRNknNn.js';
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
- /** Covenant co-signer (emulator) x-only key (32 bytes). */
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 (server's `unilateralExitDelay`, as solverd does); without it only
94
- * the server-co-signed `cancel` gets the deposit out, and an offer never expires.
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 server's own
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
- * server — as the only way back out. See the note on {@link createOffer}. */
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?: ArkadeInfo;
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: ArkadeInfo;
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` (server alone, but constrained to pay `makerWP` at least `wantAmount`),
177
- * `cancel` (user+server 2-of-2, no solver involved), `exit` (user alone after a CSV unless `noExit`;
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",