@arkade-os/swap 0.1.2 → 0.1.4
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 +31 -38
- package/dist/advanced.d.cts +8 -8
- package/dist/advanced.d.ts +8 -8
- package/dist/advanced.js +5 -3
- package/dist/{chunk-ICSREL7N.js → chunk-7BBQ74BG.js} +15 -14
- package/dist/{chunk-BLECLU5Q.js → chunk-GJKGPE3S.js} +19 -33
- package/dist/{chunk-J2PMAQP2.js → chunk-HDCC3JZR.js} +14 -11
- package/dist/index.cjs +28 -38
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +3 -3
- package/dist/{lockupContract-CIXkJPxV.d.ts → lockupContract-CdXh9yIr.d.ts} +1 -1
- package/dist/{lockupContract-CkhWMKCo.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-Diff5Flc.d.cts → offer-BxzPQ6zh.d.cts} +11 -11
- package/dist/{offer-BPD2ortO.d.ts → offer-Q1lVhrVX.d.ts} +11 -11
- package/dist/{offerFillPlan-B-5ae_gQ.d.cts → offerFillPlan-CvKlB246.d.cts} +16 -11
- package/dist/{offerFillPlan-CJzneX6F.d.ts → offerFillPlan-_PhFt4B1.d.ts} +16 -11
- package/dist/protocol.cjs +27 -38
- package/dist/protocol.d.cts +9 -8
- package/dist/protocol.d.ts +9 -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-BBVRh9ez.d.ts → repository-BOQ1qYoj.d.ts} +8 -7
- package/dist/{repository-C4pvymhs.d.cts → repository-Cut4eEkm.d.cts} +8 -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-7BiRa4oB.d.ts → watch-D15U0QpD.d.ts} +1 -1
- package/dist/{watch-Bxq-lx_6.d.cts → watch-D4PeBZ3H.d.cts} +1 -1
- package/package.json +2 -2
package/dist/protocol.cjs
CHANGED
|
@@ -1091,7 +1091,7 @@ async function deriveOffer(wallet, params) {
|
|
|
1091
1091
|
})()
|
|
1092
1092
|
]);
|
|
1093
1093
|
const operatorPubKey = import_base5.hex.decode((0, import_sdk5.toXOnlySignerHex)(info.signerPubkey));
|
|
1094
|
-
const network = (0, import_sdk5.
|
|
1094
|
+
const network = (0, import_sdk5.networkFromOperatorInfo)(info);
|
|
1095
1095
|
const emuKey = import_base5.hex.decode(
|
|
1096
1096
|
(0, import_sdk5.toXOnlySignerHex)((0, import_sdk5.resolveEmulatorPubkey)(network, params.emulatorPubkey))
|
|
1097
1097
|
);
|
|
@@ -1178,8 +1178,9 @@ async function prepareOfferCancel(wallet, offerHex, opts) {
|
|
|
1178
1178
|
identity: wallet.identity,
|
|
1179
1179
|
// registered offers resolve VTXOs from the contract repository; the indexer is the fallback
|
|
1180
1180
|
// for offers created before registration existed
|
|
1181
|
-
contractManager
|
|
1181
|
+
contractManager,
|
|
1182
1182
|
// no `network`: the row lookup is by script and the payout comes from wallet.getAddress()
|
|
1183
|
+
oneShotSubmit: wallet.oneShotSubmit
|
|
1183
1184
|
});
|
|
1184
1185
|
const operatorPubkey = swapAddress ? import_sdk5.ArkAddress.decode(swapAddress).serverPubKey : client.serverKey;
|
|
1185
1186
|
const { program, args, keys } = swapProgramBinding(offer, operatorPubkey);
|
|
@@ -1244,7 +1245,7 @@ async function connectFillContract(wallet, arkServerUrl, offer, opts = {}) {
|
|
|
1244
1245
|
const { swapAddress, emulator, emulatorPubkey } = opts;
|
|
1245
1246
|
const contractManager = await wallet.getContractManager();
|
|
1246
1247
|
const client = await import_sdk5.arkade.Arkade.connect({
|
|
1247
|
-
arkade: new import_sdk5.
|
|
1248
|
+
arkade: new import_sdk5.RestOperatorProvider(arkServerUrl),
|
|
1248
1249
|
indexer: new import_sdk5.RestIndexerProvider(arkServerUrl),
|
|
1249
1250
|
identity: wallet.identity,
|
|
1250
1251
|
contractManager,
|
|
@@ -1614,7 +1615,7 @@ var init_offer = __esm({
|
|
|
1614
1615
|
derivingClient = (wallet, info, contractManager) => import_sdk5.arkade.Arkade.connect({
|
|
1615
1616
|
arkade: { getInfo: async () => info },
|
|
1616
1617
|
identity: wallet.identity,
|
|
1617
|
-
network: (0, import_sdk5.
|
|
1618
|
+
network: (0, import_sdk5.networkFromOperatorInfo)(info),
|
|
1618
1619
|
contractManager
|
|
1619
1620
|
});
|
|
1620
1621
|
NoSpendableDepositError = class extends Error {
|
|
@@ -1731,7 +1732,7 @@ async function requestLightningSend(wallet, transport, params) {
|
|
|
1731
1732
|
);
|
|
1732
1733
|
}
|
|
1733
1734
|
const operatorPubkey = (0, import_sdk6.toXOnly)(import_base6.hex.decode(info.signerPubkey), "ark signer key");
|
|
1734
|
-
const network = (0, import_sdk6.
|
|
1735
|
+
const network = (0, import_sdk6.networkFromOperatorInfo)(info);
|
|
1735
1736
|
const derived = deriveLightningSend({
|
|
1736
1737
|
quote,
|
|
1737
1738
|
paymentHash: params.invoice.paymentHash,
|
|
@@ -1784,7 +1785,7 @@ async function requestArkadeSwap(wallet, transport, params) {
|
|
|
1784
1785
|
const makerPkScript = info === void 0 ? ownPkScript : resolveReceivePkScript(
|
|
1785
1786
|
receiveAddress,
|
|
1786
1787
|
ownPkScript,
|
|
1787
|
-
(0, import_sdk6.
|
|
1788
|
+
(0, import_sdk6.networkFromOperatorInfo)(info).hrp,
|
|
1788
1789
|
(0, import_sdk6.toXOnly)(import_base6.hex.decode(info.signerPubkey), "ark signer key")
|
|
1789
1790
|
);
|
|
1790
1791
|
const pair = rfqPair(
|
|
@@ -1944,7 +1945,7 @@ async function requestOnchainSend(wallet, transport, params) {
|
|
|
1944
1945
|
quote,
|
|
1945
1946
|
paymentHash,
|
|
1946
1947
|
payoutPubkey: params.payoutPubkey,
|
|
1947
|
-
...
|
|
1948
|
+
...operatorTerms(info, params.emulatorPubkey),
|
|
1948
1949
|
l1Network: l1NetworkFromArk(info.network),
|
|
1949
1950
|
refundAddress,
|
|
1950
1951
|
senderPubkey
|
|
@@ -2039,7 +2040,7 @@ async function requestLightningReceive(wallet, transport, params) {
|
|
|
2039
2040
|
paymentHash,
|
|
2040
2041
|
payoutPubkey,
|
|
2041
2042
|
payoutAddress,
|
|
2042
|
-
...
|
|
2043
|
+
...operatorTerms(info, params.emulatorPubkey)
|
|
2043
2044
|
});
|
|
2044
2045
|
const now = Math.floor(Date.now() / 1e3);
|
|
2045
2046
|
const { payDeadline } = verifyReceiveInvoice({
|
|
@@ -2132,7 +2133,7 @@ async function requestOnchainReceive(wallet, transport, params) {
|
|
|
2132
2133
|
payoutPubkey,
|
|
2133
2134
|
payoutAddress,
|
|
2134
2135
|
refundPubkey: params.refundPubkey,
|
|
2135
|
-
...
|
|
2136
|
+
...operatorTerms(info, params.emulatorPubkey),
|
|
2136
2137
|
l1Network: l1NetworkFromArk(info.network)
|
|
2137
2138
|
});
|
|
2138
2139
|
assertFundable({
|
|
@@ -2164,7 +2165,7 @@ async function requestOnchainReceive(wallet, transport, params) {
|
|
|
2164
2165
|
secrets
|
|
2165
2166
|
};
|
|
2166
2167
|
}
|
|
2167
|
-
var import_base6, import_solver_discovery, import_legacy2, import_sdk6, import_sdk7, solverHex, quoteSats, quoteAmountSats, quoteExpectedSats, ARKADE_BTC, LIGHTNING_BTC, ONCHAIN_BTC, arkadeAssetLeg, rfqPair, LIGHTNING_SEND_PAIR, LIGHTNING_RECEIVE_PAIR, ONCHAIN_SEND_PAIR, ONCHAIN_RECEIVE_PAIR, RFQ_TERMINAL_STATES, RFQ_REFUSAL_ERROR_CODES, isRfqRefusalErrorCode, REFUSAL_FIELDS, REFUSAL_UNITS, safeInteger, safeRefusalDetail, refusalMessage, SwapRefusal, AddressMismatch, newRfqId, lightningSendRequest, arkadeSwapRequest, canonicalAssetAmount, normalizeHexBytes, normalizeMakerPkScript, normalizeMakerPublicKey, MIN_HEADROOM_SECONDS, assertFinite, MAX_PAIR_LENGTH, assertPairLength, verifyLockupAddress, LOCKUP_SHAPE_VARIANTS, matchQuotedLockup, assertFundable, expectQuote, pairOf, httpTransport, relayTransport, SEQUENCE_GRANULARITY_SECONDS, SOLO_REFUND_HEADROOM_SECONDS, unilateralClaimDelay, unilateralRefundDelay, unilateralRefundWithoutReceiverDelay, seconds, suiteVhtlc, quotedSoloRefundDelay, offerTermsFromQuote, verifyOfferAddress, assertArkadeFundable, quoteCarrierSats, l1NetworkFromArk,
|
|
2168
|
+
var import_base6, import_solver_discovery, import_legacy2, import_sdk6, import_sdk7, solverHex, quoteSats, quoteAmountSats, quoteExpectedSats, ARKADE_BTC, LIGHTNING_BTC, ONCHAIN_BTC, arkadeAssetLeg, rfqPair, LIGHTNING_SEND_PAIR, LIGHTNING_RECEIVE_PAIR, ONCHAIN_SEND_PAIR, ONCHAIN_RECEIVE_PAIR, RFQ_TERMINAL_STATES, RFQ_REFUSAL_ERROR_CODES, isRfqRefusalErrorCode, REFUSAL_FIELDS, REFUSAL_UNITS, safeInteger, safeRefusalDetail, refusalMessage, SwapRefusal, AddressMismatch, newRfqId, lightningSendRequest, arkadeSwapRequest, canonicalAssetAmount, normalizeHexBytes, normalizeMakerPkScript, normalizeMakerPublicKey, MIN_HEADROOM_SECONDS, assertFinite, MAX_PAIR_LENGTH, assertPairLength, verifyLockupAddress, LOCKUP_SHAPE_VARIANTS, matchQuotedLockup, assertFundable, expectQuote, pairOf, httpTransport, relayTransport, SEQUENCE_GRANULARITY_SECONDS, SOLO_REFUND_HEADROOM_SECONDS, unilateralClaimDelay, unilateralRefundDelay, unilateralRefundWithoutReceiverDelay, seconds, suiteVhtlc, quotedSoloRefundDelay, offerTermsFromQuote, verifyOfferAddress, assertArkadeFundable, quoteCarrierSats, l1NetworkFromArk, operatorTerms, onchainSendRequest, lightningReceiveRequest, onchainReceiveRequest, assertQuotedAmount, MIN_CLAIM_WINDOW_SECONDS, verifyReceiveInvoice, assertReceivable, matchReceiveLockup, provisionReceive, quoteReceive;
|
|
2168
2169
|
var init_rfq = __esm({
|
|
2169
2170
|
"src/rfq.ts"() {
|
|
2170
2171
|
"use strict";
|
|
@@ -2729,8 +2730,8 @@ var init_rfq = __esm({
|
|
|
2729
2730
|
return published > 0n ? published : ASSET_CARRIER_SATS;
|
|
2730
2731
|
};
|
|
2731
2732
|
l1NetworkFromArk = (network) => network === "bitcoin" ? "bitcoin" : network === "regtest" ? "regtest" : "testnet";
|
|
2732
|
-
|
|
2733
|
-
const network = (0, import_sdk6.
|
|
2733
|
+
operatorTerms = (info, emulatorPubkey) => {
|
|
2734
|
+
const network = (0, import_sdk6.networkFromOperatorInfo)(info);
|
|
2734
2735
|
return {
|
|
2735
2736
|
operatorPubkey: (0, import_sdk6.toXOnly)(import_base6.hex.decode(info.signerPubkey), "ark signer key"),
|
|
2736
2737
|
emulatorPubkey: (0, import_sdk6.toXOnly)(
|
|
@@ -3576,7 +3577,7 @@ var operatorUnrollScript = async (operator, network) => {
|
|
|
3576
3577
|
const info = await operator.getInfo();
|
|
3577
3578
|
return (0, import_sdk8.assertValidServerUnrollScript)(
|
|
3578
3579
|
info.checkpointTapscript,
|
|
3579
|
-
network ?? (0, import_sdk8.
|
|
3580
|
+
network ?? (0, import_sdk8.networkFromOperatorInfo)(info),
|
|
3580
3581
|
(0, import_sdk8.toXOnly)(import_base7.hex.decode(info.forfeitPubkey), "forfeit key")
|
|
3581
3582
|
);
|
|
3582
3583
|
};
|
|
@@ -3622,30 +3623,16 @@ async function pushRefundWithoutReceiver(operator, input) {
|
|
|
3622
3623
|
const leaf = input.contract.refundWithoutReceiver();
|
|
3623
3624
|
const vtxos = boundedLockupSpend(input.vtxos);
|
|
3624
3625
|
const amount = vtxos.reduce((sum, vtxo) => sum + vtxo.value, 0);
|
|
3625
|
-
const
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
checkpoints.map((c) => import_base7.base64.encode(c.toPSBT()))
|
|
3634
|
-
);
|
|
3635
|
-
(0, import_sdk8.assertSubmittedArkTxid)(submitted, signedTx, "refundWithoutReceiver");
|
|
3636
|
-
const matched = (0, import_sdk8.matchServerCheckpoints)(
|
|
3637
|
-
submitted.signedCheckpointTxs,
|
|
3638
|
-
checkpoints,
|
|
3639
|
-
"refundWithoutReceiver"
|
|
3640
|
-
);
|
|
3641
|
-
const finalCheckpoints = await Promise.all(
|
|
3642
|
-
matched.map(
|
|
3643
|
-
async ({ server }) => import_base7.base64.encode((await input.sender.sign(server, [0])).toPSBT())
|
|
3644
|
-
)
|
|
3645
|
-
);
|
|
3646
|
-
await operator.finalizeTx(submitted.arkTxid, finalCheckpoints);
|
|
3626
|
+
const txid = await (0, import_sdk8.signAndSubmitOffchainTx)({
|
|
3627
|
+
identity: input.sender,
|
|
3628
|
+
provider: operator,
|
|
3629
|
+
inputs: lockupInputs(vtxos, input.contract, leaf),
|
|
3630
|
+
outputs: [{ script: refundPkScript, amount: BigInt(amount) }, ...lockupAssetOutputs(vtxos)],
|
|
3631
|
+
serverUnrollScript,
|
|
3632
|
+
oneShot: input.oneShot
|
|
3633
|
+
});
|
|
3647
3634
|
return {
|
|
3648
|
-
txid
|
|
3635
|
+
txid,
|
|
3649
3636
|
amount,
|
|
3650
3637
|
left: input.vtxos.length - vtxos.length,
|
|
3651
3638
|
spent: vtxos
|
|
@@ -5582,7 +5569,8 @@ function arkadeRefunder(deps) {
|
|
|
5582
5569
|
contract,
|
|
5583
5570
|
sender,
|
|
5584
5571
|
vtxos,
|
|
5585
|
-
network: await deps.network?.()
|
|
5572
|
+
network: await deps.network?.(),
|
|
5573
|
+
oneShot: deps.wallet.oneShotSubmit
|
|
5586
5574
|
});
|
|
5587
5575
|
if (result.left > 0 || done) {
|
|
5588
5576
|
spentBy.set(swap.rfqId, /* @__PURE__ */ new Set([...done ?? [], ...result.spent.map(keyOf)]));
|
|
@@ -5687,7 +5675,8 @@ async function pushClaim(operator, input) {
|
|
|
5687
5675
|
...lockupAssetOutputs(vtxos)
|
|
5688
5676
|
],
|
|
5689
5677
|
serverUnrollScript,
|
|
5690
|
-
verifyServerSignatures: { serverPubkey: input.contract.options.server }
|
|
5678
|
+
verifyServerSignatures: { serverPubkey: input.contract.options.server },
|
|
5679
|
+
oneShot: input.oneShot
|
|
5691
5680
|
});
|
|
5692
5681
|
return { txid, amount: locked, left: live.length - vtxos.length, spent: vtxos };
|
|
5693
5682
|
}
|
package/dist/protocol.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ProvisionedKey, ProvisionedClaimSecret, RestIndexerProvider, Transaction, ActivityResolver, IWallet, Network, OnchainProvider, VHTLC, Identity, Asset, PaymentRail } from '@arkade-os/sdk';
|
|
2
|
-
import { bh as SwapSecretsProjection, e as RfqSwapRecord, h as AssetSwap, d as AssetSwapRepository, L as LockupSpendIndexer, bb as RfqSwapState, bd as SwapOperator, bi as LockupContractSource, bj as RfqSwap, bk as ArkadeRefundResult, bl as LockupVtxo } from './repository-
|
|
3
|
-
export { c as AssetSwapStatus, bm as AvailableRfqSwapManagerCallbacks, bn as BTC_ASSET_ID, bo as LightningReceiveSwap, bp as LightningSendSwap, bq as LockupFate, br as LockupNeedsRecoveryError, bs as LockupParams, bt as LockupSpend, bu as OnchainReceiveAction, bv as OnchainReceiveNeedsChainSource, bw as OnchainReceiveSwap, bx as OnchainSendAction, by as OnchainSendSwap, bz as PersistableRfqSwap, bA as PreimageBlockedReason, bB as PreimageNotRecoverableError, bC as REFUND_MTP_LAG_SECONDS, bD as RFQ_SWAP_RETENTION_SECONDS, bE as ReceiveLockupSwap, bF as RfqRestoreFailure, bG as RfqRestoreOptions, bH as RfqRestoreResult, bg as RfqSwapActionName, bI as RfqSwapLockup, bJ as RfqSwapManager, bf as RfqSwapManagerCallbacks, bK as RfqSwapManagerConfig, bL as RfqSwapManagerDeps, bM as RfqSwapManagerEvents, bN as RfqSwapOrigin, bO as RfqSwapOriginRequired, bP as RfqSwapOutcome, a as RfqSwapRecordStore, bQ as addAssetSwap, bR as awaitRfqResolution, bS as createRfqSwapRecord, bT as findLockupVtxos, bU as getAssetSwaps, bV as isRfqTerminal, bW as nextOnchainAction, bX as nextOnchainReceiveAction, bY as normalizeRfqSwapRecord, bZ as preimageForSwapRecord, b_ as pushRefundWithoutReceiver, b$ as readLockupFate, c0 as rebuildRfqSwap, c1 as rfqSwapOriginOf, c2 as shouldRetainRfqSwap, c3 as swapSecretsToRecord, c4 as updateAssetSwap, c5 as updateRfqSwapRecord } from './repository-
|
|
4
|
-
import { h as OnchainNetwork, O as OnchainHtlc, g as OnchainHtlcParams, C as ChainSource, I as InvoiceFacts, e as RfqTransport, r as requestLightningSend, j as requestOnchainSend } from './rfq-
|
|
5
|
-
export { A as ARKADE_BTC, k as AddressMismatch, l as ChainUtxo, H as HtlcUtxo, m as LIGHTNING_BTC, n as LIGHTNING_RECEIVE_PAIR, o as LIGHTNING_SEND_PAIR, p as LOCKTIME_THRESHOLD, f as LightningReceiveContractParams, L as LightningSendContractParams, M as MAX_MIN_CONFIRMATIONS, q as MIN_CLAIM_WINDOW_SECONDS, s as ONCHAIN_BTC, t as ONCHAIN_CLAIM_MARGIN_SECONDS, u as ONCHAIN_DUST_SATS, v as ONCHAIN_ORDER_MARGIN_SECONDS, w as ONCHAIN_RECEIVE_PAIR, x as ONCHAIN_SECONDS_PER_BLOCK, y as ONCHAIN_SEND_PAIR, z as OnchainHtlcPhase, B as RelaySocket, R as RfqQuote, D as RfqRefusalReason, E as RfqStatus, F as arkadeAssetLeg, G as arkadeSwapRequest, J as assertArkadeFundable, K as awaitOnchainFill, N as buildHtlcClaim, P as buildHtlcRefund, Q as canonicalAssetAmount, U as claimOnchainFill, V as classifyOnchainHtlc, W as deriveLightningReceive, X as deriveOnchainReceive, Y as deriveOnchainSend, Z as extractPreimage, _ as httpTransport, $ as l1ScriptForAddress, a0 as lightningReceiveContract, a1 as lightningReceiveRequest, a2 as lightningSendContract, a3 as lightningSendRequest, a4 as newPreimage, a5 as normalizeMakerPkScript, a6 as normalizeMakerPublicKey, a7 as onchainHtlcScript, a8 as onchainReceiveRequest, a9 as onchainSendRequest, aa as paymentHashOf, ab as relayTransport, ac as requestArkadeSwap, ad as requestLightningReceive, ae as requestOnchainReceive, af as unilateralClaimDelay, ag as unilateralRefundDelay, ah as unilateralRefundWithoutReceiverDelay, ai as verifyLockupAddress, aj as verifyOfferAddress, ak as verifyReceiveInvoice } from './rfq-
|
|
6
|
-
export { d as ClaimPacketInput, e as LockupContractMissing, f as LockupContractReader, g as LockupContractWriter, h as SWAP_LOCKUP_CONTRACT_KIND, i as SWAP_LOCKUP_CONTRACT_LABEL, j as SWAP_LOCKUP_CONTRACT_TYPE, k as SealedClaimPacket, l as lockupContractParams, r as registerLockupContract, s as sealClaimPacket } from './lockupContract-
|
|
2
|
+
import { bh as SwapSecretsProjection, e as RfqSwapRecord, h as AssetSwap, d as AssetSwapRepository, L as LockupSpendIndexer, bb as RfqSwapState, bd as SwapOperator, bi as LockupContractSource, bj as RfqSwap, bk as ArkadeRefundResult, bl as LockupVtxo } from './repository-Cut4eEkm.cjs';
|
|
3
|
+
export { c as AssetSwapStatus, bm as AvailableRfqSwapManagerCallbacks, bn as BTC_ASSET_ID, bo as LightningReceiveSwap, bp as LightningSendSwap, bq as LockupFate, br as LockupNeedsRecoveryError, bs as LockupParams, bt as LockupSpend, bu as OnchainReceiveAction, bv as OnchainReceiveNeedsChainSource, bw as OnchainReceiveSwap, bx as OnchainSendAction, by as OnchainSendSwap, bz as PersistableRfqSwap, bA as PreimageBlockedReason, bB as PreimageNotRecoverableError, bC as REFUND_MTP_LAG_SECONDS, bD as RFQ_SWAP_RETENTION_SECONDS, bE as ReceiveLockupSwap, bF as RfqRestoreFailure, bG as RfqRestoreOptions, bH as RfqRestoreResult, bg as RfqSwapActionName, bI as RfqSwapLockup, bJ as RfqSwapManager, bf as RfqSwapManagerCallbacks, bK as RfqSwapManagerConfig, bL as RfqSwapManagerDeps, bM as RfqSwapManagerEvents, bN as RfqSwapOrigin, bO as RfqSwapOriginRequired, bP as RfqSwapOutcome, a as RfqSwapRecordStore, bQ as addAssetSwap, bR as awaitRfqResolution, bS as createRfqSwapRecord, bT as findLockupVtxos, bU as getAssetSwaps, bV as isRfqTerminal, bW as nextOnchainAction, bX as nextOnchainReceiveAction, bY as normalizeRfqSwapRecord, bZ as preimageForSwapRecord, b_ as pushRefundWithoutReceiver, b$ as readLockupFate, c0 as rebuildRfqSwap, c1 as rfqSwapOriginOf, c2 as shouldRetainRfqSwap, c3 as swapSecretsToRecord, c4 as updateAssetSwap, c5 as updateRfqSwapRecord } from './repository-Cut4eEkm.cjs';
|
|
4
|
+
import { h as OnchainNetwork, O as OnchainHtlc, g as OnchainHtlcParams, C as ChainSource, I as InvoiceFacts, e as RfqTransport, r as requestLightningSend, j as requestOnchainSend } from './rfq-CP-P0PSL.cjs';
|
|
5
|
+
export { A as ARKADE_BTC, k as AddressMismatch, l as ChainUtxo, H as HtlcUtxo, m as LIGHTNING_BTC, n as LIGHTNING_RECEIVE_PAIR, o as LIGHTNING_SEND_PAIR, p as LOCKTIME_THRESHOLD, f as LightningReceiveContractParams, L as LightningSendContractParams, M as MAX_MIN_CONFIRMATIONS, q as MIN_CLAIM_WINDOW_SECONDS, s as ONCHAIN_BTC, t as ONCHAIN_CLAIM_MARGIN_SECONDS, u as ONCHAIN_DUST_SATS, v as ONCHAIN_ORDER_MARGIN_SECONDS, w as ONCHAIN_RECEIVE_PAIR, x as ONCHAIN_SECONDS_PER_BLOCK, y as ONCHAIN_SEND_PAIR, z as OnchainHtlcPhase, B as RelaySocket, R as RfqQuote, D as RfqRefusalReason, E as RfqStatus, F as arkadeAssetLeg, G as arkadeSwapRequest, J as assertArkadeFundable, K as awaitOnchainFill, N as buildHtlcClaim, P as buildHtlcRefund, Q as canonicalAssetAmount, U as claimOnchainFill, V as classifyOnchainHtlc, W as deriveLightningReceive, X as deriveOnchainReceive, Y as deriveOnchainSend, Z as extractPreimage, _ as httpTransport, $ as l1ScriptForAddress, a0 as lightningReceiveContract, a1 as lightningReceiveRequest, a2 as lightningSendContract, a3 as lightningSendRequest, a4 as newPreimage, a5 as normalizeMakerPkScript, a6 as normalizeMakerPublicKey, a7 as onchainHtlcScript, a8 as onchainReceiveRequest, a9 as onchainSendRequest, aa as paymentHashOf, ab as relayTransport, ac as requestArkadeSwap, ad as requestLightningReceive, ae as requestOnchainReceive, af as unilateralClaimDelay, ag as unilateralRefundDelay, ah as unilateralRefundWithoutReceiverDelay, ai as verifyLockupAddress, aj as verifyOfferAddress, ak as verifyReceiveInvoice } from './rfq-CP-P0PSL.cjs';
|
|
6
|
+
export { d as ClaimPacketInput, e as LockupContractMissing, f as LockupContractReader, g as LockupContractWriter, h as SWAP_LOCKUP_CONTRACT_KIND, i as SWAP_LOCKUP_CONTRACT_LABEL, j as SWAP_LOCKUP_CONTRACT_TYPE, k as SealedClaimPacket, l as lockupContractParams, r as registerLockupContract, s as sealClaimPacket } from './lockupContract-QfbsjyXG.cjs';
|
|
7
7
|
import { Network as Network$1, LocalCardInput, TransportCardFetcher, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
|
|
8
|
-
import { O as Offer } from './offer-
|
|
9
|
-
export { A as ASSET_CARRIER_SATS, F as FillFunding, a as FillOutpoint, N as NoSpendableDepositError, c as OFFER_PACKET_TYPE, d as OfferCovenantMismatchError, e as cancelOffer, f as createOffer, g as decodeOffer, h as encodeOffer, i as fillOffer, o as offerContract, j as offerVtxoScript, s as swapPrograms } from './offer-
|
|
10
|
-
export { c as OfferSwapWatcher, W as WatchOfferSwapsParams, w as watchOfferSwaps } from './watch-
|
|
8
|
+
import { O as Offer } from './offer-BxzPQ6zh.cjs';
|
|
9
|
+
export { A as ASSET_CARRIER_SATS, F as FillFunding, a as FillOutpoint, N as NoSpendableDepositError, c as OFFER_PACKET_TYPE, d as OfferCovenantMismatchError, e as cancelOffer, f as createOffer, g as decodeOffer, h as encodeOffer, i as fillOffer, o as offerContract, j as offerVtxoScript, s as swapPrograms } from './offer-BxzPQ6zh.cjs';
|
|
10
|
+
export { c as OfferSwapWatcher, W as WatchOfferSwapsParams, w as watchOfferSwaps } from './watch-D4PeBZ3H.cjs';
|
|
11
11
|
|
|
12
12
|
/** Which wallet key signs this leg, at `profile.signer`. Omitted entirely (not blank) by a corridor
|
|
13
13
|
* whose leg this wallet never signs. */
|
|
@@ -403,6 +403,7 @@ declare function pushClaim(operator: SwapOperator, input: {
|
|
|
403
403
|
partiallyClaimed?: boolean;
|
|
404
404
|
/** @see operatorUnrollScript */
|
|
405
405
|
network?: Network;
|
|
406
|
+
oneShot?: boolean;
|
|
406
407
|
}): Promise<{
|
|
407
408
|
txid: string;
|
|
408
409
|
amount: number;
|
package/dist/protocol.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ProvisionedKey, ProvisionedClaimSecret, RestIndexerProvider, Transaction, ActivityResolver, IWallet, Network, OnchainProvider, VHTLC, Identity, Asset, PaymentRail } from '@arkade-os/sdk';
|
|
2
|
-
import { bh as SwapSecretsProjection, e as RfqSwapRecord, h as AssetSwap, d as AssetSwapRepository, L as LockupSpendIndexer, bb as RfqSwapState, bd as SwapOperator, bi as LockupContractSource, bj as RfqSwap, bk as ArkadeRefundResult, bl as LockupVtxo } from './repository-
|
|
3
|
-
export { c as AssetSwapStatus, bm as AvailableRfqSwapManagerCallbacks, bn as BTC_ASSET_ID, bo as LightningReceiveSwap, bp as LightningSendSwap, bq as LockupFate, br as LockupNeedsRecoveryError, bs as LockupParams, bt as LockupSpend, bu as OnchainReceiveAction, bv as OnchainReceiveNeedsChainSource, bw as OnchainReceiveSwap, bx as OnchainSendAction, by as OnchainSendSwap, bz as PersistableRfqSwap, bA as PreimageBlockedReason, bB as PreimageNotRecoverableError, bC as REFUND_MTP_LAG_SECONDS, bD as RFQ_SWAP_RETENTION_SECONDS, bE as ReceiveLockupSwap, bF as RfqRestoreFailure, bG as RfqRestoreOptions, bH as RfqRestoreResult, bg as RfqSwapActionName, bI as RfqSwapLockup, bJ as RfqSwapManager, bf as RfqSwapManagerCallbacks, bK as RfqSwapManagerConfig, bL as RfqSwapManagerDeps, bM as RfqSwapManagerEvents, bN as RfqSwapOrigin, bO as RfqSwapOriginRequired, bP as RfqSwapOutcome, a as RfqSwapRecordStore, bQ as addAssetSwap, bR as awaitRfqResolution, bS as createRfqSwapRecord, bT as findLockupVtxos, bU as getAssetSwaps, bV as isRfqTerminal, bW as nextOnchainAction, bX as nextOnchainReceiveAction, bY as normalizeRfqSwapRecord, bZ as preimageForSwapRecord, b_ as pushRefundWithoutReceiver, b$ as readLockupFate, c0 as rebuildRfqSwap, c1 as rfqSwapOriginOf, c2 as shouldRetainRfqSwap, c3 as swapSecretsToRecord, c4 as updateAssetSwap, c5 as updateRfqSwapRecord } from './repository-
|
|
4
|
-
import { h as OnchainNetwork, O as OnchainHtlc, g as OnchainHtlcParams, C as ChainSource, I as InvoiceFacts, e as RfqTransport, r as requestLightningSend, j as requestOnchainSend } from './rfq-
|
|
5
|
-
export { A as ARKADE_BTC, k as AddressMismatch, l as ChainUtxo, H as HtlcUtxo, m as LIGHTNING_BTC, n as LIGHTNING_RECEIVE_PAIR, o as LIGHTNING_SEND_PAIR, p as LOCKTIME_THRESHOLD, f as LightningReceiveContractParams, L as LightningSendContractParams, M as MAX_MIN_CONFIRMATIONS, q as MIN_CLAIM_WINDOW_SECONDS, s as ONCHAIN_BTC, t as ONCHAIN_CLAIM_MARGIN_SECONDS, u as ONCHAIN_DUST_SATS, v as ONCHAIN_ORDER_MARGIN_SECONDS, w as ONCHAIN_RECEIVE_PAIR, x as ONCHAIN_SECONDS_PER_BLOCK, y as ONCHAIN_SEND_PAIR, z as OnchainHtlcPhase, B as RelaySocket, R as RfqQuote, D as RfqRefusalReason, E as RfqStatus, F as arkadeAssetLeg, G as arkadeSwapRequest, J as assertArkadeFundable, K as awaitOnchainFill, N as buildHtlcClaim, P as buildHtlcRefund, Q as canonicalAssetAmount, U as claimOnchainFill, V as classifyOnchainHtlc, W as deriveLightningReceive, X as deriveOnchainReceive, Y as deriveOnchainSend, Z as extractPreimage, _ as httpTransport, $ as l1ScriptForAddress, a0 as lightningReceiveContract, a1 as lightningReceiveRequest, a2 as lightningSendContract, a3 as lightningSendRequest, a4 as newPreimage, a5 as normalizeMakerPkScript, a6 as normalizeMakerPublicKey, a7 as onchainHtlcScript, a8 as onchainReceiveRequest, a9 as onchainSendRequest, aa as paymentHashOf, ab as relayTransport, ac as requestArkadeSwap, ad as requestLightningReceive, ae as requestOnchainReceive, af as unilateralClaimDelay, ag as unilateralRefundDelay, ah as unilateralRefundWithoutReceiverDelay, ai as verifyLockupAddress, aj as verifyOfferAddress, ak as verifyReceiveInvoice } from './rfq-
|
|
6
|
-
export { d as ClaimPacketInput, e as LockupContractMissing, f as LockupContractReader, g as LockupContractWriter, h as SWAP_LOCKUP_CONTRACT_KIND, i as SWAP_LOCKUP_CONTRACT_LABEL, j as SWAP_LOCKUP_CONTRACT_TYPE, k as SealedClaimPacket, l as lockupContractParams, r as registerLockupContract, s as sealClaimPacket } from './lockupContract-
|
|
2
|
+
import { bh as SwapSecretsProjection, e as RfqSwapRecord, h as AssetSwap, d as AssetSwapRepository, L as LockupSpendIndexer, bb as RfqSwapState, bd as SwapOperator, bi as LockupContractSource, bj as RfqSwap, bk as ArkadeRefundResult, bl as LockupVtxo } from './repository-BOQ1qYoj.js';
|
|
3
|
+
export { c as AssetSwapStatus, bm as AvailableRfqSwapManagerCallbacks, bn as BTC_ASSET_ID, bo as LightningReceiveSwap, bp as LightningSendSwap, bq as LockupFate, br as LockupNeedsRecoveryError, bs as LockupParams, bt as LockupSpend, bu as OnchainReceiveAction, bv as OnchainReceiveNeedsChainSource, bw as OnchainReceiveSwap, bx as OnchainSendAction, by as OnchainSendSwap, bz as PersistableRfqSwap, bA as PreimageBlockedReason, bB as PreimageNotRecoverableError, bC as REFUND_MTP_LAG_SECONDS, bD as RFQ_SWAP_RETENTION_SECONDS, bE as ReceiveLockupSwap, bF as RfqRestoreFailure, bG as RfqRestoreOptions, bH as RfqRestoreResult, bg as RfqSwapActionName, bI as RfqSwapLockup, bJ as RfqSwapManager, bf as RfqSwapManagerCallbacks, bK as RfqSwapManagerConfig, bL as RfqSwapManagerDeps, bM as RfqSwapManagerEvents, bN as RfqSwapOrigin, bO as RfqSwapOriginRequired, bP as RfqSwapOutcome, a as RfqSwapRecordStore, bQ as addAssetSwap, bR as awaitRfqResolution, bS as createRfqSwapRecord, bT as findLockupVtxos, bU as getAssetSwaps, bV as isRfqTerminal, bW as nextOnchainAction, bX as nextOnchainReceiveAction, bY as normalizeRfqSwapRecord, bZ as preimageForSwapRecord, b_ as pushRefundWithoutReceiver, b$ as readLockupFate, c0 as rebuildRfqSwap, c1 as rfqSwapOriginOf, c2 as shouldRetainRfqSwap, c3 as swapSecretsToRecord, c4 as updateAssetSwap, c5 as updateRfqSwapRecord } from './repository-BOQ1qYoj.js';
|
|
4
|
+
import { h as OnchainNetwork, O as OnchainHtlc, g as OnchainHtlcParams, C as ChainSource, I as InvoiceFacts, e as RfqTransport, r as requestLightningSend, j as requestOnchainSend } from './rfq-CP-P0PSL.js';
|
|
5
|
+
export { A as ARKADE_BTC, k as AddressMismatch, l as ChainUtxo, H as HtlcUtxo, m as LIGHTNING_BTC, n as LIGHTNING_RECEIVE_PAIR, o as LIGHTNING_SEND_PAIR, p as LOCKTIME_THRESHOLD, f as LightningReceiveContractParams, L as LightningSendContractParams, M as MAX_MIN_CONFIRMATIONS, q as MIN_CLAIM_WINDOW_SECONDS, s as ONCHAIN_BTC, t as ONCHAIN_CLAIM_MARGIN_SECONDS, u as ONCHAIN_DUST_SATS, v as ONCHAIN_ORDER_MARGIN_SECONDS, w as ONCHAIN_RECEIVE_PAIR, x as ONCHAIN_SECONDS_PER_BLOCK, y as ONCHAIN_SEND_PAIR, z as OnchainHtlcPhase, B as RelaySocket, R as RfqQuote, D as RfqRefusalReason, E as RfqStatus, F as arkadeAssetLeg, G as arkadeSwapRequest, J as assertArkadeFundable, K as awaitOnchainFill, N as buildHtlcClaim, P as buildHtlcRefund, Q as canonicalAssetAmount, U as claimOnchainFill, V as classifyOnchainHtlc, W as deriveLightningReceive, X as deriveOnchainReceive, Y as deriveOnchainSend, Z as extractPreimage, _ as httpTransport, $ as l1ScriptForAddress, a0 as lightningReceiveContract, a1 as lightningReceiveRequest, a2 as lightningSendContract, a3 as lightningSendRequest, a4 as newPreimage, a5 as normalizeMakerPkScript, a6 as normalizeMakerPublicKey, a7 as onchainHtlcScript, a8 as onchainReceiveRequest, a9 as onchainSendRequest, aa as paymentHashOf, ab as relayTransport, ac as requestArkadeSwap, ad as requestLightningReceive, ae as requestOnchainReceive, af as unilateralClaimDelay, ag as unilateralRefundDelay, ah as unilateralRefundWithoutReceiverDelay, ai as verifyLockupAddress, aj as verifyOfferAddress, ak as verifyReceiveInvoice } from './rfq-CP-P0PSL.js';
|
|
6
|
+
export { d as ClaimPacketInput, e as LockupContractMissing, f as LockupContractReader, g as LockupContractWriter, h as SWAP_LOCKUP_CONTRACT_KIND, i as SWAP_LOCKUP_CONTRACT_LABEL, j as SWAP_LOCKUP_CONTRACT_TYPE, k as SealedClaimPacket, l as lockupContractParams, r as registerLockupContract, s as sealClaimPacket } from './lockupContract-CdXh9yIr.js';
|
|
7
7
|
import { Network as Network$1, LocalCardInput, TransportCardFetcher, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
|
|
8
|
-
import { O as Offer } from './offer-
|
|
9
|
-
export { A as ASSET_CARRIER_SATS, F as FillFunding, a as FillOutpoint, N as NoSpendableDepositError, c as OFFER_PACKET_TYPE, d as OfferCovenantMismatchError, e as cancelOffer, f as createOffer, g as decodeOffer, h as encodeOffer, i as fillOffer, o as offerContract, j as offerVtxoScript, s as swapPrograms } from './offer-
|
|
10
|
-
export { c as OfferSwapWatcher, W as WatchOfferSwapsParams, w as watchOfferSwaps } from './watch-
|
|
8
|
+
import { O as Offer } from './offer-Q1lVhrVX.js';
|
|
9
|
+
export { A as ASSET_CARRIER_SATS, F as FillFunding, a as FillOutpoint, N as NoSpendableDepositError, c as OFFER_PACKET_TYPE, d as OfferCovenantMismatchError, e as cancelOffer, f as createOffer, g as decodeOffer, h as encodeOffer, i as fillOffer, o as offerContract, j as offerVtxoScript, s as swapPrograms } from './offer-Q1lVhrVX.js';
|
|
10
|
+
export { c as OfferSwapWatcher, W as WatchOfferSwapsParams, w as watchOfferSwaps } from './watch-D15U0QpD.js';
|
|
11
11
|
|
|
12
12
|
/** Which wallet key signs this leg, at `profile.signer`. Omitted entirely (not blank) by a corridor
|
|
13
13
|
* whose leg this wallet never signs. */
|
|
@@ -403,6 +403,7 @@ declare function pushClaim(operator: SwapOperator, input: {
|
|
|
403
403
|
partiallyClaimed?: boolean;
|
|
404
404
|
/** @see operatorUnrollScript */
|
|
405
405
|
network?: Network;
|
|
406
|
+
oneShot?: boolean;
|
|
406
407
|
}): Promise<{
|
|
407
408
|
txid: string;
|
|
408
409
|
amount: number;
|
package/dist/protocol.js
CHANGED
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
validatePlan,
|
|
43
43
|
watchMarkets,
|
|
44
44
|
watchOfferSwaps
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-GJKGPE3S.js";
|
|
46
46
|
import {
|
|
47
47
|
ARKADE_BTC,
|
|
48
48
|
ASSET_CARRIER_SATS,
|
|
@@ -128,7 +128,7 @@ import {
|
|
|
128
128
|
verifyLockupAddress,
|
|
129
129
|
verifyOfferAddress,
|
|
130
130
|
verifyReceiveInvoice
|
|
131
|
-
} from "./chunk-
|
|
131
|
+
} from "./chunk-7BBQ74BG.js";
|
|
132
132
|
import {
|
|
133
133
|
collectRfqSwaps
|
|
134
134
|
} from "./chunk-A3SHHRX4.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RealmLike } from '@arkade-os/sdk/repositories/realm';
|
|
2
2
|
import { PageRequest, PageResult } from '@arkade-os/sdk';
|
|
3
|
-
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry } from '../../repository-
|
|
3
|
+
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry } from '../../repository-Cut4eEkm.cjs';
|
|
4
4
|
import '@arkade-os/solver-discovery';
|
|
5
|
-
import '../../rfq-
|
|
5
|
+
import '../../rfq-CP-P0PSL.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Realm backend for React Native.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RealmLike } from '@arkade-os/sdk/repositories/realm';
|
|
2
2
|
import { PageRequest, PageResult } from '@arkade-os/sdk';
|
|
3
|
-
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry } from '../../repository-
|
|
3
|
+
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry } from '../../repository-BOQ1qYoj.js';
|
|
4
4
|
import '@arkade-os/solver-discovery';
|
|
5
|
-
import '../../rfq-
|
|
5
|
+
import '../../rfq-CP-P0PSL.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Realm backend for React Native.
|
|
@@ -75,46 +75,46 @@ var SQLiteAssetSwapRepository = class {
|
|
|
75
75
|
* while `initPromise` stayed resolved and every later statement failed with
|
|
76
76
|
* `no such table`. */
|
|
77
77
|
async init() {
|
|
78
|
-
await this.withTx(async () => {
|
|
79
|
-
await
|
|
78
|
+
await this.withTx(async (tx) => {
|
|
79
|
+
await tx.run(`CREATE TABLE IF NOT EXISTS ${this.swaps} (
|
|
80
80
|
id TEXT PRIMARY KEY,
|
|
81
81
|
status TEXT NOT NULL,
|
|
82
82
|
created_at INTEGER NOT NULL,
|
|
83
83
|
data TEXT NOT NULL
|
|
84
84
|
)`);
|
|
85
|
-
await
|
|
85
|
+
await tx.run(
|
|
86
86
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}asset_swaps_status ON ${this.swaps} (status)`
|
|
87
87
|
);
|
|
88
|
-
await
|
|
88
|
+
await tx.run(
|
|
89
89
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}asset_swaps_created_at ON ${this.swaps} (created_at)`
|
|
90
90
|
);
|
|
91
|
-
await
|
|
91
|
+
await tx.run(`CREATE TABLE IF NOT EXISTS ${this.rfqSwaps} (
|
|
92
92
|
rfq_id TEXT PRIMARY KEY,
|
|
93
93
|
state TEXT NOT NULL,
|
|
94
94
|
updated_at INTEGER NOT NULL,
|
|
95
95
|
data TEXT NOT NULL
|
|
96
96
|
)`);
|
|
97
|
-
await
|
|
97
|
+
await tx.run(
|
|
98
98
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}rfq_updated ON ${this.rfqSwaps} (updated_at, rfq_id)`
|
|
99
99
|
);
|
|
100
|
-
await
|
|
100
|
+
await tx.run(
|
|
101
101
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}rfq_swaps_history ON ${this.rfqSwaps} (state, updated_at, rfq_id)`
|
|
102
102
|
);
|
|
103
|
-
await
|
|
104
|
-
await
|
|
103
|
+
await tx.run(`DROP INDEX IF EXISTS idx_${this.prefix}rfq_swaps_page`);
|
|
104
|
+
await tx.run(
|
|
105
105
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}rfq_swaps_state ON ${this.rfqSwaps} (state)`
|
|
106
106
|
);
|
|
107
|
-
await
|
|
107
|
+
await tx.run(`CREATE TABLE IF NOT EXISTS ${this.swapRecords} (
|
|
108
108
|
id TEXT PRIMARY KEY,
|
|
109
109
|
family TEXT NOT NULL,
|
|
110
110
|
updated_at INTEGER NOT NULL,
|
|
111
111
|
data TEXT NOT NULL
|
|
112
112
|
)`);
|
|
113
|
-
await
|
|
113
|
+
await tx.run(
|
|
114
114
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}swap_records_family ON ${this.swapRecords} (family)`
|
|
115
115
|
);
|
|
116
|
-
await
|
|
117
|
-
await
|
|
116
|
+
await tx.run(`CREATE TABLE IF NOT EXISTS ${this.scanned} (txid TEXT PRIMARY KEY)`);
|
|
117
|
+
await tx.run(
|
|
118
118
|
`CREATE TABLE IF NOT EXISTS ${this.markets} (cache_key TEXT PRIMARY KEY, data TEXT NOT NULL)`
|
|
119
119
|
);
|
|
120
120
|
});
|
|
@@ -122,7 +122,7 @@ var SQLiteAssetSwapRepository = class {
|
|
|
122
122
|
/** Every write, including the single-statement ones. The chain serializes
|
|
123
123
|
* transaction *blocks*, not bare statements: one issued between a
|
|
124
124
|
* neighbour's BEGIN IMMEDIATE and its COMMIT becomes part of that
|
|
125
|
-
* transaction and dies with it. `fn` must
|
|
125
|
+
* transaction and dies with it. `fn` must use its supplied raw executor — no
|
|
126
126
|
* repository method, no `ensureInit` — since `runInTransaction` cannot
|
|
127
127
|
* nest. */
|
|
128
128
|
withTx(fn) {
|
|
@@ -130,8 +130,8 @@ var SQLiteAssetSwapRepository = class {
|
|
|
130
130
|
}
|
|
131
131
|
async saveSwap(swap) {
|
|
132
132
|
await this.ensureInit();
|
|
133
|
-
await this.withTx(async () => {
|
|
134
|
-
await
|
|
133
|
+
await this.withTx(async (tx) => {
|
|
134
|
+
await tx.run(
|
|
135
135
|
`INSERT OR REPLACE INTO ${this.swaps} (id, status, created_at, data)
|
|
136
136
|
VALUES (?, ?, ?, ?)`,
|
|
137
137
|
[swap.id, swap.status, swap.createdAt, JSON.stringify(swap)]
|
|
@@ -143,8 +143,8 @@ var SQLiteAssetSwapRepository = class {
|
|
|
143
143
|
}
|
|
144
144
|
async saveRfqSwap(record) {
|
|
145
145
|
await this.ensureInit();
|
|
146
|
-
await this.withTx(async () => {
|
|
147
|
-
await
|
|
146
|
+
await this.withTx(async (tx) => {
|
|
147
|
+
await tx.run(
|
|
148
148
|
`INSERT OR REPLACE INTO ${this.rfqSwaps} (rfq_id, state, updated_at, data)
|
|
149
149
|
VALUES (?, ?, ?, ?)`,
|
|
150
150
|
[record.rfqId, record.state, record.updatedAt, JSON.stringify(record)]
|
|
@@ -194,14 +194,14 @@ var SQLiteAssetSwapRepository = class {
|
|
|
194
194
|
}
|
|
195
195
|
async removeRfqSwap(rfqId) {
|
|
196
196
|
await this.ensureInit();
|
|
197
|
-
await this.withTx(async () => {
|
|
198
|
-
await
|
|
197
|
+
await this.withTx(async (tx) => {
|
|
198
|
+
await tx.run(`DELETE FROM ${this.rfqSwaps} WHERE rfq_id = ?`, [rfqId]);
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
201
|
async saveSwapRecord(record) {
|
|
202
202
|
await this.ensureInit();
|
|
203
|
-
await this.withTx(async () => {
|
|
204
|
-
await
|
|
203
|
+
await this.withTx(async (tx) => {
|
|
204
|
+
await tx.run(
|
|
205
205
|
`INSERT OR REPLACE INTO ${this.swapRecords} (id, family, updated_at, data)
|
|
206
206
|
VALUES (?, ?, ?, ?)`,
|
|
207
207
|
[record.id, record.family, record.updatedAt, JSON.stringify(record)]
|
|
@@ -234,8 +234,8 @@ var SQLiteAssetSwapRepository = class {
|
|
|
234
234
|
}
|
|
235
235
|
async removeSwapRecord(id) {
|
|
236
236
|
await this.ensureInit();
|
|
237
|
-
await this.withTx(async () => {
|
|
238
|
-
await
|
|
237
|
+
await this.withTx(async (tx) => {
|
|
238
|
+
await tx.run(`DELETE FROM ${this.swapRecords} WHERE id = ?`, [id]);
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
241
|
async getScannedTxids() {
|
|
@@ -247,10 +247,10 @@ var SQLiteAssetSwapRepository = class {
|
|
|
247
247
|
await this.ensureInit();
|
|
248
248
|
const all = [...txids];
|
|
249
249
|
if (all.length === 0) return;
|
|
250
|
-
await this.withTx(async () => {
|
|
250
|
+
await this.withTx(async (tx) => {
|
|
251
251
|
for (let i = 0; i < all.length; i += INSERT_CHUNK) {
|
|
252
252
|
const chunk = all.slice(i, i + INSERT_CHUNK);
|
|
253
|
-
await
|
|
253
|
+
await tx.run(
|
|
254
254
|
`INSERT OR IGNORE INTO ${this.scanned} (txid) VALUES ${chunk.map(() => "(?)").join(", ")}`,
|
|
255
255
|
chunk
|
|
256
256
|
);
|
|
@@ -267,11 +267,11 @@ var SQLiteAssetSwapRepository = class {
|
|
|
267
267
|
}
|
|
268
268
|
async saveCachedMarkets(network, registry, entry) {
|
|
269
269
|
await this.ensureInit();
|
|
270
|
-
await this.withTx(async () => {
|
|
271
|
-
await
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
);
|
|
270
|
+
await this.withTx(async (tx) => {
|
|
271
|
+
await tx.run(`INSERT OR REPLACE INTO ${this.markets} (cache_key, data) VALUES (?, ?)`, [
|
|
272
|
+
marketsCacheKey(network, registry),
|
|
273
|
+
JSON.stringify(entry)
|
|
274
|
+
]);
|
|
275
275
|
});
|
|
276
276
|
}
|
|
277
277
|
/** Every table in one transaction: clearing swaps but keeping scanned txids
|
|
@@ -279,12 +279,12 @@ var SQLiteAssetSwapRepository = class {
|
|
|
279
279
|
* partial clear must not be observable. */
|
|
280
280
|
async clear() {
|
|
281
281
|
await this.ensureInit();
|
|
282
|
-
await this.withTx(async () => {
|
|
283
|
-
await
|
|
284
|
-
await
|
|
285
|
-
await
|
|
286
|
-
await
|
|
287
|
-
await
|
|
282
|
+
await this.withTx(async (tx) => {
|
|
283
|
+
await tx.run(`DELETE FROM ${this.swaps}`);
|
|
284
|
+
await tx.run(`DELETE FROM ${this.rfqSwaps}`);
|
|
285
|
+
await tx.run(`DELETE FROM ${this.swapRecords}`);
|
|
286
|
+
await tx.run(`DELETE FROM ${this.scanned}`);
|
|
287
|
+
await tx.run(`DELETE FROM ${this.markets}`);
|
|
288
288
|
});
|
|
289
289
|
}
|
|
290
290
|
async [Symbol.asyncDispose]() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SQLExecutor } from '@arkade-os/sdk/repositories/sqlite';
|
|
2
2
|
import { PageRequest, PageResult } from '@arkade-os/sdk';
|
|
3
|
-
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry } from '../../repository-
|
|
3
|
+
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry } from '../../repository-Cut4eEkm.cjs';
|
|
4
4
|
import '@arkade-os/solver-discovery';
|
|
5
|
-
import '../../rfq-
|
|
5
|
+
import '../../rfq-CP-P0PSL.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* SQLite backend over the SDK's `SQLExecutor`, so any driver plugs in
|
|
@@ -53,7 +53,7 @@ declare class SQLiteAssetSwapRepository implements AssetSwapRepository {
|
|
|
53
53
|
/** Every write, including the single-statement ones. The chain serializes
|
|
54
54
|
* transaction *blocks*, not bare statements: one issued between a
|
|
55
55
|
* neighbour's BEGIN IMMEDIATE and its COMMIT becomes part of that
|
|
56
|
-
* transaction and dies with it. `fn` must
|
|
56
|
+
* transaction and dies with it. `fn` must use its supplied raw executor — no
|
|
57
57
|
* repository method, no `ensureInit` — since `runInTransaction` cannot
|
|
58
58
|
* nest. */
|
|
59
59
|
private withTx;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SQLExecutor } from '@arkade-os/sdk/repositories/sqlite';
|
|
2
2
|
import { PageRequest, PageResult } from '@arkade-os/sdk';
|
|
3
|
-
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry } from '../../repository-
|
|
3
|
+
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry } from '../../repository-BOQ1qYoj.js';
|
|
4
4
|
import '@arkade-os/solver-discovery';
|
|
5
|
-
import '../../rfq-
|
|
5
|
+
import '../../rfq-CP-P0PSL.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* SQLite backend over the SDK's `SQLExecutor`, so any driver plugs in
|
|
@@ -53,7 +53,7 @@ declare class SQLiteAssetSwapRepository implements AssetSwapRepository {
|
|
|
53
53
|
/** Every write, including the single-statement ones. The chain serializes
|
|
54
54
|
* transaction *blocks*, not bare statements: one issued between a
|
|
55
55
|
* neighbour's BEGIN IMMEDIATE and its COMMIT becomes part of that
|
|
56
|
-
* transaction and dies with it. `fn` must
|
|
56
|
+
* transaction and dies with it. `fn` must use its supplied raw executor — no
|
|
57
57
|
* repository method, no `ensureInit` — since `runInTransaction` cannot
|
|
58
58
|
* nest. */
|
|
59
59
|
private withTx;
|