@satora/swap 1.11.0 → 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.
Files changed (58) hide show
  1. package/dist/{chunk-EYVSXWCA.cjs → chunk-EL4FUZJO.cjs} +565 -323
  2. package/dist/chunk-EL4FUZJO.cjs.map +1 -0
  3. package/dist/{chunk-ZAQ7YV6W.js → chunk-KECPPSZL.js} +5 -5
  4. package/dist/{chunk-ZAQ7YV6W.js.map → chunk-KECPPSZL.js.map} +1 -1
  5. package/dist/{chunk-M47Z35Z5.cjs → chunk-QJ4EK6UG.cjs} +5 -5
  6. package/dist/{chunk-M47Z35Z5.cjs.map → chunk-QJ4EK6UG.cjs.map} +1 -1
  7. package/dist/{chunk-BVTLZLT2.js → chunk-YBQPH7NH.js} +289 -47
  8. package/dist/chunk-YBQPH7NH.js.map +1 -0
  9. package/dist/delegate.cjs +2 -2
  10. package/dist/delegate.js +1 -1
  11. package/dist/dist-R6DUJG36.cjs +396 -0
  12. package/dist/{dist-RWCRSE4V.cjs.map → dist-R6DUJG36.cjs.map} +1 -1
  13. package/dist/{dist-INHW3D4S.js → dist-Y3ZVHXAJ.js} +5 -3
  14. package/dist/index.cjs +21 -13
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.js +14 -6
  17. package/dist/index.js.map +1 -1
  18. package/dist/types/cjs/pure/api/client.d.cts +1 -0
  19. package/dist/types/cjs/pure/client.d.cts +30 -3
  20. package/dist/types/cjs/pure/compose-quote.d.cts +14 -1
  21. package/dist/types/cjs/pure/create/index.d.cts +2 -1
  22. package/dist/types/cjs/pure/create/spark-to-evm.d.cts +7 -0
  23. package/dist/types/cjs/pure/create/types.d.cts +93 -2
  24. package/dist/types/cjs/pure/generated/api.d.cts +274 -2
  25. package/dist/types/cjs/pure/index.d.cts +3 -3
  26. package/dist/types/cjs/pure/redeem/arkade.d.cts +4 -1
  27. package/dist/types/cjs/pure/swap-verification.d.cts +3 -1
  28. package/dist/types/cjs/pure/tokens.d.cts +5 -0
  29. package/dist/types/cjs/pure/types/chain.d.cts +2 -2
  30. package/dist/types/cjs/pure/types/index.d.cts +1 -0
  31. package/dist/types/cjs/pure/types/promo-code.d.cts +15 -0
  32. package/dist/types/cjs/pure/types/quote.d.cts +7 -0
  33. package/dist/types/cjs/pure/types/referral-fee.d.cts +8 -0
  34. package/dist/types/cjs/pure/version.d.cts +4 -4
  35. package/dist/types/cjs/swap/client.d.cts +2 -0
  36. package/dist/types/esm/pure/api/client.d.ts +1 -0
  37. package/dist/types/esm/pure/client.d.ts +30 -3
  38. package/dist/types/esm/pure/compose-quote.d.ts +14 -1
  39. package/dist/types/esm/pure/create/index.d.ts +2 -1
  40. package/dist/types/esm/pure/create/spark-to-evm.d.ts +7 -0
  41. package/dist/types/esm/pure/create/types.d.ts +93 -2
  42. package/dist/types/esm/pure/generated/api.d.ts +274 -2
  43. package/dist/types/esm/pure/index.d.ts +3 -3
  44. package/dist/types/esm/pure/redeem/arkade.d.ts +4 -1
  45. package/dist/types/esm/pure/swap-verification.d.ts +3 -1
  46. package/dist/types/esm/pure/tokens.d.ts +5 -0
  47. package/dist/types/esm/pure/types/chain.d.ts +2 -2
  48. package/dist/types/esm/pure/types/index.d.ts +1 -0
  49. package/dist/types/esm/pure/types/promo-code.d.ts +15 -0
  50. package/dist/types/esm/pure/types/quote.d.ts +7 -0
  51. package/dist/types/esm/pure/types/referral-fee.d.ts +8 -0
  52. package/dist/types/esm/pure/version.d.ts +4 -4
  53. package/dist/types/esm/swap/client.d.ts +2 -0
  54. package/package.json +2 -2
  55. package/dist/chunk-BVTLZLT2.js.map +0 -1
  56. package/dist/chunk-EYVSXWCA.cjs.map +0 -1
  57. package/dist/dist-RWCRSE4V.cjs +0 -394
  58. /package/dist/{dist-INHW3D4S.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 _chunkM47Z35Z5cjs = require('./chunk-M47Z35Z5.cjs');
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": _chunkM47Z35Z5cjs.CLIENT_AGENT,
6852
- ..._chunkM47Z35Z5cjs.PROTOCOL_HEADERS,
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 = _chunkM47Z35Z5cjs.resolveArkadeServerUrl.call(void 0, network, arkadeServerUrl);
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 = _chunkM47Z35Z5cjs.getNetworkHrp.call(void 0, _chunkM47Z35Z5cjs.getNetworkName.call(void 0, network));
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 = (_nullishCoalesce(deps.referralBaseFeeRate, () => ( pair.fee_percentage))) + (_nullishCoalesce(deps.referralExtraFeeRate, () => ( 0)));
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
- const effectiveFeePct = (_nullishCoalesce(deps.referralBaseFeeRate, () => ( pair.fee_percentage))) + (_nullishCoalesce(deps.referralExtraFeeRate, () => ( 0)));
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
- _chunkM47Z35Z5cjs.ahash.call(void 0, hash);
8644
- const opts = _chunkM47Z35Z5cjs.checkOpts.call(void 0, { dkLen: 32, asyncTick: 10 }, _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
- _chunkM47Z35Z5cjs.anumber.call(void 0, c, "c");
8647
- _chunkM47Z35Z5cjs.anumber.call(void 0, dkLen, "dkLen");
8648
- _chunkM47Z35Z5cjs.anumber.call(void 0, asyncTick, "asyncTick");
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 = _chunkM47Z35Z5cjs.kdfInputToBytes.call(void 0, _password, "password");
8652
- const salt = _chunkM47Z35Z5cjs.kdfInputToBytes.call(void 0, _salt, "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 = _chunkM47Z35Z5cjs.hmac.create(hash, password);
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
- _chunkM47Z35Z5cjs.clean.call(void 0, u);
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 = _chunkM47Z35Z5cjs.createView.call(void 0, arr);
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
- _chunkM47Z35Z5cjs.abytes.call(void 0, ent);
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
- _chunkM47Z35Z5cjs.anumber.call(void 0, strength);
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(_chunkM47Z35Z5cjs.randomBytes.call(void 0, strength / 8), wordlist2);
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([_chunkM47Z35Z5cjs.sha2562.call(void 0, entropy)[0] >> bitsLeft << bitsLeft]);
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 _chunkM47Z35Z5cjs.utils.chain(_chunkM47Z35Z5cjs.utils.checksum(1, calcChecksum), _chunkM47Z35Z5cjs.utils.radix2(11, true), _chunkM47Z35Z5cjs.utils.alphabet(wordlist2));
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(_chunkM47Z35Z5cjs.sha512, normalize(mnemonic).nfkd, psalt(passphrase), { c: 2048, dkLen: 64 });
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 !== _chunkM47Z35Z5cjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
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, _chunkM47Z35Z5cjs.StrictVhtlcScript)({
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 = _chunkM47Z35Z5cjs.getNetworkName.call(void 0, network);
11118
- const serverUrl = _chunkM47Z35Z5cjs.resolveArkadeServerUrlByName.call(void 0, networkName, arkadeServerUrl);
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 = _chunkM47Z35Z5cjs.getNetworkHrp.call(void 0, networkName);
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 _chunkM47Z35Z5cjs.NETWORK;
11254
+ return _chunkQJ4EK6UGcjs.NETWORK;
11231
11255
  case "testnet":
11232
11256
  case "signet":
11233
- return _chunkM47Z35Z5cjs.TEST_NETWORK;
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 _chunkM47Z35Z5cjs.Script.encode(script);
11280
+ return _chunkQJ4EK6UGcjs.Script.encode(script);
11257
11281
  }
11258
11282
  function buildTimelockScript(userPubKey, refundLocktime) {
11259
- return _chunkM47Z35Z5cjs.Script.encode([
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 = _chunkM47Z35Z5cjs.p2tr.call(void 0,
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, _chunkM47Z35Z5cjs.Transaction2)({
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
- _chunkM47Z35Z5cjs.SigHash.DEFAULT,
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 = _chunkM47Z35Z5cjs.Address.call(void 0, networkConfig).encode({
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, _chunkM47Z35Z5cjs.Transaction2)({
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 = _chunkM47Z35Z5cjs.Address.call(void 0, networkConfig).encode({
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 _chunkM47Z35Z5cjs.Address.call(void 0, getNetwork(network)).encode({
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 !== _chunkM47Z35Z5cjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
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(_chunkM47Z35Z5cjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT),
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(_chunkM47Z35Z5cjs.getNetworkHrp.call(void 0, _chunkM47Z35Z5cjs.getNetworkName.call(void 0, response.network)), server).encode();
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 !== _chunkM47Z35Z5cjs.BTC_HTLC_SCRIPT_VERSION_STRICT) {
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(_chunkM47Z35Z5cjs.BTC_HTLC_SCRIPT_VERSION_STRICT),
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 = _chunkM47Z35Z5cjs.getNetworkName.call(void 0, response.network);
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: _chunkM47Z35Z5cjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT,
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', _61 => _61.targetAmount, 'optionalAccess', _62 => _62.toString, 'call', _63 => _63()]),
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', _64 => _64.bridgeParams, 'optionalAccess', _65 => _65.targetChain]),
12029
- bridge_target_token_address: _optionalChain([options, 'access', _66 => _66.bridgeParams, 'optionalAccess', _67 => _67.targetTokenAddress]),
12030
- bridge_recipient_setup: _optionalChain([options, 'access', _68 => _68.bridgeParams, 'optionalAccess', _69 => _69.recipientSetup])
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', _70 => _70.bridgeParams, 'optionalAccess', _71 => _71.recipient]),
12054
- recipientWallet: _optionalChain([options, 'access', _72 => _72.bridgeParams, 'optionalAccess', _73 => _73.recipientWallet])
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: _chunkM47Z35Z5cjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT,
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: _chunkM47Z35Z5cjs.BTC_HTLC_SCRIPT_VERSION_STRICT,
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', _74 => _74.targetAmount, 'optionalAccess', _75 => _75.toString, 'call', _76 => _76()]),
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', _77 => _77.bridgeParams, 'optionalAccess', _78 => _78.targetChain]),
12134
- bridge_target_token_address: _optionalChain([options, 'access', _79 => _79.bridgeParams, 'optionalAccess', _80 => _80.targetTokenAddress]),
12135
- bridge_recipient_setup: _optionalChain([options, 'access', _81 => _81.bridgeParams, 'optionalAccess', _82 => _82.recipientSetup])
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', _83 => _83.bridgeParams, 'optionalAccess', _84 => _84.recipient]),
12159
- recipientWallet: _optionalChain([options, 'access', _85 => _85.bridgeParams, 'optionalAccess', _86 => _86.recipientWallet])
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
- btc_htlc_script_version: _chunkM47Z35Z5cjs.BTC_HTLC_SCRIPT_VERSION_STRICT,
12184
- arkade_htlc_script_version: _chunkM47Z35Z5cjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT
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: _chunkM47Z35Z5cjs.BTC_HTLC_SCRIPT_VERSION_STRICT,
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', _87 => _87.source_token, 'optionalAccess', _88 => _88.token_id])) {
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', _89 => _89.evm_htlc_token, 'optionalAccess', _90 => _90.toLowerCase, 'call', _91 => _91()])
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: _chunkM47Z35Z5cjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT,
12300
- bridge_source_chain: _optionalChain([options, 'access', _92 => _92.inboundBridgeParams, 'optionalAccess', _93 => _93.sourceChain]),
12301
- bridge_source_token_address: _optionalChain([options, 'access', _94 => _94.inboundBridgeParams, 'optionalAccess', _95 => _95.sourceTokenAddress])
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: _chunkM47Z35Z5cjs.BTC_HTLC_SCRIPT_VERSION_STRICT,
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', _96 => _96.inboundBridgeParams, 'optionalAccess', _97 => _97.sourceChain]),
12348
- bridge_source_token_address: _optionalChain([options, 'access', _98 => _98.inboundBridgeParams, 'optionalAccess', _99 => _99.sourceTokenAddress])
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', _100 => _100.inboundBridgeParams, 'optionalAccess', _101 => _101.sourceChain]),
12407
- bridge_source_token_address: _optionalChain([options, 'access', _102 => _102.inboundBridgeParams, 'optionalAccess', _103 => _103.sourceTokenAddress])
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: _chunkM47Z35Z5cjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT,
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: _chunkM47Z35Z5cjs.BTC_HTLC_SCRIPT_VERSION_STRICT,
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', _104 => _104.targetAmount, 'optionalAccess', _105 => _105.toString, 'call', _106 => _106()]),
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', _107 => _107.bridgeParams, 'optionalAccess', _108 => _108.targetChain]),
12540
- bridge_target_token_address: _optionalChain([options, 'access', _109 => _109.bridgeParams, 'optionalAccess', _110 => _110.targetTokenAddress]),
12541
- bridge_recipient_setup: _optionalChain([options, 'access', _111 => _111.bridgeParams, 'optionalAccess', _112 => _112.recipientSetup])
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', _113 => _113.bridgeParams, 'optionalAccess', _114 => _114.recipient]),
12565
- recipientWallet: _optionalChain([options, 'access', _115 => _115.bridgeParams, 'optionalAccess', _116 => _116.recipientWallet])
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 _chunkM47Z35Z5cjs.NETWORK;
12767
+ return _chunkQJ4EK6UGcjs.NETWORK;
12590
12768
  case "testnet":
12591
12769
  case "signet":
12592
- return _chunkM47Z35Z5cjs.TEST_NETWORK;
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 = _chunkM47Z35Z5cjs.Address.call(void 0, net).decode(address2);
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 = _chunkM47Z35Z5cjs.OutScript.encode(decoded);
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', _117 => _117.onLog]), () => ( (() => {
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', _118 => _118.#socket, 'optionalAccess', _119 => _119.readyState]) === WebSocket.OPEN) {
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', _120 => _120.#socket, 'optionalAccess', _121 => _121.readyState]) === WebSocket.OPEN) return;
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 (e6) {
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 (e7) {
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', _122 => _122.#socket, 'optionalAccess', _123 => _123.readyState]) !== WebSocket.OPEN) return;
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 (e8) {
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 (e9) {
13089
+ } catch (e10) {
12912
13090
  return null;
12913
13091
  }
12914
13092
  try {
12915
- const tx = _chunkM47Z35Z5cjs.Transaction2.fromRaw(_chunk5JR6AJ3Ycjs.hexToBytes.call(void 0, rawHex), {
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 (e10) {
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', _124 => _124.safetyRecheckMs]), () => ( 5e3));
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 (e11) {
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 (e12) {
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 (e13) {
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', _125 => _125[1]]);
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": _chunkM47Z35Z5cjs.CLIENT_AGENT,
13511
- ..._chunkM47Z35Z5cjs.PROTOCOL_HEADERS
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 = _chunkM47Z35Z5cjs.getNetworkName.call(void 0, network);
13735
- const serverUrl = _chunkM47Z35Z5cjs.resolveArkadeServerUrlByName.call(void 0, networkName, arkadeServerUrl);
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 !== _chunkM47Z35Z5cjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
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, _chunkM47Z35Z5cjs.StrictVhtlcScript)(vhtlcOptions);
13757
- const hrp = _chunkM47Z35Z5cjs.getNetworkHrp.call(void 0, networkName);
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) {
@@ -13796,8 +13974,7 @@ async function buildArkadeClaim(params) {
13796
13974
  // The preimage will be added to the witness during signing
13797
13975
  witnessData: preimageBytes
13798
13976
  }));
13799
- const { ArkAddress: ArkAddress2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./dist-OHZT2JOQ-G5BFFCIV.cjs")));
13800
- const destAddr = ArkAddress2.decode(destinationAddress);
13977
+ const destAddr = _chunkBEW62OUTcjs.ArkAddress.decode(destinationAddress);
13801
13978
  const destPkScript = destAddr.pkScript;
13802
13979
  const outputs = [
13803
13980
  {
@@ -13867,7 +14044,7 @@ async function continueArkadeClaim(params) {
13867
14044
  unilateralClaimDelay,
13868
14045
  unilateralRefundDelay,
13869
14046
  unilateralRefundWithoutReceiverDelay,
13870
- // destinationAddress not needed — we continue an existing pending tx
14047
+ destinationAddress,
13871
14048
  network,
13872
14049
  arkadeHtlcScriptVersion,
13873
14050
  arkadeServerUrl
@@ -13898,8 +14075,8 @@ async function continueArkadeClaim(params) {
13898
14075
  `Preimage hash are not equal. '${_chunkRYZSWESUcjs.hex.encode(_chunkBEW62OUTcjs.ripemd1602.call(void 0, _chunkRYZSWESUcjs.hex.decode(preimageHash)))}' vs ${preimageHashBytesString}'`
13899
14076
  );
13900
14077
  }
13901
- const networkName = _chunkM47Z35Z5cjs.getNetworkName.call(void 0, network);
13902
- const serverUrl = _chunkM47Z35Z5cjs.resolveArkadeServerUrlByName.call(void 0, networkName, arkadeServerUrl);
14078
+ const networkName = _chunkQJ4EK6UGcjs.getNetworkName.call(void 0, network);
14079
+ const serverUrl = _chunkQJ4EK6UGcjs.resolveArkadeServerUrlByName.call(void 0, networkName, arkadeServerUrl);
13903
14080
  const arkProvider = new (0, _chunkBEW62OUTcjs.RestOperatorProvider)(serverUrl);
13904
14081
  const indexerProvider = new (0, _chunkBEW62OUTcjs.RestIndexerProvider)(serverUrl);
13905
14082
  const vhtlcOptions = {
@@ -13914,13 +14091,13 @@ async function continueArkadeClaim(params) {
13914
14091
  unilateralRefundWithoutReceiverDelay
13915
14092
  )
13916
14093
  };
13917
- if (arkadeHtlcScriptVersion !== void 0 && arkadeHtlcScriptVersion !== _chunkM47Z35Z5cjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
14094
+ if (arkadeHtlcScriptVersion !== void 0 && arkadeHtlcScriptVersion !== _chunkQJ4EK6UGcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
13918
14095
  throw new Error(
13919
14096
  `Unsupported Arkade HTLC script version: ${arkadeHtlcScriptVersion}`
13920
14097
  );
13921
14098
  }
13922
- const vhtlc = new (0, _chunkM47Z35Z5cjs.StrictVhtlcScript)(vhtlcOptions);
13923
- const hrp = _chunkM47Z35Z5cjs.getNetworkHrp.call(void 0, networkName);
14099
+ const vhtlc = new (0, _chunkQJ4EK6UGcjs.StrictVhtlcScript)(vhtlcOptions);
14100
+ const hrp = _chunkQJ4EK6UGcjs.getNetworkHrp.call(void 0, networkName);
13924
14101
  const computedAddress = vhtlc.address(hrp, serverPkBytes);
13925
14102
  const computedAddressStr = computedAddress.encode();
13926
14103
  if (computedAddressStr !== vhtlcAddress) {
@@ -13948,7 +14125,6 @@ async function continueArkadeClaim(params) {
13948
14125
  throw new Error("Total VTXO amount is zero");
13949
14126
  }
13950
14127
  const claimLeafScript = vhtlc.claim();
13951
- const claimScriptByte = claimLeafScript[1];
13952
14128
  const tapTree = vhtlc.encode();
13953
14129
  logger.info({
13954
14130
  event: "arkade.claim.continue_vtxos_found",
@@ -13969,7 +14145,7 @@ async function continueArkadeClaim(params) {
13969
14145
  amount: BigInt(v.value)
13970
14146
  },
13971
14147
  tapLeafScript: [claimLeafScript],
13972
- sighashType: _chunkM47Z35Z5cjs.SigHash.ALL
14148
+ sighashType: _chunkQJ4EK6UGcjs.SigHash.ALL
13973
14149
  }));
13974
14150
  const intentProof = _chunkBEW62OUTcjs.Proof.create(intentMessage, intentInputs);
13975
14151
  for (let i = 0; i < vtxos.length; i++) {
@@ -13996,6 +14172,25 @@ async function continueArkadeClaim(params) {
13996
14172
  "No pending transactions found at the VHTLC address. The claim may have already been finalized or was never submitted."
13997
14173
  );
13998
14174
  }
14175
+ if (destinationAddress) {
14176
+ const expectedScript = _chunkRYZSWESUcjs.hex.encode(
14177
+ _chunkBEW62OUTcjs.ArkAddress.decode(destinationAddress).pkScript
14178
+ );
14179
+ for (const { arkTxid, finalArkTx } of pendingTxs) {
14180
+ const arkTx = _chunkBEW62OUTcjs.Transaction2.fromPSBT(_chunkRYZSWESUcjs.base64.decode(finalArkTx));
14181
+ if (arkTx.id !== arkTxid) {
14182
+ throw new Error(
14183
+ "Pending Arkade claim transaction ID does not match its PSBT."
14184
+ );
14185
+ }
14186
+ const { amount, script } = arkTx.getOutput(0);
14187
+ if (!amount || !script || _chunkRYZSWESUcjs.hex.encode(script) !== expectedScript) {
14188
+ throw new Error(
14189
+ "Pending Arkade claim does not pay the requested destination address."
14190
+ );
14191
+ }
14192
+ }
14193
+ }
13999
14194
  logger.info({
14000
14195
  event: "arkade.claim.pending_txs_found",
14001
14196
  message: "Found pending Arkade claim transactions",
@@ -14007,9 +14202,6 @@ async function continueArkadeClaim(params) {
14007
14202
  const finalCheckpoints = await Promise.all(
14008
14203
  signedCheckpointTxs.map(async (c) => {
14009
14204
  const checkpointTx = _chunkBEW62OUTcjs.Transaction2.fromPSBT(_chunkRYZSWESUcjs.base64.decode(c));
14010
- checkpointTx.updateInput(0, {
14011
- witnessScript: claimScriptByte
14012
- });
14013
14205
  for (let i = 0; i < checkpointTx.inputsLength; i++) {
14014
14206
  ensureConditionWitness(checkpointTx, i, preimageBytes);
14015
14207
  }
@@ -14316,7 +14508,7 @@ async function rifResponse(response, path) {
14316
14508
  let body;
14317
14509
  try {
14318
14510
  body = JSON.parse(text);
14319
- } catch (e14) {
14511
+ } catch (e15) {
14320
14512
  throw new Error(
14321
14513
  `RIF Relay ${path} answered ${response.status}: ${text.slice(0, 200)}`
14322
14514
  );
@@ -14439,7 +14631,7 @@ async function claimViaSigner(params) {
14439
14631
  `Replacement transaction ${minedHash} was mined, but its claim could not yet be verified. Check the swap status or transaction before submitting another claim.`
14440
14632
  );
14441
14633
  }
14442
- if (_optionalChain([mined, 'access', _126 => _126.to, 'optionalAccess', _127 => _127.toLowerCase, 'call', _128 => _128()]) !== tx.to.toLowerCase() || mined.from.toLowerCase() !== signer.address.toLowerCase() || mined.input.toLowerCase() !== tx.data.toLowerCase()) {
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()) {
14443
14635
  throw new Error(
14444
14636
  "The wallet replaced or cancelled the claim transaction. The claim was not submitted; try again from the payout wallet."
14445
14637
  );
@@ -14575,7 +14767,7 @@ function formatApiError(error) {
14575
14767
  }
14576
14768
  try {
14577
14769
  return JSON.stringify(error);
14578
- } catch (e15) {
14770
+ } catch (e16) {
14579
14771
  }
14580
14772
  }
14581
14773
  return String(error);
@@ -14585,7 +14777,7 @@ function buildRefundScriptVhtlc(params) {
14585
14777
  const lendaswapPkBytes = parseXOnlyPubKey3(params.lendaswapPubKey);
14586
14778
  const serverPkBytes = parseXOnlyPubKey3(params.arkadeServerPubKey);
14587
14779
  const preimageHashBytes = parsePreimageHash(params.hashLock);
14588
- const networkName = _chunkM47Z35Z5cjs.getNetworkName.call(void 0, params.network);
14780
+ const networkName = _chunkQJ4EK6UGcjs.getNetworkName.call(void 0, params.network);
14589
14781
  const options = {
14590
14782
  sender: userPkBytes,
14591
14783
  receiver: lendaswapPkBytes,
@@ -14598,13 +14790,13 @@ function buildRefundScriptVhtlc(params) {
14598
14790
  params.unilateralRefundWithoutReceiverDelay
14599
14791
  )
14600
14792
  };
14601
- if (params.arkadeHtlcScriptVersion !== void 0 && params.arkadeHtlcScriptVersion !== _chunkM47Z35Z5cjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
14793
+ if (params.arkadeHtlcScriptVersion !== void 0 && params.arkadeHtlcScriptVersion !== _chunkQJ4EK6UGcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
14602
14794
  throw new Error(
14603
14795
  `Unsupported Arkade HTLC script version: ${params.arkadeHtlcScriptVersion}`
14604
14796
  );
14605
14797
  }
14606
- const vhtlc = new (0, _chunkM47Z35Z5cjs.StrictVhtlcScript)(options);
14607
- const hrp = _chunkM47Z35Z5cjs.getNetworkHrp.call(void 0, networkName);
14798
+ const vhtlc = new (0, _chunkQJ4EK6UGcjs.StrictVhtlcScript)(options);
14799
+ const hrp = _chunkQJ4EK6UGcjs.getNetworkHrp.call(void 0, networkName);
14608
14800
  const computedAddress = vhtlc.address(hrp, serverPkBytes).encode();
14609
14801
  if (computedAddress !== params.vhtlcAddress) {
14610
14802
  throw new Error(
@@ -14615,7 +14807,7 @@ function buildRefundScriptVhtlc(params) {
14615
14807
  }
14616
14808
  async function collabRefundArkadeToEvmOffchain(params) {
14617
14809
  const { vhtlc, networkName } = buildRefundScriptVhtlc(params);
14618
- const serverUrl = _chunkM47Z35Z5cjs.resolveArkadeServerUrlByName.call(void 0,
14810
+ const serverUrl = _chunkQJ4EK6UGcjs.resolveArkadeServerUrlByName.call(void 0,
14619
14811
  networkName,
14620
14812
  params.arkadeServerUrl
14621
14813
  );
@@ -14701,7 +14893,7 @@ async function collabRefundArkadeToEvmOffchain(params) {
14701
14893
  }
14702
14894
  async function collabRefundArkadeToEvmDelegate(params) {
14703
14895
  const { vhtlc, networkName } = buildRefundScriptVhtlc(params);
14704
- const serverUrl = _chunkM47Z35Z5cjs.resolveArkadeServerUrlByName.call(void 0,
14896
+ const serverUrl = _chunkQJ4EK6UGcjs.resolveArkadeServerUrlByName.call(void 0,
14705
14897
  networkName,
14706
14898
  params.arkadeServerUrl
14707
14899
  );
@@ -14716,13 +14908,13 @@ async function collabRefundArkadeToEvmDelegate(params) {
14716
14908
  }
14717
14909
  const cosignerPkHex = cosignerRes.data.cosigner_pk;
14718
14910
  const btcNetwork = _chunkBEW62OUTcjs.networks[networkName];
14719
- const forfeitDecoded = _chunkM47Z35Z5cjs.Address.call(void 0, btcNetwork).decode(serverInfo.forfeitAddress);
14911
+ const forfeitDecoded = _chunkQJ4EK6UGcjs.Address.call(void 0, btcNetwork).decode(serverInfo.forfeitAddress);
14720
14912
  if (!forfeitDecoded) {
14721
14913
  throw new Error(
14722
14914
  `Unrecognised forfeit address: ${serverInfo.forfeitAddress}`
14723
14915
  );
14724
14916
  }
14725
- const forfeitPkScript = _chunkM47Z35Z5cjs.OutScript.encode(forfeitDecoded);
14917
+ const forfeitPkScript = _chunkQJ4EK6UGcjs.OutScript.encode(forfeitDecoded);
14726
14918
  const vhtlcPkScript = _chunkRYZSWESUcjs.hex.encode(vhtlc.pkScript);
14727
14919
  const { vtxos: allVtxos } = await indexerProvider.getVtxos({
14728
14920
  scripts: [vhtlcPkScript]
@@ -14755,7 +14947,7 @@ async function collabRefundArkadeToEvmDelegate(params) {
14755
14947
  amount: BigInt(v.value)
14756
14948
  },
14757
14949
  tapLeafScript: [tapLeafScript],
14758
- sighashType: _chunkM47Z35Z5cjs.SigHash.ALL
14950
+ sighashType: _chunkQJ4EK6UGcjs.SigHash.ALL
14759
14951
  }));
14760
14952
  const intentProof = _chunkBEW62OUTcjs.Proof.create(intentMessage, intentInputs, [
14761
14953
  { script: destination.pkScript, amount: totalAmount }
@@ -14781,7 +14973,7 @@ async function collabRefundArkadeToEvmDelegate(params) {
14781
14973
  amount: vtxoAmount
14782
14974
  },
14783
14975
  tapLeafScript: [tapLeafScript],
14784
- sighashType: _chunkM47Z35Z5cjs.SigHash.ALL_ANYONECANPAY
14976
+ sighashType: _chunkQJ4EK6UGcjs.SigHash.ALL_ANYONECANPAY
14785
14977
  });
14786
14978
  forfeitTx.addOutput({
14787
14979
  script: forfeitPkScript,
@@ -14957,13 +15149,15 @@ function fromWireQuoteResponse(wire) {
14957
15149
  target_amount: wire.target_amount,
14958
15150
  net_source_amount: wire.net_source_amount,
14959
15151
  net_target_amount: wire.net_target_amount,
14960
- bridge_fee: _nullishCoalesce(wire.bridge_fee, () => ( void 0))
15152
+ bridge_fee: _nullishCoalesce(wire.bridge_fee, () => ( void 0)),
15153
+ promo: _nullishCoalesce(wire.promo, () => ( void 0))
14961
15154
  };
14962
15155
  }
14963
15156
  function fromWireReferralFeeResponse(wire) {
14964
15157
  return {
14965
15158
  extra_fee_rate: wire.extra_fee_rate,
14966
15159
  base_fee_rate: _nullishCoalesce(wire.base_fee_rate, () => ( void 0)),
15160
+ promo: _nullishCoalesce(wire.promo, () => ( void 0)),
14967
15161
  referral_label: _nullishCoalesce(wire.referral_label, () => ( void 0))
14968
15162
  };
14969
15163
  }
@@ -14997,7 +15191,7 @@ function isValidTronAddress(address2) {
14997
15191
  try {
14998
15192
  tronAddressToBytes32(address2);
14999
15193
  return true;
15000
- } catch (e16) {
15194
+ } catch (e17) {
15001
15195
  return false;
15002
15196
  }
15003
15197
  }
@@ -15031,7 +15225,7 @@ function createSwapStatusWatcher(baseUrl) {
15031
15225
  let parsed;
15032
15226
  try {
15033
15227
  parsed = JSON.parse(evt.data);
15034
- } catch (e17) {
15228
+ } catch (e18) {
15035
15229
  return;
15036
15230
  }
15037
15231
  if ("data" in parsed && parsed.channel === "swap_status") {
@@ -15050,8 +15244,8 @@ function createSwapStatusWatcher(baseUrl) {
15050
15244
  });
15051
15245
  socket.addEventListener("error", () => {
15052
15246
  try {
15053
- _optionalChain([socket, 'optionalAccess', _129 => _129.close, 'call', _130 => _130()]);
15054
- } catch (e18) {
15247
+ _optionalChain([socket, 'optionalAccess', _146 => _146.close, 'call', _147 => _147()]);
15248
+ } catch (e19) {
15055
15249
  }
15056
15250
  });
15057
15251
  }
@@ -15068,7 +15262,7 @@ function createSwapStatusWatcher(baseUrl) {
15068
15262
  }, delay);
15069
15263
  }
15070
15264
  function sendSubscribe(ids) {
15071
- if (ids.length === 0 || _optionalChain([socket, 'optionalAccess', _131 => _131.readyState]) !== WebSocket.OPEN) return;
15265
+ if (ids.length === 0 || _optionalChain([socket, 'optionalAccess', _148 => _148.readyState]) !== WebSocket.OPEN) return;
15072
15266
  const frame = {
15073
15267
  op: "subscribe",
15074
15268
  channel: "swap_status",
@@ -15077,7 +15271,7 @@ function createSwapStatusWatcher(baseUrl) {
15077
15271
  socket.send(JSON.stringify(frame));
15078
15272
  }
15079
15273
  function sendUnsubscribe(ids) {
15080
- if (ids.length === 0 || _optionalChain([socket, 'optionalAccess', _132 => _132.readyState]) !== WebSocket.OPEN) return;
15274
+ if (ids.length === 0 || _optionalChain([socket, 'optionalAccess', _149 => _149.readyState]) !== WebSocket.OPEN) return;
15081
15275
  const frame = {
15082
15276
  op: "unsubscribe",
15083
15277
  channel: "swap_status",
@@ -15093,8 +15287,8 @@ function createSwapStatusWatcher(baseUrl) {
15093
15287
  reconnectTimer = null;
15094
15288
  }
15095
15289
  try {
15096
- _optionalChain([socket, 'optionalAccess', _133 => _133.close, 'call', _134 => _134()]);
15097
- } catch (e19) {
15290
+ _optionalChain([socket, 'optionalAccess', _150 => _150.close, 'call', _151 => _151()]);
15291
+ } catch (e20) {
15098
15292
  }
15099
15293
  socket = null;
15100
15294
  }
@@ -15309,7 +15503,7 @@ async function sendCall(signer, call, label, options = {}) {
15309
15503
  type: _chunkTNZW35XAcjs.txTypeFor.call(void 0, signer.chainId),
15310
15504
  gas: await _chunkTNZW35XAcjs.gasLimitFor.call(void 0, signer, call, _nullishCoalesce(options.fallbackGas, () => ( REFUND_GAS)))
15311
15505
  });
15312
- await _optionalChain([options, 'access', _135 => _135.onSent, 'optionalCall', _136 => _136(sent)]);
15506
+ await _optionalChain([options, 'access', _152 => _152.onSent, 'optionalCall', _153 => _153(sent)]);
15313
15507
  const receipt = await signer.waitForReceipt(sent);
15314
15508
  if (receipt.status !== "success") {
15315
15509
  const reason = await _chunkTNZW35XAcjs.getRevertReason.call(void 0, signer, sent, receipt.blockNumber);
@@ -15326,8 +15520,8 @@ async function sendCall(signer, call, label, options = {}) {
15326
15520
  async function isSameCall(signer, hash, call) {
15327
15521
  try {
15328
15522
  const tx = await signer.getTransaction(hash);
15329
- return _optionalChain([tx, 'optionalAccess', _137 => _137.to, 'optionalAccess', _138 => _138.toLowerCase, 'call', _139 => _139()]) === call.to.toLowerCase() && tx.input.toLowerCase() === call.data.toLowerCase();
15330
- } catch (e20) {
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) {
15331
15525
  return false;
15332
15526
  }
15333
15527
  }
@@ -15344,7 +15538,7 @@ function dedupeTxids(txids) {
15344
15538
  function clientHashLockOf(stored) {
15345
15539
  switch (stored.response.direction) {
15346
15540
  case "evm_to_lightning":
15347
- return _optionalChain([stored, 'access', _140 => _140.lightningPaymentHash, 'optionalAccess', _141 => _141.hash]);
15541
+ return _optionalChain([stored, 'access', _157 => _157.lightningPaymentHash, 'optionalAccess', _158 => _158.hash]);
15348
15542
  case "evm_to_bitcoin":
15349
15543
  case "evm_to_arkade":
15350
15544
  return stored.preimageHash ? `0x${_chunkJZTF4JNHcjs.normalizeBytes32.call(void 0, stored.preimageHash)}` : void 0;
@@ -15359,7 +15553,7 @@ function evmHashLockOf(swap) {
15359
15553
  return hash;
15360
15554
  }
15361
15555
  function evmSourceLeg(stored) {
15362
- const rehashes = _optionalChain([stored, 'access', _142 => _142.evmRehashes, 'optionalAccess', _143 => _143.length]) ? stored.evmRehashes : void 0;
15556
+ const rehashes = _optionalChain([stored, 'access', _159 => _159.evmRehashes, 'optionalAccess', _160 => _160.length]) ? stored.evmRehashes : void 0;
15363
15557
  const swap = stored.response;
15364
15558
  return {
15365
15559
  chainId: swap.evm_chain_id,
@@ -15369,9 +15563,9 @@ function evmSourceLeg(stored) {
15369
15563
  // without it, and switches to the current hash once a rehash is
15370
15564
  // confirmed). The funding tx's SwapCreated is under the first hash, and
15371
15565
  // the rehashes are followed from there.
15372
- hashLock: _nullishCoalesce(_nullishCoalesce(_optionalChain([rehashes, 'optionalAccess', _144 => _144[0], 'optionalAccess', _145 => _145.fromHashLock]), () => ( clientHashLockOf(stored))), () => ( (swap.direction === "evm_to_bitcoin" ? swap.evm_hash_lock : swap.hash_lock))),
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))),
15373
15567
  claimAddress: swap.server_evm_address,
15374
- timelock: _nullishCoalesce(_optionalChain([rehashes, 'optionalAccess', _146 => _146.at, 'call', _147 => _147(-1), 'optionalAccess', _148 => _148.timelock]), () => ( swap.evm_refund_locktime)),
15568
+ timelock: _nullishCoalesce(_optionalChain([rehashes, 'optionalAccess', _163 => _163.at, 'call', _164 => _164(-1), 'optionalAccess', _165 => _165.timelock]), () => ( swap.evm_refund_locktime)),
15375
15569
  // This client's own record first, then the server's copy (which names
15376
15570
  // the rehash tx once a rehash is confirmed; that one carries no
15377
15571
  // SwapCreated and is skipped as unavailable).
@@ -15382,7 +15576,7 @@ function evmSourceLeg(stored) {
15382
15576
  // Read from the creation terms first, which a server refresh cannot
15383
15577
  // rewrite; a swap recorded before they named the version falls back to
15384
15578
  // the server's copy.
15385
- depositorIsSender: _optionalChain([stored, 'access', _149 => _149.evmFundingTerms, 'optionalAccess', _150 => _150.htlcVersion]) !== void 0 ? _chunkJZTF4JNHcjs.depositorIsSender.call(void 0,
15579
+ depositorIsSender: _optionalChain([stored, 'access', _166 => _166.evmFundingTerms, 'optionalAccess', _167 => _167.htlcVersion]) !== void 0 ? _chunkJZTF4JNHcjs.depositorIsSender.call(void 0,
15386
15580
  stored.evmFundingTerms.htlcKind,
15387
15581
  stored.evmFundingTerms.htlcVersion
15388
15582
  ) : _chunkJZTF4JNHcjs.depositorIsSender.call(void 0, swap.evm_htlc_kind, swap.evm_htlc_version)
@@ -15395,7 +15589,7 @@ function provesNoLockUnder(receipt, hashLock) {
15395
15589
  if (receipt.logs === void 0) return false;
15396
15590
  const hash = `0x${_chunkJZTF4JNHcjs.normalizeBytes32.call(void 0, hashLock)}`;
15397
15591
  return !receipt.logs.some(
15398
- (log) => log.topics.some((topic) => `0x${_chunkJZTF4JNHcjs.normalizeBytes32.call(void 0, topic)}` === hash) || _optionalChain([_chunkJZTF4JNHcjs.decodeSwapCreatedLog.call(void 0, log), 'optionalAccess', _151 => _151.preimageHash]) === hash
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
15399
15593
  );
15400
15594
  }
15401
15595
  var serializeAmountInput = (amount) => amount == null ? void 0 : amount.toString();
@@ -15411,7 +15605,8 @@ function satsToLightningOptions(options, sourceName) {
15411
15605
  const kind = classifyLightningDestination(destination);
15412
15606
  const common = {
15413
15607
  referralCode: options.referralCode,
15414
- extraFees: options.extraFees
15608
+ extraFees: options.extraFees,
15609
+ promoCode: options.promoCode
15415
15610
  };
15416
15611
  if (kind === "invoice") {
15417
15612
  if (options.sourceAmount != null && options.targetAmount != null) {
@@ -15453,10 +15648,10 @@ var DEFAULT_ELECTRUM_WS_URLS = {
15453
15648
  mainnet: "wss://electrs.satora.io"
15454
15649
  };
15455
15650
  function defaultAaConfig() {
15456
- if (!_chunkM47Z35Z5cjs.DEFAULT_AA_BUNDLER_URL) return void 0;
15651
+ if (!_chunkQJ4EK6UGcjs.DEFAULT_AA_BUNDLER_URL) return void 0;
15457
15652
  return {
15458
- bundlerUrl: _chunkM47Z35Z5cjs.DEFAULT_AA_BUNDLER_URL,
15459
- ..._chunkM47Z35Z5cjs.DEFAULT_AA_POLICY_ID ? { paymasterPolicyId: _chunkM47Z35Z5cjs.DEFAULT_AA_POLICY_ID } : {}
15653
+ bundlerUrl: _chunkQJ4EK6UGcjs.DEFAULT_AA_BUNDLER_URL,
15654
+ ..._chunkQJ4EK6UGcjs.DEFAULT_AA_POLICY_ID ? { paymasterPolicyId: _chunkQJ4EK6UGcjs.DEFAULT_AA_POLICY_ID } : {}
15460
15655
  };
15461
15656
  }
15462
15657
  var ClientBuilder = class {
@@ -15711,9 +15906,9 @@ var ClientBuilder = class {
15711
15906
  baseUrl: this.#baseUrl.replace(/\/+$/, ""),
15712
15907
  referralCode: this.#referralCode,
15713
15908
  defaultHeaders: this.#defaultHeaders,
15714
- esploraUrl: Array.isArray(this.#esploraUrl) ? this.#esploraUrl.map((url) => url.replace(/\/+$/, "")) : _optionalChain([this, 'access', _152 => _152.#esploraUrl, 'optionalAccess', _153 => _153.replace, 'call', _154 => _154(/\/+$/, "")]),
15715
- electrumWsUrl: _optionalChain([this, 'access', _155 => _155.#electrumWsUrl, 'optionalAccess', _156 => _156.replace, 'call', _157 => _157(/\/+$/, "")]),
15716
- arkadeServerUrl: _optionalChain([this, 'access', _158 => _158.#arkadeServerUrl, 'optionalAccess', _159 => _159.replace, 'call', _160 => _160(/\/+$/, "")]),
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(/\/+$/, "")]),
15717
15912
  aa: _nullishCoalesce(this.#aa, () => ( defaultAaConfig())),
15718
15913
  solanaRpcUrl: this.#solanaRpcUrl,
15719
15914
  logger: this.#logger,
@@ -15769,8 +15964,8 @@ var Client = class _Client {
15769
15964
  }
15770
15965
  #apiHeaders(extra) {
15771
15966
  return {
15772
- "X-Lendaswap-Client": _chunkM47Z35Z5cjs.CLIENT_AGENT,
15773
- ..._chunkM47Z35Z5cjs.PROTOCOL_HEADERS,
15967
+ "X-Lendaswap-Client": _chunkQJ4EK6UGcjs.CLIENT_AGENT,
15968
+ ..._chunkQJ4EK6UGcjs.PROTOCOL_HEADERS,
15774
15969
  ..._nullishCoalesce(this.#config.defaultHeaders, () => ( {})),
15775
15970
  ..._nullishCoalesce(extra, () => ( {}))
15776
15971
  };
@@ -15796,11 +15991,11 @@ var Client = class _Client {
15796
15991
  * Remove `onUpdate` from the given swap ids.
15797
15992
  */
15798
15993
  unsubscribeFromSwaps(swapIds, onUpdate) {
15799
- _optionalChain([this, 'access', _161 => _161.#statusWatcher, 'optionalAccess', _162 => _162.unsubscribe, 'call', _163 => _163(swapIds, onUpdate)]);
15994
+ _optionalChain([this, 'access', _178 => _178.#statusWatcher, 'optionalAccess', _179 => _179.unsubscribe, 'call', _180 => _180(swapIds, onUpdate)]);
15800
15995
  }
15801
15996
  /** Force-close the shared swap-status socket. */
15802
15997
  closeSwapStatusSocket() {
15803
- _optionalChain([this, 'access', _164 => _164.#statusWatcher, 'optionalAccess', _165 => _165.close, 'call', _166 => _166()]);
15998
+ _optionalChain([this, 'access', _181 => _181.#statusWatcher, 'optionalAccess', _182 => _182.close, 'call', _183 => _183()]);
15804
15999
  this.#statusWatcher = null;
15805
16000
  }
15806
16001
  /**
@@ -15990,7 +16185,7 @@ var Client = class _Client {
15990
16185
  * caller falls back to probing.
15991
16186
  */
15992
16187
  #delegationHintFor(swap, depositor, hint) {
15993
- const hinted = _optionalChain([swap, 'access', _167 => _167.client_evm_address, 'optionalAccess', _168 => _168.toLowerCase, 'call', _169 => _169()]);
16188
+ const hinted = _optionalChain([swap, 'access', _184 => _184.client_evm_address, 'optionalAccess', _185 => _185.toLowerCase, 'call', _186 => _186()]);
15994
16189
  return hinted && hinted === depositor.toLowerCase() ? hint : void 0;
15995
16190
  }
15996
16191
  async #isKernelDelegated(address2, chainId, serverHint) {
@@ -16004,7 +16199,7 @@ var Client = class _Client {
16004
16199
  );
16005
16200
  }
16006
16201
  if (chainId !== AA_CHAIN_ID) return false;
16007
- const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access', _170 => _170.#config, 'access', _171 => _171.aa, 'optionalAccess', _172 => _172.rpcUrl]), () => ( _optionalChain([this, 'access', _173 => _173.#config, 'access', _174 => _174.aa, 'optionalAccess', _175 => _175.bundlerUrl])));
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])));
16008
16203
  if (!rpcUrl) return false;
16009
16204
  const { createPublicClient: createPublicClient2, http: http2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./_esm-4ZKYBBIE-D33574DC.cjs")));
16010
16205
  const publicClient = createPublicClient2({ transport: http2(rpcUrl) });
@@ -16033,7 +16228,7 @@ var Client = class _Client {
16033
16228
  */
16034
16229
  #getClaimEvmSigningKey(storedSwap) {
16035
16230
  const swapKey = storedSwap.secretKey;
16036
- const clientAddress = _optionalChain([storedSwap, 'access', _176 => _176.response, 'access', _177 => _177.client_evm_address, 'optionalAccess', _178 => _178.toLowerCase, 'call', _179 => _179()]);
16231
+ const clientAddress = _optionalChain([storedSwap, 'access', _193 => _193.response, 'access', _194 => _194.client_evm_address, 'optionalAccess', _195 => _195.toLowerCase, 'call', _196 => _196()]);
16037
16232
  if (swapKey && clientAddress && clientAddress === deriveEvmAddress(swapKey).toLowerCase()) {
16038
16233
  return swapKey;
16039
16234
  }
@@ -16056,7 +16251,7 @@ var Client = class _Client {
16056
16251
  const deterministicKey = this.#getEvmSigningKey();
16057
16252
  const deterministicAddress = deriveEvmAddress(deterministicKey);
16058
16253
  const swapAddress = deriveEvmAddress(swapKey);
16059
- const clientAddress = _optionalChain([response, 'access', _180 => _180.client_evm_address, 'optionalAccess', _181 => _181.toLowerCase, 'call', _182 => _182()]);
16254
+ const clientAddress = _optionalChain([response, 'access', _197 => _197.client_evm_address, 'optionalAccess', _198 => _198.toLowerCase, 'call', _199 => _199()]);
16060
16255
  if (clientAddress === deterministicAddress.toLowerCase() || !clientAddress) {
16061
16256
  return deterministicKey;
16062
16257
  }
@@ -16219,7 +16414,7 @@ var Client = class _Client {
16219
16414
  "chain-config",
16220
16415
  () => this.getChainConfig()
16221
16416
  );
16222
- return _optionalChain([config, 'access', _183 => _183.chains, 'access', _184 => _184.find, 'call', _185 => _185((c) => String(c.chain) === String(chainId)), 'optionalAccess', _186 => _186.rif_relay]);
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]);
16223
16418
  }
16224
16419
  /**
16225
16420
  * The claim address of a native lock on a chain that claims through RIF
@@ -16249,7 +16444,11 @@ var Client = class _Client {
16249
16444
  async getReferralFee(params) {
16250
16445
  const { data, error } = await this.#apiClient.GET("/referral-fee", {
16251
16446
  params: {
16252
- query: { ref: params.referralCode, extra_fees: params.extraFees }
16447
+ query: {
16448
+ ref: params.referralCode,
16449
+ extra_fees: params.extraFees,
16450
+ promo_code: params.promoCode
16451
+ }
16253
16452
  }
16254
16453
  });
16255
16454
  if (error || !data) {
@@ -16320,12 +16519,14 @@ var Client = class _Client {
16320
16519
  ...params,
16321
16520
  referralCode: _nullishCoalesce(params.referralCode, () => ( this.#config.referralCode))
16322
16521
  };
16323
- const referralFee = params.referralCode != null || params.extraFees != null ? this.#composeStatic(
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(
16324
16528
  `referral-fee|${_nullishCoalesce(params.referralCode, () => ( ""))}|${_nullishCoalesce(params.extraFees, () => ( ""))}`,
16325
- () => this.getReferralFee({
16326
- referralCode: params.referralCode,
16327
- extraFees: params.extraFees
16328
- })
16529
+ fetchReferralFee
16329
16530
  ) : Promise.resolve(void 0);
16330
16531
  const [swapPairs, networkFees, chainConfig, referral] = await Promise.all([
16331
16532
  this.#composeStatic("swap-pairs", () => this.getSwapPairs()),
@@ -16337,8 +16538,9 @@ var Client = class _Client {
16337
16538
  swapPairs,
16338
16539
  networkFees,
16339
16540
  chainConfig,
16340
- referralExtraFeeRate: _optionalChain([referral, 'optionalAccess', _187 => _187.extra_fee_rate]),
16341
- referralBaseFeeRate: _optionalChain([referral, 'optionalAccess', _188 => _188.base_fee_rate]),
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]),
16342
16544
  getDexQuote: (p) => this.getDexQuote(p)
16343
16545
  });
16344
16546
  }
@@ -16412,6 +16614,7 @@ var Client = class _Client {
16412
16614
  // Per-call referral wins; fall back to the client default.
16413
16615
  referralCode: _nullishCoalesce(params.referralCode, () => ( this.#config.referralCode)),
16414
16616
  extraFees: params.extraFees,
16617
+ promoCode: params.promoCode,
16415
16618
  bridgeRecipientSetup: params.bridgeRecipientSetup
16416
16619
  });
16417
16620
  } catch (err) {
@@ -16465,7 +16668,8 @@ var Client = class _Client {
16465
16668
  target_amount_sats: params.targetAmountSats,
16466
16669
  // Per-call referral wins; fall back to the client default.
16467
16670
  ref: _nullishCoalesce(params.referralCode, () => ( this.#config.referralCode)),
16468
- extra_fees: params.extraFees
16671
+ extra_fees: params.extraFees,
16672
+ promo_code: params.promoCode
16469
16673
  }
16470
16674
  }
16471
16675
  });
@@ -16490,7 +16694,8 @@ var Client = class _Client {
16490
16694
  protocolFeeRate: data.protocol_fee_rate,
16491
16695
  minAmountSats: data.min_amount_sats,
16492
16696
  maxAmountSats: data.max_amount_sats,
16493
- exchangeRate: data.exchange_rate
16697
+ exchangeRate: data.exchange_rate,
16698
+ promo: _nullishCoalesce(data.promo, () => ( void 0))
16494
16699
  };
16495
16700
  }
16496
16701
  /**
@@ -16518,7 +16723,8 @@ var Client = class _Client {
16518
16723
  lnurl: kind === "lnurl" ? destination : void 0,
16519
16724
  targetAmountSats,
16520
16725
  referralCode: params.referralCode,
16521
- extraFees: params.extraFees
16726
+ extraFees: params.extraFees,
16727
+ promoCode: params.promoCode
16522
16728
  });
16523
16729
  const sourceAmountOut = evmSource ? q.sourceAmount : sourcePinned ? q.sourceAmount : String(q.targetAmountSats);
16524
16730
  const targetAmountOut = !evmSource && sourcePinned ? q.sourceAmount : String(q.targetAmountSats);
@@ -16533,7 +16739,8 @@ var Client = class _Client {
16533
16739
  source_amount: sourceAmountOut,
16534
16740
  target_amount: targetAmountOut,
16535
16741
  net_source_amount: q.sourceAmount,
16536
- net_target_amount: String(q.targetAmountSats)
16742
+ net_target_amount: String(q.targetAmountSats),
16743
+ promo: q.promo
16537
16744
  };
16538
16745
  }
16539
16746
  /**
@@ -16626,7 +16833,8 @@ var Client = class _Client {
16626
16833
  // Per-call referralCode wins; fall back to the client config default
16627
16834
  // (set via withReferralCode / withOrgCode).
16628
16835
  ref: _nullishCoalesce(params.referralCode, () => ( this.#config.referralCode)),
16629
- extra_fees: params.extraFees
16836
+ extra_fees: params.extraFees,
16837
+ promo_code: params.promoCode
16630
16838
  };
16631
16839
  const { data, error } = await this.#apiClient.GET("/quote", {
16632
16840
  params: {
@@ -16679,7 +16887,7 @@ var Client = class _Client {
16679
16887
  if (comparableId(data.id) !== comparableId(id)) {
16680
16888
  throw new Error(`Requested swap ${id}, but server returned ${data.id}`);
16681
16889
  }
16682
- if (_optionalChain([options, 'optionalAccess', _189 => _189.updateStorage]) && this.#swapStorage) {
16890
+ if (_optionalChain([options, 'optionalAccess', _207 => _207.updateStorage]) && this.#swapStorage) {
16683
16891
  const stored = await this.#swapStorage.get(id);
16684
16892
  const changed = stored ? swapTermsChange(stored, data) : void 0;
16685
16893
  if (stored && changed) {
@@ -17001,7 +17209,7 @@ var Client = class _Client {
17001
17209
  }
17002
17210
  const swap = storedSwap.response;
17003
17211
  const secret = storedSwap.preimage;
17004
- 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") {
17005
17213
  const evmSwap = swap;
17006
17214
  const bridgeTargetChain = evmSwap.bridge_target_chain;
17007
17215
  const isSolanaBridge = bridgeTargetChain === "Solana";
@@ -17013,15 +17221,15 @@ var Client = class _Client {
17013
17221
  message: "Gasless claim failed: no target address found. This swap may have been created before target address storage was implemented."
17014
17222
  };
17015
17223
  }
17016
- const bridgeRecipient = _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _190 => _190.bridgeRecipient]), () => ( storedSwap.bridgeRecipient)), () => ( (isTronBridge ? storedPayoutTarget(storedSwap) : void 0)));
17017
- const bridgeRecipientWallet = _optionalChain([options, 'optionalAccess', _191 => _191.bridgeRecipient]) !== void 0 ? _optionalChain([options, 'optionalAccess', _192 => _192.bridgeRecipientWallet]) : storedSwap.bridgeRecipientWallet;
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;
17018
17226
  if (isSolanaBridge && !bridgeRecipient) {
17019
17227
  return {
17020
17228
  success: false,
17021
17229
  message: "Solana bridge claim requires `bridgeRecipient` (the recipient's USDC ATA) in claim options. Derive it via `deriveSolanaUsdcAta` before calling claim."
17022
17230
  };
17023
17231
  }
17024
- const gaslessResult = (swap.evm_chain_id === 30 || swap.evm_chain_id === 31) && _optionalChain([options, 'optionalAccess', _193 => _193.signer]) ? await this.claimEvmWithSigner(id, options.signer, {
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, {
17025
17233
  bridgeRecipient,
17026
17234
  bridgeRecipientWallet
17027
17235
  }) : await this.claimViaGasless(id, destination, {
@@ -17073,7 +17281,7 @@ var Client = class _Client {
17073
17281
  const swap = await this.getSwap(id, {
17074
17282
  updateStorage: true
17075
17283
  });
17076
- 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") {
17077
17285
  throw new Error(
17078
17286
  `Expected an EVM-targeted swap (arkade_to_evm, bitcoin_to_evm or lightning_to_evm), got ${swap.direction}.`
17079
17287
  );
@@ -17261,7 +17469,7 @@ var Client = class _Client {
17261
17469
  }
17262
17470
  /** Whether an EVM claim can use the existing automatic sponsorship path. */
17263
17471
  canSponsorClaim(swap) {
17264
- 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;
17265
17473
  }
17266
17474
  /**
17267
17475
  * Claims through the existing server relay or configured Arbitrum UserOp.
@@ -17353,7 +17561,7 @@ var Client = class _Client {
17353
17561
  const targetTokenAddress = String(swap.target_token.token_id);
17354
17562
  const needsDexSwap = targetTokenAddress.toLowerCase() !== swap.wbtc_address.toLowerCase();
17355
17563
  let dexCalldata;
17356
- if (needsDexSwap && _optionalChain([responseData, 'optionalAccess', _194 => _194.dex_calldata])) {
17564
+ if (needsDexSwap && _optionalChain([responseData, 'optionalAccess', _212 => _212.dex_calldata])) {
17357
17565
  dexCalldata = {
17358
17566
  to: responseData.dex_calldata.to,
17359
17567
  data: responseData.dex_calldata.data,
@@ -17401,7 +17609,7 @@ var Client = class _Client {
17401
17609
  * ```
17402
17610
  */
17403
17611
  async claimArkade(id, options) {
17404
- if (!_optionalChain([options, 'optionalAccess', _195 => _195.destinationAddress])) {
17612
+ if (!_optionalChain([options, 'optionalAccess', _213 => _213.destinationAddress])) {
17405
17613
  return {
17406
17614
  success: false,
17407
17615
  message: 'Destination address is required for Arkade claims. Provide it via the options parameter: { destinationAddress: "ark1..." }'
@@ -17439,12 +17647,7 @@ var Client = class _Client {
17439
17647
  };
17440
17648
  }
17441
17649
  if (vtxoStatus === "spent") {
17442
- const continued = await this.continueArkadeClaimSwap(id);
17443
- if (continued.success) return continued;
17444
- return {
17445
- success: false,
17446
- message: "All VTXOs have already been spent."
17447
- };
17650
+ return this.#continueArkadeClaim(claimParams, options);
17448
17651
  }
17449
17652
  if (vtxoStatus === "spendable") {
17450
17653
  return this.#claimArkadeOffchain(claimParams, options);
@@ -17492,7 +17695,7 @@ var Client = class _Client {
17492
17695
  electrum,
17493
17696
  fundTxid
17494
17697
  );
17495
- if (_optionalChain([txData, 'optionalAccess', _196 => _196.vout, 'optionalAccess', _197 => _197[fundVout]])) {
17698
+ if (_optionalChain([txData, 'optionalAccess', _214 => _214.vout, 'optionalAccess', _215 => _215[fundVout]])) {
17496
17699
  return {
17497
17700
  txid: fundTxid,
17498
17701
  vout: fundVout,
@@ -17528,7 +17731,7 @@ var Client = class _Client {
17528
17731
  async #findOnchainHtlcOutputEsplora(esploraUrls, address2, fundTxid, fundVout) {
17529
17732
  if (fundTxid && fundVout !== void 0) {
17530
17733
  const txData = await fetchTransactionOutputs(esploraUrls, fundTxid);
17531
- if (_optionalChain([txData, 'optionalAccess', _198 => _198.vout, 'optionalAccess', _199 => _199[fundVout]])) {
17734
+ if (_optionalChain([txData, 'optionalAccess', _216 => _216.vout, 'optionalAccess', _217 => _217[fundVout]])) {
17532
17735
  return {
17533
17736
  txid: fundTxid,
17534
17737
  vout: fundVout,
@@ -17675,13 +17878,16 @@ var Client = class _Client {
17675
17878
  message: `Expected an Arkade-destination swap, got ${swap.direction}.`
17676
17879
  };
17677
17880
  }
17678
- const claimParams = this.#extractArkadeClaimParams(id, storedSwap);
17881
+ return this.#continueArkadeClaim(
17882
+ this.#extractArkadeClaimParams(id, storedSwap)
17883
+ );
17884
+ }
17885
+ async #continueArkadeClaim(claimParams, options) {
17679
17886
  try {
17680
17887
  const result = await continueArkadeClaim({
17681
17888
  ...claimParams,
17682
- destinationAddress: "",
17683
- // not needed for continue
17684
- arkadeServerUrl: this.#config.arkadeServerUrl,
17889
+ destinationAddress: _optionalChain([options, 'optionalAccess', _218 => _218.destinationAddress]),
17890
+ arkadeServerUrl: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _219 => _219.arkadeServerUrl]), () => ( this.#config.arkadeServerUrl)),
17685
17891
  logger: this.#config.logger,
17686
17892
  logLevel: this.#config.logLevel
17687
17893
  });
@@ -17799,7 +18005,7 @@ var Client = class _Client {
17799
18005
  */
17800
18006
  async #claimArkadeDelegate(swapId, params, options) {
17801
18007
  try {
17802
- const result = await _chunkM47Z35Z5cjs.delegateClaim.call(void 0, {
18008
+ const result = await _chunkQJ4EK6UGcjs.delegateClaim.call(void 0, {
17803
18009
  ...params,
17804
18010
  destinationAddress: options.destinationAddress,
17805
18011
  lendaswapApiUrl: this.#config.baseUrl,
@@ -17872,10 +18078,10 @@ var Client = class _Client {
17872
18078
  }
17873
18079
  if (direction === "evm_to_arkade" || direction === "evm_to_bitcoin" || direction === "evm_to_lightning") {
17874
18080
  const evmOptions = options;
17875
- if (_optionalChain([evmOptions, 'optionalAccess', _200 => _200.collaborative])) {
18081
+ if (_optionalChain([evmOptions, 'optionalAccess', _220 => _220.collaborative])) {
17876
18082
  return this.#collabRefundEvm(id);
17877
18083
  }
17878
- return this.#buildEvmSourceRefund(id, storedSwap, _optionalChain([evmOptions, 'optionalAccess', _201 => _201.signer]));
18084
+ return this.#buildEvmSourceRefund(id, storedSwap, _optionalChain([evmOptions, 'optionalAccess', _221 => _221.signer]));
17879
18085
  }
17880
18086
  return {
17881
18087
  success: false,
@@ -17969,7 +18175,7 @@ var Client = class _Client {
17969
18175
  }
17970
18176
  const btcFundTxid = swap.btc_fund_txid;
17971
18177
  const btcFundVout = swap.btc_fund_vout;
17972
- const waitForFundingMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _202 => _202.waitForFundingMs]), () => ( 3e4));
18178
+ const waitForFundingMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _222 => _222.waitForFundingMs]), () => ( 3e4));
17973
18179
  const htlcOutput = await this.#waitForOnchainHtlcOutput(
17974
18180
  esploraUrls,
17975
18181
  network,
@@ -17984,14 +18190,14 @@ var Client = class _Client {
17984
18190
  message: `Could not find UTXO at HTLC address ${btcHtlcAddress} after waiting ${waitForFundingMs}ms. The server may not have funded the HTLC yet.`
17985
18191
  };
17986
18192
  }
17987
- const destinationAddress = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _203 => _203.destinationAddress]), () => ( storedPayoutTarget(storedSwap)));
18193
+ const destinationAddress = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _223 => _223.destinationAddress]), () => ( storedPayoutTarget(storedSwap)));
17988
18194
  if (!destinationAddress) {
17989
18195
  return {
17990
18196
  success: false,
17991
18197
  message: 'Destination address is required to claim BTC. Provide it via options: { destinationAddress: "bc1p..." }'
17992
18198
  };
17993
18199
  }
17994
- const feeRateSatPerVb = await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async _204 => _204.feeRateSatPerVb]), async () => ( Math.max(2, await _asyncNullishCoalesce(await fetchFeeRateEstimate(esploraUrls, 2), async () => ( 0)))));
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)))));
17995
18201
  try {
17996
18202
  const result = buildOnchainClaimTransaction({
17997
18203
  fundingTxId: htlcOutput.txid,
@@ -18013,7 +18219,7 @@ var Client = class _Client {
18013
18219
  esploraUrls,
18014
18220
  network,
18015
18221
  result.txHex,
18016
- _nullishCoalesce(_optionalChain([options, 'optionalAccess', _205 => _205.broadcastRetries]), () => ( 5))
18222
+ _nullishCoalesce(_optionalChain([options, 'optionalAccess', _225 => _225.broadcastRetries]), () => ( 5))
18017
18223
  );
18018
18224
  return {
18019
18225
  success: true,
@@ -18043,7 +18249,7 @@ var Client = class _Client {
18043
18249
  * @internal
18044
18250
  */
18045
18251
  async #buildOnchainRefund(id, swap, options) {
18046
- if (!_optionalChain([options, 'optionalAccess', _206 => _206.destinationAddress])) {
18252
+ if (!_optionalChain([options, 'optionalAccess', _226 => _226.destinationAddress])) {
18047
18253
  return {
18048
18254
  success: false,
18049
18255
  message: 'Destination address is required for on-chain refunds. Provide it via the options parameter: { destinationAddress: "bc1q..." }'
@@ -18249,7 +18455,7 @@ network='${network}'`
18249
18455
  * @internal
18250
18456
  */
18251
18457
  async #buildArkadeRefund(id, swap, options) {
18252
- if (!_optionalChain([options, 'optionalAccess', _207 => _207.destinationAddress])) {
18458
+ if (!_optionalChain([options, 'optionalAccess', _227 => _227.destinationAddress])) {
18253
18459
  return {
18254
18460
  success: false,
18255
18461
  message: 'Destination address is required for Arkade refunds. Provide it via the options parameter: { destinationAddress: "ark1..." }'
@@ -18390,7 +18596,7 @@ network='${network}'`
18390
18596
  */
18391
18597
  async #refundArkadeDelegate(params, options) {
18392
18598
  try {
18393
- const result = await _chunkM47Z35Z5cjs.delegateRefund.call(void 0, {
18599
+ const result = await _chunkQJ4EK6UGcjs.delegateRefund.call(void 0, {
18394
18600
  ...params,
18395
18601
  lendaswapApiUrl: this.#config.baseUrl,
18396
18602
  arkadeServerUrl: _nullishCoalesce(options.arkadeServerUrl, () => ( this.#config.arkadeServerUrl)),
@@ -18485,7 +18691,7 @@ network='${network}'`
18485
18691
  const call = decodeRefundCall(server.data);
18486
18692
  const to = server.to.toLowerCase();
18487
18693
  const htlc = leg.htlcAddress.toLowerCase();
18488
- const coordinator = _optionalChain([leg, 'access', _208 => _208.coordinatorAddress, 'optionalAccess', _209 => _209.toLowerCase, 'call', _210 => _210()]);
18694
+ const coordinator = _optionalChain([leg, 'access', _228 => _228.coordinatorAddress, 'optionalAccess', _229 => _229.toLowerCase, 'call', _230 => _230()]);
18489
18695
  const signer = check.signer;
18490
18696
  let lockSender;
18491
18697
  let recipient;
@@ -18506,7 +18712,7 @@ network='${network}'`
18506
18712
  `The server's refund targets ${server.to}, not this swap's HTLC ${leg.htlcAddress}`
18507
18713
  );
18508
18714
  }
18509
- lockSender = _optionalChain([signer, 'optionalAccess', _211 => _211.address, 'access', _212 => _212.toLowerCase, 'call', _213 => _213()]);
18715
+ lockSender = _optionalChain([signer, 'optionalAccess', _231 => _231.address, 'access', _232 => _232.toLowerCase, 'call', _233 => _233()]);
18510
18716
  recipient = lockSender;
18511
18717
  break;
18512
18718
  case "refundTo":
@@ -18537,7 +18743,7 @@ network='${network}'`
18537
18743
  const read = async (tx, what) => {
18538
18744
  try {
18539
18745
  return decodeCallWord(await signer.call(tx), what);
18540
- } catch (e21) {
18746
+ } catch (e22) {
18541
18747
  return void 0;
18542
18748
  }
18543
18749
  };
@@ -18625,7 +18831,7 @@ network='${network}'`
18625
18831
  }
18626
18832
  #fundingExpectation(swapId, stored) {
18627
18833
  const hashLock = this.#clientHashLock(swapId, stored);
18628
- const terms = _optionalChain([stored, 'optionalAccess', _214 => _214.evmFundingTerms]);
18834
+ const terms = _optionalChain([stored, 'optionalAccess', _234 => _234.evmFundingTerms]);
18629
18835
  if (!terms) {
18630
18836
  throw new Error(
18631
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.`
@@ -18698,7 +18904,7 @@ network='${network}'`
18698
18904
  if (!this.#swapStorage) return;
18699
18905
  try {
18700
18906
  const stored = await this.#swapStorage.get(swapId);
18701
- if (_optionalChain([stored, 'optionalAccess', _215 => _215.evmFundTxid, 'optionalAccess', _216 => _216.toLowerCase, 'call', _217 => _217()]) !== txid.toLowerCase()) return;
18907
+ if (_optionalChain([stored, 'optionalAccess', _235 => _235.evmFundTxid, 'optionalAccess', _236 => _236.toLowerCase, 'call', _237 => _237()]) !== txid.toLowerCase()) return;
18702
18908
  await this.#swapStorage.store({
18703
18909
  ...stored,
18704
18910
  evmFundTxid: void 0,
@@ -18723,7 +18929,7 @@ network='${network}'`
18723
18929
  * `hint` is appended to the error when neither is.
18724
18930
  */
18725
18931
  #depositorOwnerSigner(swapResponse, walletSigner, hint) {
18726
- const depositor = _optionalChain([swapResponse, 'access', _218 => _218.client_evm_address, 'optionalAccess', _219 => _219.toLowerCase, 'call', _220 => _220()]);
18932
+ const depositor = _optionalChain([swapResponse, 'access', _238 => _238.client_evm_address, 'optionalAccess', _239 => _239.toLowerCase, 'call', _240 => _240()]);
18727
18933
  if (depositor === this.getEvmAddress().toLowerCase()) {
18728
18934
  return this.#keyOwnerSigner();
18729
18935
  }
@@ -18795,7 +19001,7 @@ network='${network}'`
18795
19001
  stored.secretKey ? deriveEvmAddress(stored.secretKey) : void 0
18796
19002
  ]);
18797
19003
  const expectedDepositors = uniqueAddresses([
18798
- _optionalChain([signer, 'optionalAccess', _221 => _221.address]),
19004
+ _optionalChain([signer, 'optionalAccess', _241 => _241.address]),
18799
19005
  ...sdkAddresses,
18800
19006
  stored.response.client_evm_address
18801
19007
  ]);
@@ -18821,7 +19027,7 @@ network='${network}'`
18821
19027
  expectedDepositors
18822
19028
  });
18823
19029
  const coordinatorProved = !leg.depositorIsSender && refund.sender !== signer.address.toLowerCase() && stored.evmCoordinatorAddress === void 0;
18824
- if (fundTxid.toLowerCase() !== _optionalChain([stored, 'access', _222 => _222.evmFundTxid, 'optionalAccess', _223 => _223.toLowerCase, 'call', _224 => _224()]) || coordinatorProved) {
19030
+ if (fundTxid.toLowerCase() !== _optionalChain([stored, 'access', _242 => _242.evmFundTxid, 'optionalAccess', _243 => _243.toLowerCase, 'call', _244 => _244()]) || coordinatorProved) {
18825
19031
  await this.#recordEvmFunding(id, {
18826
19032
  txid: fundTxid,
18827
19033
  coordinatorAddress: coordinatorProved ? refund.sender : void 0
@@ -18880,7 +19086,7 @@ network='${network}'`
18880
19086
  async #serverFundTxid(id) {
18881
19087
  const fresh = await this.getSwap(id);
18882
19088
  try {
18883
- await _optionalChain([this, 'access', _225 => _225.#swapStorage, 'optionalAccess', _226 => _226.update, 'call', _227 => _227(id, fresh)]);
19089
+ await _optionalChain([this, 'access', _245 => _245.#swapStorage, 'optionalAccess', _246 => _246.update, 'call', _247 => _247(id, fresh)]);
18884
19090
  } catch (error) {
18885
19091
  this.#logger.warn({
18886
19092
  event: "client.refundSwap.refreshNotStored",
@@ -18893,7 +19099,7 @@ network='${network}'`
18893
19099
  }
18894
19100
  async #refundFromFundingTx(signer, leg) {
18895
19101
  const self2 = signer.address.toLowerCase();
18896
- const coordinator = _optionalChain([leg, 'access', _228 => _228.coordinatorAddress, 'optionalAccess', _229 => _229.toLowerCase, 'call', _230 => _230()]);
19102
+ const coordinator = _optionalChain([leg, 'access', _248 => _248.coordinatorAddress, 'optionalAccess', _249 => _249.toLowerCase, 'call', _250 => _250()]);
18897
19103
  const senders = leg.depositorIsSender ? uniqueAddresses([self2, ...leg.expectedDepositors]) : coordinator === void 0 ? void 0 : [self2, coordinator];
18898
19104
  const { created, terms, hashLock } = await this.#lockFromFundingTx(signer, {
18899
19105
  ...leg,
@@ -18971,7 +19177,7 @@ network='${network}'`
18971
19177
  let known;
18972
19178
  try {
18973
19179
  known = await signer.getTransaction(leg.fundTxid);
18974
- } catch (e22) {
19180
+ } catch (e23) {
18975
19181
  known = null;
18976
19182
  }
18977
19183
  if (!known) {
@@ -19054,7 +19260,7 @@ network='${network}'`
19054
19260
  await signer.call(_chunkJZTF4JNHcjs.encodeHtlcSwapsCallData.call(void 0, htlcAddress2, key)),
19055
19261
  "swaps"
19056
19262
  );
19057
- } catch (e23) {
19263
+ } catch (e24) {
19058
19264
  return void 0;
19059
19265
  }
19060
19266
  }
@@ -19231,7 +19437,7 @@ network='${network}'`
19231
19437
  */
19232
19438
  async collabRefundEvmSwap(swapId) {
19233
19439
  const storedSwap = await this.getStoredSwap(swapId);
19234
- if (!_optionalChain([storedSwap, 'optionalAccess', _231 => _231.secretKey])) {
19440
+ if (!_optionalChain([storedSwap, 'optionalAccess', _251 => _251.secretKey])) {
19235
19441
  throw new Error(
19236
19442
  "No secret key found for this swap. Cannot sign collab refund."
19237
19443
  );
@@ -19373,7 +19579,7 @@ network='${network}'`
19373
19579
  entryPointVersion: entryPoint.version,
19374
19580
  userOperation: signed
19375
19581
  });
19376
- } catch (e24) {
19582
+ } catch (e25) {
19377
19583
  computed = void 0;
19378
19584
  }
19379
19585
  await hooks.onSigned(computed);
@@ -19390,11 +19596,11 @@ network='${network}'`
19390
19596
  } else {
19391
19597
  userOpHash = await client.sendUserOperation({ calls });
19392
19598
  }
19393
- await _optionalChain([hooks, 'access', _232 => _232.onSubmitted, 'optionalCall', _233 => _233(userOpHash)]);
19599
+ await _optionalChain([hooks, 'access', _252 => _252.onSubmitted, 'optionalCall', _253 => _253(userOpHash)]);
19394
19600
  const { receipt, success, reason } = await client.waitForUserOperationReceipt({
19395
19601
  hash: userOpHash
19396
19602
  });
19397
- await _optionalChain([hooks, 'access', _234 => _234.onIncluded, 'optionalCall', _235 => _235(receipt.transactionHash, userOpHash)]);
19603
+ await _optionalChain([hooks, 'access', _254 => _254.onIncluded, 'optionalCall', _255 => _255(receipt.transactionHash, userOpHash)]);
19398
19604
  if (!success) {
19399
19605
  throw new Error(
19400
19606
  `Sponsored UserOp ${userOpHash} reverted on-chain${reason ? `: ${reason}` : ""}`
@@ -19615,7 +19821,7 @@ network='${network}'`
19615
19821
  * no AA config, not included, or the bundler cannot be reached).
19616
19822
  */
19617
19823
  async #pendingRehashTx(rehash) {
19618
- const bundlerUrl = _optionalChain([this, 'access', _236 => _236.#config, 'access', _237 => _237.aa, 'optionalAccess', _238 => _238.bundlerUrl]);
19824
+ const bundlerUrl = _optionalChain([this, 'access', _256 => _256.#config, 'access', _257 => _257.aa, 'optionalAccess', _258 => _258.bundlerUrl]);
19619
19825
  if (!rehash.userOpHash || !bundlerUrl) return void 0;
19620
19826
  try {
19621
19827
  const response = await fetch(bundlerUrl, {
@@ -19629,8 +19835,8 @@ network='${network}'`
19629
19835
  })
19630
19836
  });
19631
19837
  const json = await response.json();
19632
- return _nullishCoalesce(_optionalChain([json, 'access', _239 => _239.result, 'optionalAccess', _240 => _240.receipt, 'optionalAccess', _241 => _241.transactionHash]), () => ( void 0));
19633
- } catch (e25) {
19838
+ return _nullishCoalesce(_optionalChain([json, 'access', _259 => _259.result, 'optionalAccess', _260 => _260.receipt, 'optionalAccess', _261 => _261.transactionHash]), () => ( void 0));
19839
+ } catch (e26) {
19634
19840
  return void 0;
19635
19841
  }
19636
19842
  }
@@ -19639,7 +19845,7 @@ network='${network}'`
19639
19845
  if (!this.#swapStorage) return;
19640
19846
  try {
19641
19847
  const stored = await this.#swapStorage.get(swapId);
19642
- const history = _optionalChain([stored, 'optionalAccess', _242 => _242.evmRehashes]);
19848
+ const history = _optionalChain([stored, 'optionalAccess', _262 => _262.evmRehashes]);
19643
19849
  if (!stored || !history) return;
19644
19850
  let index = -1;
19645
19851
  for (let i = history.length - 1; i >= 0; i--) {
@@ -19690,7 +19896,7 @@ network='${network}'`
19690
19896
  }
19691
19897
  const ownHash = this.#clientHashLock(swapId, stored);
19692
19898
  const leg = evmSourceLeg(stored);
19693
- const firstFrom = _optionalChain([leg, 'access', _243 => _243.rehashes, 'optionalAccess', _244 => _244[0], 'optionalAccess', _245 => _245.fromHashLock]);
19899
+ const firstFrom = _optionalChain([leg, 'access', _263 => _263.rehashes, 'optionalAccess', _264 => _264[0], 'optionalAccess', _265 => _265.fromHashLock]);
19694
19900
  if (firstFrom !== void 0 && `0x${_chunkJZTF4JNHcjs.normalizeBytes32.call(void 0, firstFrom)}` !== ownHash) {
19695
19901
  throw new Error(
19696
19902
  `The rehash history of swap ${swapId} starts from ${firstFrom}, not from the payment hash this client fixed (${ownHash})`
@@ -19749,7 +19955,7 @@ network='${network}'`
19749
19955
  * does not read the chain. Arbitrum only, like the paymaster.
19750
19956
  */
19751
19957
  async #aaChainReader(owner) {
19752
- const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access', _246 => _246.#config, 'access', _247 => _247.aa, 'optionalAccess', _248 => _248.rpcUrl]), () => ( _optionalChain([this, 'access', _249 => _249.#config, 'access', _250 => _250.aa, 'optionalAccess', _251 => _251.bundlerUrl])));
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])));
19753
19959
  if (!rpcUrl) {
19754
19960
  throw new Error(
19755
19961
  "A sponsored rehash reads the lock over the AA RPC; call `.withAa({ bundlerUrl, paymasterPolicyId })` on the ClientBuilder before `.build()`."
@@ -19800,7 +20006,7 @@ network='${network}'`
19800
20006
  */
19801
20007
  async retrySwapWithInvoice(swapId, invoice) {
19802
20008
  const storedSwap = await this.getStoredSwap(swapId);
19803
- if (!_optionalChain([storedSwap, 'optionalAccess', _252 => _252.secretKey])) {
20009
+ if (!_optionalChain([storedSwap, 'optionalAccess', _272 => _272.secretKey])) {
19804
20010
  throw new Error(
19805
20011
  "No secret key found for this swap. Cannot authorize the rehash."
19806
20012
  );
@@ -19952,23 +20158,23 @@ network='${network}'`
19952
20158
  updatedAt: Date.now(),
19953
20159
  // The payout this client asked for; claims pay here, never to a
19954
20160
  // server answer. Recovery rebuilding the swap keeps it.
19955
- targetAddress: _nullishCoalesce(targetAddress, () => ( _optionalChain([existing, 'optionalAccess', _253 => _253.targetAddress]))),
19956
- bridgeRecipient: _optionalChain([bridge, 'optionalAccess', _254 => _254.recipient]),
19957
- bridgeRecipientWallet: _optionalChain([bridge, 'optionalAccess', _255 => _255.recipientWallet]),
19958
- evmFundTxid: _optionalChain([existing, 'optionalAccess', _256 => _256.evmFundTxid]),
19959
- evmFundingUserOpHash: _optionalChain([existing, 'optionalAccess', _257 => _257.evmFundingUserOpHash]),
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]),
19960
20166
  // Fixed at creation and never taken from a server answer: recovery
19961
20167
  // rebuilding the swap keeps it, and a fresh device has none.
19962
- lightningPaymentHash: _nullishCoalesce(_optionalChain([commitments, 'optionalAccess', _258 => _258.lightningPaymentHash]), () => ( _optionalChain([existing, 'optionalAccess', _259 => _259.lightningPaymentHash]))),
19963
- evmFundingTerms: _nullishCoalesce(_optionalChain([commitments, 'optionalAccess', _260 => _260.evmFundingTerms]), () => ( _optionalChain([existing, 'optionalAccess', _261 => _261.evmFundingTerms]))),
19964
- evmCoordinatorAddress: _optionalChain([existing, 'optionalAccess', _262 => _262.evmCoordinatorAddress]),
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]),
19965
20171
  // The rehashes this client sent are what let a refund find the lock
19966
20172
  // that exists; the server's copy names only the current hash.
19967
- evmRehashes: _optionalChain([existing, 'optionalAccess', _263 => _263.evmRehashes]),
20173
+ evmRehashes: _optionalChain([existing, 'optionalAccess', _283 => _283.evmRehashes]),
19968
20174
  // A CCTP-inbound burn is the only way to resume or recover once the
19969
20175
  // USDC has left the source chain.
19970
- cctpBurnTxid: _optionalChain([existing, 'optionalAccess', _264 => _264.cctpBurnTxid]),
19971
- cctpBurnLastValidBlockHeight: _optionalChain([existing, 'optionalAccess', _265 => _265.cctpBurnLastValidBlockHeight])
20176
+ cctpBurnTxid: _optionalChain([existing, 'optionalAccess', _284 => _284.cctpBurnTxid]),
20177
+ cctpBurnLastValidBlockHeight: _optionalChain([existing, 'optionalAccess', _285 => _285.cctpBurnLastValidBlockHeight])
19972
20178
  };
19973
20179
  await this.#swapStorage.store(storedSwap);
19974
20180
  }
@@ -20010,7 +20216,7 @@ network='${network}'`
20010
20216
  const targetAsset = "token_id" in tgt ? { chain: tgt.chain, token_id: tgt.token_id } : { chain: tgt.chain, token_id: tgt.tokenId };
20011
20217
  if (isTronToken(sourceAsset.chain))
20012
20218
  throw new Error("Tron is a payout-only destination");
20013
- const isTronTarget = isTronToken(targetAsset.chain) || _optionalChain([options, 'access', _266 => _266.bridgeParams, 'optionalAccess', _267 => _267.targetChain]) === "Tron";
20219
+ const isTronTarget = isTronToken(targetAsset.chain) || _optionalChain([options, 'access', _286 => _286.bridgeParams, 'optionalAccess', _287 => _287.targetChain]) === "Tron";
20014
20220
  if (isTronTarget) {
20015
20221
  if (isTronToken(targetAsset.chain) && targetAsset.token_id !== USDT0_ADDRESSES.Tron) {
20016
20222
  throw new Error("Tron payouts require native USDT");
@@ -20050,7 +20256,7 @@ network='${network}'`
20050
20256
  if (isTronTarget && bridgeParams) {
20051
20257
  bridgeParams = { ...bridgeParams, recipient: options.targetAddress };
20052
20258
  }
20053
- const cctpPayout = !options.bridgeParams && bridgeParams != null && _optionalChain([bridgeParams, 'access', _268 => _268.targetTokenAddress, 'optionalAccess', _269 => _269.toLowerCase, 'call', _270 => _270()]) === _optionalChain([_chunkTKFOVRJRcjs.USDC_ADDRESSES, 'access', _271 => _271[bridgeParams.targetChain], 'optionalAccess', _272 => _272.toLowerCase, 'call', _273 => _273()]);
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()]);
20054
20260
  if (cctpPayout && options.sourceAmount != null) {
20055
20261
  const quote = await this.getQuote({
20056
20262
  sourceChain: sourceAsset.chain,
@@ -20060,11 +20266,12 @@ network='${network}'`
20060
20266
  sourceAmount: options.sourceAmount,
20061
20267
  referralCode: options.referralCode,
20062
20268
  extraFees: options.extraFees,
20269
+ promoCode: options.promoCode,
20063
20270
  bridgeRecipientSetup: options.bridgeRecipientSetup
20064
20271
  });
20065
20272
  if (BigInt(quote.net_target_amount) <= 0n) {
20066
20273
  throw new Error(
20067
- `Amount too small to bridge to ${_optionalChain([bridgeParams, 'optionalAccess', _274 => _274.targetChain])}: the CCTP fee (${_nullishCoalesce(quote.bridge_fee, () => ( "unknown"))} USDC units) leaves nothing to deliver. Increase the amount.`
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.`
20068
20275
  );
20069
20276
  }
20070
20277
  }
@@ -20111,6 +20318,7 @@ network='${network}'`
20111
20318
  targetAmount: options.targetAmount ? BigInt(options.targetAmount) : void 0,
20112
20319
  referralCode: options.referralCode,
20113
20320
  extraFees: options.extraFees,
20321
+ promoCode: options.promoCode,
20114
20322
  bridgeParams
20115
20323
  });
20116
20324
  }
@@ -20136,7 +20344,8 @@ network='${network}'`
20136
20344
  ...options.sourceAmount != null ? { sourceAmountSats: Number(options.sourceAmount) } : { targetAmountSats: Number(options.targetAmount) },
20137
20345
  targetAddress: options.targetAddress,
20138
20346
  referralCode: options.referralCode,
20139
- extraFees: options.extraFees
20347
+ extraFees: options.extraFees,
20348
+ promoCode: options.promoCode
20140
20349
  });
20141
20350
  }
20142
20351
  if (isLightning(sourceAsset) && isBtcOnchain(targetAsset)) {
@@ -20149,7 +20358,8 @@ network='${network}'`
20149
20358
  ...options.sourceAmount != null ? { sourceAmountSats: Number(options.sourceAmount) } : { targetAmountSats: Number(options.targetAmount) },
20150
20359
  targetAddress: options.targetAddress,
20151
20360
  referralCode: options.referralCode,
20152
- extraFees: options.extraFees
20361
+ extraFees: options.extraFees,
20362
+ promoCode: options.promoCode
20153
20363
  });
20154
20364
  }
20155
20365
  if (isLightning(sourceAsset) && isEvmToken(targetChain)) {
@@ -20166,6 +20376,25 @@ network='${network}'`
20166
20376
  targetAmount: options.targetAmount == null ? void 0 : BigInt(options.targetAmount),
20167
20377
  referralCode: options.referralCode,
20168
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,
20169
20398
  bridgeParams
20170
20399
  });
20171
20400
  }
@@ -20178,6 +20407,7 @@ network='${network}'`
20178
20407
  targetAmount: options.targetAmount == null ? void 0 : BigInt(options.targetAmount),
20179
20408
  referralCode: options.referralCode,
20180
20409
  extraFees: options.extraFees,
20410
+ promoCode: options.promoCode,
20181
20411
  bridgeParams
20182
20412
  });
20183
20413
  }
@@ -20191,7 +20421,8 @@ network='${network}'`
20191
20421
  satsReceive: Number(options.targetAmount),
20192
20422
  targetAddress: options.targetAddress,
20193
20423
  referralCode: options.referralCode,
20194
- extraFees: options.extraFees
20424
+ extraFees: options.extraFees,
20425
+ promoCode: options.promoCode
20195
20426
  });
20196
20427
  }
20197
20428
  if (isEvmSwapSource(sourceChain, sourceTokenId) && isLightning(targetAsset)) {
@@ -20208,6 +20439,7 @@ network='${network}'`
20208
20439
  userAddress: options.userAddress,
20209
20440
  referralCode: options.referralCode,
20210
20441
  extraFees: options.extraFees,
20442
+ promoCode: options.promoCode,
20211
20443
  gasless: options.gasless,
20212
20444
  inboundBridgeParams
20213
20445
  };
@@ -20257,6 +20489,7 @@ network='${network}'`
20257
20489
  targetAmount: options.targetAmount == null ? void 0 : Number(options.targetAmount),
20258
20490
  referralCode: options.referralCode,
20259
20491
  extraFees: options.extraFees,
20492
+ promoCode: options.promoCode,
20260
20493
  gasless: options.gasless,
20261
20494
  inboundBridgeParams
20262
20495
  });
@@ -20276,6 +20509,7 @@ network='${network}'`
20276
20509
  targetAmount: options.targetAmount == null ? void 0 : Number(options.targetAmount),
20277
20510
  referralCode: options.referralCode,
20278
20511
  extraFees: options.extraFees,
20512
+ promoCode: options.promoCode,
20279
20513
  gasless: options.gasless,
20280
20514
  inboundBridgeParams
20281
20515
  });
@@ -20463,6 +20697,13 @@ network='${network}'`
20463
20697
  await this.#rifClaimAddress(options)
20464
20698
  );
20465
20699
  }
20700
+ async createSparkToEvmSwap(options) {
20701
+ return createSparkToEvmSwap(
20702
+ options,
20703
+ this.#getCreateContext(),
20704
+ await this.#rifClaimAddress(options)
20705
+ );
20706
+ }
20466
20707
  // =========================================================================
20467
20708
  // Swap Creation - Arkade to Lightning
20468
20709
  // =========================================================================
@@ -20688,7 +20929,7 @@ network='${network}'`
20688
20929
  swapId,
20689
20930
  serverData,
20690
20931
  chainId,
20691
- _optionalChain([options, 'optionalAccess', _275 => _275.funding])
20932
+ _optionalChain([options, 'optionalAccess', _295 => _295.funding])
20692
20933
  );
20693
20934
  const nonceBytes = new Uint8Array(32);
20694
20935
  crypto.getRandomValues(nonceBytes);
@@ -20830,7 +21071,7 @@ network='${network}'`
20830
21071
  swapId,
20831
21072
  serverData,
20832
21073
  chainId,
20833
- _optionalChain([options, 'optionalAccess', _276 => _276.funding])
21074
+ _optionalChain([options, 'optionalAccess', _296 => _296.funding])
20834
21075
  );
20835
21076
  const nonceBytes = new Uint8Array(32);
20836
21077
  crypto.getRandomValues(nonceBytes);
@@ -20919,14 +21160,14 @@ network='${network}'`
20919
21160
  */
20920
21161
  async fundSwap(swapId, signer, options) {
20921
21162
  {
20922
- const stored = await _optionalChain([this, 'access', _277 => _277.#swapStorage, 'optionalAccess', _278 => _278.get, 'call', _279 => _279(swapId)]);
20923
- const response = await _asyncNullishCoalesce(await _asyncOptionalChain([stored, 'optionalAccess', async _280 => _280.response]), async () => ( await this.getSwap(swapId, { updateStorage: true })));
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 })));
20924
21165
  if ((response.direction === "evm_to_lightning" || response.direction === "evm_to_arkade" || response.direction === "evm_to_bitcoin") && response.evm_htlc_kind === "native") {
20925
21166
  const txHash2 = await this.#fundNativeLock(
20926
21167
  swapId,
20927
21168
  response,
20928
21169
  signer,
20929
- _optionalChain([options, 'optionalAccess', _281 => _281.onQuote])
21170
+ _optionalChain([options, 'optionalAccess', _301 => _301.onQuote])
20930
21171
  );
20931
21172
  return { txHash: txHash2 };
20932
21173
  }
@@ -20937,12 +21178,12 @@ network='${network}'`
20937
21178
  }
20938
21179
  }
20939
21180
  if (isCctpOnlySource(signer.chainId)) {
20940
- const stored = await _optionalChain([this, 'access', _282 => _282.#swapStorage, 'optionalAccess', _283 => _283.get, 'call', _284 => _284(swapId)]);
20941
- const swapResponse = await _asyncNullishCoalesce(await _asyncOptionalChain([stored, 'optionalAccess', async _285 => _285.response]), async () => ( await this.getSwap(swapId, { updateStorage: true })));
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 })));
20942
21183
  const source = cctpMetaForChainId(signer.chainId);
20943
21184
  const expected = {
20944
21185
  ...this.#fundingExpectation(swapId, stored),
20945
- pins: _optionalChain([options, 'optionalAccess', _286 => _286.funding])
21186
+ pins: _optionalChain([options, 'optionalAccess', _306 => _306.funding])
20946
21187
  };
20947
21188
  await this.#ensureClientHashLock(
20948
21189
  swapId,
@@ -20974,7 +21215,7 @@ network='${network}'`
20974
21215
  }
20975
21216
  const amount = BigInt(rawAmount);
20976
21217
  const destination = cctpMetaForChainId(42161);
20977
- const recordedBurn = _optionalChain([stored, 'optionalAccess', _287 => _287.cctpBurnTxid]);
21218
+ const recordedBurn = _optionalChain([stored, 'optionalAccess', _307 => _307.cctpBurnTxid]);
20978
21219
  if (recordedBurn) {
20979
21220
  const fresh = await this.getSwap(swapId, { updateStorage: true });
20980
21221
  if (fresh.status !== "pending") {
@@ -20983,7 +21224,7 @@ network='${network}'`
20983
21224
  );
20984
21225
  }
20985
21226
  }
20986
- const maxFee = recordedBurn ? 0n : await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async _288 => _288.maxFee]), async () => ( computeCctpFastFee(
21227
+ const maxFee = recordedBurn ? 0n : await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async _308 => _308.maxFee]), async () => ( computeCctpFastFee(
20987
21228
  await getCachedCctpFee({
20988
21229
  sourceDomain: source.domain,
20989
21230
  destinationDomain: destination.domain
@@ -21003,8 +21244,8 @@ network='${network}'`
21003
21244
  onBurn: (burnTxHash) => this.#recordCctpBurn(swapId, burnTxHash),
21004
21245
  amount,
21005
21246
  maxFee,
21006
- onProgress: _optionalChain([options, 'optionalAccess', _289 => _289.onProgress]),
21007
- signal: _optionalChain([options, 'optionalAccess', _290 => _290.signal])
21247
+ onProgress: _optionalChain([options, 'optionalAccess', _309 => _309.onProgress]),
21248
+ signal: _optionalChain([options, 'optionalAccess', _310 => _310.signal])
21008
21249
  });
21009
21250
  if (cctp.transactionHash) {
21010
21251
  await this.#recordEvmFunding(swapId, { txid: cctp.transactionHash });
@@ -21015,9 +21256,9 @@ network='${network}'`
21015
21256
  swapId,
21016
21257
  signer.chainId,
21017
21258
  signer.address,
21018
- { funding: _optionalChain([options, 'optionalAccess', _291 => _291.funding]) }
21259
+ { funding: _optionalChain([options, 'optionalAccess', _311 => _311.funding]) }
21019
21260
  );
21020
- _optionalChain([options, 'optionalAccess', _292 => _292.onQuote, 'optionalCall', _293 => _293({
21261
+ _optionalChain([options, 'optionalAccess', _312 => _312.onQuote, 'optionalCall', _313 => _313({
21021
21262
  sourceAmount: funding.sourceAmount,
21022
21263
  sourceTokenAddress: funding.sourceTokenAddress
21023
21264
  })]);
@@ -21065,10 +21306,10 @@ network='${network}'`
21065
21306
  swapId,
21066
21307
  signer.chainId,
21067
21308
  signer.address,
21068
- { funding: _optionalChain([options, 'optionalAccess', _294 => _294.funding]) }
21309
+ { funding: _optionalChain([options, 'optionalAccess', _314 => _314.funding]) }
21069
21310
  );
21070
21311
  if (freshFunding.sourceAmount !== funding.sourceAmount) {
21071
- _optionalChain([options, 'optionalAccess', _295 => _295.onQuote, 'optionalCall', _296 => _296({
21312
+ _optionalChain([options, 'optionalAccess', _315 => _315.onQuote, 'optionalCall', _316 => _316({
21072
21313
  sourceAmount: freshFunding.sourceAmount,
21073
21314
  sourceTokenAddress: freshFunding.sourceTokenAddress
21074
21315
  })]);
@@ -21078,7 +21319,7 @@ network='${network}'`
21078
21319
  if (/^0x[0-9a-fA-F]{128}0[01]$/.test(signature) && signer.getCode) {
21079
21320
  try {
21080
21321
  depositorCode = await signer.getCode(signer.address);
21081
- } catch (e26) {
21322
+ } catch (e27) {
21082
21323
  }
21083
21324
  }
21084
21325
  const encoded = _chunkJZTF4JNHcjs.encodeExecuteAndCreateWithPermit2.call(void 0,
@@ -21144,17 +21385,17 @@ network='${network}'`
21144
21385
  * @returns The Arbitrum settlement tx hash (or UserOp hash) and the burn
21145
21386
  */
21146
21387
  async fundSwapFromSolana(swapId, signer, options) {
21147
- const rpcUrl = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _297 => _297.rpcUrl]), () => ( this.#config.solanaRpcUrl));
21388
+ const rpcUrl = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _317 => _317.rpcUrl]), () => ( this.#config.solanaRpcUrl));
21148
21389
  if (!rpcUrl) {
21149
21390
  throw new Error(
21150
21391
  "Funding from Solana needs a Solana RPC URL. Pass `rpcUrl` or call `.withSolanaRpcUrl(url)` on the ClientBuilder."
21151
21392
  );
21152
21393
  }
21153
- const stored = await _optionalChain([this, 'access', _298 => _298.#swapStorage, 'optionalAccess', _299 => _299.get, 'call', _300 => _300(swapId)]);
21154
- const swapResponse = await _asyncNullishCoalesce(await _asyncOptionalChain([stored, 'optionalAccess', async _301 => _301.response]), async () => ( await this.getSwap(swapId, { updateStorage: true })));
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 })));
21155
21396
  const expected = {
21156
21397
  ...this.#fundingExpectation(swapId, stored),
21157
- pins: _optionalChain([options, 'optionalAccess', _302 => _302.funding])
21398
+ pins: _optionalChain([options, 'optionalAccess', _322 => _322.funding])
21158
21399
  };
21159
21400
  await this.#ensureClientHashLock(
21160
21401
  swapId,
@@ -21178,7 +21419,7 @@ network='${network}'`
21178
21419
  );
21179
21420
  }
21180
21421
  const amount = BigInt(bridge.source_amount);
21181
- const recordedBurn = _optionalChain([stored, 'optionalAccess', _303 => _303.cctpBurnTxid]);
21422
+ const recordedBurn = _optionalChain([stored, 'optionalAccess', _323 => _323.cctpBurnTxid]);
21182
21423
  if (recordedBurn) {
21183
21424
  const fresh = await this.getSwap(swapId, { updateStorage: true });
21184
21425
  if (fresh.status !== "pending") {
@@ -21187,7 +21428,7 @@ network='${network}'`
21187
21428
  );
21188
21429
  }
21189
21430
  }
21190
- const maxFee = recordedBurn ? 0n : await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async _304 => _304.maxFee]), async () => ( computeCctpFastFee(
21431
+ const maxFee = recordedBurn ? 0n : await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async _324 => _324.maxFee]), async () => ( computeCctpFastFee(
21191
21432
  await getCachedCctpFee({
21192
21433
  sourceDomain: _chunkTKFOVRJRcjs.CCTP_DOMAINS.Solana,
21193
21434
  destinationDomain: _chunkTKFOVRJRcjs.CCTP_DOMAINS.Arbitrum
@@ -21209,13 +21450,13 @@ network='${network}'`
21209
21450
  ),
21210
21451
  rpcUrl,
21211
21452
  burnSignature: recordedBurn,
21212
- burnLastValidBlockHeight: _optionalChain([stored, 'optionalAccess', _305 => _305.cctpBurnLastValidBlockHeight]),
21453
+ burnLastValidBlockHeight: _optionalChain([stored, 'optionalAccess', _325 => _325.cctpBurnLastValidBlockHeight]),
21213
21454
  onBurn: (burnSignature, lastValidBlockHeight) => this.#recordCctpBurn(swapId, burnSignature, lastValidBlockHeight),
21214
21455
  amount,
21215
21456
  maxFee,
21216
- priorityFeeMicroLamports: _optionalChain([options, 'optionalAccess', _306 => _306.priorityFeeMicroLamports]),
21217
- onProgress: _optionalChain([options, 'optionalAccess', _307 => _307.onProgress]),
21218
- signal: _optionalChain([options, 'optionalAccess', _308 => _308.signal])
21457
+ priorityFeeMicroLamports: _optionalChain([options, 'optionalAccess', _326 => _326.priorityFeeMicroLamports]),
21458
+ onProgress: _optionalChain([options, 'optionalAccess', _327 => _327.onProgress]),
21459
+ signal: _optionalChain([options, 'optionalAccess', _328 => _328.signal])
21219
21460
  }
21220
21461
  );
21221
21462
  if (cctp.transactionHash) {
@@ -21233,7 +21474,7 @@ network='${network}'`
21233
21474
  * `withSolanaRpcUrl` on the builder
21234
21475
  */
21235
21476
  async getSolanaUsdcBalance(owner, options) {
21236
- const rpcUrl = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _309 => _309.rpcUrl]), () => ( this.#config.solanaRpcUrl));
21477
+ const rpcUrl = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _329 => _329.rpcUrl]), () => ( this.#config.solanaRpcUrl));
21237
21478
  if (!rpcUrl) {
21238
21479
  throw new Error(
21239
21480
  "Reading a Solana balance needs a Solana RPC URL. Pass `rpcUrl` or call `.withSolanaRpcUrl(url)` on the ClientBuilder."
@@ -21269,7 +21510,7 @@ network='${network}'`
21269
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`
21270
21511
  );
21271
21512
  }
21272
- _optionalChain([onQuote, 'optionalCall', _310 => _310({
21513
+ _optionalChain([onQuote, 'optionalCall', _330 => _330({
21273
21514
  sourceAmount: amount,
21274
21515
  sourceTokenAddress: _chunkJZTF4JNHcjs.NATIVE_TOKEN_ADDRESS
21275
21516
  })]);
@@ -21278,7 +21519,7 @@ network='${network}'`
21278
21519
  "This legacy Rootstock swap requires coordinator funding. Create a new swap with the updated backend before funding."
21279
21520
  );
21280
21521
  }
21281
- if (signer.address.toLowerCase() !== _optionalChain([swap, 'access', _311 => _311.client_evm_address, 'optionalAccess', _312 => _312.toLowerCase, 'call', _313 => _313()])) {
21522
+ if (signer.address.toLowerCase() !== _optionalChain([swap, 'access', _331 => _331.client_evm_address, 'optionalAccess', _332 => _332.toLowerCase, 'call', _333 => _333()])) {
21282
21523
  throw new Error(
21283
21524
  "Connect the source wallet recorded on this swap to fund RBTC."
21284
21525
  );
@@ -21309,7 +21550,7 @@ network='${network}'`
21309
21550
  swapId,
21310
21551
  signer,
21311
21552
  [
21312
- await _asyncOptionalChain([(await this.getStoredSwap(swapId)), 'optionalAccess', async _314 => _314.evmFundTxid]),
21553
+ await _asyncOptionalChain([(await this.getStoredSwap(swapId)), 'optionalAccess', async _334 => _334.evmFundTxid]),
21313
21554
  swap.evm_fund_txid
21314
21555
  ],
21315
21556
  hashLock
@@ -21343,7 +21584,7 @@ network='${network}'`
21343
21584
  let known;
21344
21585
  try {
21345
21586
  known = await signer.getTransaction(txid);
21346
- } catch (e27) {
21587
+ } catch (e28) {
21347
21588
  known = null;
21348
21589
  }
21349
21590
  if (!known) refuse("the node does not know and may still land");
@@ -21354,7 +21595,7 @@ network='${network}'`
21354
21595
  FUNDING_RECEIPT_WAIT_MS,
21355
21596
  `not mined within ${FUNDING_RECEIPT_WAIT_MS / 1e3}s`
21356
21597
  );
21357
- } catch (e28) {
21598
+ } catch (e29) {
21358
21599
  return refuse("is not mined yet");
21359
21600
  }
21360
21601
  if (receipt.status !== "success") continue;
@@ -21378,7 +21619,7 @@ network='${network}'`
21378
21619
  });
21379
21620
  const receipt = await signer.waitForReceipt(txHash);
21380
21621
  if (receipt.status !== "success") {
21381
- if (_optionalChain([options, 'optionalAccess', _315 => _315.forgetFailed])) await this.#forgetEvmFunding(swapId, txHash);
21622
+ if (_optionalChain([options, 'optionalAccess', _335 => _335.forgetFailed])) await this.#forgetEvmFunding(swapId, txHash);
21382
21623
  const reason = await _chunkTNZW35XAcjs.getRevertReason.call(void 0, signer, txHash, receipt.blockNumber);
21383
21624
  throw new Error(`Funding transaction failed: ${reason}`);
21384
21625
  }
@@ -21402,7 +21643,7 @@ network='${network}'`
21402
21643
  }).length > 0;
21403
21644
  }
21404
21645
  if (!created && replaced) {
21405
- if (_optionalChain([options, 'optionalAccess', _316 => _316.forgetFailed]) && provesNoLockUnder(receipt, expected.preimageHash)) {
21646
+ if (_optionalChain([options, 'optionalAccess', _336 => _336.forgetFailed]) && provesNoLockUnder(receipt, expected.preimageHash)) {
21406
21647
  await this.#forgetEvmFunding(swapId, txHash);
21407
21648
  }
21408
21649
  throw new Error(
@@ -21592,7 +21833,7 @@ network='${network}'`
21592
21833
  }
21593
21834
  async #actualRefundTransfer(oldSwap, smartAccountAddress) {
21594
21835
  const txHash = oldSwap.evm_claim_txid;
21595
- const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access', _317 => _317.#config, 'access', _318 => _318.aa, 'optionalAccess', _319 => _319.rpcUrl]), () => ( _optionalChain([this, 'access', _320 => _320.#config, 'access', _321 => _321.aa, 'optionalAccess', _322 => _322.bundlerUrl])));
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])));
21596
21837
  if (!txHash || !rpcUrl) return null;
21597
21838
  const { createPublicClient: createPublicClient2, http: http2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./_esm-4ZKYBBIE-D33574DC.cjs")));
21598
21839
  const { arbitrum: arbitrum2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./chains-D6LHJZMI-AAYKXZGC.cjs")));
@@ -21605,13 +21846,13 @@ network='${network}'`
21605
21846
  receipt = await publicClient.getTransactionReceipt({
21606
21847
  hash: txHash
21607
21848
  });
21608
- } catch (e29) {
21849
+ } catch (e30) {
21609
21850
  return null;
21610
21851
  }
21611
21852
  const transferTopic = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
21612
21853
  const paddedRecipient = smartAccountAddress.replace(/^0x/i, "").toLowerCase().padStart(64, "0");
21613
21854
  const transfers = receipt.logs.filter(
21614
- (log) => _optionalChain([log, 'access', _323 => _323.topics, 'access', _324 => _324[0], 'optionalAccess', _325 => _325.toLowerCase, 'call', _326 => _326()]) === transferTopic && _optionalChain([log, 'access', _327 => _327.topics, 'access', _328 => _328[2], 'optionalAccess', _329 => _329.replace, 'call', _330 => _330(/^0x/i, ""), 'access', _331 => _331.toLowerCase, 'call', _332 => _332()]) === paddedRecipient
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
21615
21856
  ).map((log) => ({
21616
21857
  tokenAddress: log.address,
21617
21858
  amount: BigInt(log.data).toString()
@@ -21698,8 +21939,8 @@ network='${network}'`
21698
21939
  {
21699
21940
  chain: refundChain,
21700
21941
  address: actualRefund.tokenAddress,
21701
- symbol: _nullishCoalesce(_optionalChain([actualMeta, 'optionalAccess', _333 => _333.symbol]), () => ( "ERC-20")),
21702
- decimals: _nullishCoalesce(_optionalChain([actualMeta, 'optionalAccess', _334 => _334.decimals]), () => ( 18)),
21942
+ symbol: _nullishCoalesce(_optionalChain([actualMeta, 'optionalAccess', _353 => _353.symbol]), () => ( "ERC-20")),
21943
+ decimals: _nullishCoalesce(_optionalChain([actualMeta, 'optionalAccess', _354 => _354.decimals]), () => ( 18)),
21703
21944
  amount: actualRefund.amount
21704
21945
  }
21705
21946
  ] : [],
@@ -21867,9 +22108,9 @@ network='${network}'`
21867
22108
  }
21868
22109
  const { client_evm_address: depositor, gasless } = stored.response;
21869
22110
  let owner;
21870
- if (_optionalChain([depositor, 'optionalAccess', _335 => _335.toLowerCase, 'call', _336 => _336()]) === this.getEvmAddress().toLowerCase()) {
22111
+ if (_optionalChain([depositor, 'optionalAccess', _355 => _355.toLowerCase, 'call', _356 => _356()]) === this.getEvmAddress().toLowerCase()) {
21871
22112
  owner = this.#keyOwnerSigner();
21872
- } else if (gasless && _optionalChain([depositor, 'optionalAccess', _337 => _337.toLowerCase, 'call', _338 => _338()]) === deriveEvmAddress(stored.secretKey).toLowerCase()) {
22113
+ } else if (gasless && _optionalChain([depositor, 'optionalAccess', _357 => _357.toLowerCase, 'call', _358 => _358()]) === deriveEvmAddress(stored.secretKey).toLowerCase()) {
21873
22114
  owner = keyToKernelOwnerSigner(
21874
22115
  _chunk5JR6AJ3Ycjs.hexToBytes.call(void 0, stored.secretKey.replace(/^0x/, "")),
21875
22116
  42161
@@ -21908,7 +22149,7 @@ network='${network}'`
21908
22149
  * with its key (whose signer does not read the chain).
21909
22150
  */
21910
22151
  async #aaRpcCall() {
21911
- const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access', _339 => _339.#config, 'access', _340 => _340.aa, 'optionalAccess', _341 => _341.rpcUrl]), () => ( _optionalChain([this, 'access', _342 => _342.#config, 'access', _343 => _343.aa, 'optionalAccess', _344 => _344.bundlerUrl])));
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])));
21912
22153
  if (!rpcUrl) {
21913
22154
  throw new Error(
21914
22155
  "Reading a refunded balance without a signer requires AA config (`.withAa(...)`)."
@@ -21949,7 +22190,7 @@ network='${network}'`
21949
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()\`.`
21950
22191
  );
21951
22192
  }
21952
- if (!_optionalChain([this, 'access', _345 => _345.#config, 'access', _346 => _346.aa, 'access', _347 => _347.paymasterPolicyId, 'optionalAccess', _348 => _348.trim, 'call', _349 => _349()])) {
22193
+ if (!_optionalChain([this, 'access', _365 => _365.#config, 'access', _366 => _366.aa, 'access', _367 => _367.paymasterPolicyId, 'optionalAccess', _368 => _368.trim, 'call', _369 => _369()])) {
21953
22194
  if (this.#config.aa.allowSelfPaidFunding) return { mode: "self-paid" };
21954
22195
  throw new Error(
21955
22196
  "Sponsored funding requires a paymasterPolicyId. Self-paid local tests must explicitly set allowSelfPaidFunding and prefund the account with ETH."
@@ -22029,7 +22270,7 @@ network='${network}'`
22029
22270
  swapId,
22030
22271
  serverData,
22031
22272
  chainId,
22032
- _optionalChain([options, 'optionalAccess', _350 => _350.funding])
22273
+ _optionalChain([options, 'optionalAccess', _370 => _370.funding])
22033
22274
  );
22034
22275
  const nonceBytes = new Uint8Array(32);
22035
22276
  crypto.getRandomValues(nonceBytes);
@@ -22074,7 +22315,7 @@ network='${network}'`
22074
22315
  delegated
22075
22316
  );
22076
22317
  let eip2612Permit;
22077
- if (_optionalChain([serverData, 'access', _351 => _351.eip2612, 'optionalAccess', _352 => _352.supported]) && !serverData.eip2612.already_approved) {
22318
+ if (_optionalChain([serverData, 'access', _371 => _371.eip2612, 'optionalAccess', _372 => _372.supported]) && !serverData.eip2612.already_approved) {
22078
22319
  const maxUint256 = BigInt(
22079
22320
  "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
22080
22321
  );
@@ -22182,7 +22423,7 @@ network='${network}'`
22182
22423
  }
22183
22424
  const expected = {
22184
22425
  ...this.#fundingExpectation(swapId, stored),
22185
- pins: _optionalChain([options, 'optionalAccess', _353 => _353.funding])
22426
+ pins: _optionalChain([options, 'optionalAccess', _373 => _373.funding])
22186
22427
  };
22187
22428
  if (expected.terms.chainId !== AA_CHAIN_ID) {
22188
22429
  throw new Error(
@@ -22194,7 +22435,7 @@ network='${network}'`
22194
22435
  const { arbitrum: arbitrum2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./chains-D6LHJZMI-AAYKXZGC.cjs")));
22195
22436
  const rpc = createPublicClient2({
22196
22437
  chain: arbitrum2,
22197
- transport: http2(_nullishCoalesce(_optionalChain([this, 'access', _354 => _354.#config, 'access', _355 => _355.aa, 'optionalAccess', _356 => _356.rpcUrl]), () => ( _optionalChain([this, 'access', _357 => _357.#config, 'access', _358 => _358.aa, 'optionalAccess', _359 => _359.bundlerUrl]))))
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]))))
22198
22439
  });
22199
22440
  const receipt = await rpc.getTransactionReceipt({
22200
22441
  hash: stored.evmFundTxid
@@ -22260,7 +22501,7 @@ network='${network}'`
22260
22501
  return { txHash };
22261
22502
  }
22262
22503
  async #setFundingUserOp(swapId, hash) {
22263
- const current = await _optionalChain([this, 'access', _360 => _360.#swapStorage, 'optionalAccess', _361 => _361.get, 'call', _362 => _362(swapId)]);
22504
+ const current = await _optionalChain([this, 'access', _380 => _380.#swapStorage, 'optionalAccess', _381 => _381.get, 'call', _382 => _382(swapId)]);
22264
22505
  if (!current || !this.#swapStorage)
22265
22506
  throw new Error("Cannot persist funding operation");
22266
22507
  await this.#swapStorage.store({
@@ -22277,7 +22518,7 @@ network='${network}'`
22277
22518
  * here.
22278
22519
  */
22279
22520
  #gaslessDepositorKey(swapId, stored, swap) {
22280
- const depositor = _optionalChain([swap, 'access', _363 => _363.client_evm_address, 'optionalAccess', _364 => _364.toLowerCase, 'call', _365 => _365()]);
22521
+ const depositor = _optionalChain([swap, 'access', _383 => _383.client_evm_address, 'optionalAccess', _384 => _384.toLowerCase, 'call', _385 => _385()]);
22281
22522
  const sharedKey = this.#getEvmSigningKey();
22282
22523
  if (!depositor || depositor === deriveEvmAddress(sharedKey).toLowerCase()) {
22283
22524
  return sharedKey;
@@ -22318,7 +22559,7 @@ network='${network}'`
22318
22559
  );
22319
22560
  }
22320
22561
  const response = storedSwap.response;
22321
- const depositor = _optionalChain([response, 'access', _366 => _366.client_evm_address, 'optionalAccess', _367 => _367.toLowerCase, 'call', _368 => _368()]);
22562
+ const depositor = _optionalChain([response, 'access', _386 => _386.client_evm_address, 'optionalAccess', _387 => _387.toLowerCase, 'call', _388 => _388()]);
22322
22563
  const sharedKey = this.#getEvmSigningKey();
22323
22564
  const sharedAddress = deriveEvmAddress(sharedKey).toLowerCase();
22324
22565
  const swapAddress = deriveEvmAddress(storedSwap.secretKey).toLowerCase();
@@ -22379,7 +22620,7 @@ network='${network}'`
22379
22620
  if (!sourceChain) {
22380
22621
  throw new Error(`Swap ${swapId} is not a CCTP-inbound swap.`);
22381
22622
  }
22382
- const burnTxHash = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _369 => _369.burnTxHash]), () => ( stored.cctpBurnTxid));
22623
+ const burnTxHash = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _389 => _389.burnTxHash]), () => ( stored.cctpBurnTxid));
22383
22624
  if (!burnTxHash) {
22384
22625
  throw new Error(
22385
22626
  `No CCTP burn is recorded for swap ${swapId}; pass it as \`burnTxHash\`.`
@@ -22390,13 +22631,13 @@ network='${network}'`
22390
22631
  {
22391
22632
  signer: this.#depositorOwnerSigner(
22392
22633
  stored.response,
22393
- _optionalChain([options, 'optionalAccess', _370 => _370.ownerSigner])
22634
+ _optionalChain([options, 'optionalAccess', _390 => _390.ownerSigner])
22394
22635
  ),
22395
22636
  burnTxHash,
22396
22637
  sourceChain,
22397
22638
  recipient,
22398
- onProgress: _optionalChain([options, 'optionalAccess', _371 => _371.onProgress]),
22399
- signal: _optionalChain([options, 'optionalAccess', _372 => _372.signal])
22639
+ onProgress: _optionalChain([options, 'optionalAccess', _391 => _391.onProgress]),
22640
+ signal: _optionalChain([options, 'optionalAccess', _392 => _392.signal])
22400
22641
  }
22401
22642
  );
22402
22643
  }
@@ -22540,14 +22781,14 @@ function b64Encode(u) {
22540
22781
  return btoa(bin);
22541
22782
  }
22542
22783
  function isP2tr(script) {
22543
- return _optionalChain([script, 'optionalAccess', _373 => _373.length]) === 34 && script[0] === 81 && script[1] === 32;
22784
+ return _optionalChain([script, 'optionalAccess', _393 => _393.length]) === 34 && script[0] === 81 && script[1] === 32;
22544
22785
  }
22545
22786
  function parseEscrowPsbt(psbt) {
22546
22787
  const lenient = _chunkBEW62OUTcjs.Transaction2.fromPSBT(psbt, { disableScriptCheck: true });
22547
22788
  let stripped = false;
22548
22789
  for (let i = 0; i < lenient.inputsLength; i++) {
22549
22790
  const input = lenient.getInput(i);
22550
- if (input.witnessScript && isP2tr(_optionalChain([input, 'access', _374 => _374.witnessUtxo, 'optionalAccess', _375 => _375.script]))) {
22791
+ if (input.witnessScript && isP2tr(_optionalChain([input, 'access', _394 => _394.witnessUtxo, 'optionalAccess', _395 => _395.script]))) {
22551
22792
  lenient.updateInput(i, { witnessScript: void 0 }, true);
22552
22793
  stripped = true;
22553
22794
  }
@@ -22679,11 +22920,11 @@ var IdbWalletStorage = class {
22679
22920
  }
22680
22921
  async getMnemonic() {
22681
22922
  const record = await this.#db.wallet.get(MNEMONIC_KEY);
22682
- if (_optionalChain([record, 'optionalAccess', _376 => _376.value])) {
22923
+ if (_optionalChain([record, 'optionalAccess', _396 => _396.value])) {
22683
22924
  return record.value;
22684
22925
  }
22685
22926
  const v2Wallet = await readV2Wallet();
22686
- if (!_optionalChain([v2Wallet, 'optionalAccess', _377 => _377.mnemonic])) {
22927
+ if (!_optionalChain([v2Wallet, 'optionalAccess', _397 => _397.mnemonic])) {
22687
22928
  return null;
22688
22929
  }
22689
22930
  await this.setMnemonic(v2Wallet.mnemonic);
@@ -22698,7 +22939,7 @@ var IdbWalletStorage = class {
22698
22939
  }
22699
22940
  async getKeyIndex() {
22700
22941
  const record = await this.#db.wallet.get(KEY_INDEX_KEY);
22701
- return _nullishCoalesce(_optionalChain([record, 'optionalAccess', _378 => _378.value]), () => ( 0));
22942
+ return _nullishCoalesce(_optionalChain([record, 'optionalAccess', _398 => _398.value]), () => ( 0));
22702
22943
  }
22703
22944
  async setKeyIndex(index) {
22704
22945
  await this.#db.wallet.put({ key: KEY_INDEX_KEY, value: index });
@@ -22706,7 +22947,7 @@ var IdbWalletStorage = class {
22706
22947
  async incrementKeyIndex() {
22707
22948
  return this.#db.transaction("rw", this.#db.wallet, async () => {
22708
22949
  const record = await this.#db.wallet.get(KEY_INDEX_KEY);
22709
- const current = _nullishCoalesce(_optionalChain([record, 'optionalAccess', _379 => _379.value]), () => ( 0));
22950
+ const current = _nullishCoalesce(_optionalChain([record, 'optionalAccess', _399 => _399.value]), () => ( 0));
22710
22951
  await this.#db.wallet.put({ key: KEY_INDEX_KEY, value: current + 1 });
22711
22952
  return current;
22712
22953
  });
@@ -22762,7 +23003,7 @@ function readV2Wallet() {
22762
23003
  }
22763
23004
  const request = indexedDB.open(V2_DB_NAME);
22764
23005
  request.onupgradeneeded = () => {
22765
- _optionalChain([request, 'access', _380 => _380.transaction, 'optionalAccess', _381 => _381.abort, 'call', _382 => _382()]);
23006
+ _optionalChain([request, 'access', _400 => _400.transaction, 'optionalAccess', _401 => _401.abort, 'call', _402 => _402()]);
22766
23007
  };
22767
23008
  request.onerror = () => {
22768
23009
  resolve(null);
@@ -22794,7 +23035,7 @@ function readV2Wallet() {
22794
23035
  db.close();
22795
23036
  resolve(null);
22796
23037
  };
22797
- } catch (e30) {
23038
+ } catch (e31) {
22798
23039
  db.close();
22799
23040
  resolve(null);
22800
23041
  }
@@ -22987,10 +23228,11 @@ async function getUsdPrices(tokens, options = {}) {
22987
23228
 
22988
23229
 
22989
23230
 
22990
- 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.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;
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;
22991
23233
  /*! Bundled license information:
22992
23234
 
22993
23235
  @scure/bip39/index.js:
22994
23236
  (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
22995
23237
  */
22996
- //# sourceMappingURL=chunk-EYVSXWCA.cjs.map
23238
+ //# sourceMappingURL=chunk-EL4FUZJO.cjs.map