@satora/swap 1.11.1 → 1.12.0
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/dist/{chunk-4NVWIR74.cjs → chunk-EL4FUZJO.cjs} +538 -308
- package/dist/chunk-EL4FUZJO.cjs.map +1 -0
- package/dist/{chunk-TT3J2OOS.js → chunk-KECPPSZL.js} +5 -5
- package/dist/{chunk-TT3J2OOS.js.map → chunk-KECPPSZL.js.map} +1 -1
- package/dist/{chunk-Q4TOBBAN.cjs → chunk-QJ4EK6UG.cjs} +5 -5
- package/dist/{chunk-Q4TOBBAN.cjs.map → chunk-QJ4EK6UG.cjs.map} +1 -1
- package/dist/{chunk-WQMAL2VD.js → chunk-YBQPH7NH.js} +260 -30
- package/dist/chunk-YBQPH7NH.js.map +1 -0
- package/dist/delegate.cjs +2 -2
- package/dist/delegate.js +1 -1
- package/dist/dist-R6DUJG36.cjs +396 -0
- package/dist/{dist-MHRQ5FFV.cjs.map → dist-R6DUJG36.cjs.map} +1 -1
- package/dist/{dist-SHY7I6SH.js → dist-Y3ZVHXAJ.js} +5 -3
- package/dist/index.cjs +21 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/dist/types/cjs/pure/api/client.d.cts +1 -0
- package/dist/types/cjs/pure/client.d.cts +30 -3
- package/dist/types/cjs/pure/compose-quote.d.cts +14 -1
- package/dist/types/cjs/pure/create/index.d.cts +2 -1
- package/dist/types/cjs/pure/create/spark-to-evm.d.cts +7 -0
- package/dist/types/cjs/pure/create/types.d.cts +93 -2
- package/dist/types/cjs/pure/generated/api.d.cts +274 -2
- package/dist/types/cjs/pure/index.d.cts +3 -3
- package/dist/types/cjs/pure/swap-verification.d.cts +3 -1
- package/dist/types/cjs/pure/tokens.d.cts +5 -0
- package/dist/types/cjs/pure/types/chain.d.cts +2 -2
- package/dist/types/cjs/pure/types/index.d.cts +1 -0
- package/dist/types/cjs/pure/types/promo-code.d.cts +15 -0
- package/dist/types/cjs/pure/types/quote.d.cts +7 -0
- package/dist/types/cjs/pure/types/referral-fee.d.cts +8 -0
- package/dist/types/cjs/pure/version.d.cts +4 -4
- package/dist/types/cjs/swap/client.d.cts +2 -0
- package/dist/types/esm/pure/api/client.d.ts +1 -0
- package/dist/types/esm/pure/client.d.ts +30 -3
- package/dist/types/esm/pure/compose-quote.d.ts +14 -1
- package/dist/types/esm/pure/create/index.d.ts +2 -1
- package/dist/types/esm/pure/create/spark-to-evm.d.ts +7 -0
- package/dist/types/esm/pure/create/types.d.ts +93 -2
- package/dist/types/esm/pure/generated/api.d.ts +274 -2
- package/dist/types/esm/pure/index.d.ts +3 -3
- package/dist/types/esm/pure/swap-verification.d.ts +3 -1
- package/dist/types/esm/pure/tokens.d.ts +5 -0
- package/dist/types/esm/pure/types/chain.d.ts +2 -2
- package/dist/types/esm/pure/types/index.d.ts +1 -0
- package/dist/types/esm/pure/types/promo-code.d.ts +15 -0
- package/dist/types/esm/pure/types/quote.d.ts +7 -0
- package/dist/types/esm/pure/types/referral-fee.d.ts +8 -0
- package/dist/types/esm/pure/version.d.ts +4 -4
- package/dist/types/esm/swap/client.d.ts +2 -0
- package/package.json +2 -2
- package/dist/chunk-4NVWIR74.cjs.map +0 -1
- package/dist/chunk-WQMAL2VD.js.map +0 -1
- package/dist/dist-MHRQ5FFV.cjs +0 -394
- /package/dist/{dist-SHY7I6SH.js.map → dist-Y3ZVHXAJ.js.map} +0 -0
|
@@ -115,7 +115,7 @@ var _chunkTNZW35XAcjs = require('./chunk-TNZW35XA.cjs');
|
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
|
|
118
|
-
var
|
|
118
|
+
var _chunkQJ4EK6UGcjs = require('./chunk-QJ4EK6UG.cjs');
|
|
119
119
|
|
|
120
120
|
|
|
121
121
|
|
|
@@ -158,6 +158,7 @@ var _chunk5JR6AJ3Ycjs = require('./chunk-5JR6AJ3Y.cjs');
|
|
|
158
158
|
|
|
159
159
|
|
|
160
160
|
|
|
161
|
+
|
|
161
162
|
var _chunkRYZSWESUcjs = require('./chunk-RYZSWESU.cjs');
|
|
162
163
|
|
|
163
164
|
|
|
@@ -6848,8 +6849,8 @@ function removeTrailingSlash(url) {
|
|
|
6848
6849
|
}
|
|
6849
6850
|
function createApiClient(options) {
|
|
6850
6851
|
const headers = {
|
|
6851
|
-
"X-Lendaswap-Client":
|
|
6852
|
-
...
|
|
6852
|
+
"X-Lendaswap-Client": _chunkQJ4EK6UGcjs.CLIENT_AGENT,
|
|
6853
|
+
..._chunkQJ4EK6UGcjs.PROTOCOL_HEADERS,
|
|
6853
6854
|
..._nullishCoalesce(options.defaultHeaders, () => ( {}))
|
|
6854
6855
|
};
|
|
6855
6856
|
return createClient({
|
|
@@ -6862,7 +6863,7 @@ async function getVhtlcAmounts(params) {
|
|
|
6862
6863
|
const { vhtlcAddress, network, arkadeServerUrl } = params;
|
|
6863
6864
|
const decoded = _chunkBEW62OUTcjs.ArkAddress.decode(vhtlcAddress);
|
|
6864
6865
|
const pkScript = _chunkRYZSWESUcjs.hex.encode(decoded.pkScript);
|
|
6865
|
-
const serverUrl =
|
|
6866
|
+
const serverUrl = _chunkQJ4EK6UGcjs.resolveArkadeServerUrl.call(void 0, network, arkadeServerUrl);
|
|
6866
6867
|
const indexerProvider = new (0, _chunkBEW62OUTcjs.RestIndexerProvider)(serverUrl);
|
|
6867
6868
|
const [spendableResult, spentResult, recoverableResult] = await Promise.all([
|
|
6868
6869
|
indexerProvider.getVtxos({ scripts: [pkScript], spendableOnly: true }),
|
|
@@ -6897,7 +6898,7 @@ function parseArkadeAddress(address2, network) {
|
|
|
6897
6898
|
throw new Error(`Invalid Arkade address: ${reason}`);
|
|
6898
6899
|
}
|
|
6899
6900
|
if (network !== void 0) {
|
|
6900
|
-
const expectedHrp =
|
|
6901
|
+
const expectedHrp = _chunkQJ4EK6UGcjs.getNetworkHrp.call(void 0, _chunkQJ4EK6UGcjs.getNetworkName.call(void 0, network));
|
|
6901
6902
|
if (decoded.hrp !== expectedHrp) {
|
|
6902
6903
|
throw new Error(
|
|
6903
6904
|
`Arkade address has wrong network: expected "${expectedHrp}1..." prefix, got "${decoded.hrp}1..."`
|
|
@@ -7949,6 +7950,7 @@ var TBTC_ETHEREUM = "0x18084fbA666a33d37592fA2633fD49a74DD93a88";
|
|
|
7949
7950
|
var TBTC_ARBITRUM = "0x6c84a8f1c29108F47a79964b5Fe888D4f4D0dE40";
|
|
7950
7951
|
var Asset = {
|
|
7951
7952
|
// Bitcoin
|
|
7953
|
+
BTC_SPARK: { chain: "Spark", tokenId: "btc" },
|
|
7952
7954
|
BTC_LIGHTNING: { chain: "Lightning", tokenId: "btc" },
|
|
7953
7955
|
BTC_ARKADE: { chain: "Arkade", tokenId: "btc" },
|
|
7954
7956
|
BTC_ONCHAIN: { chain: "Bitcoin", tokenId: "btc" },
|
|
@@ -8039,7 +8041,7 @@ function isBtcOnchain(token) {
|
|
|
8039
8041
|
return token.chain.toLowerCase() === "bitcoin";
|
|
8040
8042
|
}
|
|
8041
8043
|
function isBtc(token) {
|
|
8042
|
-
return isLightning(token) || isArkade(token) || isBtcOnchain(token);
|
|
8044
|
+
return isSpark(token) || isLightning(token) || isArkade(token) || isBtcOnchain(token);
|
|
8043
8045
|
}
|
|
8044
8046
|
function isBtcPegged(token) {
|
|
8045
8047
|
const sym = token.symbol.toLowerCase();
|
|
@@ -8126,6 +8128,7 @@ function toChain(str) {
|
|
|
8126
8128
|
if (c === "arbitrum" || c === "42161") return "42161";
|
|
8127
8129
|
if (c === "rootstock" || c === "30") return "30";
|
|
8128
8130
|
if (c === "31") return "31";
|
|
8131
|
+
if (c === "spark") return "Spark";
|
|
8129
8132
|
if (c === "lightning") return "Lightning";
|
|
8130
8133
|
if (c === "arkade") return "Arkade";
|
|
8131
8134
|
if (c === "bitcoin") return "Bitcoin";
|
|
@@ -8183,6 +8186,9 @@ function getUsdt0BridgeTokens() {
|
|
|
8183
8186
|
}
|
|
8184
8187
|
return tokens;
|
|
8185
8188
|
}
|
|
8189
|
+
function isSpark(token) {
|
|
8190
|
+
return token.chain.toLowerCase() === "spark";
|
|
8191
|
+
}
|
|
8186
8192
|
function pivotForChain(chainConfig, chain) {
|
|
8187
8193
|
const entry = chainConfig.chains.find((c) => c.chain === chain);
|
|
8188
8194
|
if (!entry) return void 0;
|
|
@@ -8388,9 +8394,10 @@ async function composeBtcToEvm(params, deps) {
|
|
|
8388
8394
|
);
|
|
8389
8395
|
}
|
|
8390
8396
|
const { btcSats, evmSmallest, evmDecimals } = pivot;
|
|
8397
|
+
ensureWithinPromoCap(deps, btcSats);
|
|
8391
8398
|
let { bridgeFee } = pivot;
|
|
8392
8399
|
const networkFeeSats = baseNetworkFeeSats + pivot.bridgeNativeFeeSats;
|
|
8393
|
-
const effectiveFeePct = (
|
|
8400
|
+
const effectiveFeePct = baseFeePct(deps, pair.fee_percentage) + (_nullishCoalesce(deps.referralExtraFeeRate, () => ( 0)));
|
|
8394
8401
|
const FEE_SCALE = 10n ** 18n;
|
|
8395
8402
|
const feePctScaled = BigInt(Math.round(effectiveFeePct * Number(FEE_SCALE)));
|
|
8396
8403
|
const protocolFee = Number(btcSats * feePctScaled / FEE_SCALE);
|
|
@@ -8430,7 +8437,7 @@ async function composeBtcToEvm(params, deps) {
|
|
|
8430
8437
|
protocol_fee: protocolFee,
|
|
8431
8438
|
protocol_fee_rate: effectiveFeePct,
|
|
8432
8439
|
min_amount: pair.min_sats,
|
|
8433
|
-
max_amount: pair.max_sats,
|
|
8440
|
+
max_amount: maxSats(deps, pair.max_sats),
|
|
8434
8441
|
source_amount: btcSats.toString(),
|
|
8435
8442
|
// Source-pinned: `evmSmallest` is the delivered (fee-netted) DEX output, so
|
|
8436
8443
|
// gross it back up by the bridge fee — `target_amount` is the gross output
|
|
@@ -8442,7 +8449,8 @@ async function composeBtcToEvm(params, deps) {
|
|
|
8442
8449
|
target_amount: (params.sourceAmount != null ? grossTarget : evmSmallest).toString(),
|
|
8443
8450
|
net_source_amount: netSource.toString(),
|
|
8444
8451
|
net_target_amount: netTarget.toString(),
|
|
8445
|
-
bridge_fee: bridgeFee > 0n ? Number(bridgeFee) : void 0
|
|
8452
|
+
bridge_fee: bridgeFee > 0n ? Number(bridgeFee) : void 0,
|
|
8453
|
+
promo: deps.referralPromo
|
|
8446
8454
|
};
|
|
8447
8455
|
}
|
|
8448
8456
|
async function dexSourcePinned(btcSats, params, deps, btcPegged, pivotChainId, toToken, pivotScale) {
|
|
@@ -8551,7 +8559,8 @@ async function composeEvmToBtc(params, deps) {
|
|
|
8551
8559
|
);
|
|
8552
8560
|
}
|
|
8553
8561
|
const { btcSats, evmSmallest, evmDecimals, bridgeFee } = pivot;
|
|
8554
|
-
|
|
8562
|
+
ensureWithinPromoCap(deps, btcSats);
|
|
8563
|
+
const effectiveFeePct = baseFeePct(deps, pair.fee_percentage) + (_nullishCoalesce(deps.referralExtraFeeRate, () => ( 0)));
|
|
8555
8564
|
const FEE_SCALE = 10n ** 18n;
|
|
8556
8565
|
const feePctScaled = BigInt(Math.round(effectiveFeePct * Number(FEE_SCALE)));
|
|
8557
8566
|
const protocolFee = Number(btcSats * feePctScaled / FEE_SCALE);
|
|
@@ -8573,7 +8582,7 @@ async function composeEvmToBtc(params, deps) {
|
|
|
8573
8582
|
protocol_fee: protocolFee,
|
|
8574
8583
|
protocol_fee_rate: effectiveFeePct,
|
|
8575
8584
|
min_amount: pair.min_sats,
|
|
8576
|
-
max_amount: pair.max_sats,
|
|
8585
|
+
max_amount: maxSats(deps, pair.max_sats),
|
|
8577
8586
|
// EVM→BTC: the EVM source is the bridged side. The dex-quote already
|
|
8578
8587
|
// reports `evmSmallest` as the gross the user supplies (the inbound fee was
|
|
8579
8588
|
// folded onto it), so `source_amount` needs no adjustment — just surface
|
|
@@ -8582,7 +8591,8 @@ async function composeEvmToBtc(params, deps) {
|
|
|
8582
8591
|
target_amount: btcSats.toString(),
|
|
8583
8592
|
net_source_amount: netSource.toString(),
|
|
8584
8593
|
net_target_amount: netTarget.toString(),
|
|
8585
|
-
bridge_fee: bridgeFee > 0n ? Number(bridgeFee) : void 0
|
|
8594
|
+
bridge_fee: bridgeFee > 0n ? Number(bridgeFee) : void 0,
|
|
8595
|
+
promo: deps.referralPromo
|
|
8586
8596
|
};
|
|
8587
8597
|
}
|
|
8588
8598
|
async function dexEvmToBtcSourcePinned(evmSmallest, params, deps, btcPegged, pivotChainId, tokenChainId, pivotScale) {
|
|
@@ -8636,22 +8646,36 @@ function calculateExchangeRate(btcSats, evmSmallest, evmDecimals) {
|
|
|
8636
8646
|
frac = frac.replace(/0+$/, "");
|
|
8637
8647
|
return frac.length === 0 ? intPart.toString() : `${intPart}.${frac}`;
|
|
8638
8648
|
}
|
|
8649
|
+
function baseFeePct(deps, pairFeePct) {
|
|
8650
|
+
return _nullishCoalesce(_nullishCoalesce(_optionalChain([deps, 'access', _61 => _61.referralPromo, 'optionalAccess', _62 => _62.fee_rate]), () => ( deps.referralBaseFeeRate)), () => ( pairFeePct));
|
|
8651
|
+
}
|
|
8652
|
+
function ensureWithinPromoCap(deps, btcSats) {
|
|
8653
|
+
const promo = deps.referralPromo;
|
|
8654
|
+
if (promo && btcSats > BigInt(promo.max_amount_sats)) {
|
|
8655
|
+
throw new Error(
|
|
8656
|
+
`promo code only applies to swaps up to ${promo.max_amount_sats} sats`
|
|
8657
|
+
);
|
|
8658
|
+
}
|
|
8659
|
+
}
|
|
8660
|
+
function maxSats(deps, pairMaxSats) {
|
|
8661
|
+
return deps.referralPromo ? Math.max(pairMaxSats, deps.referralPromo.max_amount_sats) : pairMaxSats;
|
|
8662
|
+
}
|
|
8639
8663
|
_chunk5JR6AJ3Ycjs.init_sha2.call(void 0, );
|
|
8640
8664
|
_chunk5JR6AJ3Ycjs.init_utils.call(void 0, );
|
|
8641
8665
|
_chunkBEW62OUTcjs.init_bip32.call(void 0, );
|
|
8642
8666
|
function pbkdf2Init(hash, _password, _salt, _opts) {
|
|
8643
|
-
|
|
8644
|
-
const opts =
|
|
8667
|
+
_chunkQJ4EK6UGcjs.ahash.call(void 0, hash);
|
|
8668
|
+
const opts = _chunkQJ4EK6UGcjs.checkOpts.call(void 0, { dkLen: 32, asyncTick: 10 }, _opts);
|
|
8645
8669
|
const { c, dkLen, asyncTick } = opts;
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8670
|
+
_chunkQJ4EK6UGcjs.anumber.call(void 0, c, "c");
|
|
8671
|
+
_chunkQJ4EK6UGcjs.anumber.call(void 0, dkLen, "dkLen");
|
|
8672
|
+
_chunkQJ4EK6UGcjs.anumber.call(void 0, asyncTick, "asyncTick");
|
|
8649
8673
|
if (c < 1)
|
|
8650
8674
|
throw new Error("iterations (c) must be >= 1");
|
|
8651
|
-
const password =
|
|
8652
|
-
const salt =
|
|
8675
|
+
const password = _chunkQJ4EK6UGcjs.kdfInputToBytes.call(void 0, _password, "password");
|
|
8676
|
+
const salt = _chunkQJ4EK6UGcjs.kdfInputToBytes.call(void 0, _salt, "salt");
|
|
8653
8677
|
const DK = new Uint8Array(dkLen);
|
|
8654
|
-
const PRF =
|
|
8678
|
+
const PRF = _chunkQJ4EK6UGcjs.hmac.create(hash, password);
|
|
8655
8679
|
const PRFSalt = PRF._cloneInto().update(salt);
|
|
8656
8680
|
return { c, dkLen, asyncTick, DK, PRF, PRFSalt };
|
|
8657
8681
|
}
|
|
@@ -8660,14 +8684,14 @@ function pbkdf2Output(PRF, PRFSalt, DK, prfW, u) {
|
|
|
8660
8684
|
PRFSalt.destroy();
|
|
8661
8685
|
if (prfW)
|
|
8662
8686
|
prfW.destroy();
|
|
8663
|
-
|
|
8687
|
+
_chunkQJ4EK6UGcjs.clean.call(void 0, u);
|
|
8664
8688
|
return DK;
|
|
8665
8689
|
}
|
|
8666
8690
|
function pbkdf2(hash, password, salt, opts) {
|
|
8667
8691
|
const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts);
|
|
8668
8692
|
let prfW;
|
|
8669
8693
|
const arr = new Uint8Array(4);
|
|
8670
|
-
const view =
|
|
8694
|
+
const view = _chunkQJ4EK6UGcjs.createView.call(void 0, arr);
|
|
8671
8695
|
const u = new Uint8Array(PRF.outputLen);
|
|
8672
8696
|
for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) {
|
|
8673
8697
|
const Ti = DK.subarray(pos, pos + PRF.outputLen);
|
|
@@ -8696,19 +8720,19 @@ function normalize(str) {
|
|
|
8696
8720
|
return { nfkd: norm, words };
|
|
8697
8721
|
}
|
|
8698
8722
|
function aentropy(ent) {
|
|
8699
|
-
|
|
8723
|
+
_chunkQJ4EK6UGcjs.abytes.call(void 0, ent);
|
|
8700
8724
|
if (![16, 20, 24, 28, 32].includes(ent.length))
|
|
8701
8725
|
throw new Error("invalid entropy length");
|
|
8702
8726
|
}
|
|
8703
8727
|
function generateMnemonic(wordlist2, strength = 128) {
|
|
8704
|
-
|
|
8728
|
+
_chunkQJ4EK6UGcjs.anumber.call(void 0, strength);
|
|
8705
8729
|
if (strength % 32 !== 0 || strength > 256)
|
|
8706
8730
|
throw new TypeError("Invalid entropy");
|
|
8707
|
-
return entropyToMnemonic(
|
|
8731
|
+
return entropyToMnemonic(_chunkQJ4EK6UGcjs.randomBytes.call(void 0, strength / 8), wordlist2);
|
|
8708
8732
|
}
|
|
8709
8733
|
var calcChecksum = (entropy) => {
|
|
8710
8734
|
const bitsLeft = 8 - entropy.length / 4;
|
|
8711
|
-
return new Uint8Array([
|
|
8735
|
+
return new Uint8Array([_chunkQJ4EK6UGcjs.sha2562.call(void 0, entropy)[0] >> bitsLeft << bitsLeft]);
|
|
8712
8736
|
};
|
|
8713
8737
|
function getCoder(wordlist2) {
|
|
8714
8738
|
if (!Array.isArray(wordlist2) || wordlist2.length !== 2048 || typeof wordlist2[0] !== "string")
|
|
@@ -8717,7 +8741,7 @@ function getCoder(wordlist2) {
|
|
|
8717
8741
|
if (typeof i !== "string")
|
|
8718
8742
|
throw new Error("wordlist: non-string element: " + i);
|
|
8719
8743
|
});
|
|
8720
|
-
return
|
|
8744
|
+
return _chunkQJ4EK6UGcjs.utils.chain(_chunkQJ4EK6UGcjs.utils.checksum(1, calcChecksum), _chunkQJ4EK6UGcjs.utils.radix2(11, true), _chunkQJ4EK6UGcjs.utils.alphabet(wordlist2));
|
|
8721
8745
|
}
|
|
8722
8746
|
function mnemonicToEntropy(mnemonic, wordlist2) {
|
|
8723
8747
|
const { words } = normalize(mnemonic);
|
|
@@ -8740,7 +8764,7 @@ function validateMnemonic(mnemonic, wordlist2) {
|
|
|
8740
8764
|
}
|
|
8741
8765
|
var psalt = (passphrase) => nfkd("mnemonic" + passphrase);
|
|
8742
8766
|
function mnemonicToSeedSync(mnemonic, passphrase = "") {
|
|
8743
|
-
return pbkdf2(
|
|
8767
|
+
return pbkdf2(_chunkQJ4EK6UGcjs.sha512, normalize(mnemonic).nfkd, psalt(passphrase), { c: 2048, dkLen: 64 });
|
|
8744
8768
|
}
|
|
8745
8769
|
var wordlist = `abandon
|
|
8746
8770
|
ability
|
|
@@ -11058,12 +11082,12 @@ function parseXOnlyPubKey(pubKeyHex) {
|
|
|
11058
11082
|
);
|
|
11059
11083
|
}
|
|
11060
11084
|
function refundableVhtlc(params) {
|
|
11061
|
-
if (params.scriptVersion !== void 0 && params.scriptVersion !==
|
|
11085
|
+
if (params.scriptVersion !== void 0 && params.scriptVersion !== _chunkQJ4EK6UGcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
|
|
11062
11086
|
throw new Error(
|
|
11063
11087
|
`Unsupported Arkade HTLC script version: ${params.scriptVersion}`
|
|
11064
11088
|
);
|
|
11065
11089
|
}
|
|
11066
|
-
return new (0,
|
|
11090
|
+
return new (0, _chunkQJ4EK6UGcjs.StrictVhtlcScript)({
|
|
11067
11091
|
sender: parseXOnlyPubKey(params.senderPubKey),
|
|
11068
11092
|
receiver: parseXOnlyPubKey(params.receiverPubKey),
|
|
11069
11093
|
server: parseXOnlyPubKey(params.serverPubKey),
|
|
@@ -11114,8 +11138,8 @@ async function buildArkadeRefund(params) {
|
|
|
11114
11138
|
`Invalid hash lock length: expected 20 or 32, got ${hashLockBytes.length}`
|
|
11115
11139
|
);
|
|
11116
11140
|
}
|
|
11117
|
-
const networkName =
|
|
11118
|
-
const serverUrl =
|
|
11141
|
+
const networkName = _chunkQJ4EK6UGcjs.getNetworkName.call(void 0, network);
|
|
11142
|
+
const serverUrl = _chunkQJ4EK6UGcjs.resolveArkadeServerUrlByName.call(void 0, networkName, arkadeServerUrl);
|
|
11119
11143
|
const arkProvider = new (0, _chunkBEW62OUTcjs.RestOperatorProvider)(serverUrl);
|
|
11120
11144
|
const indexerProvider = new (0, _chunkBEW62OUTcjs.RestIndexerProvider)(serverUrl);
|
|
11121
11145
|
const serverInfo = await arkProvider.getInfo();
|
|
@@ -11130,7 +11154,7 @@ async function buildArkadeRefund(params) {
|
|
|
11130
11154
|
unilateralRefundWithoutReceiverDelay,
|
|
11131
11155
|
scriptVersion: arkadeHtlcScriptVersion
|
|
11132
11156
|
});
|
|
11133
|
-
const hrp =
|
|
11157
|
+
const hrp = _chunkQJ4EK6UGcjs.getNetworkHrp.call(void 0, networkName);
|
|
11134
11158
|
const computedAddress = vhtlc.address(hrp, serverPkBytes);
|
|
11135
11159
|
const computedAddressStr = computedAddress.encode();
|
|
11136
11160
|
if (computedAddressStr !== vhtlcAddress) {
|
|
@@ -11227,10 +11251,10 @@ var REGTEST_NETWORK = {
|
|
|
11227
11251
|
function getNetwork(network) {
|
|
11228
11252
|
switch (network) {
|
|
11229
11253
|
case "mainnet":
|
|
11230
|
-
return
|
|
11254
|
+
return _chunkQJ4EK6UGcjs.NETWORK;
|
|
11231
11255
|
case "testnet":
|
|
11232
11256
|
case "signet":
|
|
11233
|
-
return
|
|
11257
|
+
return _chunkQJ4EK6UGcjs.TEST_NETWORK;
|
|
11234
11258
|
case "regtest":
|
|
11235
11259
|
return REGTEST_NETWORK;
|
|
11236
11260
|
default:
|
|
@@ -11253,10 +11277,10 @@ function buildHashlockScript(hashLock, serverPubKey, btcHtlcScriptVersion = 1) {
|
|
|
11253
11277
|
hashLock,
|
|
11254
11278
|
"EQUAL"
|
|
11255
11279
|
];
|
|
11256
|
-
return
|
|
11280
|
+
return _chunkQJ4EK6UGcjs.Script.encode(script);
|
|
11257
11281
|
}
|
|
11258
11282
|
function buildTimelockScript(userPubKey, refundLocktime) {
|
|
11259
|
-
return
|
|
11283
|
+
return _chunkQJ4EK6UGcjs.Script.encode([
|
|
11260
11284
|
refundLocktime,
|
|
11261
11285
|
"CHECKLOCKTIMEVERIFY",
|
|
11262
11286
|
"DROP",
|
|
@@ -11274,7 +11298,7 @@ function buildHtlcTaprootInfo(hashLock, serverPubKey, userPubKey, refundLocktime
|
|
|
11274
11298
|
btcHtlcScriptVersion
|
|
11275
11299
|
);
|
|
11276
11300
|
const timelockScript = buildTimelockScript(userPubKey, refundLocktime);
|
|
11277
|
-
const p2tr2 =
|
|
11301
|
+
const p2tr2 = _chunkQJ4EK6UGcjs.p2tr.call(void 0,
|
|
11278
11302
|
NUMS_POINT.slice(1),
|
|
11279
11303
|
// Remove the 02/03 prefix for x-only
|
|
11280
11304
|
[{ script: hashlockScript }, { script: timelockScript }],
|
|
@@ -11357,7 +11381,7 @@ function buildOnchainClaimTransaction(params) {
|
|
|
11357
11381
|
throw new Error("Failed to build tapLeafScript for hashlock");
|
|
11358
11382
|
}
|
|
11359
11383
|
const hashlockLeaf = tapLeafScript[0];
|
|
11360
|
-
const tx = new (0,
|
|
11384
|
+
const tx = new (0, _chunkQJ4EK6UGcjs.Transaction2)({
|
|
11361
11385
|
allowUnknownOutputs: true,
|
|
11362
11386
|
allowUnknownInputs: true
|
|
11363
11387
|
});
|
|
@@ -11378,7 +11402,7 @@ function buildOnchainClaimTransaction(params) {
|
|
|
11378
11402
|
const sighash = tx.preimageWitnessV1(
|
|
11379
11403
|
0,
|
|
11380
11404
|
[p2tr2.script],
|
|
11381
|
-
|
|
11405
|
+
_chunkQJ4EK6UGcjs.SigHash.DEFAULT,
|
|
11382
11406
|
[htlcAmount],
|
|
11383
11407
|
void 0,
|
|
11384
11408
|
leafScript,
|
|
@@ -11399,7 +11423,7 @@ function buildOnchainClaimTransaction(params) {
|
|
|
11399
11423
|
});
|
|
11400
11424
|
const txHex = _chunkRYZSWESUcjs.hex.encode(tx.extract());
|
|
11401
11425
|
const txId = tx.id;
|
|
11402
|
-
const htlcAddress2 =
|
|
11426
|
+
const htlcAddress2 = _chunkQJ4EK6UGcjs.Address.call(void 0, networkConfig).encode({
|
|
11403
11427
|
type: "tr",
|
|
11404
11428
|
pubkey: p2tr2.tweakedPubkey
|
|
11405
11429
|
});
|
|
@@ -11469,7 +11493,7 @@ function buildOnchainRefundTransaction(params) {
|
|
|
11469
11493
|
throw new Error("Failed to build tapLeafScript for timelock");
|
|
11470
11494
|
}
|
|
11471
11495
|
const timelockLeaf = tapLeafScript[1];
|
|
11472
|
-
const tx = new (0,
|
|
11496
|
+
const tx = new (0, _chunkQJ4EK6UGcjs.Transaction2)({
|
|
11473
11497
|
allowUnknownOutputs: true,
|
|
11474
11498
|
allowUnknownInputs: true,
|
|
11475
11499
|
lockTime: refundLocktime
|
|
@@ -11490,7 +11514,7 @@ function buildOnchainRefundTransaction(params) {
|
|
|
11490
11514
|
tx.finalize();
|
|
11491
11515
|
const txHex = _chunkRYZSWESUcjs.hex.encode(tx.extract());
|
|
11492
11516
|
const txId = tx.id;
|
|
11493
|
-
const htlcAddress2 =
|
|
11517
|
+
const htlcAddress2 = _chunkQJ4EK6UGcjs.Address.call(void 0, networkConfig).encode({
|
|
11494
11518
|
type: "tr",
|
|
11495
11519
|
pubkey: p2tr2.tweakedPubkey
|
|
11496
11520
|
});
|
|
@@ -11523,7 +11547,7 @@ function htlcAddress(hashLock, serverPubKey, userPubKey, refundLocktime, network
|
|
|
11523
11547
|
refundLocktime,
|
|
11524
11548
|
btcHtlcScriptVersion
|
|
11525
11549
|
);
|
|
11526
|
-
return
|
|
11550
|
+
return _chunkQJ4EK6UGcjs.Address.call(void 0, getNetwork(network)).encode({
|
|
11527
11551
|
type: "tr",
|
|
11528
11552
|
pubkey: p2tr2.tweakedPubkey
|
|
11529
11553
|
});
|
|
@@ -11640,12 +11664,12 @@ function checkedLightningPaymentHash(options, data) {
|
|
|
11640
11664
|
}
|
|
11641
11665
|
function assertFundedVhtlc(response, addressField, address2, hash160, refundPublicKey, lockDescription) {
|
|
11642
11666
|
const swapId = response.id;
|
|
11643
|
-
if (response.arkade_htlc_script_version !==
|
|
11667
|
+
if (response.arkade_htlc_script_version !== _chunkQJ4EK6UGcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
|
|
11644
11668
|
throw new SwapVerificationError(
|
|
11645
11669
|
`Swap ${swapId} uses Arkade HTLC script version ${response.arkade_htlc_script_version}, which this client cannot refund; do not fund it`,
|
|
11646
11670
|
{
|
|
11647
11671
|
field: "arkade_htlc_script_version",
|
|
11648
|
-
expected: String(
|
|
11672
|
+
expected: String(_chunkQJ4EK6UGcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT),
|
|
11649
11673
|
received: String(response.arkade_htlc_script_version),
|
|
11650
11674
|
swapId
|
|
11651
11675
|
}
|
|
@@ -11662,7 +11686,7 @@ function assertFundedVhtlc(response, addressField, address2, hash160, refundPubl
|
|
|
11662
11686
|
unilateralRefundDelay: response.unilateral_refund_delay,
|
|
11663
11687
|
unilateralRefundWithoutReceiverDelay: response.unilateral_refund_without_receiver_delay
|
|
11664
11688
|
});
|
|
11665
|
-
const expected = vhtlc.address(
|
|
11689
|
+
const expected = vhtlc.address(_chunkQJ4EK6UGcjs.getNetworkHrp.call(void 0, _chunkQJ4EK6UGcjs.getNetworkName.call(void 0, response.network)), server).encode();
|
|
11666
11690
|
if (expected !== address2) {
|
|
11667
11691
|
throw new SwapVerificationError(
|
|
11668
11692
|
`Swap ${swapId}'s VHTLC address ${address2} does not lock to ${lockDescription} and this client's refund key (expected ${expected}); do not fund it`,
|
|
@@ -11706,12 +11730,12 @@ function assertHashLock(swapId, field, hashLock, accepted) {
|
|
|
11706
11730
|
}
|
|
11707
11731
|
function assertFundedHtlc(response, hashField, hashLock, serverPk, hash160, refundPublicKey, lockDescription) {
|
|
11708
11732
|
const swapId = response.id;
|
|
11709
|
-
if (response.btc_htlc_script_version !==
|
|
11733
|
+
if (response.btc_htlc_script_version !== _chunkQJ4EK6UGcjs.BTC_HTLC_SCRIPT_VERSION_STRICT) {
|
|
11710
11734
|
throw new SwapVerificationError(
|
|
11711
11735
|
`Swap ${swapId} uses Bitcoin HTLC script version ${response.btc_htlc_script_version}, which this client cannot refund; do not fund it`,
|
|
11712
11736
|
{
|
|
11713
11737
|
field: "btc_htlc_script_version",
|
|
11714
|
-
expected: String(
|
|
11738
|
+
expected: String(_chunkQJ4EK6UGcjs.BTC_HTLC_SCRIPT_VERSION_STRICT),
|
|
11715
11739
|
received: String(response.btc_htlc_script_version),
|
|
11716
11740
|
swapId
|
|
11717
11741
|
}
|
|
@@ -11724,7 +11748,7 @@ function assertFundedHtlc(response, hashField, hashLock, serverPk, hash160, refu
|
|
|
11724
11748
|
{ field: hashField, expected: hash160, received: serverHash160, swapId }
|
|
11725
11749
|
);
|
|
11726
11750
|
}
|
|
11727
|
-
const name =
|
|
11751
|
+
const name = _chunkQJ4EK6UGcjs.getNetworkName.call(void 0, response.network);
|
|
11728
11752
|
const network = name === "bitcoin" ? "mainnet" : name === "mutinynet" ? "signet" : name;
|
|
11729
11753
|
const binds = verifyHtlcAddress(
|
|
11730
11754
|
response.btc_htlc_address,
|
|
@@ -11797,6 +11821,9 @@ function recoveredKeysChange(stored, index, derivedPreimageHash) {
|
|
|
11797
11821
|
function unboundTerms(fresh, swapParams) {
|
|
11798
11822
|
try {
|
|
11799
11823
|
switch (fresh.direction) {
|
|
11824
|
+
case "spark_to_evm":
|
|
11825
|
+
assertSparkFunding(fresh, _chunk5JR6AJ3Ycjs.bytesToHex.call(void 0, swapParams.preimageHash));
|
|
11826
|
+
break;
|
|
11800
11827
|
case "lightning_to_arkade":
|
|
11801
11828
|
case "lightning_to_evm":
|
|
11802
11829
|
case "lightning_to_bitcoin":
|
|
@@ -11878,6 +11905,7 @@ var PAYOUT_FIELD = {
|
|
|
11878
11905
|
arkade_to_evm: "target_evm_address",
|
|
11879
11906
|
bitcoin_to_evm: "target_evm_address",
|
|
11880
11907
|
lightning_to_evm: "target_evm_address",
|
|
11908
|
+
spark_to_evm: "target_evm_address",
|
|
11881
11909
|
evm_to_bitcoin: "target_btc_address",
|
|
11882
11910
|
lightning_to_bitcoin: "target_btc_address",
|
|
11883
11911
|
btc_to_arkade: "target_arkade_address",
|
|
@@ -11931,6 +11959,15 @@ function withStoredTerms(stored, fresh, refused) {
|
|
|
11931
11959
|
if (field in before) kept[field] = before[field];
|
|
11932
11960
|
else if (condemned.includes(field)) delete kept[field];
|
|
11933
11961
|
}
|
|
11962
|
+
if (stored.response.direction === "spark_to_evm") {
|
|
11963
|
+
const original = stored.response;
|
|
11964
|
+
kept.funding = {
|
|
11965
|
+
...original.funding,
|
|
11966
|
+
payment_id: fresh.direction === "spark_to_evm" ? _nullishCoalesce(_optionalChain([fresh, 'access', _63 => _63.funding, 'optionalAccess', _64 => _64.payment_id]), () => ( original.funding.payment_id)) : original.funding.payment_id
|
|
11967
|
+
};
|
|
11968
|
+
kept.source_amount = original.source_amount;
|
|
11969
|
+
kept.network = original.network;
|
|
11970
|
+
}
|
|
11934
11971
|
return kept;
|
|
11935
11972
|
}
|
|
11936
11973
|
function swapTermsChange(stored, fresh) {
|
|
@@ -11954,6 +11991,30 @@ function swapTermsChange(stored, fresh) {
|
|
|
11954
11991
|
};
|
|
11955
11992
|
const payout = _nullishCoalesce(compare(["direction", "bridge_target_chain"], (value) => value), () => ( compare(PAYOUT_FIELDS, addressKey)));
|
|
11956
11993
|
if (payout) return payout;
|
|
11994
|
+
if (stored.response.direction === "spark_to_evm" && fresh.direction === "spark_to_evm") {
|
|
11995
|
+
const old = stored.response;
|
|
11996
|
+
if (old.funding.address !== fresh.funding.address)
|
|
11997
|
+
return changed(
|
|
11998
|
+
"funding.address",
|
|
11999
|
+
old.funding.address,
|
|
12000
|
+
fresh.funding.address
|
|
12001
|
+
);
|
|
12002
|
+
if (old.funding.expiry_duration_secs !== fresh.funding.expiry_duration_secs)
|
|
12003
|
+
return changed(
|
|
12004
|
+
"funding.expiry_duration_secs",
|
|
12005
|
+
String(old.funding.expiry_duration_secs),
|
|
12006
|
+
String(fresh.funding.expiry_duration_secs)
|
|
12007
|
+
);
|
|
12008
|
+
if (old.source_amount !== fresh.source_amount)
|
|
12009
|
+
return changed("source_amount", old.source_amount, fresh.source_amount);
|
|
12010
|
+
if (old.network !== fresh.network)
|
|
12011
|
+
return changed("network", old.network, fresh.network);
|
|
12012
|
+
try {
|
|
12013
|
+
assertSparkFunding(fresh, stored.preimageHash);
|
|
12014
|
+
} catch (error) {
|
|
12015
|
+
return error instanceof SwapVerificationError ? error : changed("funding", "valid native Spark terms", String(error));
|
|
12016
|
+
}
|
|
12017
|
+
}
|
|
11957
12018
|
if (EVM_SOURCED.has(stored.response.direction)) return void 0;
|
|
11958
12019
|
const difference = _nullishCoalesce(_nullishCoalesce(compare(HASH_FIELDS, normalizeHash), () => ( compare(ADDRESS_FIELDS, (address2) => address2.toLowerCase()))), () => ( compare(INVOICE_FIELDS, invoiceKey)));
|
|
11959
12020
|
if (difference) return difference;
|
|
@@ -11971,6 +12032,50 @@ function swapTermsChange(stored, fresh) {
|
|
|
11971
12032
|
}
|
|
11972
12033
|
return void 0;
|
|
11973
12034
|
}
|
|
12035
|
+
function assertSparkFunding(data, ownHash) {
|
|
12036
|
+
const fail = (field, expected, received) => {
|
|
12037
|
+
throw new SwapVerificationError("Invalid native Spark funding terms", {
|
|
12038
|
+
field,
|
|
12039
|
+
expected,
|
|
12040
|
+
received,
|
|
12041
|
+
swapId: data.id
|
|
12042
|
+
});
|
|
12043
|
+
};
|
|
12044
|
+
if (normalizeHash(data.hash_lock) !== normalizeHash(ownHash)) {
|
|
12045
|
+
fail("hash_lock", ownHash, data.hash_lock);
|
|
12046
|
+
}
|
|
12047
|
+
let prefix;
|
|
12048
|
+
try {
|
|
12049
|
+
prefix = _chunkRYZSWESUcjs.bech32m.decode(
|
|
12050
|
+
data.funding.address,
|
|
12051
|
+
1023
|
|
12052
|
+
).prefix;
|
|
12053
|
+
} catch (e6) {
|
|
12054
|
+
fail(
|
|
12055
|
+
"funding.address",
|
|
12056
|
+
"valid Spark bech32m address",
|
|
12057
|
+
data.funding.address
|
|
12058
|
+
);
|
|
12059
|
+
return;
|
|
12060
|
+
}
|
|
12061
|
+
const expectedPrefix = data.network === "bitcoin" ? "spark" : data.network === "regtest" ? "sparkrt" : void 0;
|
|
12062
|
+
if (!expectedPrefix || prefix !== expectedPrefix)
|
|
12063
|
+
fail(
|
|
12064
|
+
"funding.address",
|
|
12065
|
+
_nullishCoalesce(expectedPrefix, () => ( "supported Spark network")),
|
|
12066
|
+
prefix
|
|
12067
|
+
);
|
|
12068
|
+
if (!Number.isSafeInteger(data.funding.expiry_duration_secs) || data.funding.expiry_duration_secs <= 0) {
|
|
12069
|
+
fail(
|
|
12070
|
+
"funding.expiry_duration_secs",
|
|
12071
|
+
"positive safe integer",
|
|
12072
|
+
String(data.funding.expiry_duration_secs)
|
|
12073
|
+
);
|
|
12074
|
+
}
|
|
12075
|
+
if (!/^[1-9][0-9]*$/.test(data.source_amount) || BigInt(data.source_amount) > 18446744073709551615n) {
|
|
12076
|
+
fail("source_amount", "positive u64 sats", data.source_amount);
|
|
12077
|
+
}
|
|
12078
|
+
}
|
|
11974
12079
|
var MAX_RETRIES = 10;
|
|
11975
12080
|
var SKIP_COUNT = 10;
|
|
11976
12081
|
function isHashCollisionError(message) {
|
|
@@ -12013,7 +12118,7 @@ async function createArkadeToEvmSwapGeneric(options, ctx, claimingAddressOverrid
|
|
|
12013
12118
|
const claimingAddress = _nullishCoalesce(claimingAddressOverride, () => ( deriveEvmAddress(swapParams.secretKey)));
|
|
12014
12119
|
const body = {
|
|
12015
12120
|
hash_lock: hashLock,
|
|
12016
|
-
arkade_htlc_script_version:
|
|
12121
|
+
arkade_htlc_script_version: _chunkQJ4EK6UGcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT,
|
|
12017
12122
|
refund_pk: refundPk,
|
|
12018
12123
|
user_id: userId,
|
|
12019
12124
|
claiming_address: claimingAddress,
|
|
@@ -12021,13 +12126,14 @@ async function createArkadeToEvmSwapGeneric(options, ctx, claimingAddressOverrid
|
|
|
12021
12126
|
token_address: options.tokenAddress,
|
|
12022
12127
|
evm_chain_id: options.evmChainId,
|
|
12023
12128
|
amount_in: options.sourceAmount ? Number(options.sourceAmount) : void 0,
|
|
12024
|
-
amount_out: _optionalChain([options, 'access',
|
|
12129
|
+
amount_out: _optionalChain([options, 'access', _65 => _65.targetAmount, 'optionalAccess', _66 => _66.toString, 'call', _67 => _67()]),
|
|
12025
12130
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12026
12131
|
extra_fees: options.extraFees,
|
|
12132
|
+
promo_code: options.promoCode,
|
|
12027
12133
|
gasless: _nullishCoalesce(options.gasless, () => ( true)),
|
|
12028
|
-
bridge_target_chain: _optionalChain([options, 'access',
|
|
12029
|
-
bridge_target_token_address: _optionalChain([options, 'access',
|
|
12030
|
-
bridge_recipient_setup: _optionalChain([options, 'access',
|
|
12134
|
+
bridge_target_chain: _optionalChain([options, 'access', _68 => _68.bridgeParams, 'optionalAccess', _69 => _69.targetChain]),
|
|
12135
|
+
bridge_target_token_address: _optionalChain([options, 'access', _70 => _70.bridgeParams, 'optionalAccess', _71 => _71.targetTokenAddress]),
|
|
12136
|
+
bridge_recipient_setup: _optionalChain([options, 'access', _72 => _72.bridgeParams, 'optionalAccess', _73 => _73.recipientSetup])
|
|
12031
12137
|
};
|
|
12032
12138
|
const { data, error } = await ctx.apiClient.POST("/swap/arkade/evm", {
|
|
12033
12139
|
body
|
|
@@ -12050,8 +12156,8 @@ async function createArkadeToEvmSwapGeneric(options, ctx, claimingAddressOverrid
|
|
|
12050
12156
|
},
|
|
12051
12157
|
options.targetAddress,
|
|
12052
12158
|
{
|
|
12053
|
-
recipient: _optionalChain([options, 'access',
|
|
12054
|
-
recipientWallet: _optionalChain([options, 'access',
|
|
12159
|
+
recipient: _optionalChain([options, 'access', _74 => _74.bridgeParams, 'optionalAccess', _75 => _75.recipient]),
|
|
12160
|
+
recipientWallet: _optionalChain([options, 'access', _76 => _76.bridgeParams, 'optionalAccess', _77 => _77.recipientWallet])
|
|
12055
12161
|
}
|
|
12056
12162
|
);
|
|
12057
12163
|
return { response: data, swapParams };
|
|
@@ -12087,9 +12193,10 @@ async function createArkadeToLightningSwap(options, ctx) {
|
|
|
12087
12193
|
target_amount_sats: options.targetAmountSats,
|
|
12088
12194
|
refund_pk: refundPk,
|
|
12089
12195
|
user_id: userId,
|
|
12090
|
-
arkade_htlc_script_version:
|
|
12196
|
+
arkade_htlc_script_version: _chunkQJ4EK6UGcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT,
|
|
12091
12197
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12092
|
-
extra_fees: options.extraFees
|
|
12198
|
+
extra_fees: options.extraFees,
|
|
12199
|
+
promo_code: options.promoCode
|
|
12093
12200
|
};
|
|
12094
12201
|
const { data, error } = await ctx.apiClient.POST("/swap/arkade/lightning", {
|
|
12095
12202
|
body
|
|
@@ -12118,7 +12225,7 @@ async function createBitcoinToEvmSwap(options, ctx, claimingAddressOverride) {
|
|
|
12118
12225
|
const claimingAddress = _nullishCoalesce(claimingAddressOverride, () => ( deriveEvmAddress(swapParams.secretKey)));
|
|
12119
12226
|
const body = {
|
|
12120
12227
|
hash_lock: hashLock,
|
|
12121
|
-
btc_htlc_script_version:
|
|
12228
|
+
btc_htlc_script_version: _chunkQJ4EK6UGcjs.BTC_HTLC_SCRIPT_VERSION_STRICT,
|
|
12122
12229
|
refund_pk: refundPk,
|
|
12123
12230
|
user_id: userId,
|
|
12124
12231
|
claiming_address: claimingAddress,
|
|
@@ -12126,13 +12233,14 @@ async function createBitcoinToEvmSwap(options, ctx, claimingAddressOverride) {
|
|
|
12126
12233
|
token_address: options.tokenAddress,
|
|
12127
12234
|
evm_chain_id: options.evmChainId,
|
|
12128
12235
|
amount_in: options.sourceAmount,
|
|
12129
|
-
amount_out: _optionalChain([options, 'access',
|
|
12236
|
+
amount_out: _optionalChain([options, 'access', _78 => _78.targetAmount, 'optionalAccess', _79 => _79.toString, 'call', _80 => _80()]),
|
|
12130
12237
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12131
12238
|
extra_fees: options.extraFees,
|
|
12239
|
+
promo_code: options.promoCode,
|
|
12132
12240
|
gasless: _nullishCoalesce(options.gasless, () => ( true)),
|
|
12133
|
-
bridge_target_chain: _optionalChain([options, 'access',
|
|
12134
|
-
bridge_target_token_address: _optionalChain([options, 'access',
|
|
12135
|
-
bridge_recipient_setup: _optionalChain([options, 'access',
|
|
12241
|
+
bridge_target_chain: _optionalChain([options, 'access', _81 => _81.bridgeParams, 'optionalAccess', _82 => _82.targetChain]),
|
|
12242
|
+
bridge_target_token_address: _optionalChain([options, 'access', _83 => _83.bridgeParams, 'optionalAccess', _84 => _84.targetTokenAddress]),
|
|
12243
|
+
bridge_recipient_setup: _optionalChain([options, 'access', _85 => _85.bridgeParams, 'optionalAccess', _86 => _86.recipientSetup])
|
|
12136
12244
|
};
|
|
12137
12245
|
const { data, error } = await ctx.apiClient.POST("/swap/bitcoin/evm", {
|
|
12138
12246
|
body
|
|
@@ -12155,8 +12263,8 @@ async function createBitcoinToEvmSwap(options, ctx, claimingAddressOverride) {
|
|
|
12155
12263
|
},
|
|
12156
12264
|
options.targetAddress,
|
|
12157
12265
|
{
|
|
12158
|
-
recipient: _optionalChain([options, 'access',
|
|
12159
|
-
recipientWallet: _optionalChain([options, 'access',
|
|
12266
|
+
recipient: _optionalChain([options, 'access', _87 => _87.bridgeParams, 'optionalAccess', _88 => _88.recipient]),
|
|
12267
|
+
recipientWallet: _optionalChain([options, 'access', _89 => _89.bridgeParams, 'optionalAccess', _90 => _90.recipientWallet])
|
|
12160
12268
|
}
|
|
12161
12269
|
);
|
|
12162
12270
|
return { response: data, swapParams };
|
|
@@ -12180,8 +12288,9 @@ async function createBitcoinToArkadeSwap(options, ctx) {
|
|
|
12180
12288
|
target_arkade_address: options.targetAddress,
|
|
12181
12289
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12182
12290
|
extra_fees: options.extraFees,
|
|
12183
|
-
|
|
12184
|
-
|
|
12291
|
+
promo_code: options.promoCode,
|
|
12292
|
+
btc_htlc_script_version: _chunkQJ4EK6UGcjs.BTC_HTLC_SCRIPT_VERSION_STRICT,
|
|
12293
|
+
arkade_htlc_script_version: _chunkQJ4EK6UGcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT
|
|
12185
12294
|
};
|
|
12186
12295
|
const { data, error } = await ctx.apiClient.POST("/swap/bitcoin/arkade", {
|
|
12187
12296
|
body
|
|
@@ -12235,9 +12344,10 @@ async function createBitcoinToLightningSwap(options, ctx) {
|
|
|
12235
12344
|
target_amount_sats: options.targetAmountSats,
|
|
12236
12345
|
refund_pk: refundPk,
|
|
12237
12346
|
user_id: userId,
|
|
12238
|
-
btc_htlc_script_version:
|
|
12347
|
+
btc_htlc_script_version: _chunkQJ4EK6UGcjs.BTC_HTLC_SCRIPT_VERSION_STRICT,
|
|
12239
12348
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12240
|
-
extra_fees: options.extraFees
|
|
12349
|
+
extra_fees: options.extraFees,
|
|
12350
|
+
promo_code: options.promoCode
|
|
12241
12351
|
};
|
|
12242
12352
|
const { data, error } = await ctx.apiClient.POST("/swap/bitcoin/lightning", {
|
|
12243
12353
|
body
|
|
@@ -12258,7 +12368,7 @@ async function createBitcoinToLightningSwap(options, ctx) {
|
|
|
12258
12368
|
return { response: data, swapParams };
|
|
12259
12369
|
}
|
|
12260
12370
|
function fundingTermsOf(data) {
|
|
12261
|
-
if (!data.evm_chain_id || !data.evm_coordinator_address || !data.evm_htlc_address || !data.server_evm_address || !data.evm_refund_locktime || data.source_amount === void 0 || data.source_amount === null || !_optionalChain([data, 'access',
|
|
12371
|
+
if (!data.evm_chain_id || !data.evm_coordinator_address || !data.evm_htlc_address || !data.server_evm_address || !data.evm_refund_locktime || data.source_amount === void 0 || data.source_amount === null || !_optionalChain([data, 'access', _91 => _91.source_token, 'optionalAccess', _92 => _92.token_id])) {
|
|
12262
12372
|
return void 0;
|
|
12263
12373
|
}
|
|
12264
12374
|
return {
|
|
@@ -12271,7 +12381,7 @@ function fundingTermsOf(data) {
|
|
|
12271
12381
|
timelock: data.evm_refund_locktime,
|
|
12272
12382
|
sourceToken: data.source_token.token_id.toLowerCase(),
|
|
12273
12383
|
sourceAmount: String(data.source_amount),
|
|
12274
|
-
lockToken: _optionalChain([data, 'access',
|
|
12384
|
+
lockToken: _optionalChain([data, 'access', _93 => _93.evm_htlc_token, 'optionalAccess', _94 => _94.toLowerCase, 'call', _95 => _95()])
|
|
12275
12385
|
};
|
|
12276
12386
|
}
|
|
12277
12387
|
async function createEvmToArkadeSwapGeneric(options, ctx) {
|
|
@@ -12295,10 +12405,11 @@ async function createEvmToArkadeSwapGeneric(options, ctx) {
|
|
|
12295
12405
|
amount_out: options.targetAmount ? Number(options.targetAmount) : void 0,
|
|
12296
12406
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12297
12407
|
extra_fees: options.extraFees,
|
|
12408
|
+
promo_code: options.promoCode,
|
|
12298
12409
|
gasless: _nullishCoalesce(options.gasless, () => ( false)),
|
|
12299
|
-
arkade_htlc_script_version:
|
|
12300
|
-
bridge_source_chain: _optionalChain([options, 'access',
|
|
12301
|
-
bridge_source_token_address: _optionalChain([options, 'access',
|
|
12410
|
+
arkade_htlc_script_version: _chunkQJ4EK6UGcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT,
|
|
12411
|
+
bridge_source_chain: _optionalChain([options, 'access', _96 => _96.inboundBridgeParams, 'optionalAccess', _97 => _97.sourceChain]),
|
|
12412
|
+
bridge_source_token_address: _optionalChain([options, 'access', _98 => _98.inboundBridgeParams, 'optionalAccess', _99 => _99.sourceTokenAddress])
|
|
12302
12413
|
}
|
|
12303
12414
|
});
|
|
12304
12415
|
if (error) {
|
|
@@ -12332,7 +12443,7 @@ async function createEvmToBitcoinSwap(options, ctx) {
|
|
|
12332
12443
|
const { data, error } = await ctx.apiClient.POST("/swap/evm/bitcoin", {
|
|
12333
12444
|
body: {
|
|
12334
12445
|
hash_lock: hashLock,
|
|
12335
|
-
btc_htlc_script_version:
|
|
12446
|
+
btc_htlc_script_version: _chunkQJ4EK6UGcjs.BTC_HTLC_SCRIPT_VERSION_STRICT,
|
|
12336
12447
|
claim_pk: claimPk,
|
|
12337
12448
|
user_id: userId,
|
|
12338
12449
|
token_address: options.tokenAddress,
|
|
@@ -12343,9 +12454,10 @@ async function createEvmToBitcoinSwap(options, ctx) {
|
|
|
12343
12454
|
amount_out: options.targetAmount ? Number(options.targetAmount) : void 0,
|
|
12344
12455
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12345
12456
|
extra_fees: options.extraFees,
|
|
12457
|
+
promo_code: options.promoCode,
|
|
12346
12458
|
gasless: _nullishCoalesce(options.gasless, () => ( false)),
|
|
12347
|
-
bridge_source_chain: _optionalChain([options, 'access',
|
|
12348
|
-
bridge_source_token_address: _optionalChain([options, 'access',
|
|
12459
|
+
bridge_source_chain: _optionalChain([options, 'access', _100 => _100.inboundBridgeParams, 'optionalAccess', _101 => _101.sourceChain]),
|
|
12460
|
+
bridge_source_token_address: _optionalChain([options, 'access', _102 => _102.inboundBridgeParams, 'optionalAccess', _103 => _103.sourceTokenAddress])
|
|
12349
12461
|
}
|
|
12350
12462
|
});
|
|
12351
12463
|
if (error) {
|
|
@@ -12402,9 +12514,10 @@ async function createEvmToLightningSwap(options, ctx) {
|
|
|
12402
12514
|
user_id: userId,
|
|
12403
12515
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12404
12516
|
extra_fees: options.extraFees,
|
|
12517
|
+
promo_code: options.promoCode,
|
|
12405
12518
|
gasless: _nullishCoalesce(options.gasless, () => ( false)),
|
|
12406
|
-
bridge_source_chain: _optionalChain([options, 'access',
|
|
12407
|
-
bridge_source_token_address: _optionalChain([options, 'access',
|
|
12519
|
+
bridge_source_chain: _optionalChain([options, 'access', _104 => _104.inboundBridgeParams, 'optionalAccess', _105 => _105.sourceChain]),
|
|
12520
|
+
bridge_source_token_address: _optionalChain([options, 'access', _106 => _106.inboundBridgeParams, 'optionalAccess', _107 => _107.sourceTokenAddress])
|
|
12408
12521
|
}
|
|
12409
12522
|
});
|
|
12410
12523
|
if (error) {
|
|
@@ -12446,9 +12559,10 @@ async function createLightningToArkadeSwap(options, ctx) {
|
|
|
12446
12559
|
source_amount_sats: options.sourceAmountSats,
|
|
12447
12560
|
target_amount_sats: options.targetAmountSats,
|
|
12448
12561
|
target_arkade_address: options.targetAddress,
|
|
12449
|
-
arkade_htlc_script_version:
|
|
12562
|
+
arkade_htlc_script_version: _chunkQJ4EK6UGcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT,
|
|
12450
12563
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12451
12564
|
extra_fees: options.extraFees,
|
|
12565
|
+
promo_code: options.promoCode,
|
|
12452
12566
|
// `undefined` is omitted from the JSON body so the server applies its
|
|
12453
12567
|
// default; an explicit "" is sent to blank the invoice description.
|
|
12454
12568
|
invoice_description: options.invoiceDescription
|
|
@@ -12488,9 +12602,10 @@ async function createLightningToBitcoinSwap(options, ctx) {
|
|
|
12488
12602
|
source_amount_sats: options.sourceAmountSats,
|
|
12489
12603
|
target_amount_sats: options.targetAmountSats,
|
|
12490
12604
|
target_address: options.targetAddress,
|
|
12491
|
-
btc_htlc_script_version:
|
|
12605
|
+
btc_htlc_script_version: _chunkQJ4EK6UGcjs.BTC_HTLC_SCRIPT_VERSION_STRICT,
|
|
12492
12606
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12493
12607
|
extra_fees: options.extraFees,
|
|
12608
|
+
promo_code: options.promoCode,
|
|
12494
12609
|
invoice_description: options.invoiceDescription
|
|
12495
12610
|
};
|
|
12496
12611
|
const { data, error } = await ctx.apiClient.POST(
|
|
@@ -12531,14 +12646,15 @@ async function createLightningToEvmSwap(options, ctx, claimingAddressOverride) {
|
|
|
12531
12646
|
token_address: options.tokenAddress,
|
|
12532
12647
|
evm_chain_id: options.evmChainId,
|
|
12533
12648
|
amount_in: options.sourceAmount,
|
|
12534
|
-
amount_out: _optionalChain([options, 'access',
|
|
12649
|
+
amount_out: _optionalChain([options, 'access', _108 => _108.targetAmount, 'optionalAccess', _109 => _109.toString, 'call', _110 => _110()]),
|
|
12535
12650
|
invoice_description: options.invoiceDescription,
|
|
12536
12651
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12537
12652
|
extra_fees: options.extraFees,
|
|
12653
|
+
promo_code: options.promoCode,
|
|
12538
12654
|
gasless: _nullishCoalesce(options.gasless, () => ( true)),
|
|
12539
|
-
bridge_target_chain: _optionalChain([options, 'access',
|
|
12540
|
-
bridge_target_token_address: _optionalChain([options, 'access',
|
|
12541
|
-
bridge_recipient_setup: _optionalChain([options, 'access',
|
|
12655
|
+
bridge_target_chain: _optionalChain([options, 'access', _111 => _111.bridgeParams, 'optionalAccess', _112 => _112.targetChain]),
|
|
12656
|
+
bridge_target_token_address: _optionalChain([options, 'access', _113 => _113.bridgeParams, 'optionalAccess', _114 => _114.targetTokenAddress]),
|
|
12657
|
+
bridge_recipient_setup: _optionalChain([options, 'access', _115 => _115.bridgeParams, 'optionalAccess', _116 => _116.recipientSetup])
|
|
12542
12658
|
};
|
|
12543
12659
|
const { data, error } = await ctx.apiClient.POST("/swap/lightning/evm", {
|
|
12544
12660
|
body
|
|
@@ -12561,8 +12677,70 @@ async function createLightningToEvmSwap(options, ctx, claimingAddressOverride) {
|
|
|
12561
12677
|
},
|
|
12562
12678
|
options.targetAddress,
|
|
12563
12679
|
{
|
|
12564
|
-
recipient: _optionalChain([options, 'access',
|
|
12565
|
-
recipientWallet: _optionalChain([options, 'access',
|
|
12680
|
+
recipient: _optionalChain([options, 'access', _117 => _117.bridgeParams, 'optionalAccess', _118 => _118.recipient]),
|
|
12681
|
+
recipientWallet: _optionalChain([options, 'access', _119 => _119.bridgeParams, 'optionalAccess', _120 => _120.recipientWallet])
|
|
12682
|
+
}
|
|
12683
|
+
);
|
|
12684
|
+
return { response: data, swapParams };
|
|
12685
|
+
});
|
|
12686
|
+
}
|
|
12687
|
+
async function createSparkToEvmSwap(options, ctx, claimingAddressOverride) {
|
|
12688
|
+
if (options.sourceAmount == null === (options.targetAmount == null)) {
|
|
12689
|
+
throw new Error("Provide exactly one of sourceAmount or targetAmount");
|
|
12690
|
+
}
|
|
12691
|
+
if (options.sourceAmount != null && (!Number.isSafeInteger(options.sourceAmount) || options.sourceAmount <= 0)) {
|
|
12692
|
+
throw new Error("sourceAmount must be a positive safe integer in sats");
|
|
12693
|
+
}
|
|
12694
|
+
return retryOnHashCollision(ctx, async () => {
|
|
12695
|
+
const swapParams = await ctx.deriveSwapParams();
|
|
12696
|
+
const hashLock = `0x${_chunk5JR6AJ3Ycjs.bytesToHex.call(void 0, swapParams.preimageHash)}`;
|
|
12697
|
+
const userId = _chunk5JR6AJ3Ycjs.bytesToHex.call(void 0, swapParams.userId);
|
|
12698
|
+
const claimingAddress = _nullishCoalesce(claimingAddressOverride, () => ( deriveEvmAddress(swapParams.secretKey)));
|
|
12699
|
+
const body = {
|
|
12700
|
+
hash_lock: hashLock,
|
|
12701
|
+
user_id: userId,
|
|
12702
|
+
claiming_address: claimingAddress,
|
|
12703
|
+
target_address: options.targetAddress,
|
|
12704
|
+
token_address: options.tokenAddress,
|
|
12705
|
+
evm_chain_id: options.evmChainId,
|
|
12706
|
+
amount_in: options.sourceAmount,
|
|
12707
|
+
amount_out: _optionalChain([options, 'access', _121 => _121.targetAmount, 'optionalAccess', _122 => _122.toString, 'call', _123 => _123()]),
|
|
12708
|
+
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12709
|
+
extra_fees: options.extraFees,
|
|
12710
|
+
promo_code: options.promoCode,
|
|
12711
|
+
gasless: _nullishCoalesce(options.gasless, () => ( true)),
|
|
12712
|
+
bridge_target_chain: _optionalChain([options, 'access', _124 => _124.bridgeParams, 'optionalAccess', _125 => _125.targetChain]),
|
|
12713
|
+
bridge_target_token_address: _optionalChain([options, 'access', _126 => _126.bridgeParams, 'optionalAccess', _127 => _127.targetTokenAddress]),
|
|
12714
|
+
bridge_recipient_setup: _optionalChain([options, 'access', _128 => _128.bridgeParams, 'optionalAccess', _129 => _129.recipientSetup])
|
|
12715
|
+
};
|
|
12716
|
+
const { data, error } = await ctx.apiClient.POST("/swap/spark/evm", {
|
|
12717
|
+
body
|
|
12718
|
+
});
|
|
12719
|
+
if (error) {
|
|
12720
|
+
throw new Error(`Failed to create swap: ${JSON.stringify(error)}`);
|
|
12721
|
+
}
|
|
12722
|
+
if (!data) {
|
|
12723
|
+
throw new Error("No swap data returned");
|
|
12724
|
+
}
|
|
12725
|
+
assertSparkFunding(data, hashLock);
|
|
12726
|
+
if (options.sourceAmount != null && BigInt(data.source_amount) !== BigInt(options.sourceAmount)) {
|
|
12727
|
+
throw new Error(
|
|
12728
|
+
"Native Spark source amount differs from the requested amount"
|
|
12729
|
+
);
|
|
12730
|
+
}
|
|
12731
|
+
assertAddressEchoed(data, "target_evm_address", options.targetAddress);
|
|
12732
|
+
assertAddressEchoed(data, "client_evm_address", claimingAddress);
|
|
12733
|
+
await ctx.storeSwap(
|
|
12734
|
+
data.id,
|
|
12735
|
+
swapParams,
|
|
12736
|
+
{
|
|
12737
|
+
...data,
|
|
12738
|
+
direction: "spark_to_evm"
|
|
12739
|
+
},
|
|
12740
|
+
options.targetAddress,
|
|
12741
|
+
{
|
|
12742
|
+
recipient: _optionalChain([options, 'access', _130 => _130.bridgeParams, 'optionalAccess', _131 => _131.recipient]),
|
|
12743
|
+
recipientWallet: _optionalChain([options, 'access', _132 => _132.bridgeParams, 'optionalAccess', _133 => _133.recipientWallet])
|
|
12566
12744
|
}
|
|
12567
12745
|
);
|
|
12568
12746
|
return { response: data, swapParams };
|
|
@@ -12586,10 +12764,10 @@ var REGTEST_NETWORK2 = {
|
|
|
12586
12764
|
function toBtcSignerNetwork(network) {
|
|
12587
12765
|
switch (network) {
|
|
12588
12766
|
case "mainnet":
|
|
12589
|
-
return
|
|
12767
|
+
return _chunkQJ4EK6UGcjs.NETWORK;
|
|
12590
12768
|
case "testnet":
|
|
12591
12769
|
case "signet":
|
|
12592
|
-
return
|
|
12770
|
+
return _chunkQJ4EK6UGcjs.TEST_NETWORK;
|
|
12593
12771
|
case "regtest":
|
|
12594
12772
|
return REGTEST_NETWORK2;
|
|
12595
12773
|
default:
|
|
@@ -12598,9 +12776,9 @@ function toBtcSignerNetwork(network) {
|
|
|
12598
12776
|
}
|
|
12599
12777
|
function addressToScriptHash(address2, network) {
|
|
12600
12778
|
const net = toBtcSignerNetwork(network);
|
|
12601
|
-
const decoded =
|
|
12779
|
+
const decoded = _chunkQJ4EK6UGcjs.Address.call(void 0, net).decode(address2);
|
|
12602
12780
|
if (!decoded) throw new Error(`Unrecognised Bitcoin address: ${address2}`);
|
|
12603
|
-
const script =
|
|
12781
|
+
const script = _chunkQJ4EK6UGcjs.OutScript.encode(decoded);
|
|
12604
12782
|
return _chunk5JR6AJ3Ycjs.bytesToHex.call(void 0, _chunk5JR6AJ3Ycjs.sha256.call(void 0, script).reverse());
|
|
12605
12783
|
}
|
|
12606
12784
|
var ElectrumWsClient = class {
|
|
@@ -12619,7 +12797,7 @@ var ElectrumWsClient = class {
|
|
|
12619
12797
|
#closed = false;
|
|
12620
12798
|
constructor(url, opts) {
|
|
12621
12799
|
this.#url = url;
|
|
12622
|
-
this.#log = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
12800
|
+
this.#log = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _134 => _134.onLog]), () => ( (() => {
|
|
12623
12801
|
})));
|
|
12624
12802
|
}
|
|
12625
12803
|
/**
|
|
@@ -12692,7 +12870,7 @@ var ElectrumWsClient = class {
|
|
|
12692
12870
|
handlers.delete(onChange);
|
|
12693
12871
|
if (handlers.size > 0) return;
|
|
12694
12872
|
this.#scriptHashHandlers.delete(scripthash);
|
|
12695
|
-
if (_optionalChain([this, 'access',
|
|
12873
|
+
if (_optionalChain([this, 'access', _135 => _135.#socket, 'optionalAccess', _136 => _136.readyState]) === WebSocket.OPEN) {
|
|
12696
12874
|
this.request("blockchain.scripthash.unsubscribe", [scripthash]).catch(
|
|
12697
12875
|
() => {
|
|
12698
12876
|
}
|
|
@@ -12712,7 +12890,7 @@ var ElectrumWsClient = class {
|
|
|
12712
12890
|
}
|
|
12713
12891
|
async #ensureConnected() {
|
|
12714
12892
|
if (this.#closed) throw new Error("Electrum client closed");
|
|
12715
|
-
if (_optionalChain([this, 'access',
|
|
12893
|
+
if (_optionalChain([this, 'access', _137 => _137.#socket, 'optionalAccess', _138 => _138.readyState]) === WebSocket.OPEN) return;
|
|
12716
12894
|
this.#connecting ??= this.#connect().finally(() => {
|
|
12717
12895
|
this.#connecting = null;
|
|
12718
12896
|
});
|
|
@@ -12735,7 +12913,7 @@ var ElectrumWsClient = class {
|
|
|
12735
12913
|
);
|
|
12736
12914
|
try {
|
|
12737
12915
|
socket.close();
|
|
12738
|
-
} catch (
|
|
12916
|
+
} catch (e7) {
|
|
12739
12917
|
}
|
|
12740
12918
|
}, CONNECT_TIMEOUT_MS);
|
|
12741
12919
|
socket.addEventListener("open", () => {
|
|
@@ -12785,7 +12963,7 @@ var ElectrumWsClient = class {
|
|
|
12785
12963
|
if (socket && socket.readyState !== WebSocket.CLOSED) {
|
|
12786
12964
|
try {
|
|
12787
12965
|
socket.close();
|
|
12788
|
-
} catch (
|
|
12966
|
+
} catch (e8) {
|
|
12789
12967
|
}
|
|
12790
12968
|
}
|
|
12791
12969
|
for (const [id, pending] of this.#pending) {
|
|
@@ -12825,7 +13003,7 @@ var ElectrumWsClient = class {
|
|
|
12825
13003
|
#startPing() {
|
|
12826
13004
|
this.#stopPing();
|
|
12827
13005
|
this.#pingTimer = setInterval(() => {
|
|
12828
|
-
if (_optionalChain([this, 'access',
|
|
13006
|
+
if (_optionalChain([this, 'access', _139 => _139.#socket, 'optionalAccess', _140 => _140.readyState]) !== WebSocket.OPEN) return;
|
|
12829
13007
|
this.request("server.ping", []).catch(() => {
|
|
12830
13008
|
if (this.#socket && this.#socket.readyState === WebSocket.OPEN) {
|
|
12831
13009
|
this.#teardownSocket(new Error("Electrum keepalive timed out"));
|
|
@@ -12850,7 +13028,7 @@ var ElectrumWsClient = class {
|
|
|
12850
13028
|
let parsed;
|
|
12851
13029
|
try {
|
|
12852
13030
|
parsed = JSON.parse(trimmed);
|
|
12853
|
-
} catch (
|
|
13031
|
+
} catch (e9) {
|
|
12854
13032
|
continue;
|
|
12855
13033
|
}
|
|
12856
13034
|
if (parsed.id !== void 0 && parsed.id !== null) {
|
|
@@ -12908,11 +13086,11 @@ async function electrumFetchTransactionOutputs(client, txid) {
|
|
|
12908
13086
|
let rawHex;
|
|
12909
13087
|
try {
|
|
12910
13088
|
rawHex = await client.request("blockchain.transaction.get", [txid]);
|
|
12911
|
-
} catch (
|
|
13089
|
+
} catch (e10) {
|
|
12912
13090
|
return null;
|
|
12913
13091
|
}
|
|
12914
13092
|
try {
|
|
12915
|
-
const tx =
|
|
13093
|
+
const tx = _chunkQJ4EK6UGcjs.Transaction2.fromRaw(_chunk5JR6AJ3Ycjs.hexToBytes.call(void 0, rawHex), {
|
|
12916
13094
|
allowUnknownOutputs: true,
|
|
12917
13095
|
allowUnknownInputs: true,
|
|
12918
13096
|
disableScriptCheck: true
|
|
@@ -12922,7 +13100,7 @@ async function electrumFetchTransactionOutputs(client, txid) {
|
|
|
12922
13100
|
vout.push({ value: Number(_nullishCoalesce(tx.getOutput(i).amount, () => ( 0n))) });
|
|
12923
13101
|
}
|
|
12924
13102
|
return { vout };
|
|
12925
|
-
} catch (
|
|
13103
|
+
} catch (e11) {
|
|
12926
13104
|
return null;
|
|
12927
13105
|
}
|
|
12928
13106
|
}
|
|
@@ -12935,7 +13113,7 @@ async function electrumBroadcastTransaction(client, txHex) {
|
|
|
12935
13113
|
}
|
|
12936
13114
|
async function electrumWaitForOutputByAddress(client, address2, network, timeoutMs, opts) {
|
|
12937
13115
|
const scripthash = addressToScriptHash(address2, network);
|
|
12938
|
-
const safetyRecheckMs = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
13116
|
+
const safetyRecheckMs = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _141 => _141.safetyRecheckMs]), () => ( 5e3));
|
|
12939
13117
|
return new Promise((resolve, reject) => {
|
|
12940
13118
|
let settled = false;
|
|
12941
13119
|
let deadlineTimer = null;
|
|
@@ -12960,7 +13138,7 @@ async function electrumWaitForOutputByAddress(client, address2, network, timeout
|
|
|
12960
13138
|
network
|
|
12961
13139
|
);
|
|
12962
13140
|
if (output) finish({ ok: output });
|
|
12963
|
-
} catch (
|
|
13141
|
+
} catch (e12) {
|
|
12964
13142
|
} finally {
|
|
12965
13143
|
checking = false;
|
|
12966
13144
|
}
|
|
@@ -13052,7 +13230,7 @@ async function fetchTransactionOutputs(esploraUrls, txid) {
|
|
|
13052
13230
|
}
|
|
13053
13231
|
return await response.json();
|
|
13054
13232
|
});
|
|
13055
|
-
} catch (
|
|
13233
|
+
} catch (e13) {
|
|
13056
13234
|
return null;
|
|
13057
13235
|
}
|
|
13058
13236
|
}
|
|
@@ -13073,7 +13251,7 @@ async function fetchFeeRateEstimate(esploraUrls, targetBlocks) {
|
|
|
13073
13251
|
}
|
|
13074
13252
|
return rate;
|
|
13075
13253
|
});
|
|
13076
|
-
} catch (
|
|
13254
|
+
} catch (e14) {
|
|
13077
13255
|
return void 0;
|
|
13078
13256
|
}
|
|
13079
13257
|
}
|
|
@@ -13500,15 +13678,15 @@ function alreadyClaimedStatus(errorText) {
|
|
|
13500
13678
|
const match = /cannot claim a swap in (client_redeeming|client_redeemed|server_redeemed)/.exec(
|
|
13501
13679
|
errorText
|
|
13502
13680
|
);
|
|
13503
|
-
return _optionalChain([match, 'optionalAccess',
|
|
13681
|
+
return _optionalChain([match, 'optionalAccess', _142 => _142[1]]);
|
|
13504
13682
|
}
|
|
13505
13683
|
async function postClaim(baseUrl, swapId, body) {
|
|
13506
13684
|
const response = await fetch(`${baseUrl}/swap/${swapId}/claim-gasless`, {
|
|
13507
13685
|
method: "POST",
|
|
13508
13686
|
headers: {
|
|
13509
13687
|
"Content-Type": "application/json",
|
|
13510
|
-
"X-Lendaswap-Client":
|
|
13511
|
-
...
|
|
13688
|
+
"X-Lendaswap-Client": _chunkQJ4EK6UGcjs.CLIENT_AGENT,
|
|
13689
|
+
..._chunkQJ4EK6UGcjs.PROTOCOL_HEADERS
|
|
13512
13690
|
},
|
|
13513
13691
|
body: JSON.stringify(body)
|
|
13514
13692
|
});
|
|
@@ -13731,8 +13909,8 @@ async function buildArkadeClaim(params) {
|
|
|
13731
13909
|
`Preimage hash are not equal. '${_chunkRYZSWESUcjs.hex.encode(_chunkBEW62OUTcjs.ripemd1602.call(void 0, _chunkRYZSWESUcjs.hex.decode(preimageHash)))}' vs ${preimageHashBytesString}'`
|
|
13732
13910
|
);
|
|
13733
13911
|
}
|
|
13734
|
-
const networkName =
|
|
13735
|
-
const serverUrl =
|
|
13912
|
+
const networkName = _chunkQJ4EK6UGcjs.getNetworkName.call(void 0, network);
|
|
13913
|
+
const serverUrl = _chunkQJ4EK6UGcjs.resolveArkadeServerUrlByName.call(void 0, networkName, arkadeServerUrl);
|
|
13736
13914
|
const arkProvider = new (0, _chunkBEW62OUTcjs.RestOperatorProvider)(serverUrl);
|
|
13737
13915
|
const indexerProvider = new (0, _chunkBEW62OUTcjs.RestIndexerProvider)(serverUrl);
|
|
13738
13916
|
const serverInfo = await arkProvider.getInfo();
|
|
@@ -13748,13 +13926,13 @@ async function buildArkadeClaim(params) {
|
|
|
13748
13926
|
unilateralRefundWithoutReceiverDelay
|
|
13749
13927
|
)
|
|
13750
13928
|
};
|
|
13751
|
-
if (arkadeHtlcScriptVersion !== void 0 && arkadeHtlcScriptVersion !==
|
|
13929
|
+
if (arkadeHtlcScriptVersion !== void 0 && arkadeHtlcScriptVersion !== _chunkQJ4EK6UGcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
|
|
13752
13930
|
throw new Error(
|
|
13753
13931
|
`Unsupported Arkade HTLC script version: ${arkadeHtlcScriptVersion}`
|
|
13754
13932
|
);
|
|
13755
13933
|
}
|
|
13756
|
-
const vhtlc = new (0,
|
|
13757
|
-
const hrp =
|
|
13934
|
+
const vhtlc = new (0, _chunkQJ4EK6UGcjs.StrictVhtlcScript)(vhtlcOptions);
|
|
13935
|
+
const hrp = _chunkQJ4EK6UGcjs.getNetworkHrp.call(void 0, networkName);
|
|
13758
13936
|
const computedAddress = vhtlc.address(hrp, serverPkBytes);
|
|
13759
13937
|
const computedAddressStr = computedAddress.encode();
|
|
13760
13938
|
if (computedAddressStr !== vhtlcAddress) {
|
|
@@ -13897,8 +14075,8 @@ async function continueArkadeClaim(params) {
|
|
|
13897
14075
|
`Preimage hash are not equal. '${_chunkRYZSWESUcjs.hex.encode(_chunkBEW62OUTcjs.ripemd1602.call(void 0, _chunkRYZSWESUcjs.hex.decode(preimageHash)))}' vs ${preimageHashBytesString}'`
|
|
13898
14076
|
);
|
|
13899
14077
|
}
|
|
13900
|
-
const networkName =
|
|
13901
|
-
const serverUrl =
|
|
14078
|
+
const networkName = _chunkQJ4EK6UGcjs.getNetworkName.call(void 0, network);
|
|
14079
|
+
const serverUrl = _chunkQJ4EK6UGcjs.resolveArkadeServerUrlByName.call(void 0, networkName, arkadeServerUrl);
|
|
13902
14080
|
const arkProvider = new (0, _chunkBEW62OUTcjs.RestOperatorProvider)(serverUrl);
|
|
13903
14081
|
const indexerProvider = new (0, _chunkBEW62OUTcjs.RestIndexerProvider)(serverUrl);
|
|
13904
14082
|
const vhtlcOptions = {
|
|
@@ -13913,13 +14091,13 @@ async function continueArkadeClaim(params) {
|
|
|
13913
14091
|
unilateralRefundWithoutReceiverDelay
|
|
13914
14092
|
)
|
|
13915
14093
|
};
|
|
13916
|
-
if (arkadeHtlcScriptVersion !== void 0 && arkadeHtlcScriptVersion !==
|
|
14094
|
+
if (arkadeHtlcScriptVersion !== void 0 && arkadeHtlcScriptVersion !== _chunkQJ4EK6UGcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
|
|
13917
14095
|
throw new Error(
|
|
13918
14096
|
`Unsupported Arkade HTLC script version: ${arkadeHtlcScriptVersion}`
|
|
13919
14097
|
);
|
|
13920
14098
|
}
|
|
13921
|
-
const vhtlc = new (0,
|
|
13922
|
-
const hrp =
|
|
14099
|
+
const vhtlc = new (0, _chunkQJ4EK6UGcjs.StrictVhtlcScript)(vhtlcOptions);
|
|
14100
|
+
const hrp = _chunkQJ4EK6UGcjs.getNetworkHrp.call(void 0, networkName);
|
|
13923
14101
|
const computedAddress = vhtlc.address(hrp, serverPkBytes);
|
|
13924
14102
|
const computedAddressStr = computedAddress.encode();
|
|
13925
14103
|
if (computedAddressStr !== vhtlcAddress) {
|
|
@@ -13967,7 +14145,7 @@ async function continueArkadeClaim(params) {
|
|
|
13967
14145
|
amount: BigInt(v.value)
|
|
13968
14146
|
},
|
|
13969
14147
|
tapLeafScript: [claimLeafScript],
|
|
13970
|
-
sighashType:
|
|
14148
|
+
sighashType: _chunkQJ4EK6UGcjs.SigHash.ALL
|
|
13971
14149
|
}));
|
|
13972
14150
|
const intentProof = _chunkBEW62OUTcjs.Proof.create(intentMessage, intentInputs);
|
|
13973
14151
|
for (let i = 0; i < vtxos.length; i++) {
|
|
@@ -14330,7 +14508,7 @@ async function rifResponse(response, path) {
|
|
|
14330
14508
|
let body;
|
|
14331
14509
|
try {
|
|
14332
14510
|
body = JSON.parse(text);
|
|
14333
|
-
} catch (
|
|
14511
|
+
} catch (e15) {
|
|
14334
14512
|
throw new Error(
|
|
14335
14513
|
`RIF Relay ${path} answered ${response.status}: ${text.slice(0, 200)}`
|
|
14336
14514
|
);
|
|
@@ -14453,7 +14631,7 @@ async function claimViaSigner(params) {
|
|
|
14453
14631
|
`Replacement transaction ${minedHash} was mined, but its claim could not yet be verified. Check the swap status or transaction before submitting another claim.`
|
|
14454
14632
|
);
|
|
14455
14633
|
}
|
|
14456
|
-
if (_optionalChain([mined, 'access',
|
|
14634
|
+
if (_optionalChain([mined, 'access', _143 => _143.to, 'optionalAccess', _144 => _144.toLowerCase, 'call', _145 => _145()]) !== tx.to.toLowerCase() || mined.from.toLowerCase() !== signer.address.toLowerCase() || mined.input.toLowerCase() !== tx.data.toLowerCase()) {
|
|
14457
14635
|
throw new Error(
|
|
14458
14636
|
"The wallet replaced or cancelled the claim transaction. The claim was not submitted; try again from the payout wallet."
|
|
14459
14637
|
);
|
|
@@ -14589,7 +14767,7 @@ function formatApiError(error) {
|
|
|
14589
14767
|
}
|
|
14590
14768
|
try {
|
|
14591
14769
|
return JSON.stringify(error);
|
|
14592
|
-
} catch (
|
|
14770
|
+
} catch (e16) {
|
|
14593
14771
|
}
|
|
14594
14772
|
}
|
|
14595
14773
|
return String(error);
|
|
@@ -14599,7 +14777,7 @@ function buildRefundScriptVhtlc(params) {
|
|
|
14599
14777
|
const lendaswapPkBytes = parseXOnlyPubKey3(params.lendaswapPubKey);
|
|
14600
14778
|
const serverPkBytes = parseXOnlyPubKey3(params.arkadeServerPubKey);
|
|
14601
14779
|
const preimageHashBytes = parsePreimageHash(params.hashLock);
|
|
14602
|
-
const networkName =
|
|
14780
|
+
const networkName = _chunkQJ4EK6UGcjs.getNetworkName.call(void 0, params.network);
|
|
14603
14781
|
const options = {
|
|
14604
14782
|
sender: userPkBytes,
|
|
14605
14783
|
receiver: lendaswapPkBytes,
|
|
@@ -14612,13 +14790,13 @@ function buildRefundScriptVhtlc(params) {
|
|
|
14612
14790
|
params.unilateralRefundWithoutReceiverDelay
|
|
14613
14791
|
)
|
|
14614
14792
|
};
|
|
14615
|
-
if (params.arkadeHtlcScriptVersion !== void 0 && params.arkadeHtlcScriptVersion !==
|
|
14793
|
+
if (params.arkadeHtlcScriptVersion !== void 0 && params.arkadeHtlcScriptVersion !== _chunkQJ4EK6UGcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
|
|
14616
14794
|
throw new Error(
|
|
14617
14795
|
`Unsupported Arkade HTLC script version: ${params.arkadeHtlcScriptVersion}`
|
|
14618
14796
|
);
|
|
14619
14797
|
}
|
|
14620
|
-
const vhtlc = new (0,
|
|
14621
|
-
const hrp =
|
|
14798
|
+
const vhtlc = new (0, _chunkQJ4EK6UGcjs.StrictVhtlcScript)(options);
|
|
14799
|
+
const hrp = _chunkQJ4EK6UGcjs.getNetworkHrp.call(void 0, networkName);
|
|
14622
14800
|
const computedAddress = vhtlc.address(hrp, serverPkBytes).encode();
|
|
14623
14801
|
if (computedAddress !== params.vhtlcAddress) {
|
|
14624
14802
|
throw new Error(
|
|
@@ -14629,7 +14807,7 @@ function buildRefundScriptVhtlc(params) {
|
|
|
14629
14807
|
}
|
|
14630
14808
|
async function collabRefundArkadeToEvmOffchain(params) {
|
|
14631
14809
|
const { vhtlc, networkName } = buildRefundScriptVhtlc(params);
|
|
14632
|
-
const serverUrl =
|
|
14810
|
+
const serverUrl = _chunkQJ4EK6UGcjs.resolveArkadeServerUrlByName.call(void 0,
|
|
14633
14811
|
networkName,
|
|
14634
14812
|
params.arkadeServerUrl
|
|
14635
14813
|
);
|
|
@@ -14715,7 +14893,7 @@ async function collabRefundArkadeToEvmOffchain(params) {
|
|
|
14715
14893
|
}
|
|
14716
14894
|
async function collabRefundArkadeToEvmDelegate(params) {
|
|
14717
14895
|
const { vhtlc, networkName } = buildRefundScriptVhtlc(params);
|
|
14718
|
-
const serverUrl =
|
|
14896
|
+
const serverUrl = _chunkQJ4EK6UGcjs.resolveArkadeServerUrlByName.call(void 0,
|
|
14719
14897
|
networkName,
|
|
14720
14898
|
params.arkadeServerUrl
|
|
14721
14899
|
);
|
|
@@ -14730,13 +14908,13 @@ async function collabRefundArkadeToEvmDelegate(params) {
|
|
|
14730
14908
|
}
|
|
14731
14909
|
const cosignerPkHex = cosignerRes.data.cosigner_pk;
|
|
14732
14910
|
const btcNetwork = _chunkBEW62OUTcjs.networks[networkName];
|
|
14733
|
-
const forfeitDecoded =
|
|
14911
|
+
const forfeitDecoded = _chunkQJ4EK6UGcjs.Address.call(void 0, btcNetwork).decode(serverInfo.forfeitAddress);
|
|
14734
14912
|
if (!forfeitDecoded) {
|
|
14735
14913
|
throw new Error(
|
|
14736
14914
|
`Unrecognised forfeit address: ${serverInfo.forfeitAddress}`
|
|
14737
14915
|
);
|
|
14738
14916
|
}
|
|
14739
|
-
const forfeitPkScript =
|
|
14917
|
+
const forfeitPkScript = _chunkQJ4EK6UGcjs.OutScript.encode(forfeitDecoded);
|
|
14740
14918
|
const vhtlcPkScript = _chunkRYZSWESUcjs.hex.encode(vhtlc.pkScript);
|
|
14741
14919
|
const { vtxos: allVtxos } = await indexerProvider.getVtxos({
|
|
14742
14920
|
scripts: [vhtlcPkScript]
|
|
@@ -14769,7 +14947,7 @@ async function collabRefundArkadeToEvmDelegate(params) {
|
|
|
14769
14947
|
amount: BigInt(v.value)
|
|
14770
14948
|
},
|
|
14771
14949
|
tapLeafScript: [tapLeafScript],
|
|
14772
|
-
sighashType:
|
|
14950
|
+
sighashType: _chunkQJ4EK6UGcjs.SigHash.ALL
|
|
14773
14951
|
}));
|
|
14774
14952
|
const intentProof = _chunkBEW62OUTcjs.Proof.create(intentMessage, intentInputs, [
|
|
14775
14953
|
{ script: destination.pkScript, amount: totalAmount }
|
|
@@ -14795,7 +14973,7 @@ async function collabRefundArkadeToEvmDelegate(params) {
|
|
|
14795
14973
|
amount: vtxoAmount
|
|
14796
14974
|
},
|
|
14797
14975
|
tapLeafScript: [tapLeafScript],
|
|
14798
|
-
sighashType:
|
|
14976
|
+
sighashType: _chunkQJ4EK6UGcjs.SigHash.ALL_ANYONECANPAY
|
|
14799
14977
|
});
|
|
14800
14978
|
forfeitTx.addOutput({
|
|
14801
14979
|
script: forfeitPkScript,
|
|
@@ -14971,13 +15149,15 @@ function fromWireQuoteResponse(wire) {
|
|
|
14971
15149
|
target_amount: wire.target_amount,
|
|
14972
15150
|
net_source_amount: wire.net_source_amount,
|
|
14973
15151
|
net_target_amount: wire.net_target_amount,
|
|
14974
|
-
bridge_fee: _nullishCoalesce(wire.bridge_fee, () => ( void 0))
|
|
15152
|
+
bridge_fee: _nullishCoalesce(wire.bridge_fee, () => ( void 0)),
|
|
15153
|
+
promo: _nullishCoalesce(wire.promo, () => ( void 0))
|
|
14975
15154
|
};
|
|
14976
15155
|
}
|
|
14977
15156
|
function fromWireReferralFeeResponse(wire) {
|
|
14978
15157
|
return {
|
|
14979
15158
|
extra_fee_rate: wire.extra_fee_rate,
|
|
14980
15159
|
base_fee_rate: _nullishCoalesce(wire.base_fee_rate, () => ( void 0)),
|
|
15160
|
+
promo: _nullishCoalesce(wire.promo, () => ( void 0)),
|
|
14981
15161
|
referral_label: _nullishCoalesce(wire.referral_label, () => ( void 0))
|
|
14982
15162
|
};
|
|
14983
15163
|
}
|
|
@@ -15011,7 +15191,7 @@ function isValidTronAddress(address2) {
|
|
|
15011
15191
|
try {
|
|
15012
15192
|
tronAddressToBytes32(address2);
|
|
15013
15193
|
return true;
|
|
15014
|
-
} catch (
|
|
15194
|
+
} catch (e17) {
|
|
15015
15195
|
return false;
|
|
15016
15196
|
}
|
|
15017
15197
|
}
|
|
@@ -15045,7 +15225,7 @@ function createSwapStatusWatcher(baseUrl) {
|
|
|
15045
15225
|
let parsed;
|
|
15046
15226
|
try {
|
|
15047
15227
|
parsed = JSON.parse(evt.data);
|
|
15048
|
-
} catch (
|
|
15228
|
+
} catch (e18) {
|
|
15049
15229
|
return;
|
|
15050
15230
|
}
|
|
15051
15231
|
if ("data" in parsed && parsed.channel === "swap_status") {
|
|
@@ -15064,8 +15244,8 @@ function createSwapStatusWatcher(baseUrl) {
|
|
|
15064
15244
|
});
|
|
15065
15245
|
socket.addEventListener("error", () => {
|
|
15066
15246
|
try {
|
|
15067
|
-
_optionalChain([socket, 'optionalAccess',
|
|
15068
|
-
} catch (
|
|
15247
|
+
_optionalChain([socket, 'optionalAccess', _146 => _146.close, 'call', _147 => _147()]);
|
|
15248
|
+
} catch (e19) {
|
|
15069
15249
|
}
|
|
15070
15250
|
});
|
|
15071
15251
|
}
|
|
@@ -15082,7 +15262,7 @@ function createSwapStatusWatcher(baseUrl) {
|
|
|
15082
15262
|
}, delay);
|
|
15083
15263
|
}
|
|
15084
15264
|
function sendSubscribe(ids) {
|
|
15085
|
-
if (ids.length === 0 || _optionalChain([socket, 'optionalAccess',
|
|
15265
|
+
if (ids.length === 0 || _optionalChain([socket, 'optionalAccess', _148 => _148.readyState]) !== WebSocket.OPEN) return;
|
|
15086
15266
|
const frame = {
|
|
15087
15267
|
op: "subscribe",
|
|
15088
15268
|
channel: "swap_status",
|
|
@@ -15091,7 +15271,7 @@ function createSwapStatusWatcher(baseUrl) {
|
|
|
15091
15271
|
socket.send(JSON.stringify(frame));
|
|
15092
15272
|
}
|
|
15093
15273
|
function sendUnsubscribe(ids) {
|
|
15094
|
-
if (ids.length === 0 || _optionalChain([socket, 'optionalAccess',
|
|
15274
|
+
if (ids.length === 0 || _optionalChain([socket, 'optionalAccess', _149 => _149.readyState]) !== WebSocket.OPEN) return;
|
|
15095
15275
|
const frame = {
|
|
15096
15276
|
op: "unsubscribe",
|
|
15097
15277
|
channel: "swap_status",
|
|
@@ -15107,8 +15287,8 @@ function createSwapStatusWatcher(baseUrl) {
|
|
|
15107
15287
|
reconnectTimer = null;
|
|
15108
15288
|
}
|
|
15109
15289
|
try {
|
|
15110
|
-
_optionalChain([socket, 'optionalAccess',
|
|
15111
|
-
} catch (
|
|
15290
|
+
_optionalChain([socket, 'optionalAccess', _150 => _150.close, 'call', _151 => _151()]);
|
|
15291
|
+
} catch (e20) {
|
|
15112
15292
|
}
|
|
15113
15293
|
socket = null;
|
|
15114
15294
|
}
|
|
@@ -15323,7 +15503,7 @@ async function sendCall(signer, call, label, options = {}) {
|
|
|
15323
15503
|
type: _chunkTNZW35XAcjs.txTypeFor.call(void 0, signer.chainId),
|
|
15324
15504
|
gas: await _chunkTNZW35XAcjs.gasLimitFor.call(void 0, signer, call, _nullishCoalesce(options.fallbackGas, () => ( REFUND_GAS)))
|
|
15325
15505
|
});
|
|
15326
|
-
await _optionalChain([options, 'access',
|
|
15506
|
+
await _optionalChain([options, 'access', _152 => _152.onSent, 'optionalCall', _153 => _153(sent)]);
|
|
15327
15507
|
const receipt = await signer.waitForReceipt(sent);
|
|
15328
15508
|
if (receipt.status !== "success") {
|
|
15329
15509
|
const reason = await _chunkTNZW35XAcjs.getRevertReason.call(void 0, signer, sent, receipt.blockNumber);
|
|
@@ -15340,8 +15520,8 @@ async function sendCall(signer, call, label, options = {}) {
|
|
|
15340
15520
|
async function isSameCall(signer, hash, call) {
|
|
15341
15521
|
try {
|
|
15342
15522
|
const tx = await signer.getTransaction(hash);
|
|
15343
|
-
return _optionalChain([tx, 'optionalAccess',
|
|
15344
|
-
} catch (
|
|
15523
|
+
return _optionalChain([tx, 'optionalAccess', _154 => _154.to, 'optionalAccess', _155 => _155.toLowerCase, 'call', _156 => _156()]) === call.to.toLowerCase() && tx.input.toLowerCase() === call.data.toLowerCase();
|
|
15524
|
+
} catch (e21) {
|
|
15345
15525
|
return false;
|
|
15346
15526
|
}
|
|
15347
15527
|
}
|
|
@@ -15358,7 +15538,7 @@ function dedupeTxids(txids) {
|
|
|
15358
15538
|
function clientHashLockOf(stored) {
|
|
15359
15539
|
switch (stored.response.direction) {
|
|
15360
15540
|
case "evm_to_lightning":
|
|
15361
|
-
return _optionalChain([stored, 'access',
|
|
15541
|
+
return _optionalChain([stored, 'access', _157 => _157.lightningPaymentHash, 'optionalAccess', _158 => _158.hash]);
|
|
15362
15542
|
case "evm_to_bitcoin":
|
|
15363
15543
|
case "evm_to_arkade":
|
|
15364
15544
|
return stored.preimageHash ? `0x${_chunkJZTF4JNHcjs.normalizeBytes32.call(void 0, stored.preimageHash)}` : void 0;
|
|
@@ -15373,7 +15553,7 @@ function evmHashLockOf(swap) {
|
|
|
15373
15553
|
return hash;
|
|
15374
15554
|
}
|
|
15375
15555
|
function evmSourceLeg(stored) {
|
|
15376
|
-
const rehashes = _optionalChain([stored, 'access',
|
|
15556
|
+
const rehashes = _optionalChain([stored, 'access', _159 => _159.evmRehashes, 'optionalAccess', _160 => _160.length]) ? stored.evmRehashes : void 0;
|
|
15377
15557
|
const swap = stored.response;
|
|
15378
15558
|
return {
|
|
15379
15559
|
chainId: swap.evm_chain_id,
|
|
@@ -15383,9 +15563,9 @@ function evmSourceLeg(stored) {
|
|
|
15383
15563
|
// without it, and switches to the current hash once a rehash is
|
|
15384
15564
|
// confirmed). The funding tx's SwapCreated is under the first hash, and
|
|
15385
15565
|
// the rehashes are followed from there.
|
|
15386
|
-
hashLock: _nullishCoalesce(_nullishCoalesce(_optionalChain([rehashes, 'optionalAccess',
|
|
15566
|
+
hashLock: _nullishCoalesce(_nullishCoalesce(_optionalChain([rehashes, 'optionalAccess', _161 => _161[0], 'optionalAccess', _162 => _162.fromHashLock]), () => ( clientHashLockOf(stored))), () => ( (swap.direction === "evm_to_bitcoin" ? swap.evm_hash_lock : swap.hash_lock))),
|
|
15387
15567
|
claimAddress: swap.server_evm_address,
|
|
15388
|
-
timelock: _nullishCoalesce(_optionalChain([rehashes, 'optionalAccess',
|
|
15568
|
+
timelock: _nullishCoalesce(_optionalChain([rehashes, 'optionalAccess', _163 => _163.at, 'call', _164 => _164(-1), 'optionalAccess', _165 => _165.timelock]), () => ( swap.evm_refund_locktime)),
|
|
15389
15569
|
// This client's own record first, then the server's copy (which names
|
|
15390
15570
|
// the rehash tx once a rehash is confirmed; that one carries no
|
|
15391
15571
|
// SwapCreated and is skipped as unavailable).
|
|
@@ -15396,7 +15576,7 @@ function evmSourceLeg(stored) {
|
|
|
15396
15576
|
// Read from the creation terms first, which a server refresh cannot
|
|
15397
15577
|
// rewrite; a swap recorded before they named the version falls back to
|
|
15398
15578
|
// the server's copy.
|
|
15399
|
-
depositorIsSender: _optionalChain([stored, 'access',
|
|
15579
|
+
depositorIsSender: _optionalChain([stored, 'access', _166 => _166.evmFundingTerms, 'optionalAccess', _167 => _167.htlcVersion]) !== void 0 ? _chunkJZTF4JNHcjs.depositorIsSender.call(void 0,
|
|
15400
15580
|
stored.evmFundingTerms.htlcKind,
|
|
15401
15581
|
stored.evmFundingTerms.htlcVersion
|
|
15402
15582
|
) : _chunkJZTF4JNHcjs.depositorIsSender.call(void 0, swap.evm_htlc_kind, swap.evm_htlc_version)
|
|
@@ -15409,7 +15589,7 @@ function provesNoLockUnder(receipt, hashLock) {
|
|
|
15409
15589
|
if (receipt.logs === void 0) return false;
|
|
15410
15590
|
const hash = `0x${_chunkJZTF4JNHcjs.normalizeBytes32.call(void 0, hashLock)}`;
|
|
15411
15591
|
return !receipt.logs.some(
|
|
15412
|
-
(log) => log.topics.some((topic) => `0x${_chunkJZTF4JNHcjs.normalizeBytes32.call(void 0, topic)}` === hash) || _optionalChain([_chunkJZTF4JNHcjs.decodeSwapCreatedLog.call(void 0, log), 'optionalAccess',
|
|
15592
|
+
(log) => log.topics.some((topic) => `0x${_chunkJZTF4JNHcjs.normalizeBytes32.call(void 0, topic)}` === hash) || _optionalChain([_chunkJZTF4JNHcjs.decodeSwapCreatedLog.call(void 0, log), 'optionalAccess', _168 => _168.preimageHash]) === hash
|
|
15413
15593
|
);
|
|
15414
15594
|
}
|
|
15415
15595
|
var serializeAmountInput = (amount) => amount == null ? void 0 : amount.toString();
|
|
@@ -15425,7 +15605,8 @@ function satsToLightningOptions(options, sourceName) {
|
|
|
15425
15605
|
const kind = classifyLightningDestination(destination);
|
|
15426
15606
|
const common = {
|
|
15427
15607
|
referralCode: options.referralCode,
|
|
15428
|
-
extraFees: options.extraFees
|
|
15608
|
+
extraFees: options.extraFees,
|
|
15609
|
+
promoCode: options.promoCode
|
|
15429
15610
|
};
|
|
15430
15611
|
if (kind === "invoice") {
|
|
15431
15612
|
if (options.sourceAmount != null && options.targetAmount != null) {
|
|
@@ -15467,10 +15648,10 @@ var DEFAULT_ELECTRUM_WS_URLS = {
|
|
|
15467
15648
|
mainnet: "wss://electrs.satora.io"
|
|
15468
15649
|
};
|
|
15469
15650
|
function defaultAaConfig() {
|
|
15470
|
-
if (!
|
|
15651
|
+
if (!_chunkQJ4EK6UGcjs.DEFAULT_AA_BUNDLER_URL) return void 0;
|
|
15471
15652
|
return {
|
|
15472
|
-
bundlerUrl:
|
|
15473
|
-
...
|
|
15653
|
+
bundlerUrl: _chunkQJ4EK6UGcjs.DEFAULT_AA_BUNDLER_URL,
|
|
15654
|
+
..._chunkQJ4EK6UGcjs.DEFAULT_AA_POLICY_ID ? { paymasterPolicyId: _chunkQJ4EK6UGcjs.DEFAULT_AA_POLICY_ID } : {}
|
|
15474
15655
|
};
|
|
15475
15656
|
}
|
|
15476
15657
|
var ClientBuilder = class {
|
|
@@ -15725,9 +15906,9 @@ var ClientBuilder = class {
|
|
|
15725
15906
|
baseUrl: this.#baseUrl.replace(/\/+$/, ""),
|
|
15726
15907
|
referralCode: this.#referralCode,
|
|
15727
15908
|
defaultHeaders: this.#defaultHeaders,
|
|
15728
|
-
esploraUrl: Array.isArray(this.#esploraUrl) ? this.#esploraUrl.map((url) => url.replace(/\/+$/, "")) : _optionalChain([this, 'access',
|
|
15729
|
-
electrumWsUrl: _optionalChain([this, 'access',
|
|
15730
|
-
arkadeServerUrl: _optionalChain([this, 'access',
|
|
15909
|
+
esploraUrl: Array.isArray(this.#esploraUrl) ? this.#esploraUrl.map((url) => url.replace(/\/+$/, "")) : _optionalChain([this, 'access', _169 => _169.#esploraUrl, 'optionalAccess', _170 => _170.replace, 'call', _171 => _171(/\/+$/, "")]),
|
|
15910
|
+
electrumWsUrl: _optionalChain([this, 'access', _172 => _172.#electrumWsUrl, 'optionalAccess', _173 => _173.replace, 'call', _174 => _174(/\/+$/, "")]),
|
|
15911
|
+
arkadeServerUrl: _optionalChain([this, 'access', _175 => _175.#arkadeServerUrl, 'optionalAccess', _176 => _176.replace, 'call', _177 => _177(/\/+$/, "")]),
|
|
15731
15912
|
aa: _nullishCoalesce(this.#aa, () => ( defaultAaConfig())),
|
|
15732
15913
|
solanaRpcUrl: this.#solanaRpcUrl,
|
|
15733
15914
|
logger: this.#logger,
|
|
@@ -15783,8 +15964,8 @@ var Client = class _Client {
|
|
|
15783
15964
|
}
|
|
15784
15965
|
#apiHeaders(extra) {
|
|
15785
15966
|
return {
|
|
15786
|
-
"X-Lendaswap-Client":
|
|
15787
|
-
...
|
|
15967
|
+
"X-Lendaswap-Client": _chunkQJ4EK6UGcjs.CLIENT_AGENT,
|
|
15968
|
+
..._chunkQJ4EK6UGcjs.PROTOCOL_HEADERS,
|
|
15788
15969
|
..._nullishCoalesce(this.#config.defaultHeaders, () => ( {})),
|
|
15789
15970
|
..._nullishCoalesce(extra, () => ( {}))
|
|
15790
15971
|
};
|
|
@@ -15810,11 +15991,11 @@ var Client = class _Client {
|
|
|
15810
15991
|
* Remove `onUpdate` from the given swap ids.
|
|
15811
15992
|
*/
|
|
15812
15993
|
unsubscribeFromSwaps(swapIds, onUpdate) {
|
|
15813
|
-
_optionalChain([this, 'access',
|
|
15994
|
+
_optionalChain([this, 'access', _178 => _178.#statusWatcher, 'optionalAccess', _179 => _179.unsubscribe, 'call', _180 => _180(swapIds, onUpdate)]);
|
|
15814
15995
|
}
|
|
15815
15996
|
/** Force-close the shared swap-status socket. */
|
|
15816
15997
|
closeSwapStatusSocket() {
|
|
15817
|
-
_optionalChain([this, 'access',
|
|
15998
|
+
_optionalChain([this, 'access', _181 => _181.#statusWatcher, 'optionalAccess', _182 => _182.close, 'call', _183 => _183()]);
|
|
15818
15999
|
this.#statusWatcher = null;
|
|
15819
16000
|
}
|
|
15820
16001
|
/**
|
|
@@ -16004,7 +16185,7 @@ var Client = class _Client {
|
|
|
16004
16185
|
* caller falls back to probing.
|
|
16005
16186
|
*/
|
|
16006
16187
|
#delegationHintFor(swap, depositor, hint) {
|
|
16007
|
-
const hinted = _optionalChain([swap, 'access',
|
|
16188
|
+
const hinted = _optionalChain([swap, 'access', _184 => _184.client_evm_address, 'optionalAccess', _185 => _185.toLowerCase, 'call', _186 => _186()]);
|
|
16008
16189
|
return hinted && hinted === depositor.toLowerCase() ? hint : void 0;
|
|
16009
16190
|
}
|
|
16010
16191
|
async #isKernelDelegated(address2, chainId, serverHint) {
|
|
@@ -16018,7 +16199,7 @@ var Client = class _Client {
|
|
|
16018
16199
|
);
|
|
16019
16200
|
}
|
|
16020
16201
|
if (chainId !== AA_CHAIN_ID) return false;
|
|
16021
|
-
const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access',
|
|
16202
|
+
const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access', _187 => _187.#config, 'access', _188 => _188.aa, 'optionalAccess', _189 => _189.rpcUrl]), () => ( _optionalChain([this, 'access', _190 => _190.#config, 'access', _191 => _191.aa, 'optionalAccess', _192 => _192.bundlerUrl])));
|
|
16022
16203
|
if (!rpcUrl) return false;
|
|
16023
16204
|
const { createPublicClient: createPublicClient2, http: http2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./_esm-4ZKYBBIE-D33574DC.cjs")));
|
|
16024
16205
|
const publicClient = createPublicClient2({ transport: http2(rpcUrl) });
|
|
@@ -16047,7 +16228,7 @@ var Client = class _Client {
|
|
|
16047
16228
|
*/
|
|
16048
16229
|
#getClaimEvmSigningKey(storedSwap) {
|
|
16049
16230
|
const swapKey = storedSwap.secretKey;
|
|
16050
|
-
const clientAddress = _optionalChain([storedSwap, 'access',
|
|
16231
|
+
const clientAddress = _optionalChain([storedSwap, 'access', _193 => _193.response, 'access', _194 => _194.client_evm_address, 'optionalAccess', _195 => _195.toLowerCase, 'call', _196 => _196()]);
|
|
16051
16232
|
if (swapKey && clientAddress && clientAddress === deriveEvmAddress(swapKey).toLowerCase()) {
|
|
16052
16233
|
return swapKey;
|
|
16053
16234
|
}
|
|
@@ -16070,7 +16251,7 @@ var Client = class _Client {
|
|
|
16070
16251
|
const deterministicKey = this.#getEvmSigningKey();
|
|
16071
16252
|
const deterministicAddress = deriveEvmAddress(deterministicKey);
|
|
16072
16253
|
const swapAddress = deriveEvmAddress(swapKey);
|
|
16073
|
-
const clientAddress = _optionalChain([response, 'access',
|
|
16254
|
+
const clientAddress = _optionalChain([response, 'access', _197 => _197.client_evm_address, 'optionalAccess', _198 => _198.toLowerCase, 'call', _199 => _199()]);
|
|
16074
16255
|
if (clientAddress === deterministicAddress.toLowerCase() || !clientAddress) {
|
|
16075
16256
|
return deterministicKey;
|
|
16076
16257
|
}
|
|
@@ -16233,7 +16414,7 @@ var Client = class _Client {
|
|
|
16233
16414
|
"chain-config",
|
|
16234
16415
|
() => this.getChainConfig()
|
|
16235
16416
|
);
|
|
16236
|
-
return _optionalChain([config, 'access',
|
|
16417
|
+
return _optionalChain([config, 'access', _200 => _200.chains, 'access', _201 => _201.find, 'call', _202 => _202((c) => String(c.chain) === String(chainId)), 'optionalAccess', _203 => _203.rif_relay]);
|
|
16237
16418
|
}
|
|
16238
16419
|
/**
|
|
16239
16420
|
* The claim address of a native lock on a chain that claims through RIF
|
|
@@ -16263,7 +16444,11 @@ var Client = class _Client {
|
|
|
16263
16444
|
async getReferralFee(params) {
|
|
16264
16445
|
const { data, error } = await this.#apiClient.GET("/referral-fee", {
|
|
16265
16446
|
params: {
|
|
16266
|
-
query: {
|
|
16447
|
+
query: {
|
|
16448
|
+
ref: params.referralCode,
|
|
16449
|
+
extra_fees: params.extraFees,
|
|
16450
|
+
promo_code: params.promoCode
|
|
16451
|
+
}
|
|
16267
16452
|
}
|
|
16268
16453
|
});
|
|
16269
16454
|
if (error || !data) {
|
|
@@ -16334,12 +16519,14 @@ var Client = class _Client {
|
|
|
16334
16519
|
...params,
|
|
16335
16520
|
referralCode: _nullishCoalesce(params.referralCode, () => ( this.#config.referralCode))
|
|
16336
16521
|
};
|
|
16337
|
-
const
|
|
16522
|
+
const fetchReferralFee = () => this.getReferralFee({
|
|
16523
|
+
referralCode: params.referralCode,
|
|
16524
|
+
extraFees: params.extraFees,
|
|
16525
|
+
promoCode: params.promoCode
|
|
16526
|
+
});
|
|
16527
|
+
const referralFee = params.promoCode != null ? fetchReferralFee() : params.referralCode != null || params.extraFees != null ? this.#composeStatic(
|
|
16338
16528
|
`referral-fee|${_nullishCoalesce(params.referralCode, () => ( ""))}|${_nullishCoalesce(params.extraFees, () => ( ""))}`,
|
|
16339
|
-
|
|
16340
|
-
referralCode: params.referralCode,
|
|
16341
|
-
extraFees: params.extraFees
|
|
16342
|
-
})
|
|
16529
|
+
fetchReferralFee
|
|
16343
16530
|
) : Promise.resolve(void 0);
|
|
16344
16531
|
const [swapPairs, networkFees, chainConfig, referral] = await Promise.all([
|
|
16345
16532
|
this.#composeStatic("swap-pairs", () => this.getSwapPairs()),
|
|
@@ -16351,8 +16538,9 @@ var Client = class _Client {
|
|
|
16351
16538
|
swapPairs,
|
|
16352
16539
|
networkFees,
|
|
16353
16540
|
chainConfig,
|
|
16354
|
-
referralExtraFeeRate: _optionalChain([referral, 'optionalAccess',
|
|
16355
|
-
referralBaseFeeRate: _optionalChain([referral, 'optionalAccess',
|
|
16541
|
+
referralExtraFeeRate: _optionalChain([referral, 'optionalAccess', _204 => _204.extra_fee_rate]),
|
|
16542
|
+
referralBaseFeeRate: _optionalChain([referral, 'optionalAccess', _205 => _205.base_fee_rate]),
|
|
16543
|
+
referralPromo: _optionalChain([referral, 'optionalAccess', _206 => _206.promo]),
|
|
16356
16544
|
getDexQuote: (p) => this.getDexQuote(p)
|
|
16357
16545
|
});
|
|
16358
16546
|
}
|
|
@@ -16426,6 +16614,7 @@ var Client = class _Client {
|
|
|
16426
16614
|
// Per-call referral wins; fall back to the client default.
|
|
16427
16615
|
referralCode: _nullishCoalesce(params.referralCode, () => ( this.#config.referralCode)),
|
|
16428
16616
|
extraFees: params.extraFees,
|
|
16617
|
+
promoCode: params.promoCode,
|
|
16429
16618
|
bridgeRecipientSetup: params.bridgeRecipientSetup
|
|
16430
16619
|
});
|
|
16431
16620
|
} catch (err) {
|
|
@@ -16479,7 +16668,8 @@ var Client = class _Client {
|
|
|
16479
16668
|
target_amount_sats: params.targetAmountSats,
|
|
16480
16669
|
// Per-call referral wins; fall back to the client default.
|
|
16481
16670
|
ref: _nullishCoalesce(params.referralCode, () => ( this.#config.referralCode)),
|
|
16482
|
-
extra_fees: params.extraFees
|
|
16671
|
+
extra_fees: params.extraFees,
|
|
16672
|
+
promo_code: params.promoCode
|
|
16483
16673
|
}
|
|
16484
16674
|
}
|
|
16485
16675
|
});
|
|
@@ -16504,7 +16694,8 @@ var Client = class _Client {
|
|
|
16504
16694
|
protocolFeeRate: data.protocol_fee_rate,
|
|
16505
16695
|
minAmountSats: data.min_amount_sats,
|
|
16506
16696
|
maxAmountSats: data.max_amount_sats,
|
|
16507
|
-
exchangeRate: data.exchange_rate
|
|
16697
|
+
exchangeRate: data.exchange_rate,
|
|
16698
|
+
promo: _nullishCoalesce(data.promo, () => ( void 0))
|
|
16508
16699
|
};
|
|
16509
16700
|
}
|
|
16510
16701
|
/**
|
|
@@ -16532,7 +16723,8 @@ var Client = class _Client {
|
|
|
16532
16723
|
lnurl: kind === "lnurl" ? destination : void 0,
|
|
16533
16724
|
targetAmountSats,
|
|
16534
16725
|
referralCode: params.referralCode,
|
|
16535
|
-
extraFees: params.extraFees
|
|
16726
|
+
extraFees: params.extraFees,
|
|
16727
|
+
promoCode: params.promoCode
|
|
16536
16728
|
});
|
|
16537
16729
|
const sourceAmountOut = evmSource ? q.sourceAmount : sourcePinned ? q.sourceAmount : String(q.targetAmountSats);
|
|
16538
16730
|
const targetAmountOut = !evmSource && sourcePinned ? q.sourceAmount : String(q.targetAmountSats);
|
|
@@ -16547,7 +16739,8 @@ var Client = class _Client {
|
|
|
16547
16739
|
source_amount: sourceAmountOut,
|
|
16548
16740
|
target_amount: targetAmountOut,
|
|
16549
16741
|
net_source_amount: q.sourceAmount,
|
|
16550
|
-
net_target_amount: String(q.targetAmountSats)
|
|
16742
|
+
net_target_amount: String(q.targetAmountSats),
|
|
16743
|
+
promo: q.promo
|
|
16551
16744
|
};
|
|
16552
16745
|
}
|
|
16553
16746
|
/**
|
|
@@ -16640,7 +16833,8 @@ var Client = class _Client {
|
|
|
16640
16833
|
// Per-call referralCode wins; fall back to the client config default
|
|
16641
16834
|
// (set via withReferralCode / withOrgCode).
|
|
16642
16835
|
ref: _nullishCoalesce(params.referralCode, () => ( this.#config.referralCode)),
|
|
16643
|
-
extra_fees: params.extraFees
|
|
16836
|
+
extra_fees: params.extraFees,
|
|
16837
|
+
promo_code: params.promoCode
|
|
16644
16838
|
};
|
|
16645
16839
|
const { data, error } = await this.#apiClient.GET("/quote", {
|
|
16646
16840
|
params: {
|
|
@@ -16693,7 +16887,7 @@ var Client = class _Client {
|
|
|
16693
16887
|
if (comparableId(data.id) !== comparableId(id)) {
|
|
16694
16888
|
throw new Error(`Requested swap ${id}, but server returned ${data.id}`);
|
|
16695
16889
|
}
|
|
16696
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
16890
|
+
if (_optionalChain([options, 'optionalAccess', _207 => _207.updateStorage]) && this.#swapStorage) {
|
|
16697
16891
|
const stored = await this.#swapStorage.get(id);
|
|
16698
16892
|
const changed = stored ? swapTermsChange(stored, data) : void 0;
|
|
16699
16893
|
if (stored && changed) {
|
|
@@ -17015,7 +17209,7 @@ var Client = class _Client {
|
|
|
17015
17209
|
}
|
|
17016
17210
|
const swap = storedSwap.response;
|
|
17017
17211
|
const secret = storedSwap.preimage;
|
|
17018
|
-
if (swap.direction === "arkade_to_evm" || swap.direction === "bitcoin_to_evm" || swap.direction === "lightning_to_evm") {
|
|
17212
|
+
if (swap.direction === "arkade_to_evm" || swap.direction === "bitcoin_to_evm" || swap.direction === "lightning_to_evm" || swap.direction === "spark_to_evm") {
|
|
17019
17213
|
const evmSwap = swap;
|
|
17020
17214
|
const bridgeTargetChain = evmSwap.bridge_target_chain;
|
|
17021
17215
|
const isSolanaBridge = bridgeTargetChain === "Solana";
|
|
@@ -17027,15 +17221,15 @@ var Client = class _Client {
|
|
|
17027
17221
|
message: "Gasless claim failed: no target address found. This swap may have been created before target address storage was implemented."
|
|
17028
17222
|
};
|
|
17029
17223
|
}
|
|
17030
|
-
const bridgeRecipient = _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
17031
|
-
const bridgeRecipientWallet = _optionalChain([options, 'optionalAccess',
|
|
17224
|
+
const bridgeRecipient = _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _208 => _208.bridgeRecipient]), () => ( storedSwap.bridgeRecipient)), () => ( (isTronBridge ? storedPayoutTarget(storedSwap) : void 0)));
|
|
17225
|
+
const bridgeRecipientWallet = _optionalChain([options, 'optionalAccess', _209 => _209.bridgeRecipient]) !== void 0 ? _optionalChain([options, 'optionalAccess', _210 => _210.bridgeRecipientWallet]) : storedSwap.bridgeRecipientWallet;
|
|
17032
17226
|
if (isSolanaBridge && !bridgeRecipient) {
|
|
17033
17227
|
return {
|
|
17034
17228
|
success: false,
|
|
17035
17229
|
message: "Solana bridge claim requires `bridgeRecipient` (the recipient's USDC ATA) in claim options. Derive it via `deriveSolanaUsdcAta` before calling claim."
|
|
17036
17230
|
};
|
|
17037
17231
|
}
|
|
17038
|
-
const gaslessResult = (swap.evm_chain_id === 30 || swap.evm_chain_id === 31) && _optionalChain([options, 'optionalAccess',
|
|
17232
|
+
const gaslessResult = (swap.evm_chain_id === 30 || swap.evm_chain_id === 31) && _optionalChain([options, 'optionalAccess', _211 => _211.signer]) ? await this.claimEvmWithSigner(id, options.signer, {
|
|
17039
17233
|
bridgeRecipient,
|
|
17040
17234
|
bridgeRecipientWallet
|
|
17041
17235
|
}) : await this.claimViaGasless(id, destination, {
|
|
@@ -17087,7 +17281,7 @@ var Client = class _Client {
|
|
|
17087
17281
|
const swap = await this.getSwap(id, {
|
|
17088
17282
|
updateStorage: true
|
|
17089
17283
|
});
|
|
17090
|
-
if (swap.direction !== "arkade_to_evm" && swap.direction !== "bitcoin_to_evm" && swap.direction !== "lightning_to_evm") {
|
|
17284
|
+
if (swap.direction !== "arkade_to_evm" && swap.direction !== "bitcoin_to_evm" && swap.direction !== "lightning_to_evm" && swap.direction !== "spark_to_evm") {
|
|
17091
17285
|
throw new Error(
|
|
17092
17286
|
`Expected an EVM-targeted swap (arkade_to_evm, bitcoin_to_evm or lightning_to_evm), got ${swap.direction}.`
|
|
17093
17287
|
);
|
|
@@ -17275,7 +17469,7 @@ var Client = class _Client {
|
|
|
17275
17469
|
}
|
|
17276
17470
|
/** Whether an EVM claim can use the existing automatic sponsorship path. */
|
|
17277
17471
|
canSponsorClaim(swap) {
|
|
17278
|
-
return (swap.direction === "arkade_to_evm" || swap.direction === "bitcoin_to_evm" || swap.direction === "lightning_to_evm") && swap.evm_chain_id !== 30 && swap.evm_chain_id !== 31;
|
|
17472
|
+
return (swap.direction === "arkade_to_evm" || swap.direction === "bitcoin_to_evm" || swap.direction === "lightning_to_evm" || swap.direction === "spark_to_evm") && swap.evm_chain_id !== 30 && swap.evm_chain_id !== 31;
|
|
17279
17473
|
}
|
|
17280
17474
|
/**
|
|
17281
17475
|
* Claims through the existing server relay or configured Arbitrum UserOp.
|
|
@@ -17367,7 +17561,7 @@ var Client = class _Client {
|
|
|
17367
17561
|
const targetTokenAddress = String(swap.target_token.token_id);
|
|
17368
17562
|
const needsDexSwap = targetTokenAddress.toLowerCase() !== swap.wbtc_address.toLowerCase();
|
|
17369
17563
|
let dexCalldata;
|
|
17370
|
-
if (needsDexSwap && _optionalChain([responseData, 'optionalAccess',
|
|
17564
|
+
if (needsDexSwap && _optionalChain([responseData, 'optionalAccess', _212 => _212.dex_calldata])) {
|
|
17371
17565
|
dexCalldata = {
|
|
17372
17566
|
to: responseData.dex_calldata.to,
|
|
17373
17567
|
data: responseData.dex_calldata.data,
|
|
@@ -17415,7 +17609,7 @@ var Client = class _Client {
|
|
|
17415
17609
|
* ```
|
|
17416
17610
|
*/
|
|
17417
17611
|
async claimArkade(id, options) {
|
|
17418
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
17612
|
+
if (!_optionalChain([options, 'optionalAccess', _213 => _213.destinationAddress])) {
|
|
17419
17613
|
return {
|
|
17420
17614
|
success: false,
|
|
17421
17615
|
message: 'Destination address is required for Arkade claims. Provide it via the options parameter: { destinationAddress: "ark1..." }'
|
|
@@ -17501,7 +17695,7 @@ var Client = class _Client {
|
|
|
17501
17695
|
electrum,
|
|
17502
17696
|
fundTxid
|
|
17503
17697
|
);
|
|
17504
|
-
if (_optionalChain([txData, 'optionalAccess',
|
|
17698
|
+
if (_optionalChain([txData, 'optionalAccess', _214 => _214.vout, 'optionalAccess', _215 => _215[fundVout]])) {
|
|
17505
17699
|
return {
|
|
17506
17700
|
txid: fundTxid,
|
|
17507
17701
|
vout: fundVout,
|
|
@@ -17537,7 +17731,7 @@ var Client = class _Client {
|
|
|
17537
17731
|
async #findOnchainHtlcOutputEsplora(esploraUrls, address2, fundTxid, fundVout) {
|
|
17538
17732
|
if (fundTxid && fundVout !== void 0) {
|
|
17539
17733
|
const txData = await fetchTransactionOutputs(esploraUrls, fundTxid);
|
|
17540
|
-
if (_optionalChain([txData, 'optionalAccess',
|
|
17734
|
+
if (_optionalChain([txData, 'optionalAccess', _216 => _216.vout, 'optionalAccess', _217 => _217[fundVout]])) {
|
|
17541
17735
|
return {
|
|
17542
17736
|
txid: fundTxid,
|
|
17543
17737
|
vout: fundVout,
|
|
@@ -17692,8 +17886,8 @@ var Client = class _Client {
|
|
|
17692
17886
|
try {
|
|
17693
17887
|
const result = await continueArkadeClaim({
|
|
17694
17888
|
...claimParams,
|
|
17695
|
-
destinationAddress: _optionalChain([options, 'optionalAccess',
|
|
17696
|
-
arkadeServerUrl: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
17889
|
+
destinationAddress: _optionalChain([options, 'optionalAccess', _218 => _218.destinationAddress]),
|
|
17890
|
+
arkadeServerUrl: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _219 => _219.arkadeServerUrl]), () => ( this.#config.arkadeServerUrl)),
|
|
17697
17891
|
logger: this.#config.logger,
|
|
17698
17892
|
logLevel: this.#config.logLevel
|
|
17699
17893
|
});
|
|
@@ -17811,7 +18005,7 @@ var Client = class _Client {
|
|
|
17811
18005
|
*/
|
|
17812
18006
|
async #claimArkadeDelegate(swapId, params, options) {
|
|
17813
18007
|
try {
|
|
17814
|
-
const result = await
|
|
18008
|
+
const result = await _chunkQJ4EK6UGcjs.delegateClaim.call(void 0, {
|
|
17815
18009
|
...params,
|
|
17816
18010
|
destinationAddress: options.destinationAddress,
|
|
17817
18011
|
lendaswapApiUrl: this.#config.baseUrl,
|
|
@@ -17884,10 +18078,10 @@ var Client = class _Client {
|
|
|
17884
18078
|
}
|
|
17885
18079
|
if (direction === "evm_to_arkade" || direction === "evm_to_bitcoin" || direction === "evm_to_lightning") {
|
|
17886
18080
|
const evmOptions = options;
|
|
17887
|
-
if (_optionalChain([evmOptions, 'optionalAccess',
|
|
18081
|
+
if (_optionalChain([evmOptions, 'optionalAccess', _220 => _220.collaborative])) {
|
|
17888
18082
|
return this.#collabRefundEvm(id);
|
|
17889
18083
|
}
|
|
17890
|
-
return this.#buildEvmSourceRefund(id, storedSwap, _optionalChain([evmOptions, 'optionalAccess',
|
|
18084
|
+
return this.#buildEvmSourceRefund(id, storedSwap, _optionalChain([evmOptions, 'optionalAccess', _221 => _221.signer]));
|
|
17891
18085
|
}
|
|
17892
18086
|
return {
|
|
17893
18087
|
success: false,
|
|
@@ -17981,7 +18175,7 @@ var Client = class _Client {
|
|
|
17981
18175
|
}
|
|
17982
18176
|
const btcFundTxid = swap.btc_fund_txid;
|
|
17983
18177
|
const btcFundVout = swap.btc_fund_vout;
|
|
17984
|
-
const waitForFundingMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
18178
|
+
const waitForFundingMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _222 => _222.waitForFundingMs]), () => ( 3e4));
|
|
17985
18179
|
const htlcOutput = await this.#waitForOnchainHtlcOutput(
|
|
17986
18180
|
esploraUrls,
|
|
17987
18181
|
network,
|
|
@@ -17996,14 +18190,14 @@ var Client = class _Client {
|
|
|
17996
18190
|
message: `Could not find UTXO at HTLC address ${btcHtlcAddress} after waiting ${waitForFundingMs}ms. The server may not have funded the HTLC yet.`
|
|
17997
18191
|
};
|
|
17998
18192
|
}
|
|
17999
|
-
const destinationAddress = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
18193
|
+
const destinationAddress = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _223 => _223.destinationAddress]), () => ( storedPayoutTarget(storedSwap)));
|
|
18000
18194
|
if (!destinationAddress) {
|
|
18001
18195
|
return {
|
|
18002
18196
|
success: false,
|
|
18003
18197
|
message: 'Destination address is required to claim BTC. Provide it via options: { destinationAddress: "bc1p..." }'
|
|
18004
18198
|
};
|
|
18005
18199
|
}
|
|
18006
|
-
const feeRateSatPerVb = await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async
|
|
18200
|
+
const feeRateSatPerVb = await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async _224 => _224.feeRateSatPerVb]), async () => ( Math.max(2, await _asyncNullishCoalesce(await fetchFeeRateEstimate(esploraUrls, 2), async () => ( 0)))));
|
|
18007
18201
|
try {
|
|
18008
18202
|
const result = buildOnchainClaimTransaction({
|
|
18009
18203
|
fundingTxId: htlcOutput.txid,
|
|
@@ -18025,7 +18219,7 @@ var Client = class _Client {
|
|
|
18025
18219
|
esploraUrls,
|
|
18026
18220
|
network,
|
|
18027
18221
|
result.txHex,
|
|
18028
|
-
_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
18222
|
+
_nullishCoalesce(_optionalChain([options, 'optionalAccess', _225 => _225.broadcastRetries]), () => ( 5))
|
|
18029
18223
|
);
|
|
18030
18224
|
return {
|
|
18031
18225
|
success: true,
|
|
@@ -18055,7 +18249,7 @@ var Client = class _Client {
|
|
|
18055
18249
|
* @internal
|
|
18056
18250
|
*/
|
|
18057
18251
|
async #buildOnchainRefund(id, swap, options) {
|
|
18058
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
18252
|
+
if (!_optionalChain([options, 'optionalAccess', _226 => _226.destinationAddress])) {
|
|
18059
18253
|
return {
|
|
18060
18254
|
success: false,
|
|
18061
18255
|
message: 'Destination address is required for on-chain refunds. Provide it via the options parameter: { destinationAddress: "bc1q..." }'
|
|
@@ -18261,7 +18455,7 @@ network='${network}'`
|
|
|
18261
18455
|
* @internal
|
|
18262
18456
|
*/
|
|
18263
18457
|
async #buildArkadeRefund(id, swap, options) {
|
|
18264
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
18458
|
+
if (!_optionalChain([options, 'optionalAccess', _227 => _227.destinationAddress])) {
|
|
18265
18459
|
return {
|
|
18266
18460
|
success: false,
|
|
18267
18461
|
message: 'Destination address is required for Arkade refunds. Provide it via the options parameter: { destinationAddress: "ark1..." }'
|
|
@@ -18402,7 +18596,7 @@ network='${network}'`
|
|
|
18402
18596
|
*/
|
|
18403
18597
|
async #refundArkadeDelegate(params, options) {
|
|
18404
18598
|
try {
|
|
18405
|
-
const result = await
|
|
18599
|
+
const result = await _chunkQJ4EK6UGcjs.delegateRefund.call(void 0, {
|
|
18406
18600
|
...params,
|
|
18407
18601
|
lendaswapApiUrl: this.#config.baseUrl,
|
|
18408
18602
|
arkadeServerUrl: _nullishCoalesce(options.arkadeServerUrl, () => ( this.#config.arkadeServerUrl)),
|
|
@@ -18497,7 +18691,7 @@ network='${network}'`
|
|
|
18497
18691
|
const call = decodeRefundCall(server.data);
|
|
18498
18692
|
const to = server.to.toLowerCase();
|
|
18499
18693
|
const htlc = leg.htlcAddress.toLowerCase();
|
|
18500
|
-
const coordinator = _optionalChain([leg, 'access',
|
|
18694
|
+
const coordinator = _optionalChain([leg, 'access', _228 => _228.coordinatorAddress, 'optionalAccess', _229 => _229.toLowerCase, 'call', _230 => _230()]);
|
|
18501
18695
|
const signer = check.signer;
|
|
18502
18696
|
let lockSender;
|
|
18503
18697
|
let recipient;
|
|
@@ -18518,7 +18712,7 @@ network='${network}'`
|
|
|
18518
18712
|
`The server's refund targets ${server.to}, not this swap's HTLC ${leg.htlcAddress}`
|
|
18519
18713
|
);
|
|
18520
18714
|
}
|
|
18521
|
-
lockSender = _optionalChain([signer, 'optionalAccess',
|
|
18715
|
+
lockSender = _optionalChain([signer, 'optionalAccess', _231 => _231.address, 'access', _232 => _232.toLowerCase, 'call', _233 => _233()]);
|
|
18522
18716
|
recipient = lockSender;
|
|
18523
18717
|
break;
|
|
18524
18718
|
case "refundTo":
|
|
@@ -18549,7 +18743,7 @@ network='${network}'`
|
|
|
18549
18743
|
const read = async (tx, what) => {
|
|
18550
18744
|
try {
|
|
18551
18745
|
return decodeCallWord(await signer.call(tx), what);
|
|
18552
|
-
} catch (
|
|
18746
|
+
} catch (e22) {
|
|
18553
18747
|
return void 0;
|
|
18554
18748
|
}
|
|
18555
18749
|
};
|
|
@@ -18637,7 +18831,7 @@ network='${network}'`
|
|
|
18637
18831
|
}
|
|
18638
18832
|
#fundingExpectation(swapId, stored) {
|
|
18639
18833
|
const hashLock = this.#clientHashLock(swapId, stored);
|
|
18640
|
-
const terms = _optionalChain([stored, 'optionalAccess',
|
|
18834
|
+
const terms = _optionalChain([stored, 'optionalAccess', _234 => _234.evmFundingTerms]);
|
|
18641
18835
|
if (!terms) {
|
|
18642
18836
|
throw new Error(
|
|
18643
18837
|
`Swap ${swapId} has no funding terms recorded by this client at creation (it was recovered, or created by an older SDK), so the server's funding payload cannot be checked; refusing to fund it. Refund it instead.`
|
|
@@ -18710,7 +18904,7 @@ network='${network}'`
|
|
|
18710
18904
|
if (!this.#swapStorage) return;
|
|
18711
18905
|
try {
|
|
18712
18906
|
const stored = await this.#swapStorage.get(swapId);
|
|
18713
|
-
if (_optionalChain([stored, 'optionalAccess',
|
|
18907
|
+
if (_optionalChain([stored, 'optionalAccess', _235 => _235.evmFundTxid, 'optionalAccess', _236 => _236.toLowerCase, 'call', _237 => _237()]) !== txid.toLowerCase()) return;
|
|
18714
18908
|
await this.#swapStorage.store({
|
|
18715
18909
|
...stored,
|
|
18716
18910
|
evmFundTxid: void 0,
|
|
@@ -18735,7 +18929,7 @@ network='${network}'`
|
|
|
18735
18929
|
* `hint` is appended to the error when neither is.
|
|
18736
18930
|
*/
|
|
18737
18931
|
#depositorOwnerSigner(swapResponse, walletSigner, hint) {
|
|
18738
|
-
const depositor = _optionalChain([swapResponse, 'access',
|
|
18932
|
+
const depositor = _optionalChain([swapResponse, 'access', _238 => _238.client_evm_address, 'optionalAccess', _239 => _239.toLowerCase, 'call', _240 => _240()]);
|
|
18739
18933
|
if (depositor === this.getEvmAddress().toLowerCase()) {
|
|
18740
18934
|
return this.#keyOwnerSigner();
|
|
18741
18935
|
}
|
|
@@ -18807,7 +19001,7 @@ network='${network}'`
|
|
|
18807
19001
|
stored.secretKey ? deriveEvmAddress(stored.secretKey) : void 0
|
|
18808
19002
|
]);
|
|
18809
19003
|
const expectedDepositors = uniqueAddresses([
|
|
18810
|
-
_optionalChain([signer, 'optionalAccess',
|
|
19004
|
+
_optionalChain([signer, 'optionalAccess', _241 => _241.address]),
|
|
18811
19005
|
...sdkAddresses,
|
|
18812
19006
|
stored.response.client_evm_address
|
|
18813
19007
|
]);
|
|
@@ -18833,7 +19027,7 @@ network='${network}'`
|
|
|
18833
19027
|
expectedDepositors
|
|
18834
19028
|
});
|
|
18835
19029
|
const coordinatorProved = !leg.depositorIsSender && refund.sender !== signer.address.toLowerCase() && stored.evmCoordinatorAddress === void 0;
|
|
18836
|
-
if (fundTxid.toLowerCase() !== _optionalChain([stored, 'access',
|
|
19030
|
+
if (fundTxid.toLowerCase() !== _optionalChain([stored, 'access', _242 => _242.evmFundTxid, 'optionalAccess', _243 => _243.toLowerCase, 'call', _244 => _244()]) || coordinatorProved) {
|
|
18837
19031
|
await this.#recordEvmFunding(id, {
|
|
18838
19032
|
txid: fundTxid,
|
|
18839
19033
|
coordinatorAddress: coordinatorProved ? refund.sender : void 0
|
|
@@ -18892,7 +19086,7 @@ network='${network}'`
|
|
|
18892
19086
|
async #serverFundTxid(id) {
|
|
18893
19087
|
const fresh = await this.getSwap(id);
|
|
18894
19088
|
try {
|
|
18895
|
-
await _optionalChain([this, 'access',
|
|
19089
|
+
await _optionalChain([this, 'access', _245 => _245.#swapStorage, 'optionalAccess', _246 => _246.update, 'call', _247 => _247(id, fresh)]);
|
|
18896
19090
|
} catch (error) {
|
|
18897
19091
|
this.#logger.warn({
|
|
18898
19092
|
event: "client.refundSwap.refreshNotStored",
|
|
@@ -18905,7 +19099,7 @@ network='${network}'`
|
|
|
18905
19099
|
}
|
|
18906
19100
|
async #refundFromFundingTx(signer, leg) {
|
|
18907
19101
|
const self2 = signer.address.toLowerCase();
|
|
18908
|
-
const coordinator = _optionalChain([leg, 'access',
|
|
19102
|
+
const coordinator = _optionalChain([leg, 'access', _248 => _248.coordinatorAddress, 'optionalAccess', _249 => _249.toLowerCase, 'call', _250 => _250()]);
|
|
18909
19103
|
const senders = leg.depositorIsSender ? uniqueAddresses([self2, ...leg.expectedDepositors]) : coordinator === void 0 ? void 0 : [self2, coordinator];
|
|
18910
19104
|
const { created, terms, hashLock } = await this.#lockFromFundingTx(signer, {
|
|
18911
19105
|
...leg,
|
|
@@ -18983,7 +19177,7 @@ network='${network}'`
|
|
|
18983
19177
|
let known;
|
|
18984
19178
|
try {
|
|
18985
19179
|
known = await signer.getTransaction(leg.fundTxid);
|
|
18986
|
-
} catch (
|
|
19180
|
+
} catch (e23) {
|
|
18987
19181
|
known = null;
|
|
18988
19182
|
}
|
|
18989
19183
|
if (!known) {
|
|
@@ -19066,7 +19260,7 @@ network='${network}'`
|
|
|
19066
19260
|
await signer.call(_chunkJZTF4JNHcjs.encodeHtlcSwapsCallData.call(void 0, htlcAddress2, key)),
|
|
19067
19261
|
"swaps"
|
|
19068
19262
|
);
|
|
19069
|
-
} catch (
|
|
19263
|
+
} catch (e24) {
|
|
19070
19264
|
return void 0;
|
|
19071
19265
|
}
|
|
19072
19266
|
}
|
|
@@ -19243,7 +19437,7 @@ network='${network}'`
|
|
|
19243
19437
|
*/
|
|
19244
19438
|
async collabRefundEvmSwap(swapId) {
|
|
19245
19439
|
const storedSwap = await this.getStoredSwap(swapId);
|
|
19246
|
-
if (!_optionalChain([storedSwap, 'optionalAccess',
|
|
19440
|
+
if (!_optionalChain([storedSwap, 'optionalAccess', _251 => _251.secretKey])) {
|
|
19247
19441
|
throw new Error(
|
|
19248
19442
|
"No secret key found for this swap. Cannot sign collab refund."
|
|
19249
19443
|
);
|
|
@@ -19385,7 +19579,7 @@ network='${network}'`
|
|
|
19385
19579
|
entryPointVersion: entryPoint.version,
|
|
19386
19580
|
userOperation: signed
|
|
19387
19581
|
});
|
|
19388
|
-
} catch (
|
|
19582
|
+
} catch (e25) {
|
|
19389
19583
|
computed = void 0;
|
|
19390
19584
|
}
|
|
19391
19585
|
await hooks.onSigned(computed);
|
|
@@ -19402,11 +19596,11 @@ network='${network}'`
|
|
|
19402
19596
|
} else {
|
|
19403
19597
|
userOpHash = await client.sendUserOperation({ calls });
|
|
19404
19598
|
}
|
|
19405
|
-
await _optionalChain([hooks, 'access',
|
|
19599
|
+
await _optionalChain([hooks, 'access', _252 => _252.onSubmitted, 'optionalCall', _253 => _253(userOpHash)]);
|
|
19406
19600
|
const { receipt, success, reason } = await client.waitForUserOperationReceipt({
|
|
19407
19601
|
hash: userOpHash
|
|
19408
19602
|
});
|
|
19409
|
-
await _optionalChain([hooks, 'access',
|
|
19603
|
+
await _optionalChain([hooks, 'access', _254 => _254.onIncluded, 'optionalCall', _255 => _255(receipt.transactionHash, userOpHash)]);
|
|
19410
19604
|
if (!success) {
|
|
19411
19605
|
throw new Error(
|
|
19412
19606
|
`Sponsored UserOp ${userOpHash} reverted on-chain${reason ? `: ${reason}` : ""}`
|
|
@@ -19627,7 +19821,7 @@ network='${network}'`
|
|
|
19627
19821
|
* no AA config, not included, or the bundler cannot be reached).
|
|
19628
19822
|
*/
|
|
19629
19823
|
async #pendingRehashTx(rehash) {
|
|
19630
|
-
const bundlerUrl = _optionalChain([this, 'access',
|
|
19824
|
+
const bundlerUrl = _optionalChain([this, 'access', _256 => _256.#config, 'access', _257 => _257.aa, 'optionalAccess', _258 => _258.bundlerUrl]);
|
|
19631
19825
|
if (!rehash.userOpHash || !bundlerUrl) return void 0;
|
|
19632
19826
|
try {
|
|
19633
19827
|
const response = await fetch(bundlerUrl, {
|
|
@@ -19641,8 +19835,8 @@ network='${network}'`
|
|
|
19641
19835
|
})
|
|
19642
19836
|
});
|
|
19643
19837
|
const json = await response.json();
|
|
19644
|
-
return _nullishCoalesce(_optionalChain([json, 'access',
|
|
19645
|
-
} catch (
|
|
19838
|
+
return _nullishCoalesce(_optionalChain([json, 'access', _259 => _259.result, 'optionalAccess', _260 => _260.receipt, 'optionalAccess', _261 => _261.transactionHash]), () => ( void 0));
|
|
19839
|
+
} catch (e26) {
|
|
19646
19840
|
return void 0;
|
|
19647
19841
|
}
|
|
19648
19842
|
}
|
|
@@ -19651,7 +19845,7 @@ network='${network}'`
|
|
|
19651
19845
|
if (!this.#swapStorage) return;
|
|
19652
19846
|
try {
|
|
19653
19847
|
const stored = await this.#swapStorage.get(swapId);
|
|
19654
|
-
const history = _optionalChain([stored, 'optionalAccess',
|
|
19848
|
+
const history = _optionalChain([stored, 'optionalAccess', _262 => _262.evmRehashes]);
|
|
19655
19849
|
if (!stored || !history) return;
|
|
19656
19850
|
let index = -1;
|
|
19657
19851
|
for (let i = history.length - 1; i >= 0; i--) {
|
|
@@ -19702,7 +19896,7 @@ network='${network}'`
|
|
|
19702
19896
|
}
|
|
19703
19897
|
const ownHash = this.#clientHashLock(swapId, stored);
|
|
19704
19898
|
const leg = evmSourceLeg(stored);
|
|
19705
|
-
const firstFrom = _optionalChain([leg, 'access',
|
|
19899
|
+
const firstFrom = _optionalChain([leg, 'access', _263 => _263.rehashes, 'optionalAccess', _264 => _264[0], 'optionalAccess', _265 => _265.fromHashLock]);
|
|
19706
19900
|
if (firstFrom !== void 0 && `0x${_chunkJZTF4JNHcjs.normalizeBytes32.call(void 0, firstFrom)}` !== ownHash) {
|
|
19707
19901
|
throw new Error(
|
|
19708
19902
|
`The rehash history of swap ${swapId} starts from ${firstFrom}, not from the payment hash this client fixed (${ownHash})`
|
|
@@ -19761,7 +19955,7 @@ network='${network}'`
|
|
|
19761
19955
|
* does not read the chain. Arbitrum only, like the paymaster.
|
|
19762
19956
|
*/
|
|
19763
19957
|
async #aaChainReader(owner) {
|
|
19764
|
-
const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access',
|
|
19958
|
+
const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access', _266 => _266.#config, 'access', _267 => _267.aa, 'optionalAccess', _268 => _268.rpcUrl]), () => ( _optionalChain([this, 'access', _269 => _269.#config, 'access', _270 => _270.aa, 'optionalAccess', _271 => _271.bundlerUrl])));
|
|
19765
19959
|
if (!rpcUrl) {
|
|
19766
19960
|
throw new Error(
|
|
19767
19961
|
"A sponsored rehash reads the lock over the AA RPC; call `.withAa({ bundlerUrl, paymasterPolicyId })` on the ClientBuilder before `.build()`."
|
|
@@ -19812,7 +20006,7 @@ network='${network}'`
|
|
|
19812
20006
|
*/
|
|
19813
20007
|
async retrySwapWithInvoice(swapId, invoice) {
|
|
19814
20008
|
const storedSwap = await this.getStoredSwap(swapId);
|
|
19815
|
-
if (!_optionalChain([storedSwap, 'optionalAccess',
|
|
20009
|
+
if (!_optionalChain([storedSwap, 'optionalAccess', _272 => _272.secretKey])) {
|
|
19816
20010
|
throw new Error(
|
|
19817
20011
|
"No secret key found for this swap. Cannot authorize the rehash."
|
|
19818
20012
|
);
|
|
@@ -19964,23 +20158,23 @@ network='${network}'`
|
|
|
19964
20158
|
updatedAt: Date.now(),
|
|
19965
20159
|
// The payout this client asked for; claims pay here, never to a
|
|
19966
20160
|
// server answer. Recovery rebuilding the swap keeps it.
|
|
19967
|
-
targetAddress: _nullishCoalesce(targetAddress, () => ( _optionalChain([existing, 'optionalAccess',
|
|
19968
|
-
bridgeRecipient: _optionalChain([bridge, 'optionalAccess',
|
|
19969
|
-
bridgeRecipientWallet: _optionalChain([bridge, 'optionalAccess',
|
|
19970
|
-
evmFundTxid: _optionalChain([existing, 'optionalAccess',
|
|
19971
|
-
evmFundingUserOpHash: _optionalChain([existing, 'optionalAccess',
|
|
20161
|
+
targetAddress: _nullishCoalesce(targetAddress, () => ( _optionalChain([existing, 'optionalAccess', _273 => _273.targetAddress]))),
|
|
20162
|
+
bridgeRecipient: _optionalChain([bridge, 'optionalAccess', _274 => _274.recipient]),
|
|
20163
|
+
bridgeRecipientWallet: _optionalChain([bridge, 'optionalAccess', _275 => _275.recipientWallet]),
|
|
20164
|
+
evmFundTxid: _optionalChain([existing, 'optionalAccess', _276 => _276.evmFundTxid]),
|
|
20165
|
+
evmFundingUserOpHash: _optionalChain([existing, 'optionalAccess', _277 => _277.evmFundingUserOpHash]),
|
|
19972
20166
|
// Fixed at creation and never taken from a server answer: recovery
|
|
19973
20167
|
// rebuilding the swap keeps it, and a fresh device has none.
|
|
19974
|
-
lightningPaymentHash: _nullishCoalesce(_optionalChain([commitments, 'optionalAccess',
|
|
19975
|
-
evmFundingTerms: _nullishCoalesce(_optionalChain([commitments, 'optionalAccess',
|
|
19976
|
-
evmCoordinatorAddress: _optionalChain([existing, 'optionalAccess',
|
|
20168
|
+
lightningPaymentHash: _nullishCoalesce(_optionalChain([commitments, 'optionalAccess', _278 => _278.lightningPaymentHash]), () => ( _optionalChain([existing, 'optionalAccess', _279 => _279.lightningPaymentHash]))),
|
|
20169
|
+
evmFundingTerms: _nullishCoalesce(_optionalChain([commitments, 'optionalAccess', _280 => _280.evmFundingTerms]), () => ( _optionalChain([existing, 'optionalAccess', _281 => _281.evmFundingTerms]))),
|
|
20170
|
+
evmCoordinatorAddress: _optionalChain([existing, 'optionalAccess', _282 => _282.evmCoordinatorAddress]),
|
|
19977
20171
|
// The rehashes this client sent are what let a refund find the lock
|
|
19978
20172
|
// that exists; the server's copy names only the current hash.
|
|
19979
|
-
evmRehashes: _optionalChain([existing, 'optionalAccess',
|
|
20173
|
+
evmRehashes: _optionalChain([existing, 'optionalAccess', _283 => _283.evmRehashes]),
|
|
19980
20174
|
// A CCTP-inbound burn is the only way to resume or recover once the
|
|
19981
20175
|
// USDC has left the source chain.
|
|
19982
|
-
cctpBurnTxid: _optionalChain([existing, 'optionalAccess',
|
|
19983
|
-
cctpBurnLastValidBlockHeight: _optionalChain([existing, 'optionalAccess',
|
|
20176
|
+
cctpBurnTxid: _optionalChain([existing, 'optionalAccess', _284 => _284.cctpBurnTxid]),
|
|
20177
|
+
cctpBurnLastValidBlockHeight: _optionalChain([existing, 'optionalAccess', _285 => _285.cctpBurnLastValidBlockHeight])
|
|
19984
20178
|
};
|
|
19985
20179
|
await this.#swapStorage.store(storedSwap);
|
|
19986
20180
|
}
|
|
@@ -20022,7 +20216,7 @@ network='${network}'`
|
|
|
20022
20216
|
const targetAsset = "token_id" in tgt ? { chain: tgt.chain, token_id: tgt.token_id } : { chain: tgt.chain, token_id: tgt.tokenId };
|
|
20023
20217
|
if (isTronToken(sourceAsset.chain))
|
|
20024
20218
|
throw new Error("Tron is a payout-only destination");
|
|
20025
|
-
const isTronTarget = isTronToken(targetAsset.chain) || _optionalChain([options, 'access',
|
|
20219
|
+
const isTronTarget = isTronToken(targetAsset.chain) || _optionalChain([options, 'access', _286 => _286.bridgeParams, 'optionalAccess', _287 => _287.targetChain]) === "Tron";
|
|
20026
20220
|
if (isTronTarget) {
|
|
20027
20221
|
if (isTronToken(targetAsset.chain) && targetAsset.token_id !== USDT0_ADDRESSES.Tron) {
|
|
20028
20222
|
throw new Error("Tron payouts require native USDT");
|
|
@@ -20062,7 +20256,7 @@ network='${network}'`
|
|
|
20062
20256
|
if (isTronTarget && bridgeParams) {
|
|
20063
20257
|
bridgeParams = { ...bridgeParams, recipient: options.targetAddress };
|
|
20064
20258
|
}
|
|
20065
|
-
const cctpPayout = !options.bridgeParams && bridgeParams != null && _optionalChain([bridgeParams, 'access',
|
|
20259
|
+
const cctpPayout = !options.bridgeParams && bridgeParams != null && _optionalChain([bridgeParams, 'access', _288 => _288.targetTokenAddress, 'optionalAccess', _289 => _289.toLowerCase, 'call', _290 => _290()]) === _optionalChain([_chunkTKFOVRJRcjs.USDC_ADDRESSES, 'access', _291 => _291[bridgeParams.targetChain], 'optionalAccess', _292 => _292.toLowerCase, 'call', _293 => _293()]);
|
|
20066
20260
|
if (cctpPayout && options.sourceAmount != null) {
|
|
20067
20261
|
const quote = await this.getQuote({
|
|
20068
20262
|
sourceChain: sourceAsset.chain,
|
|
@@ -20072,11 +20266,12 @@ network='${network}'`
|
|
|
20072
20266
|
sourceAmount: options.sourceAmount,
|
|
20073
20267
|
referralCode: options.referralCode,
|
|
20074
20268
|
extraFees: options.extraFees,
|
|
20269
|
+
promoCode: options.promoCode,
|
|
20075
20270
|
bridgeRecipientSetup: options.bridgeRecipientSetup
|
|
20076
20271
|
});
|
|
20077
20272
|
if (BigInt(quote.net_target_amount) <= 0n) {
|
|
20078
20273
|
throw new Error(
|
|
20079
|
-
`Amount too small to bridge to ${_optionalChain([bridgeParams, 'optionalAccess',
|
|
20274
|
+
`Amount too small to bridge to ${_optionalChain([bridgeParams, 'optionalAccess', _294 => _294.targetChain])}: the CCTP fee (${_nullishCoalesce(quote.bridge_fee, () => ( "unknown"))} USDC units) leaves nothing to deliver. Increase the amount.`
|
|
20080
20275
|
);
|
|
20081
20276
|
}
|
|
20082
20277
|
}
|
|
@@ -20123,6 +20318,7 @@ network='${network}'`
|
|
|
20123
20318
|
targetAmount: options.targetAmount ? BigInt(options.targetAmount) : void 0,
|
|
20124
20319
|
referralCode: options.referralCode,
|
|
20125
20320
|
extraFees: options.extraFees,
|
|
20321
|
+
promoCode: options.promoCode,
|
|
20126
20322
|
bridgeParams
|
|
20127
20323
|
});
|
|
20128
20324
|
}
|
|
@@ -20148,7 +20344,8 @@ network='${network}'`
|
|
|
20148
20344
|
...options.sourceAmount != null ? { sourceAmountSats: Number(options.sourceAmount) } : { targetAmountSats: Number(options.targetAmount) },
|
|
20149
20345
|
targetAddress: options.targetAddress,
|
|
20150
20346
|
referralCode: options.referralCode,
|
|
20151
|
-
extraFees: options.extraFees
|
|
20347
|
+
extraFees: options.extraFees,
|
|
20348
|
+
promoCode: options.promoCode
|
|
20152
20349
|
});
|
|
20153
20350
|
}
|
|
20154
20351
|
if (isLightning(sourceAsset) && isBtcOnchain(targetAsset)) {
|
|
@@ -20161,7 +20358,8 @@ network='${network}'`
|
|
|
20161
20358
|
...options.sourceAmount != null ? { sourceAmountSats: Number(options.sourceAmount) } : { targetAmountSats: Number(options.targetAmount) },
|
|
20162
20359
|
targetAddress: options.targetAddress,
|
|
20163
20360
|
referralCode: options.referralCode,
|
|
20164
|
-
extraFees: options.extraFees
|
|
20361
|
+
extraFees: options.extraFees,
|
|
20362
|
+
promoCode: options.promoCode
|
|
20165
20363
|
});
|
|
20166
20364
|
}
|
|
20167
20365
|
if (isLightning(sourceAsset) && isEvmToken(targetChain)) {
|
|
@@ -20178,6 +20376,25 @@ network='${network}'`
|
|
|
20178
20376
|
targetAmount: options.targetAmount == null ? void 0 : BigInt(options.targetAmount),
|
|
20179
20377
|
referralCode: options.referralCode,
|
|
20180
20378
|
extraFees: options.extraFees,
|
|
20379
|
+
promoCode: options.promoCode,
|
|
20380
|
+
bridgeParams
|
|
20381
|
+
});
|
|
20382
|
+
}
|
|
20383
|
+
if (sourceAsset.chain === "Spark" && isEvmToken(targetChain)) {
|
|
20384
|
+
if (options.sourceAmount == null === (options.targetAmount == null)) {
|
|
20385
|
+
throw new Error(
|
|
20386
|
+
"Provide exactly one of sourceAmount (sats on Spark) or targetAmount (token units to receive) for Spark \u2192 EVM swaps"
|
|
20387
|
+
);
|
|
20388
|
+
}
|
|
20389
|
+
return this.createSparkToEvmSwap({
|
|
20390
|
+
targetAddress: options.targetAddress,
|
|
20391
|
+
tokenAddress,
|
|
20392
|
+
evmChainId: Number(targetChain),
|
|
20393
|
+
sourceAmount: options.sourceAmount == null ? void 0 : Number(options.sourceAmount),
|
|
20394
|
+
targetAmount: options.targetAmount == null ? void 0 : BigInt(options.targetAmount),
|
|
20395
|
+
referralCode: options.referralCode,
|
|
20396
|
+
extraFees: options.extraFees,
|
|
20397
|
+
promoCode: options.promoCode,
|
|
20181
20398
|
bridgeParams
|
|
20182
20399
|
});
|
|
20183
20400
|
}
|
|
@@ -20190,6 +20407,7 @@ network='${network}'`
|
|
|
20190
20407
|
targetAmount: options.targetAmount == null ? void 0 : BigInt(options.targetAmount),
|
|
20191
20408
|
referralCode: options.referralCode,
|
|
20192
20409
|
extraFees: options.extraFees,
|
|
20410
|
+
promoCode: options.promoCode,
|
|
20193
20411
|
bridgeParams
|
|
20194
20412
|
});
|
|
20195
20413
|
}
|
|
@@ -20203,7 +20421,8 @@ network='${network}'`
|
|
|
20203
20421
|
satsReceive: Number(options.targetAmount),
|
|
20204
20422
|
targetAddress: options.targetAddress,
|
|
20205
20423
|
referralCode: options.referralCode,
|
|
20206
|
-
extraFees: options.extraFees
|
|
20424
|
+
extraFees: options.extraFees,
|
|
20425
|
+
promoCode: options.promoCode
|
|
20207
20426
|
});
|
|
20208
20427
|
}
|
|
20209
20428
|
if (isEvmSwapSource(sourceChain, sourceTokenId) && isLightning(targetAsset)) {
|
|
@@ -20220,6 +20439,7 @@ network='${network}'`
|
|
|
20220
20439
|
userAddress: options.userAddress,
|
|
20221
20440
|
referralCode: options.referralCode,
|
|
20222
20441
|
extraFees: options.extraFees,
|
|
20442
|
+
promoCode: options.promoCode,
|
|
20223
20443
|
gasless: options.gasless,
|
|
20224
20444
|
inboundBridgeParams
|
|
20225
20445
|
};
|
|
@@ -20269,6 +20489,7 @@ network='${network}'`
|
|
|
20269
20489
|
targetAmount: options.targetAmount == null ? void 0 : Number(options.targetAmount),
|
|
20270
20490
|
referralCode: options.referralCode,
|
|
20271
20491
|
extraFees: options.extraFees,
|
|
20492
|
+
promoCode: options.promoCode,
|
|
20272
20493
|
gasless: options.gasless,
|
|
20273
20494
|
inboundBridgeParams
|
|
20274
20495
|
});
|
|
@@ -20288,6 +20509,7 @@ network='${network}'`
|
|
|
20288
20509
|
targetAmount: options.targetAmount == null ? void 0 : Number(options.targetAmount),
|
|
20289
20510
|
referralCode: options.referralCode,
|
|
20290
20511
|
extraFees: options.extraFees,
|
|
20512
|
+
promoCode: options.promoCode,
|
|
20291
20513
|
gasless: options.gasless,
|
|
20292
20514
|
inboundBridgeParams
|
|
20293
20515
|
});
|
|
@@ -20475,6 +20697,13 @@ network='${network}'`
|
|
|
20475
20697
|
await this.#rifClaimAddress(options)
|
|
20476
20698
|
);
|
|
20477
20699
|
}
|
|
20700
|
+
async createSparkToEvmSwap(options) {
|
|
20701
|
+
return createSparkToEvmSwap(
|
|
20702
|
+
options,
|
|
20703
|
+
this.#getCreateContext(),
|
|
20704
|
+
await this.#rifClaimAddress(options)
|
|
20705
|
+
);
|
|
20706
|
+
}
|
|
20478
20707
|
// =========================================================================
|
|
20479
20708
|
// Swap Creation - Arkade to Lightning
|
|
20480
20709
|
// =========================================================================
|
|
@@ -20700,7 +20929,7 @@ network='${network}'`
|
|
|
20700
20929
|
swapId,
|
|
20701
20930
|
serverData,
|
|
20702
20931
|
chainId,
|
|
20703
|
-
_optionalChain([options, 'optionalAccess',
|
|
20932
|
+
_optionalChain([options, 'optionalAccess', _295 => _295.funding])
|
|
20704
20933
|
);
|
|
20705
20934
|
const nonceBytes = new Uint8Array(32);
|
|
20706
20935
|
crypto.getRandomValues(nonceBytes);
|
|
@@ -20842,7 +21071,7 @@ network='${network}'`
|
|
|
20842
21071
|
swapId,
|
|
20843
21072
|
serverData,
|
|
20844
21073
|
chainId,
|
|
20845
|
-
_optionalChain([options, 'optionalAccess',
|
|
21074
|
+
_optionalChain([options, 'optionalAccess', _296 => _296.funding])
|
|
20846
21075
|
);
|
|
20847
21076
|
const nonceBytes = new Uint8Array(32);
|
|
20848
21077
|
crypto.getRandomValues(nonceBytes);
|
|
@@ -20931,14 +21160,14 @@ network='${network}'`
|
|
|
20931
21160
|
*/
|
|
20932
21161
|
async fundSwap(swapId, signer, options) {
|
|
20933
21162
|
{
|
|
20934
|
-
const stored = await _optionalChain([this, 'access',
|
|
20935
|
-
const response = await _asyncNullishCoalesce(await _asyncOptionalChain([stored, 'optionalAccess', async
|
|
21163
|
+
const stored = await _optionalChain([this, 'access', _297 => _297.#swapStorage, 'optionalAccess', _298 => _298.get, 'call', _299 => _299(swapId)]);
|
|
21164
|
+
const response = await _asyncNullishCoalesce(await _asyncOptionalChain([stored, 'optionalAccess', async _300 => _300.response]), async () => ( await this.getSwap(swapId, { updateStorage: true })));
|
|
20936
21165
|
if ((response.direction === "evm_to_lightning" || response.direction === "evm_to_arkade" || response.direction === "evm_to_bitcoin") && response.evm_htlc_kind === "native") {
|
|
20937
21166
|
const txHash2 = await this.#fundNativeLock(
|
|
20938
21167
|
swapId,
|
|
20939
21168
|
response,
|
|
20940
21169
|
signer,
|
|
20941
|
-
_optionalChain([options, 'optionalAccess',
|
|
21170
|
+
_optionalChain([options, 'optionalAccess', _301 => _301.onQuote])
|
|
20942
21171
|
);
|
|
20943
21172
|
return { txHash: txHash2 };
|
|
20944
21173
|
}
|
|
@@ -20949,12 +21178,12 @@ network='${network}'`
|
|
|
20949
21178
|
}
|
|
20950
21179
|
}
|
|
20951
21180
|
if (isCctpOnlySource(signer.chainId)) {
|
|
20952
|
-
const stored = await _optionalChain([this, 'access',
|
|
20953
|
-
const swapResponse = await _asyncNullishCoalesce(await _asyncOptionalChain([stored, 'optionalAccess', async
|
|
21181
|
+
const stored = await _optionalChain([this, 'access', _302 => _302.#swapStorage, 'optionalAccess', _303 => _303.get, 'call', _304 => _304(swapId)]);
|
|
21182
|
+
const swapResponse = await _asyncNullishCoalesce(await _asyncOptionalChain([stored, 'optionalAccess', async _305 => _305.response]), async () => ( await this.getSwap(swapId, { updateStorage: true })));
|
|
20954
21183
|
const source = cctpMetaForChainId(signer.chainId);
|
|
20955
21184
|
const expected = {
|
|
20956
21185
|
...this.#fundingExpectation(swapId, stored),
|
|
20957
|
-
pins: _optionalChain([options, 'optionalAccess',
|
|
21186
|
+
pins: _optionalChain([options, 'optionalAccess', _306 => _306.funding])
|
|
20958
21187
|
};
|
|
20959
21188
|
await this.#ensureClientHashLock(
|
|
20960
21189
|
swapId,
|
|
@@ -20986,7 +21215,7 @@ network='${network}'`
|
|
|
20986
21215
|
}
|
|
20987
21216
|
const amount = BigInt(rawAmount);
|
|
20988
21217
|
const destination = cctpMetaForChainId(42161);
|
|
20989
|
-
const recordedBurn = _optionalChain([stored, 'optionalAccess',
|
|
21218
|
+
const recordedBurn = _optionalChain([stored, 'optionalAccess', _307 => _307.cctpBurnTxid]);
|
|
20990
21219
|
if (recordedBurn) {
|
|
20991
21220
|
const fresh = await this.getSwap(swapId, { updateStorage: true });
|
|
20992
21221
|
if (fresh.status !== "pending") {
|
|
@@ -20995,7 +21224,7 @@ network='${network}'`
|
|
|
20995
21224
|
);
|
|
20996
21225
|
}
|
|
20997
21226
|
}
|
|
20998
|
-
const maxFee = recordedBurn ? 0n : await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async
|
|
21227
|
+
const maxFee = recordedBurn ? 0n : await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async _308 => _308.maxFee]), async () => ( computeCctpFastFee(
|
|
20999
21228
|
await getCachedCctpFee({
|
|
21000
21229
|
sourceDomain: source.domain,
|
|
21001
21230
|
destinationDomain: destination.domain
|
|
@@ -21015,8 +21244,8 @@ network='${network}'`
|
|
|
21015
21244
|
onBurn: (burnTxHash) => this.#recordCctpBurn(swapId, burnTxHash),
|
|
21016
21245
|
amount,
|
|
21017
21246
|
maxFee,
|
|
21018
|
-
onProgress: _optionalChain([options, 'optionalAccess',
|
|
21019
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
21247
|
+
onProgress: _optionalChain([options, 'optionalAccess', _309 => _309.onProgress]),
|
|
21248
|
+
signal: _optionalChain([options, 'optionalAccess', _310 => _310.signal])
|
|
21020
21249
|
});
|
|
21021
21250
|
if (cctp.transactionHash) {
|
|
21022
21251
|
await this.#recordEvmFunding(swapId, { txid: cctp.transactionHash });
|
|
@@ -21027,9 +21256,9 @@ network='${network}'`
|
|
|
21027
21256
|
swapId,
|
|
21028
21257
|
signer.chainId,
|
|
21029
21258
|
signer.address,
|
|
21030
|
-
{ funding: _optionalChain([options, 'optionalAccess',
|
|
21259
|
+
{ funding: _optionalChain([options, 'optionalAccess', _311 => _311.funding]) }
|
|
21031
21260
|
);
|
|
21032
|
-
_optionalChain([options, 'optionalAccess',
|
|
21261
|
+
_optionalChain([options, 'optionalAccess', _312 => _312.onQuote, 'optionalCall', _313 => _313({
|
|
21033
21262
|
sourceAmount: funding.sourceAmount,
|
|
21034
21263
|
sourceTokenAddress: funding.sourceTokenAddress
|
|
21035
21264
|
})]);
|
|
@@ -21077,10 +21306,10 @@ network='${network}'`
|
|
|
21077
21306
|
swapId,
|
|
21078
21307
|
signer.chainId,
|
|
21079
21308
|
signer.address,
|
|
21080
|
-
{ funding: _optionalChain([options, 'optionalAccess',
|
|
21309
|
+
{ funding: _optionalChain([options, 'optionalAccess', _314 => _314.funding]) }
|
|
21081
21310
|
);
|
|
21082
21311
|
if (freshFunding.sourceAmount !== funding.sourceAmount) {
|
|
21083
|
-
_optionalChain([options, 'optionalAccess',
|
|
21312
|
+
_optionalChain([options, 'optionalAccess', _315 => _315.onQuote, 'optionalCall', _316 => _316({
|
|
21084
21313
|
sourceAmount: freshFunding.sourceAmount,
|
|
21085
21314
|
sourceTokenAddress: freshFunding.sourceTokenAddress
|
|
21086
21315
|
})]);
|
|
@@ -21090,7 +21319,7 @@ network='${network}'`
|
|
|
21090
21319
|
if (/^0x[0-9a-fA-F]{128}0[01]$/.test(signature) && signer.getCode) {
|
|
21091
21320
|
try {
|
|
21092
21321
|
depositorCode = await signer.getCode(signer.address);
|
|
21093
|
-
} catch (
|
|
21322
|
+
} catch (e27) {
|
|
21094
21323
|
}
|
|
21095
21324
|
}
|
|
21096
21325
|
const encoded = _chunkJZTF4JNHcjs.encodeExecuteAndCreateWithPermit2.call(void 0,
|
|
@@ -21156,17 +21385,17 @@ network='${network}'`
|
|
|
21156
21385
|
* @returns The Arbitrum settlement tx hash (or UserOp hash) and the burn
|
|
21157
21386
|
*/
|
|
21158
21387
|
async fundSwapFromSolana(swapId, signer, options) {
|
|
21159
|
-
const rpcUrl = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
21388
|
+
const rpcUrl = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _317 => _317.rpcUrl]), () => ( this.#config.solanaRpcUrl));
|
|
21160
21389
|
if (!rpcUrl) {
|
|
21161
21390
|
throw new Error(
|
|
21162
21391
|
"Funding from Solana needs a Solana RPC URL. Pass `rpcUrl` or call `.withSolanaRpcUrl(url)` on the ClientBuilder."
|
|
21163
21392
|
);
|
|
21164
21393
|
}
|
|
21165
|
-
const stored = await _optionalChain([this, 'access',
|
|
21166
|
-
const swapResponse = await _asyncNullishCoalesce(await _asyncOptionalChain([stored, 'optionalAccess', async
|
|
21394
|
+
const stored = await _optionalChain([this, 'access', _318 => _318.#swapStorage, 'optionalAccess', _319 => _319.get, 'call', _320 => _320(swapId)]);
|
|
21395
|
+
const swapResponse = await _asyncNullishCoalesce(await _asyncOptionalChain([stored, 'optionalAccess', async _321 => _321.response]), async () => ( await this.getSwap(swapId, { updateStorage: true })));
|
|
21167
21396
|
const expected = {
|
|
21168
21397
|
...this.#fundingExpectation(swapId, stored),
|
|
21169
|
-
pins: _optionalChain([options, 'optionalAccess',
|
|
21398
|
+
pins: _optionalChain([options, 'optionalAccess', _322 => _322.funding])
|
|
21170
21399
|
};
|
|
21171
21400
|
await this.#ensureClientHashLock(
|
|
21172
21401
|
swapId,
|
|
@@ -21190,7 +21419,7 @@ network='${network}'`
|
|
|
21190
21419
|
);
|
|
21191
21420
|
}
|
|
21192
21421
|
const amount = BigInt(bridge.source_amount);
|
|
21193
|
-
const recordedBurn = _optionalChain([stored, 'optionalAccess',
|
|
21422
|
+
const recordedBurn = _optionalChain([stored, 'optionalAccess', _323 => _323.cctpBurnTxid]);
|
|
21194
21423
|
if (recordedBurn) {
|
|
21195
21424
|
const fresh = await this.getSwap(swapId, { updateStorage: true });
|
|
21196
21425
|
if (fresh.status !== "pending") {
|
|
@@ -21199,7 +21428,7 @@ network='${network}'`
|
|
|
21199
21428
|
);
|
|
21200
21429
|
}
|
|
21201
21430
|
}
|
|
21202
|
-
const maxFee = recordedBurn ? 0n : await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async
|
|
21431
|
+
const maxFee = recordedBurn ? 0n : await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async _324 => _324.maxFee]), async () => ( computeCctpFastFee(
|
|
21203
21432
|
await getCachedCctpFee({
|
|
21204
21433
|
sourceDomain: _chunkTKFOVRJRcjs.CCTP_DOMAINS.Solana,
|
|
21205
21434
|
destinationDomain: _chunkTKFOVRJRcjs.CCTP_DOMAINS.Arbitrum
|
|
@@ -21221,13 +21450,13 @@ network='${network}'`
|
|
|
21221
21450
|
),
|
|
21222
21451
|
rpcUrl,
|
|
21223
21452
|
burnSignature: recordedBurn,
|
|
21224
|
-
burnLastValidBlockHeight: _optionalChain([stored, 'optionalAccess',
|
|
21453
|
+
burnLastValidBlockHeight: _optionalChain([stored, 'optionalAccess', _325 => _325.cctpBurnLastValidBlockHeight]),
|
|
21225
21454
|
onBurn: (burnSignature, lastValidBlockHeight) => this.#recordCctpBurn(swapId, burnSignature, lastValidBlockHeight),
|
|
21226
21455
|
amount,
|
|
21227
21456
|
maxFee,
|
|
21228
|
-
priorityFeeMicroLamports: _optionalChain([options, 'optionalAccess',
|
|
21229
|
-
onProgress: _optionalChain([options, 'optionalAccess',
|
|
21230
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
21457
|
+
priorityFeeMicroLamports: _optionalChain([options, 'optionalAccess', _326 => _326.priorityFeeMicroLamports]),
|
|
21458
|
+
onProgress: _optionalChain([options, 'optionalAccess', _327 => _327.onProgress]),
|
|
21459
|
+
signal: _optionalChain([options, 'optionalAccess', _328 => _328.signal])
|
|
21231
21460
|
}
|
|
21232
21461
|
);
|
|
21233
21462
|
if (cctp.transactionHash) {
|
|
@@ -21245,7 +21474,7 @@ network='${network}'`
|
|
|
21245
21474
|
* `withSolanaRpcUrl` on the builder
|
|
21246
21475
|
*/
|
|
21247
21476
|
async getSolanaUsdcBalance(owner, options) {
|
|
21248
|
-
const rpcUrl = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
21477
|
+
const rpcUrl = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _329 => _329.rpcUrl]), () => ( this.#config.solanaRpcUrl));
|
|
21249
21478
|
if (!rpcUrl) {
|
|
21250
21479
|
throw new Error(
|
|
21251
21480
|
"Reading a Solana balance needs a Solana RPC URL. Pass `rpcUrl` or call `.withSolanaRpcUrl(url)` on the ClientBuilder."
|
|
@@ -21281,7 +21510,7 @@ network='${network}'`
|
|
|
21281
21510
|
`The server's swap names HTLC ${swap.evm_htlc_address}, claimer ${swap.server_evm_address} and timelock ${swap.evm_refund_locktime}, not the ${terms.htlcAddress}, ${terms.claimAddress} and ${terms.timelock} it was created with; refusing to fund it`
|
|
21282
21511
|
);
|
|
21283
21512
|
}
|
|
21284
|
-
_optionalChain([onQuote, 'optionalCall',
|
|
21513
|
+
_optionalChain([onQuote, 'optionalCall', _330 => _330({
|
|
21285
21514
|
sourceAmount: amount,
|
|
21286
21515
|
sourceTokenAddress: _chunkJZTF4JNHcjs.NATIVE_TOKEN_ADDRESS
|
|
21287
21516
|
})]);
|
|
@@ -21290,7 +21519,7 @@ network='${network}'`
|
|
|
21290
21519
|
"This legacy Rootstock swap requires coordinator funding. Create a new swap with the updated backend before funding."
|
|
21291
21520
|
);
|
|
21292
21521
|
}
|
|
21293
|
-
if (signer.address.toLowerCase() !== _optionalChain([swap, 'access',
|
|
21522
|
+
if (signer.address.toLowerCase() !== _optionalChain([swap, 'access', _331 => _331.client_evm_address, 'optionalAccess', _332 => _332.toLowerCase, 'call', _333 => _333()])) {
|
|
21294
21523
|
throw new Error(
|
|
21295
21524
|
"Connect the source wallet recorded on this swap to fund RBTC."
|
|
21296
21525
|
);
|
|
@@ -21321,7 +21550,7 @@ network='${network}'`
|
|
|
21321
21550
|
swapId,
|
|
21322
21551
|
signer,
|
|
21323
21552
|
[
|
|
21324
|
-
await _asyncOptionalChain([(await this.getStoredSwap(swapId)), 'optionalAccess', async
|
|
21553
|
+
await _asyncOptionalChain([(await this.getStoredSwap(swapId)), 'optionalAccess', async _334 => _334.evmFundTxid]),
|
|
21325
21554
|
swap.evm_fund_txid
|
|
21326
21555
|
],
|
|
21327
21556
|
hashLock
|
|
@@ -21355,7 +21584,7 @@ network='${network}'`
|
|
|
21355
21584
|
let known;
|
|
21356
21585
|
try {
|
|
21357
21586
|
known = await signer.getTransaction(txid);
|
|
21358
|
-
} catch (
|
|
21587
|
+
} catch (e28) {
|
|
21359
21588
|
known = null;
|
|
21360
21589
|
}
|
|
21361
21590
|
if (!known) refuse("the node does not know and may still land");
|
|
@@ -21366,7 +21595,7 @@ network='${network}'`
|
|
|
21366
21595
|
FUNDING_RECEIPT_WAIT_MS,
|
|
21367
21596
|
`not mined within ${FUNDING_RECEIPT_WAIT_MS / 1e3}s`
|
|
21368
21597
|
);
|
|
21369
|
-
} catch (
|
|
21598
|
+
} catch (e29) {
|
|
21370
21599
|
return refuse("is not mined yet");
|
|
21371
21600
|
}
|
|
21372
21601
|
if (receipt.status !== "success") continue;
|
|
@@ -21390,7 +21619,7 @@ network='${network}'`
|
|
|
21390
21619
|
});
|
|
21391
21620
|
const receipt = await signer.waitForReceipt(txHash);
|
|
21392
21621
|
if (receipt.status !== "success") {
|
|
21393
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
21622
|
+
if (_optionalChain([options, 'optionalAccess', _335 => _335.forgetFailed])) await this.#forgetEvmFunding(swapId, txHash);
|
|
21394
21623
|
const reason = await _chunkTNZW35XAcjs.getRevertReason.call(void 0, signer, txHash, receipt.blockNumber);
|
|
21395
21624
|
throw new Error(`Funding transaction failed: ${reason}`);
|
|
21396
21625
|
}
|
|
@@ -21414,7 +21643,7 @@ network='${network}'`
|
|
|
21414
21643
|
}).length > 0;
|
|
21415
21644
|
}
|
|
21416
21645
|
if (!created && replaced) {
|
|
21417
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
21646
|
+
if (_optionalChain([options, 'optionalAccess', _336 => _336.forgetFailed]) && provesNoLockUnder(receipt, expected.preimageHash)) {
|
|
21418
21647
|
await this.#forgetEvmFunding(swapId, txHash);
|
|
21419
21648
|
}
|
|
21420
21649
|
throw new Error(
|
|
@@ -21604,7 +21833,7 @@ network='${network}'`
|
|
|
21604
21833
|
}
|
|
21605
21834
|
async #actualRefundTransfer(oldSwap, smartAccountAddress) {
|
|
21606
21835
|
const txHash = oldSwap.evm_claim_txid;
|
|
21607
|
-
const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access',
|
|
21836
|
+
const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access', _337 => _337.#config, 'access', _338 => _338.aa, 'optionalAccess', _339 => _339.rpcUrl]), () => ( _optionalChain([this, 'access', _340 => _340.#config, 'access', _341 => _341.aa, 'optionalAccess', _342 => _342.bundlerUrl])));
|
|
21608
21837
|
if (!txHash || !rpcUrl) return null;
|
|
21609
21838
|
const { createPublicClient: createPublicClient2, http: http2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./_esm-4ZKYBBIE-D33574DC.cjs")));
|
|
21610
21839
|
const { arbitrum: arbitrum2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./chains-D6LHJZMI-AAYKXZGC.cjs")));
|
|
@@ -21617,13 +21846,13 @@ network='${network}'`
|
|
|
21617
21846
|
receipt = await publicClient.getTransactionReceipt({
|
|
21618
21847
|
hash: txHash
|
|
21619
21848
|
});
|
|
21620
|
-
} catch (
|
|
21849
|
+
} catch (e30) {
|
|
21621
21850
|
return null;
|
|
21622
21851
|
}
|
|
21623
21852
|
const transferTopic = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
|
|
21624
21853
|
const paddedRecipient = smartAccountAddress.replace(/^0x/i, "").toLowerCase().padStart(64, "0");
|
|
21625
21854
|
const transfers = receipt.logs.filter(
|
|
21626
|
-
(log) => _optionalChain([log, 'access',
|
|
21855
|
+
(log) => _optionalChain([log, 'access', _343 => _343.topics, 'access', _344 => _344[0], 'optionalAccess', _345 => _345.toLowerCase, 'call', _346 => _346()]) === transferTopic && _optionalChain([log, 'access', _347 => _347.topics, 'access', _348 => _348[2], 'optionalAccess', _349 => _349.replace, 'call', _350 => _350(/^0x/i, ""), 'access', _351 => _351.toLowerCase, 'call', _352 => _352()]) === paddedRecipient
|
|
21627
21856
|
).map((log) => ({
|
|
21628
21857
|
tokenAddress: log.address,
|
|
21629
21858
|
amount: BigInt(log.data).toString()
|
|
@@ -21710,8 +21939,8 @@ network='${network}'`
|
|
|
21710
21939
|
{
|
|
21711
21940
|
chain: refundChain,
|
|
21712
21941
|
address: actualRefund.tokenAddress,
|
|
21713
|
-
symbol: _nullishCoalesce(_optionalChain([actualMeta, 'optionalAccess',
|
|
21714
|
-
decimals: _nullishCoalesce(_optionalChain([actualMeta, 'optionalAccess',
|
|
21942
|
+
symbol: _nullishCoalesce(_optionalChain([actualMeta, 'optionalAccess', _353 => _353.symbol]), () => ( "ERC-20")),
|
|
21943
|
+
decimals: _nullishCoalesce(_optionalChain([actualMeta, 'optionalAccess', _354 => _354.decimals]), () => ( 18)),
|
|
21715
21944
|
amount: actualRefund.amount
|
|
21716
21945
|
}
|
|
21717
21946
|
] : [],
|
|
@@ -21879,9 +22108,9 @@ network='${network}'`
|
|
|
21879
22108
|
}
|
|
21880
22109
|
const { client_evm_address: depositor, gasless } = stored.response;
|
|
21881
22110
|
let owner;
|
|
21882
|
-
if (_optionalChain([depositor, 'optionalAccess',
|
|
22111
|
+
if (_optionalChain([depositor, 'optionalAccess', _355 => _355.toLowerCase, 'call', _356 => _356()]) === this.getEvmAddress().toLowerCase()) {
|
|
21883
22112
|
owner = this.#keyOwnerSigner();
|
|
21884
|
-
} else if (gasless && _optionalChain([depositor, 'optionalAccess',
|
|
22113
|
+
} else if (gasless && _optionalChain([depositor, 'optionalAccess', _357 => _357.toLowerCase, 'call', _358 => _358()]) === deriveEvmAddress(stored.secretKey).toLowerCase()) {
|
|
21885
22114
|
owner = keyToKernelOwnerSigner(
|
|
21886
22115
|
_chunk5JR6AJ3Ycjs.hexToBytes.call(void 0, stored.secretKey.replace(/^0x/, "")),
|
|
21887
22116
|
42161
|
|
@@ -21920,7 +22149,7 @@ network='${network}'`
|
|
|
21920
22149
|
* with its key (whose signer does not read the chain).
|
|
21921
22150
|
*/
|
|
21922
22151
|
async #aaRpcCall() {
|
|
21923
|
-
const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access',
|
|
22152
|
+
const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access', _359 => _359.#config, 'access', _360 => _360.aa, 'optionalAccess', _361 => _361.rpcUrl]), () => ( _optionalChain([this, 'access', _362 => _362.#config, 'access', _363 => _363.aa, 'optionalAccess', _364 => _364.bundlerUrl])));
|
|
21924
22153
|
if (!rpcUrl) {
|
|
21925
22154
|
throw new Error(
|
|
21926
22155
|
"Reading a refunded balance without a signer requires AA config (`.withAa(...)`)."
|
|
@@ -21961,7 +22190,7 @@ network='${network}'`
|
|
|
21961
22190
|
`Gasless funding on chain ${chainId} is submitted by this SDK as a sponsored UserOp and requires AA config. Call \`.withAa({ bundlerUrl, paymasterPolicyId })\` on the ClientBuilder before \`.build()\`.`
|
|
21962
22191
|
);
|
|
21963
22192
|
}
|
|
21964
|
-
if (!_optionalChain([this, 'access',
|
|
22193
|
+
if (!_optionalChain([this, 'access', _365 => _365.#config, 'access', _366 => _366.aa, 'access', _367 => _367.paymasterPolicyId, 'optionalAccess', _368 => _368.trim, 'call', _369 => _369()])) {
|
|
21965
22194
|
if (this.#config.aa.allowSelfPaidFunding) return { mode: "self-paid" };
|
|
21966
22195
|
throw new Error(
|
|
21967
22196
|
"Sponsored funding requires a paymasterPolicyId. Self-paid local tests must explicitly set allowSelfPaidFunding and prefund the account with ETH."
|
|
@@ -22041,7 +22270,7 @@ network='${network}'`
|
|
|
22041
22270
|
swapId,
|
|
22042
22271
|
serverData,
|
|
22043
22272
|
chainId,
|
|
22044
|
-
_optionalChain([options, 'optionalAccess',
|
|
22273
|
+
_optionalChain([options, 'optionalAccess', _370 => _370.funding])
|
|
22045
22274
|
);
|
|
22046
22275
|
const nonceBytes = new Uint8Array(32);
|
|
22047
22276
|
crypto.getRandomValues(nonceBytes);
|
|
@@ -22086,7 +22315,7 @@ network='${network}'`
|
|
|
22086
22315
|
delegated
|
|
22087
22316
|
);
|
|
22088
22317
|
let eip2612Permit;
|
|
22089
|
-
if (_optionalChain([serverData, 'access',
|
|
22318
|
+
if (_optionalChain([serverData, 'access', _371 => _371.eip2612, 'optionalAccess', _372 => _372.supported]) && !serverData.eip2612.already_approved) {
|
|
22090
22319
|
const maxUint256 = BigInt(
|
|
22091
22320
|
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
|
22092
22321
|
);
|
|
@@ -22194,7 +22423,7 @@ network='${network}'`
|
|
|
22194
22423
|
}
|
|
22195
22424
|
const expected = {
|
|
22196
22425
|
...this.#fundingExpectation(swapId, stored),
|
|
22197
|
-
pins: _optionalChain([options, 'optionalAccess',
|
|
22426
|
+
pins: _optionalChain([options, 'optionalAccess', _373 => _373.funding])
|
|
22198
22427
|
};
|
|
22199
22428
|
if (expected.terms.chainId !== AA_CHAIN_ID) {
|
|
22200
22429
|
throw new Error(
|
|
@@ -22206,7 +22435,7 @@ network='${network}'`
|
|
|
22206
22435
|
const { arbitrum: arbitrum2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./chains-D6LHJZMI-AAYKXZGC.cjs")));
|
|
22207
22436
|
const rpc = createPublicClient2({
|
|
22208
22437
|
chain: arbitrum2,
|
|
22209
|
-
transport: http2(_nullishCoalesce(_optionalChain([this, 'access',
|
|
22438
|
+
transport: http2(_nullishCoalesce(_optionalChain([this, 'access', _374 => _374.#config, 'access', _375 => _375.aa, 'optionalAccess', _376 => _376.rpcUrl]), () => ( _optionalChain([this, 'access', _377 => _377.#config, 'access', _378 => _378.aa, 'optionalAccess', _379 => _379.bundlerUrl]))))
|
|
22210
22439
|
});
|
|
22211
22440
|
const receipt = await rpc.getTransactionReceipt({
|
|
22212
22441
|
hash: stored.evmFundTxid
|
|
@@ -22272,7 +22501,7 @@ network='${network}'`
|
|
|
22272
22501
|
return { txHash };
|
|
22273
22502
|
}
|
|
22274
22503
|
async #setFundingUserOp(swapId, hash) {
|
|
22275
|
-
const current = await _optionalChain([this, 'access',
|
|
22504
|
+
const current = await _optionalChain([this, 'access', _380 => _380.#swapStorage, 'optionalAccess', _381 => _381.get, 'call', _382 => _382(swapId)]);
|
|
22276
22505
|
if (!current || !this.#swapStorage)
|
|
22277
22506
|
throw new Error("Cannot persist funding operation");
|
|
22278
22507
|
await this.#swapStorage.store({
|
|
@@ -22289,7 +22518,7 @@ network='${network}'`
|
|
|
22289
22518
|
* here.
|
|
22290
22519
|
*/
|
|
22291
22520
|
#gaslessDepositorKey(swapId, stored, swap) {
|
|
22292
|
-
const depositor = _optionalChain([swap, 'access',
|
|
22521
|
+
const depositor = _optionalChain([swap, 'access', _383 => _383.client_evm_address, 'optionalAccess', _384 => _384.toLowerCase, 'call', _385 => _385()]);
|
|
22293
22522
|
const sharedKey = this.#getEvmSigningKey();
|
|
22294
22523
|
if (!depositor || depositor === deriveEvmAddress(sharedKey).toLowerCase()) {
|
|
22295
22524
|
return sharedKey;
|
|
@@ -22330,7 +22559,7 @@ network='${network}'`
|
|
|
22330
22559
|
);
|
|
22331
22560
|
}
|
|
22332
22561
|
const response = storedSwap.response;
|
|
22333
|
-
const depositor = _optionalChain([response, 'access',
|
|
22562
|
+
const depositor = _optionalChain([response, 'access', _386 => _386.client_evm_address, 'optionalAccess', _387 => _387.toLowerCase, 'call', _388 => _388()]);
|
|
22334
22563
|
const sharedKey = this.#getEvmSigningKey();
|
|
22335
22564
|
const sharedAddress = deriveEvmAddress(sharedKey).toLowerCase();
|
|
22336
22565
|
const swapAddress = deriveEvmAddress(storedSwap.secretKey).toLowerCase();
|
|
@@ -22391,7 +22620,7 @@ network='${network}'`
|
|
|
22391
22620
|
if (!sourceChain) {
|
|
22392
22621
|
throw new Error(`Swap ${swapId} is not a CCTP-inbound swap.`);
|
|
22393
22622
|
}
|
|
22394
|
-
const burnTxHash = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
22623
|
+
const burnTxHash = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _389 => _389.burnTxHash]), () => ( stored.cctpBurnTxid));
|
|
22395
22624
|
if (!burnTxHash) {
|
|
22396
22625
|
throw new Error(
|
|
22397
22626
|
`No CCTP burn is recorded for swap ${swapId}; pass it as \`burnTxHash\`.`
|
|
@@ -22402,13 +22631,13 @@ network='${network}'`
|
|
|
22402
22631
|
{
|
|
22403
22632
|
signer: this.#depositorOwnerSigner(
|
|
22404
22633
|
stored.response,
|
|
22405
|
-
_optionalChain([options, 'optionalAccess',
|
|
22634
|
+
_optionalChain([options, 'optionalAccess', _390 => _390.ownerSigner])
|
|
22406
22635
|
),
|
|
22407
22636
|
burnTxHash,
|
|
22408
22637
|
sourceChain,
|
|
22409
22638
|
recipient,
|
|
22410
|
-
onProgress: _optionalChain([options, 'optionalAccess',
|
|
22411
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
22639
|
+
onProgress: _optionalChain([options, 'optionalAccess', _391 => _391.onProgress]),
|
|
22640
|
+
signal: _optionalChain([options, 'optionalAccess', _392 => _392.signal])
|
|
22412
22641
|
}
|
|
22413
22642
|
);
|
|
22414
22643
|
}
|
|
@@ -22552,14 +22781,14 @@ function b64Encode(u) {
|
|
|
22552
22781
|
return btoa(bin);
|
|
22553
22782
|
}
|
|
22554
22783
|
function isP2tr(script) {
|
|
22555
|
-
return _optionalChain([script, 'optionalAccess',
|
|
22784
|
+
return _optionalChain([script, 'optionalAccess', _393 => _393.length]) === 34 && script[0] === 81 && script[1] === 32;
|
|
22556
22785
|
}
|
|
22557
22786
|
function parseEscrowPsbt(psbt) {
|
|
22558
22787
|
const lenient = _chunkBEW62OUTcjs.Transaction2.fromPSBT(psbt, { disableScriptCheck: true });
|
|
22559
22788
|
let stripped = false;
|
|
22560
22789
|
for (let i = 0; i < lenient.inputsLength; i++) {
|
|
22561
22790
|
const input = lenient.getInput(i);
|
|
22562
|
-
if (input.witnessScript && isP2tr(_optionalChain([input, 'access',
|
|
22791
|
+
if (input.witnessScript && isP2tr(_optionalChain([input, 'access', _394 => _394.witnessUtxo, 'optionalAccess', _395 => _395.script]))) {
|
|
22563
22792
|
lenient.updateInput(i, { witnessScript: void 0 }, true);
|
|
22564
22793
|
stripped = true;
|
|
22565
22794
|
}
|
|
@@ -22691,11 +22920,11 @@ var IdbWalletStorage = class {
|
|
|
22691
22920
|
}
|
|
22692
22921
|
async getMnemonic() {
|
|
22693
22922
|
const record = await this.#db.wallet.get(MNEMONIC_KEY);
|
|
22694
|
-
if (_optionalChain([record, 'optionalAccess',
|
|
22923
|
+
if (_optionalChain([record, 'optionalAccess', _396 => _396.value])) {
|
|
22695
22924
|
return record.value;
|
|
22696
22925
|
}
|
|
22697
22926
|
const v2Wallet = await readV2Wallet();
|
|
22698
|
-
if (!_optionalChain([v2Wallet, 'optionalAccess',
|
|
22927
|
+
if (!_optionalChain([v2Wallet, 'optionalAccess', _397 => _397.mnemonic])) {
|
|
22699
22928
|
return null;
|
|
22700
22929
|
}
|
|
22701
22930
|
await this.setMnemonic(v2Wallet.mnemonic);
|
|
@@ -22710,7 +22939,7 @@ var IdbWalletStorage = class {
|
|
|
22710
22939
|
}
|
|
22711
22940
|
async getKeyIndex() {
|
|
22712
22941
|
const record = await this.#db.wallet.get(KEY_INDEX_KEY);
|
|
22713
|
-
return _nullishCoalesce(_optionalChain([record, 'optionalAccess',
|
|
22942
|
+
return _nullishCoalesce(_optionalChain([record, 'optionalAccess', _398 => _398.value]), () => ( 0));
|
|
22714
22943
|
}
|
|
22715
22944
|
async setKeyIndex(index) {
|
|
22716
22945
|
await this.#db.wallet.put({ key: KEY_INDEX_KEY, value: index });
|
|
@@ -22718,7 +22947,7 @@ var IdbWalletStorage = class {
|
|
|
22718
22947
|
async incrementKeyIndex() {
|
|
22719
22948
|
return this.#db.transaction("rw", this.#db.wallet, async () => {
|
|
22720
22949
|
const record = await this.#db.wallet.get(KEY_INDEX_KEY);
|
|
22721
|
-
const current = _nullishCoalesce(_optionalChain([record, 'optionalAccess',
|
|
22950
|
+
const current = _nullishCoalesce(_optionalChain([record, 'optionalAccess', _399 => _399.value]), () => ( 0));
|
|
22722
22951
|
await this.#db.wallet.put({ key: KEY_INDEX_KEY, value: current + 1 });
|
|
22723
22952
|
return current;
|
|
22724
22953
|
});
|
|
@@ -22774,7 +23003,7 @@ function readV2Wallet() {
|
|
|
22774
23003
|
}
|
|
22775
23004
|
const request = indexedDB.open(V2_DB_NAME);
|
|
22776
23005
|
request.onupgradeneeded = () => {
|
|
22777
|
-
_optionalChain([request, 'access',
|
|
23006
|
+
_optionalChain([request, 'access', _400 => _400.transaction, 'optionalAccess', _401 => _401.abort, 'call', _402 => _402()]);
|
|
22778
23007
|
};
|
|
22779
23008
|
request.onerror = () => {
|
|
22780
23009
|
resolve(null);
|
|
@@ -22806,7 +23035,7 @@ function readV2Wallet() {
|
|
|
22806
23035
|
db.close();
|
|
22807
23036
|
resolve(null);
|
|
22808
23037
|
};
|
|
22809
|
-
} catch (
|
|
23038
|
+
} catch (e31) {
|
|
22810
23039
|
db.close();
|
|
22811
23040
|
resolve(null);
|
|
22812
23041
|
}
|
|
@@ -22999,10 +23228,11 @@ async function getUsdPrices(tokens, options = {}) {
|
|
|
22999
23228
|
|
|
23000
23229
|
|
|
23001
23230
|
|
|
23002
|
-
|
|
23231
|
+
|
|
23232
|
+
exports.createApiClient = createApiClient; exports.getVhtlcAmounts = getVhtlcAmounts; exports.parseArkadeAddress = parseArkadeAddress; exports.isValidArkadeAddress = isValidArkadeAddress; exports.invoicePaymentHash = invoicePaymentHash; exports.invoiceAmountMsat = invoiceAmountMsat; exports.fetchCctpFee = fetchCctpFee; exports.computeCctpFastFee = computeCctpFastFee; exports.addressToBytes32 = addressToBytes32; exports.bytes32ToAddress = bytes32ToAddress; exports.getDomain = getDomain; exports.needsBridge = needsBridge; exports.isValidSolanaAddress = isValidSolanaAddress; exports.solanaAddressToBytes32 = solanaAddressToBytes32; exports.approveAndBurn = approveAndBurn; exports.encodeDepositForBurn = encodeDepositForBurn; exports.CHAIN_ID_TO_CCTP_NAME = CHAIN_ID_TO_CCTP_NAME; exports.DIRECT_SOURCE_CHAIN_IDS = DIRECT_SOURCE_CHAIN_IDS; exports.isCctpOnlySource = isCctpOnlySource; exports.CCTP_STANDARD_ONLY_CHAIN_IDS = CCTP_STANDARD_ONLY_CHAIN_IDS; exports.finalityForChainId = finalityForChainId; exports.cctpMetaForChainId = cctpMetaForChainId; exports.CCTP_VIEM_CHAINS = CCTP_VIEM_CHAINS; exports.getCctpViemChain = getCctpViemChain; exports.getCctpViemChainByName = getCctpViemChainByName; exports.cctpFundSwap = cctpFundSwap; exports.CctpInboundClient = CctpInboundClient; exports.deriveEvmAddress = deriveEvmAddress; exports.signEvmDigest = signEvmDigest; exports.signEvmMessage = signEvmMessage; exports.MAX_UINT256 = MAX_UINT256; exports.signEip2612Permit = signEip2612Permit; exports.buildDomainSeparator = buildDomainSeparator; exports.USDC_DOMAIN_FIELDS = USDC_DOMAIN_FIELDS; exports.signPermit2Witness = signPermit2Witness; exports.recoverCctpInbound = recoverCctpInbound; exports.LZ_EIDS = LZ_EIDS; exports.USDT0_ADDRESSES = USDT0_ADDRESSES; exports.trackMessage = trackMessage; exports.getMessageStatus = getMessageStatus; exports.getExplorerUrl = getExplorerUrl; exports.getEid = getEid; exports.needsBridge2 = needsBridge2; exports.Asset = Asset; exports.BTC_LIGHTNING = BTC_LIGHTNING; exports.BTC_ARKADE = BTC_ARKADE; exports.BTC_ONCHAIN = BTC_ONCHAIN; exports.BTC_LIGHTNING_INFO = BTC_LIGHTNING_INFO; exports.BTC_ARKADE_INFO = BTC_ARKADE_INFO; exports.BTC_ONCHAIN_INFO = BTC_ONCHAIN_INFO; exports.isLightning = isLightning; exports.isArkade = isArkade; exports.isBtcOnchain = isBtcOnchain; exports.isBtc = isBtc; exports.isBtcPegged = isBtcPegged; exports.isEvmToken = isEvmToken; exports.isSourceEvmChain = isSourceEvmChain; exports.isBridgeOnlyChain = isBridgeOnlyChain; exports.isNativeLockTarget = isNativeLockTarget; exports.isEvmSwapSource = isEvmSwapSource; exports.isTronToken = isTronToken; exports.isCctpRoutedUsdcTarget = isCctpRoutedUsdcTarget; exports.isBridgedTarget = isBridgedTarget; exports.isSolanaToken = isSolanaToken; exports.isCctpUsdc = isCctpUsdc; exports.isEthereumToken = isEthereumToken; exports.isPolygonToken = isPolygonToken; exports.isArbitrumToken = isArbitrumToken; exports.isBaseToken = isBaseToken; exports.isOptimismToken = isOptimismToken; exports.isAvalancheToken = isAvalancheToken; exports.isLineaToken = isLineaToken; exports.isSonicToken = isSonicToken; exports.toChain = toChain; exports.toChainName = toChainName; exports.getBridgeTargetChain = getBridgeTargetChain; exports.getCctpBridgeTokens = getCctpBridgeTokens; exports.getUsdt0BridgeTokens = getUsdt0BridgeTokens; exports.isSpark = isSpark; exports.Signer = Signer; exports.computeHash160 = computeHash160; exports.buildOnchainClaimTransaction = buildOnchainClaimTransaction; exports.buildOnchainRefundTransaction = buildOnchainRefundTransaction; exports.verifyHtlcAddress = verifyHtlcAddress; exports.SwapVerificationError = SwapVerificationError; exports.addressToScriptHash = addressToScriptHash; exports.ElectrumWsClient = ElectrumWsClient; exports.electrumFindOutputByAddress = electrumFindOutputByAddress; exports.electrumFetchTransactionOutputs = electrumFetchTransactionOutputs; exports.electrumBroadcastTransaction = electrumBroadcastTransaction; exports.electrumWaitForOutputByAddress = electrumWaitForOutputByAddress; exports.KERNEL_DELEGATION_TARGET = KERNEL_DELEGATION_TARGET; exports.parseEip7702Delegation = parseEip7702Delegation; exports.isKernelDelegation = isKernelDelegation; exports.kernelErc1271Digest = kernelErc1271Digest; exports.wrapKernelErc1271Signature = wrapKernelErc1271Signature; exports.buildArkadeClaim = buildArkadeClaim; exports.RIF_SMART_WALLET_INDEX = RIF_SMART_WALLET_INDEX; exports.rifSmartWalletAddress = rifSmartWalletAddress; exports.rifSmartWallet = rifSmartWallet; exports.WalletClaimRequiredError = WalletClaimRequiredError; exports.SWAP_STORAGE_VERSION = SWAP_STORAGE_VERSION; exports.InMemoryWalletStorage = InMemoryWalletStorage; exports.InMemorySwapStorage = InMemorySwapStorage; exports.inMemoryStorageFactory = inMemoryStorageFactory; exports.tronAddressToBytes32 = tronAddressToBytes32; exports.isValidTronAddress = isValidTronAddress; exports.RehashNotRecordedError = RehashNotRecordedError; exports.rehashAuthorizationMessage = rehashAuthorizationMessage; exports.DEFAULT_ELECTRUM_WS_URLS = DEFAULT_ELECTRUM_WS_URLS; exports.ClientBuilder = ClientBuilder; exports.Client = Client; exports.signEscrowArkTx = signEscrowArkTx; exports.signEscrowCheckpoints = signEscrowCheckpoints; exports.signEscrowDelegate = signEscrowDelegate; exports.getArkTxid = getArkTxid; exports.computeExchangeRate = computeExchangeRate; exports.calculateTargetAmount = calculateTargetAmount; exports.calculateSourceAmount = calculateSourceAmount; exports.IdbWalletStorage = IdbWalletStorage; exports.IdbSwapStorage = IdbSwapStorage; exports.idbStorageFactory = idbStorageFactory; exports.getUsdPrices = getUsdPrices;
|
|
23003
23233
|
/*! Bundled license information:
|
|
23004
23234
|
|
|
23005
23235
|
@scure/bip39/index.js:
|
|
23006
23236
|
(*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
23007
23237
|
*/
|
|
23008
|
-
//# sourceMappingURL=chunk-
|
|
23238
|
+
//# sourceMappingURL=chunk-EL4FUZJO.cjs.map
|