@satora/swap 1.11.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-EYVSXWCA.cjs → chunk-4NVWIR74.cjs} +216 -204
- package/dist/chunk-4NVWIR74.cjs.map +1 -0
- package/dist/{chunk-M47Z35Z5.cjs → chunk-Q4TOBBAN.cjs} +5 -5
- package/dist/{chunk-M47Z35Z5.cjs.map → chunk-Q4TOBBAN.cjs.map} +1 -1
- package/dist/{chunk-ZAQ7YV6W.js → chunk-TT3J2OOS.js} +5 -5
- package/dist/{chunk-ZAQ7YV6W.js.map → chunk-TT3J2OOS.js.map} +1 -1
- package/dist/{chunk-BVTLZLT2.js → chunk-WQMAL2VD.js} +31 -19
- package/dist/{chunk-BVTLZLT2.js.map → chunk-WQMAL2VD.js.map} +1 -1
- package/dist/delegate.cjs +2 -2
- package/dist/delegate.js +1 -1
- package/dist/dist-MHRQ5FFV.cjs +394 -0
- package/dist/{dist-RWCRSE4V.cjs.map → dist-MHRQ5FFV.cjs.map} +1 -1
- package/dist/{dist-INHW3D4S.js → dist-SHY7I6SH.js} +3 -3
- package/dist/index.cjs +10 -10
- package/dist/index.js +3 -3
- package/dist/types/cjs/pure/redeem/arkade.d.cts +4 -1
- package/dist/types/cjs/pure/version.d.cts +4 -4
- package/dist/types/esm/pure/redeem/arkade.d.ts +4 -1
- package/dist/types/esm/pure/version.d.ts +4 -4
- package/package.json +1 -1
- package/dist/chunk-EYVSXWCA.cjs.map +0 -1
- package/dist/dist-RWCRSE4V.cjs +0 -394
- /package/dist/{dist-INHW3D4S.js.map → dist-SHY7I6SH.js.map} +0 -0
|
@@ -115,7 +115,7 @@ var _chunkTNZW35XAcjs = require('./chunk-TNZW35XA.cjs');
|
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
|
|
118
|
-
var
|
|
118
|
+
var _chunkQ4TOBBANcjs = require('./chunk-Q4TOBBAN.cjs');
|
|
119
119
|
|
|
120
120
|
|
|
121
121
|
|
|
@@ -6848,8 +6848,8 @@ function removeTrailingSlash(url) {
|
|
|
6848
6848
|
}
|
|
6849
6849
|
function createApiClient(options) {
|
|
6850
6850
|
const headers = {
|
|
6851
|
-
"X-Lendaswap-Client":
|
|
6852
|
-
...
|
|
6851
|
+
"X-Lendaswap-Client": _chunkQ4TOBBANcjs.CLIENT_AGENT,
|
|
6852
|
+
..._chunkQ4TOBBANcjs.PROTOCOL_HEADERS,
|
|
6853
6853
|
..._nullishCoalesce(options.defaultHeaders, () => ( {}))
|
|
6854
6854
|
};
|
|
6855
6855
|
return createClient({
|
|
@@ -6862,7 +6862,7 @@ async function getVhtlcAmounts(params) {
|
|
|
6862
6862
|
const { vhtlcAddress, network, arkadeServerUrl } = params;
|
|
6863
6863
|
const decoded = _chunkBEW62OUTcjs.ArkAddress.decode(vhtlcAddress);
|
|
6864
6864
|
const pkScript = _chunkRYZSWESUcjs.hex.encode(decoded.pkScript);
|
|
6865
|
-
const serverUrl =
|
|
6865
|
+
const serverUrl = _chunkQ4TOBBANcjs.resolveArkadeServerUrl.call(void 0, network, arkadeServerUrl);
|
|
6866
6866
|
const indexerProvider = new (0, _chunkBEW62OUTcjs.RestIndexerProvider)(serverUrl);
|
|
6867
6867
|
const [spendableResult, spentResult, recoverableResult] = await Promise.all([
|
|
6868
6868
|
indexerProvider.getVtxos({ scripts: [pkScript], spendableOnly: true }),
|
|
@@ -6897,7 +6897,7 @@ function parseArkadeAddress(address2, network) {
|
|
|
6897
6897
|
throw new Error(`Invalid Arkade address: ${reason}`);
|
|
6898
6898
|
}
|
|
6899
6899
|
if (network !== void 0) {
|
|
6900
|
-
const expectedHrp =
|
|
6900
|
+
const expectedHrp = _chunkQ4TOBBANcjs.getNetworkHrp.call(void 0, _chunkQ4TOBBANcjs.getNetworkName.call(void 0, network));
|
|
6901
6901
|
if (decoded.hrp !== expectedHrp) {
|
|
6902
6902
|
throw new Error(
|
|
6903
6903
|
`Arkade address has wrong network: expected "${expectedHrp}1..." prefix, got "${decoded.hrp}1..."`
|
|
@@ -8640,18 +8640,18 @@ _chunk5JR6AJ3Ycjs.init_sha2.call(void 0, );
|
|
|
8640
8640
|
_chunk5JR6AJ3Ycjs.init_utils.call(void 0, );
|
|
8641
8641
|
_chunkBEW62OUTcjs.init_bip32.call(void 0, );
|
|
8642
8642
|
function pbkdf2Init(hash, _password, _salt, _opts) {
|
|
8643
|
-
|
|
8644
|
-
const opts =
|
|
8643
|
+
_chunkQ4TOBBANcjs.ahash.call(void 0, hash);
|
|
8644
|
+
const opts = _chunkQ4TOBBANcjs.checkOpts.call(void 0, { dkLen: 32, asyncTick: 10 }, _opts);
|
|
8645
8645
|
const { c, dkLen, asyncTick } = opts;
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8646
|
+
_chunkQ4TOBBANcjs.anumber.call(void 0, c, "c");
|
|
8647
|
+
_chunkQ4TOBBANcjs.anumber.call(void 0, dkLen, "dkLen");
|
|
8648
|
+
_chunkQ4TOBBANcjs.anumber.call(void 0, asyncTick, "asyncTick");
|
|
8649
8649
|
if (c < 1)
|
|
8650
8650
|
throw new Error("iterations (c) must be >= 1");
|
|
8651
|
-
const password =
|
|
8652
|
-
const salt =
|
|
8651
|
+
const password = _chunkQ4TOBBANcjs.kdfInputToBytes.call(void 0, _password, "password");
|
|
8652
|
+
const salt = _chunkQ4TOBBANcjs.kdfInputToBytes.call(void 0, _salt, "salt");
|
|
8653
8653
|
const DK = new Uint8Array(dkLen);
|
|
8654
|
-
const PRF =
|
|
8654
|
+
const PRF = _chunkQ4TOBBANcjs.hmac.create(hash, password);
|
|
8655
8655
|
const PRFSalt = PRF._cloneInto().update(salt);
|
|
8656
8656
|
return { c, dkLen, asyncTick, DK, PRF, PRFSalt };
|
|
8657
8657
|
}
|
|
@@ -8660,14 +8660,14 @@ function pbkdf2Output(PRF, PRFSalt, DK, prfW, u) {
|
|
|
8660
8660
|
PRFSalt.destroy();
|
|
8661
8661
|
if (prfW)
|
|
8662
8662
|
prfW.destroy();
|
|
8663
|
-
|
|
8663
|
+
_chunkQ4TOBBANcjs.clean.call(void 0, u);
|
|
8664
8664
|
return DK;
|
|
8665
8665
|
}
|
|
8666
8666
|
function pbkdf2(hash, password, salt, opts) {
|
|
8667
8667
|
const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts);
|
|
8668
8668
|
let prfW;
|
|
8669
8669
|
const arr = new Uint8Array(4);
|
|
8670
|
-
const view =
|
|
8670
|
+
const view = _chunkQ4TOBBANcjs.createView.call(void 0, arr);
|
|
8671
8671
|
const u = new Uint8Array(PRF.outputLen);
|
|
8672
8672
|
for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) {
|
|
8673
8673
|
const Ti = DK.subarray(pos, pos + PRF.outputLen);
|
|
@@ -8696,19 +8696,19 @@ function normalize(str) {
|
|
|
8696
8696
|
return { nfkd: norm, words };
|
|
8697
8697
|
}
|
|
8698
8698
|
function aentropy(ent) {
|
|
8699
|
-
|
|
8699
|
+
_chunkQ4TOBBANcjs.abytes.call(void 0, ent);
|
|
8700
8700
|
if (![16, 20, 24, 28, 32].includes(ent.length))
|
|
8701
8701
|
throw new Error("invalid entropy length");
|
|
8702
8702
|
}
|
|
8703
8703
|
function generateMnemonic(wordlist2, strength = 128) {
|
|
8704
|
-
|
|
8704
|
+
_chunkQ4TOBBANcjs.anumber.call(void 0, strength);
|
|
8705
8705
|
if (strength % 32 !== 0 || strength > 256)
|
|
8706
8706
|
throw new TypeError("Invalid entropy");
|
|
8707
|
-
return entropyToMnemonic(
|
|
8707
|
+
return entropyToMnemonic(_chunkQ4TOBBANcjs.randomBytes.call(void 0, strength / 8), wordlist2);
|
|
8708
8708
|
}
|
|
8709
8709
|
var calcChecksum = (entropy) => {
|
|
8710
8710
|
const bitsLeft = 8 - entropy.length / 4;
|
|
8711
|
-
return new Uint8Array([
|
|
8711
|
+
return new Uint8Array([_chunkQ4TOBBANcjs.sha2562.call(void 0, entropy)[0] >> bitsLeft << bitsLeft]);
|
|
8712
8712
|
};
|
|
8713
8713
|
function getCoder(wordlist2) {
|
|
8714
8714
|
if (!Array.isArray(wordlist2) || wordlist2.length !== 2048 || typeof wordlist2[0] !== "string")
|
|
@@ -8717,7 +8717,7 @@ function getCoder(wordlist2) {
|
|
|
8717
8717
|
if (typeof i !== "string")
|
|
8718
8718
|
throw new Error("wordlist: non-string element: " + i);
|
|
8719
8719
|
});
|
|
8720
|
-
return
|
|
8720
|
+
return _chunkQ4TOBBANcjs.utils.chain(_chunkQ4TOBBANcjs.utils.checksum(1, calcChecksum), _chunkQ4TOBBANcjs.utils.radix2(11, true), _chunkQ4TOBBANcjs.utils.alphabet(wordlist2));
|
|
8721
8721
|
}
|
|
8722
8722
|
function mnemonicToEntropy(mnemonic, wordlist2) {
|
|
8723
8723
|
const { words } = normalize(mnemonic);
|
|
@@ -8740,7 +8740,7 @@ function validateMnemonic(mnemonic, wordlist2) {
|
|
|
8740
8740
|
}
|
|
8741
8741
|
var psalt = (passphrase) => nfkd("mnemonic" + passphrase);
|
|
8742
8742
|
function mnemonicToSeedSync(mnemonic, passphrase = "") {
|
|
8743
|
-
return pbkdf2(
|
|
8743
|
+
return pbkdf2(_chunkQ4TOBBANcjs.sha512, normalize(mnemonic).nfkd, psalt(passphrase), { c: 2048, dkLen: 64 });
|
|
8744
8744
|
}
|
|
8745
8745
|
var wordlist = `abandon
|
|
8746
8746
|
ability
|
|
@@ -11058,12 +11058,12 @@ function parseXOnlyPubKey(pubKeyHex) {
|
|
|
11058
11058
|
);
|
|
11059
11059
|
}
|
|
11060
11060
|
function refundableVhtlc(params) {
|
|
11061
|
-
if (params.scriptVersion !== void 0 && params.scriptVersion !==
|
|
11061
|
+
if (params.scriptVersion !== void 0 && params.scriptVersion !== _chunkQ4TOBBANcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
|
|
11062
11062
|
throw new Error(
|
|
11063
11063
|
`Unsupported Arkade HTLC script version: ${params.scriptVersion}`
|
|
11064
11064
|
);
|
|
11065
11065
|
}
|
|
11066
|
-
return new (0,
|
|
11066
|
+
return new (0, _chunkQ4TOBBANcjs.StrictVhtlcScript)({
|
|
11067
11067
|
sender: parseXOnlyPubKey(params.senderPubKey),
|
|
11068
11068
|
receiver: parseXOnlyPubKey(params.receiverPubKey),
|
|
11069
11069
|
server: parseXOnlyPubKey(params.serverPubKey),
|
|
@@ -11114,8 +11114,8 @@ async function buildArkadeRefund(params) {
|
|
|
11114
11114
|
`Invalid hash lock length: expected 20 or 32, got ${hashLockBytes.length}`
|
|
11115
11115
|
);
|
|
11116
11116
|
}
|
|
11117
|
-
const networkName =
|
|
11118
|
-
const serverUrl =
|
|
11117
|
+
const networkName = _chunkQ4TOBBANcjs.getNetworkName.call(void 0, network);
|
|
11118
|
+
const serverUrl = _chunkQ4TOBBANcjs.resolveArkadeServerUrlByName.call(void 0, networkName, arkadeServerUrl);
|
|
11119
11119
|
const arkProvider = new (0, _chunkBEW62OUTcjs.RestOperatorProvider)(serverUrl);
|
|
11120
11120
|
const indexerProvider = new (0, _chunkBEW62OUTcjs.RestIndexerProvider)(serverUrl);
|
|
11121
11121
|
const serverInfo = await arkProvider.getInfo();
|
|
@@ -11130,7 +11130,7 @@ async function buildArkadeRefund(params) {
|
|
|
11130
11130
|
unilateralRefundWithoutReceiverDelay,
|
|
11131
11131
|
scriptVersion: arkadeHtlcScriptVersion
|
|
11132
11132
|
});
|
|
11133
|
-
const hrp =
|
|
11133
|
+
const hrp = _chunkQ4TOBBANcjs.getNetworkHrp.call(void 0, networkName);
|
|
11134
11134
|
const computedAddress = vhtlc.address(hrp, serverPkBytes);
|
|
11135
11135
|
const computedAddressStr = computedAddress.encode();
|
|
11136
11136
|
if (computedAddressStr !== vhtlcAddress) {
|
|
@@ -11227,10 +11227,10 @@ var REGTEST_NETWORK = {
|
|
|
11227
11227
|
function getNetwork(network) {
|
|
11228
11228
|
switch (network) {
|
|
11229
11229
|
case "mainnet":
|
|
11230
|
-
return
|
|
11230
|
+
return _chunkQ4TOBBANcjs.NETWORK;
|
|
11231
11231
|
case "testnet":
|
|
11232
11232
|
case "signet":
|
|
11233
|
-
return
|
|
11233
|
+
return _chunkQ4TOBBANcjs.TEST_NETWORK;
|
|
11234
11234
|
case "regtest":
|
|
11235
11235
|
return REGTEST_NETWORK;
|
|
11236
11236
|
default:
|
|
@@ -11253,10 +11253,10 @@ function buildHashlockScript(hashLock, serverPubKey, btcHtlcScriptVersion = 1) {
|
|
|
11253
11253
|
hashLock,
|
|
11254
11254
|
"EQUAL"
|
|
11255
11255
|
];
|
|
11256
|
-
return
|
|
11256
|
+
return _chunkQ4TOBBANcjs.Script.encode(script);
|
|
11257
11257
|
}
|
|
11258
11258
|
function buildTimelockScript(userPubKey, refundLocktime) {
|
|
11259
|
-
return
|
|
11259
|
+
return _chunkQ4TOBBANcjs.Script.encode([
|
|
11260
11260
|
refundLocktime,
|
|
11261
11261
|
"CHECKLOCKTIMEVERIFY",
|
|
11262
11262
|
"DROP",
|
|
@@ -11274,7 +11274,7 @@ function buildHtlcTaprootInfo(hashLock, serverPubKey, userPubKey, refundLocktime
|
|
|
11274
11274
|
btcHtlcScriptVersion
|
|
11275
11275
|
);
|
|
11276
11276
|
const timelockScript = buildTimelockScript(userPubKey, refundLocktime);
|
|
11277
|
-
const p2tr2 =
|
|
11277
|
+
const p2tr2 = _chunkQ4TOBBANcjs.p2tr.call(void 0,
|
|
11278
11278
|
NUMS_POINT.slice(1),
|
|
11279
11279
|
// Remove the 02/03 prefix for x-only
|
|
11280
11280
|
[{ script: hashlockScript }, { script: timelockScript }],
|
|
@@ -11357,7 +11357,7 @@ function buildOnchainClaimTransaction(params) {
|
|
|
11357
11357
|
throw new Error("Failed to build tapLeafScript for hashlock");
|
|
11358
11358
|
}
|
|
11359
11359
|
const hashlockLeaf = tapLeafScript[0];
|
|
11360
|
-
const tx = new (0,
|
|
11360
|
+
const tx = new (0, _chunkQ4TOBBANcjs.Transaction2)({
|
|
11361
11361
|
allowUnknownOutputs: true,
|
|
11362
11362
|
allowUnknownInputs: true
|
|
11363
11363
|
});
|
|
@@ -11378,7 +11378,7 @@ function buildOnchainClaimTransaction(params) {
|
|
|
11378
11378
|
const sighash = tx.preimageWitnessV1(
|
|
11379
11379
|
0,
|
|
11380
11380
|
[p2tr2.script],
|
|
11381
|
-
|
|
11381
|
+
_chunkQ4TOBBANcjs.SigHash.DEFAULT,
|
|
11382
11382
|
[htlcAmount],
|
|
11383
11383
|
void 0,
|
|
11384
11384
|
leafScript,
|
|
@@ -11399,7 +11399,7 @@ function buildOnchainClaimTransaction(params) {
|
|
|
11399
11399
|
});
|
|
11400
11400
|
const txHex = _chunkRYZSWESUcjs.hex.encode(tx.extract());
|
|
11401
11401
|
const txId = tx.id;
|
|
11402
|
-
const htlcAddress2 =
|
|
11402
|
+
const htlcAddress2 = _chunkQ4TOBBANcjs.Address.call(void 0, networkConfig).encode({
|
|
11403
11403
|
type: "tr",
|
|
11404
11404
|
pubkey: p2tr2.tweakedPubkey
|
|
11405
11405
|
});
|
|
@@ -11469,7 +11469,7 @@ function buildOnchainRefundTransaction(params) {
|
|
|
11469
11469
|
throw new Error("Failed to build tapLeafScript for timelock");
|
|
11470
11470
|
}
|
|
11471
11471
|
const timelockLeaf = tapLeafScript[1];
|
|
11472
|
-
const tx = new (0,
|
|
11472
|
+
const tx = new (0, _chunkQ4TOBBANcjs.Transaction2)({
|
|
11473
11473
|
allowUnknownOutputs: true,
|
|
11474
11474
|
allowUnknownInputs: true,
|
|
11475
11475
|
lockTime: refundLocktime
|
|
@@ -11490,7 +11490,7 @@ function buildOnchainRefundTransaction(params) {
|
|
|
11490
11490
|
tx.finalize();
|
|
11491
11491
|
const txHex = _chunkRYZSWESUcjs.hex.encode(tx.extract());
|
|
11492
11492
|
const txId = tx.id;
|
|
11493
|
-
const htlcAddress2 =
|
|
11493
|
+
const htlcAddress2 = _chunkQ4TOBBANcjs.Address.call(void 0, networkConfig).encode({
|
|
11494
11494
|
type: "tr",
|
|
11495
11495
|
pubkey: p2tr2.tweakedPubkey
|
|
11496
11496
|
});
|
|
@@ -11523,7 +11523,7 @@ function htlcAddress(hashLock, serverPubKey, userPubKey, refundLocktime, network
|
|
|
11523
11523
|
refundLocktime,
|
|
11524
11524
|
btcHtlcScriptVersion
|
|
11525
11525
|
);
|
|
11526
|
-
return
|
|
11526
|
+
return _chunkQ4TOBBANcjs.Address.call(void 0, getNetwork(network)).encode({
|
|
11527
11527
|
type: "tr",
|
|
11528
11528
|
pubkey: p2tr2.tweakedPubkey
|
|
11529
11529
|
});
|
|
@@ -11640,12 +11640,12 @@ function checkedLightningPaymentHash(options, data) {
|
|
|
11640
11640
|
}
|
|
11641
11641
|
function assertFundedVhtlc(response, addressField, address2, hash160, refundPublicKey, lockDescription) {
|
|
11642
11642
|
const swapId = response.id;
|
|
11643
|
-
if (response.arkade_htlc_script_version !==
|
|
11643
|
+
if (response.arkade_htlc_script_version !== _chunkQ4TOBBANcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
|
|
11644
11644
|
throw new SwapVerificationError(
|
|
11645
11645
|
`Swap ${swapId} uses Arkade HTLC script version ${response.arkade_htlc_script_version}, which this client cannot refund; do not fund it`,
|
|
11646
11646
|
{
|
|
11647
11647
|
field: "arkade_htlc_script_version",
|
|
11648
|
-
expected: String(
|
|
11648
|
+
expected: String(_chunkQ4TOBBANcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT),
|
|
11649
11649
|
received: String(response.arkade_htlc_script_version),
|
|
11650
11650
|
swapId
|
|
11651
11651
|
}
|
|
@@ -11662,7 +11662,7 @@ function assertFundedVhtlc(response, addressField, address2, hash160, refundPubl
|
|
|
11662
11662
|
unilateralRefundDelay: response.unilateral_refund_delay,
|
|
11663
11663
|
unilateralRefundWithoutReceiverDelay: response.unilateral_refund_without_receiver_delay
|
|
11664
11664
|
});
|
|
11665
|
-
const expected = vhtlc.address(
|
|
11665
|
+
const expected = vhtlc.address(_chunkQ4TOBBANcjs.getNetworkHrp.call(void 0, _chunkQ4TOBBANcjs.getNetworkName.call(void 0, response.network)), server).encode();
|
|
11666
11666
|
if (expected !== address2) {
|
|
11667
11667
|
throw new SwapVerificationError(
|
|
11668
11668
|
`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 +11706,12 @@ function assertHashLock(swapId, field, hashLock, accepted) {
|
|
|
11706
11706
|
}
|
|
11707
11707
|
function assertFundedHtlc(response, hashField, hashLock, serverPk, hash160, refundPublicKey, lockDescription) {
|
|
11708
11708
|
const swapId = response.id;
|
|
11709
|
-
if (response.btc_htlc_script_version !==
|
|
11709
|
+
if (response.btc_htlc_script_version !== _chunkQ4TOBBANcjs.BTC_HTLC_SCRIPT_VERSION_STRICT) {
|
|
11710
11710
|
throw new SwapVerificationError(
|
|
11711
11711
|
`Swap ${swapId} uses Bitcoin HTLC script version ${response.btc_htlc_script_version}, which this client cannot refund; do not fund it`,
|
|
11712
11712
|
{
|
|
11713
11713
|
field: "btc_htlc_script_version",
|
|
11714
|
-
expected: String(
|
|
11714
|
+
expected: String(_chunkQ4TOBBANcjs.BTC_HTLC_SCRIPT_VERSION_STRICT),
|
|
11715
11715
|
received: String(response.btc_htlc_script_version),
|
|
11716
11716
|
swapId
|
|
11717
11717
|
}
|
|
@@ -11724,7 +11724,7 @@ function assertFundedHtlc(response, hashField, hashLock, serverPk, hash160, refu
|
|
|
11724
11724
|
{ field: hashField, expected: hash160, received: serverHash160, swapId }
|
|
11725
11725
|
);
|
|
11726
11726
|
}
|
|
11727
|
-
const name =
|
|
11727
|
+
const name = _chunkQ4TOBBANcjs.getNetworkName.call(void 0, response.network);
|
|
11728
11728
|
const network = name === "bitcoin" ? "mainnet" : name === "mutinynet" ? "signet" : name;
|
|
11729
11729
|
const binds = verifyHtlcAddress(
|
|
11730
11730
|
response.btc_htlc_address,
|
|
@@ -12013,7 +12013,7 @@ async function createArkadeToEvmSwapGeneric(options, ctx, claimingAddressOverrid
|
|
|
12013
12013
|
const claimingAddress = _nullishCoalesce(claimingAddressOverride, () => ( deriveEvmAddress(swapParams.secretKey)));
|
|
12014
12014
|
const body = {
|
|
12015
12015
|
hash_lock: hashLock,
|
|
12016
|
-
arkade_htlc_script_version:
|
|
12016
|
+
arkade_htlc_script_version: _chunkQ4TOBBANcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT,
|
|
12017
12017
|
refund_pk: refundPk,
|
|
12018
12018
|
user_id: userId,
|
|
12019
12019
|
claiming_address: claimingAddress,
|
|
@@ -12087,7 +12087,7 @@ async function createArkadeToLightningSwap(options, ctx) {
|
|
|
12087
12087
|
target_amount_sats: options.targetAmountSats,
|
|
12088
12088
|
refund_pk: refundPk,
|
|
12089
12089
|
user_id: userId,
|
|
12090
|
-
arkade_htlc_script_version:
|
|
12090
|
+
arkade_htlc_script_version: _chunkQ4TOBBANcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT,
|
|
12091
12091
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12092
12092
|
extra_fees: options.extraFees
|
|
12093
12093
|
};
|
|
@@ -12118,7 +12118,7 @@ async function createBitcoinToEvmSwap(options, ctx, claimingAddressOverride) {
|
|
|
12118
12118
|
const claimingAddress = _nullishCoalesce(claimingAddressOverride, () => ( deriveEvmAddress(swapParams.secretKey)));
|
|
12119
12119
|
const body = {
|
|
12120
12120
|
hash_lock: hashLock,
|
|
12121
|
-
btc_htlc_script_version:
|
|
12121
|
+
btc_htlc_script_version: _chunkQ4TOBBANcjs.BTC_HTLC_SCRIPT_VERSION_STRICT,
|
|
12122
12122
|
refund_pk: refundPk,
|
|
12123
12123
|
user_id: userId,
|
|
12124
12124
|
claiming_address: claimingAddress,
|
|
@@ -12180,8 +12180,8 @@ async function createBitcoinToArkadeSwap(options, ctx) {
|
|
|
12180
12180
|
target_arkade_address: options.targetAddress,
|
|
12181
12181
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12182
12182
|
extra_fees: options.extraFees,
|
|
12183
|
-
btc_htlc_script_version:
|
|
12184
|
-
arkade_htlc_script_version:
|
|
12183
|
+
btc_htlc_script_version: _chunkQ4TOBBANcjs.BTC_HTLC_SCRIPT_VERSION_STRICT,
|
|
12184
|
+
arkade_htlc_script_version: _chunkQ4TOBBANcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT
|
|
12185
12185
|
};
|
|
12186
12186
|
const { data, error } = await ctx.apiClient.POST("/swap/bitcoin/arkade", {
|
|
12187
12187
|
body
|
|
@@ -12235,7 +12235,7 @@ async function createBitcoinToLightningSwap(options, ctx) {
|
|
|
12235
12235
|
target_amount_sats: options.targetAmountSats,
|
|
12236
12236
|
refund_pk: refundPk,
|
|
12237
12237
|
user_id: userId,
|
|
12238
|
-
btc_htlc_script_version:
|
|
12238
|
+
btc_htlc_script_version: _chunkQ4TOBBANcjs.BTC_HTLC_SCRIPT_VERSION_STRICT,
|
|
12239
12239
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12240
12240
|
extra_fees: options.extraFees
|
|
12241
12241
|
};
|
|
@@ -12296,7 +12296,7 @@ async function createEvmToArkadeSwapGeneric(options, ctx) {
|
|
|
12296
12296
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12297
12297
|
extra_fees: options.extraFees,
|
|
12298
12298
|
gasless: _nullishCoalesce(options.gasless, () => ( false)),
|
|
12299
|
-
arkade_htlc_script_version:
|
|
12299
|
+
arkade_htlc_script_version: _chunkQ4TOBBANcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT,
|
|
12300
12300
|
bridge_source_chain: _optionalChain([options, 'access', _92 => _92.inboundBridgeParams, 'optionalAccess', _93 => _93.sourceChain]),
|
|
12301
12301
|
bridge_source_token_address: _optionalChain([options, 'access', _94 => _94.inboundBridgeParams, 'optionalAccess', _95 => _95.sourceTokenAddress])
|
|
12302
12302
|
}
|
|
@@ -12332,7 +12332,7 @@ async function createEvmToBitcoinSwap(options, ctx) {
|
|
|
12332
12332
|
const { data, error } = await ctx.apiClient.POST("/swap/evm/bitcoin", {
|
|
12333
12333
|
body: {
|
|
12334
12334
|
hash_lock: hashLock,
|
|
12335
|
-
btc_htlc_script_version:
|
|
12335
|
+
btc_htlc_script_version: _chunkQ4TOBBANcjs.BTC_HTLC_SCRIPT_VERSION_STRICT,
|
|
12336
12336
|
claim_pk: claimPk,
|
|
12337
12337
|
user_id: userId,
|
|
12338
12338
|
token_address: options.tokenAddress,
|
|
@@ -12446,7 +12446,7 @@ async function createLightningToArkadeSwap(options, ctx) {
|
|
|
12446
12446
|
source_amount_sats: options.sourceAmountSats,
|
|
12447
12447
|
target_amount_sats: options.targetAmountSats,
|
|
12448
12448
|
target_arkade_address: options.targetAddress,
|
|
12449
|
-
arkade_htlc_script_version:
|
|
12449
|
+
arkade_htlc_script_version: _chunkQ4TOBBANcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT,
|
|
12450
12450
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12451
12451
|
extra_fees: options.extraFees,
|
|
12452
12452
|
// `undefined` is omitted from the JSON body so the server applies its
|
|
@@ -12488,7 +12488,7 @@ async function createLightningToBitcoinSwap(options, ctx) {
|
|
|
12488
12488
|
source_amount_sats: options.sourceAmountSats,
|
|
12489
12489
|
target_amount_sats: options.targetAmountSats,
|
|
12490
12490
|
target_address: options.targetAddress,
|
|
12491
|
-
btc_htlc_script_version:
|
|
12491
|
+
btc_htlc_script_version: _chunkQ4TOBBANcjs.BTC_HTLC_SCRIPT_VERSION_STRICT,
|
|
12492
12492
|
referral_code: _nullishCoalesce(options.referralCode, () => ( ctx.referralCode)),
|
|
12493
12493
|
extra_fees: options.extraFees,
|
|
12494
12494
|
invoice_description: options.invoiceDescription
|
|
@@ -12586,10 +12586,10 @@ var REGTEST_NETWORK2 = {
|
|
|
12586
12586
|
function toBtcSignerNetwork(network) {
|
|
12587
12587
|
switch (network) {
|
|
12588
12588
|
case "mainnet":
|
|
12589
|
-
return
|
|
12589
|
+
return _chunkQ4TOBBANcjs.NETWORK;
|
|
12590
12590
|
case "testnet":
|
|
12591
12591
|
case "signet":
|
|
12592
|
-
return
|
|
12592
|
+
return _chunkQ4TOBBANcjs.TEST_NETWORK;
|
|
12593
12593
|
case "regtest":
|
|
12594
12594
|
return REGTEST_NETWORK2;
|
|
12595
12595
|
default:
|
|
@@ -12598,9 +12598,9 @@ function toBtcSignerNetwork(network) {
|
|
|
12598
12598
|
}
|
|
12599
12599
|
function addressToScriptHash(address2, network) {
|
|
12600
12600
|
const net = toBtcSignerNetwork(network);
|
|
12601
|
-
const decoded =
|
|
12601
|
+
const decoded = _chunkQ4TOBBANcjs.Address.call(void 0, net).decode(address2);
|
|
12602
12602
|
if (!decoded) throw new Error(`Unrecognised Bitcoin address: ${address2}`);
|
|
12603
|
-
const script =
|
|
12603
|
+
const script = _chunkQ4TOBBANcjs.OutScript.encode(decoded);
|
|
12604
12604
|
return _chunk5JR6AJ3Ycjs.bytesToHex.call(void 0, _chunk5JR6AJ3Ycjs.sha256.call(void 0, script).reverse());
|
|
12605
12605
|
}
|
|
12606
12606
|
var ElectrumWsClient = class {
|
|
@@ -12912,7 +12912,7 @@ async function electrumFetchTransactionOutputs(client, txid) {
|
|
|
12912
12912
|
return null;
|
|
12913
12913
|
}
|
|
12914
12914
|
try {
|
|
12915
|
-
const tx =
|
|
12915
|
+
const tx = _chunkQ4TOBBANcjs.Transaction2.fromRaw(_chunk5JR6AJ3Ycjs.hexToBytes.call(void 0, rawHex), {
|
|
12916
12916
|
allowUnknownOutputs: true,
|
|
12917
12917
|
allowUnknownInputs: true,
|
|
12918
12918
|
disableScriptCheck: true
|
|
@@ -13507,8 +13507,8 @@ async function postClaim(baseUrl, swapId, body) {
|
|
|
13507
13507
|
method: "POST",
|
|
13508
13508
|
headers: {
|
|
13509
13509
|
"Content-Type": "application/json",
|
|
13510
|
-
"X-Lendaswap-Client":
|
|
13511
|
-
...
|
|
13510
|
+
"X-Lendaswap-Client": _chunkQ4TOBBANcjs.CLIENT_AGENT,
|
|
13511
|
+
..._chunkQ4TOBBANcjs.PROTOCOL_HEADERS
|
|
13512
13512
|
},
|
|
13513
13513
|
body: JSON.stringify(body)
|
|
13514
13514
|
});
|
|
@@ -13731,8 +13731,8 @@ async function buildArkadeClaim(params) {
|
|
|
13731
13731
|
`Preimage hash are not equal. '${_chunkRYZSWESUcjs.hex.encode(_chunkBEW62OUTcjs.ripemd1602.call(void 0, _chunkRYZSWESUcjs.hex.decode(preimageHash)))}' vs ${preimageHashBytesString}'`
|
|
13732
13732
|
);
|
|
13733
13733
|
}
|
|
13734
|
-
const networkName =
|
|
13735
|
-
const serverUrl =
|
|
13734
|
+
const networkName = _chunkQ4TOBBANcjs.getNetworkName.call(void 0, network);
|
|
13735
|
+
const serverUrl = _chunkQ4TOBBANcjs.resolveArkadeServerUrlByName.call(void 0, networkName, arkadeServerUrl);
|
|
13736
13736
|
const arkProvider = new (0, _chunkBEW62OUTcjs.RestOperatorProvider)(serverUrl);
|
|
13737
13737
|
const indexerProvider = new (0, _chunkBEW62OUTcjs.RestIndexerProvider)(serverUrl);
|
|
13738
13738
|
const serverInfo = await arkProvider.getInfo();
|
|
@@ -13748,13 +13748,13 @@ async function buildArkadeClaim(params) {
|
|
|
13748
13748
|
unilateralRefundWithoutReceiverDelay
|
|
13749
13749
|
)
|
|
13750
13750
|
};
|
|
13751
|
-
if (arkadeHtlcScriptVersion !== void 0 && arkadeHtlcScriptVersion !==
|
|
13751
|
+
if (arkadeHtlcScriptVersion !== void 0 && arkadeHtlcScriptVersion !== _chunkQ4TOBBANcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
|
|
13752
13752
|
throw new Error(
|
|
13753
13753
|
`Unsupported Arkade HTLC script version: ${arkadeHtlcScriptVersion}`
|
|
13754
13754
|
);
|
|
13755
13755
|
}
|
|
13756
|
-
const vhtlc = new (0,
|
|
13757
|
-
const hrp =
|
|
13756
|
+
const vhtlc = new (0, _chunkQ4TOBBANcjs.StrictVhtlcScript)(vhtlcOptions);
|
|
13757
|
+
const hrp = _chunkQ4TOBBANcjs.getNetworkHrp.call(void 0, networkName);
|
|
13758
13758
|
const computedAddress = vhtlc.address(hrp, serverPkBytes);
|
|
13759
13759
|
const computedAddressStr = computedAddress.encode();
|
|
13760
13760
|
if (computedAddressStr !== vhtlcAddress) {
|
|
@@ -13796,8 +13796,7 @@ async function buildArkadeClaim(params) {
|
|
|
13796
13796
|
// The preimage will be added to the witness during signing
|
|
13797
13797
|
witnessData: preimageBytes
|
|
13798
13798
|
}));
|
|
13799
|
-
const
|
|
13800
|
-
const destAddr = ArkAddress2.decode(destinationAddress);
|
|
13799
|
+
const destAddr = _chunkBEW62OUTcjs.ArkAddress.decode(destinationAddress);
|
|
13801
13800
|
const destPkScript = destAddr.pkScript;
|
|
13802
13801
|
const outputs = [
|
|
13803
13802
|
{
|
|
@@ -13867,7 +13866,7 @@ async function continueArkadeClaim(params) {
|
|
|
13867
13866
|
unilateralClaimDelay,
|
|
13868
13867
|
unilateralRefundDelay,
|
|
13869
13868
|
unilateralRefundWithoutReceiverDelay,
|
|
13870
|
-
|
|
13869
|
+
destinationAddress,
|
|
13871
13870
|
network,
|
|
13872
13871
|
arkadeHtlcScriptVersion,
|
|
13873
13872
|
arkadeServerUrl
|
|
@@ -13898,8 +13897,8 @@ async function continueArkadeClaim(params) {
|
|
|
13898
13897
|
`Preimage hash are not equal. '${_chunkRYZSWESUcjs.hex.encode(_chunkBEW62OUTcjs.ripemd1602.call(void 0, _chunkRYZSWESUcjs.hex.decode(preimageHash)))}' vs ${preimageHashBytesString}'`
|
|
13899
13898
|
);
|
|
13900
13899
|
}
|
|
13901
|
-
const networkName =
|
|
13902
|
-
const serverUrl =
|
|
13900
|
+
const networkName = _chunkQ4TOBBANcjs.getNetworkName.call(void 0, network);
|
|
13901
|
+
const serverUrl = _chunkQ4TOBBANcjs.resolveArkadeServerUrlByName.call(void 0, networkName, arkadeServerUrl);
|
|
13903
13902
|
const arkProvider = new (0, _chunkBEW62OUTcjs.RestOperatorProvider)(serverUrl);
|
|
13904
13903
|
const indexerProvider = new (0, _chunkBEW62OUTcjs.RestIndexerProvider)(serverUrl);
|
|
13905
13904
|
const vhtlcOptions = {
|
|
@@ -13914,13 +13913,13 @@ async function continueArkadeClaim(params) {
|
|
|
13914
13913
|
unilateralRefundWithoutReceiverDelay
|
|
13915
13914
|
)
|
|
13916
13915
|
};
|
|
13917
|
-
if (arkadeHtlcScriptVersion !== void 0 && arkadeHtlcScriptVersion !==
|
|
13916
|
+
if (arkadeHtlcScriptVersion !== void 0 && arkadeHtlcScriptVersion !== _chunkQ4TOBBANcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
|
|
13918
13917
|
throw new Error(
|
|
13919
13918
|
`Unsupported Arkade HTLC script version: ${arkadeHtlcScriptVersion}`
|
|
13920
13919
|
);
|
|
13921
13920
|
}
|
|
13922
|
-
const vhtlc = new (0,
|
|
13923
|
-
const hrp =
|
|
13921
|
+
const vhtlc = new (0, _chunkQ4TOBBANcjs.StrictVhtlcScript)(vhtlcOptions);
|
|
13922
|
+
const hrp = _chunkQ4TOBBANcjs.getNetworkHrp.call(void 0, networkName);
|
|
13924
13923
|
const computedAddress = vhtlc.address(hrp, serverPkBytes);
|
|
13925
13924
|
const computedAddressStr = computedAddress.encode();
|
|
13926
13925
|
if (computedAddressStr !== vhtlcAddress) {
|
|
@@ -13948,7 +13947,6 @@ async function continueArkadeClaim(params) {
|
|
|
13948
13947
|
throw new Error("Total VTXO amount is zero");
|
|
13949
13948
|
}
|
|
13950
13949
|
const claimLeafScript = vhtlc.claim();
|
|
13951
|
-
const claimScriptByte = claimLeafScript[1];
|
|
13952
13950
|
const tapTree = vhtlc.encode();
|
|
13953
13951
|
logger.info({
|
|
13954
13952
|
event: "arkade.claim.continue_vtxos_found",
|
|
@@ -13969,7 +13967,7 @@ async function continueArkadeClaim(params) {
|
|
|
13969
13967
|
amount: BigInt(v.value)
|
|
13970
13968
|
},
|
|
13971
13969
|
tapLeafScript: [claimLeafScript],
|
|
13972
|
-
sighashType:
|
|
13970
|
+
sighashType: _chunkQ4TOBBANcjs.SigHash.ALL
|
|
13973
13971
|
}));
|
|
13974
13972
|
const intentProof = _chunkBEW62OUTcjs.Proof.create(intentMessage, intentInputs);
|
|
13975
13973
|
for (let i = 0; i < vtxos.length; i++) {
|
|
@@ -13996,6 +13994,25 @@ async function continueArkadeClaim(params) {
|
|
|
13996
13994
|
"No pending transactions found at the VHTLC address. The claim may have already been finalized or was never submitted."
|
|
13997
13995
|
);
|
|
13998
13996
|
}
|
|
13997
|
+
if (destinationAddress) {
|
|
13998
|
+
const expectedScript = _chunkRYZSWESUcjs.hex.encode(
|
|
13999
|
+
_chunkBEW62OUTcjs.ArkAddress.decode(destinationAddress).pkScript
|
|
14000
|
+
);
|
|
14001
|
+
for (const { arkTxid, finalArkTx } of pendingTxs) {
|
|
14002
|
+
const arkTx = _chunkBEW62OUTcjs.Transaction2.fromPSBT(_chunkRYZSWESUcjs.base64.decode(finalArkTx));
|
|
14003
|
+
if (arkTx.id !== arkTxid) {
|
|
14004
|
+
throw new Error(
|
|
14005
|
+
"Pending Arkade claim transaction ID does not match its PSBT."
|
|
14006
|
+
);
|
|
14007
|
+
}
|
|
14008
|
+
const { amount, script } = arkTx.getOutput(0);
|
|
14009
|
+
if (!amount || !script || _chunkRYZSWESUcjs.hex.encode(script) !== expectedScript) {
|
|
14010
|
+
throw new Error(
|
|
14011
|
+
"Pending Arkade claim does not pay the requested destination address."
|
|
14012
|
+
);
|
|
14013
|
+
}
|
|
14014
|
+
}
|
|
14015
|
+
}
|
|
13999
14016
|
logger.info({
|
|
14000
14017
|
event: "arkade.claim.pending_txs_found",
|
|
14001
14018
|
message: "Found pending Arkade claim transactions",
|
|
@@ -14007,9 +14024,6 @@ async function continueArkadeClaim(params) {
|
|
|
14007
14024
|
const finalCheckpoints = await Promise.all(
|
|
14008
14025
|
signedCheckpointTxs.map(async (c) => {
|
|
14009
14026
|
const checkpointTx = _chunkBEW62OUTcjs.Transaction2.fromPSBT(_chunkRYZSWESUcjs.base64.decode(c));
|
|
14010
|
-
checkpointTx.updateInput(0, {
|
|
14011
|
-
witnessScript: claimScriptByte
|
|
14012
|
-
});
|
|
14013
14027
|
for (let i = 0; i < checkpointTx.inputsLength; i++) {
|
|
14014
14028
|
ensureConditionWitness(checkpointTx, i, preimageBytes);
|
|
14015
14029
|
}
|
|
@@ -14585,7 +14599,7 @@ function buildRefundScriptVhtlc(params) {
|
|
|
14585
14599
|
const lendaswapPkBytes = parseXOnlyPubKey3(params.lendaswapPubKey);
|
|
14586
14600
|
const serverPkBytes = parseXOnlyPubKey3(params.arkadeServerPubKey);
|
|
14587
14601
|
const preimageHashBytes = parsePreimageHash(params.hashLock);
|
|
14588
|
-
const networkName =
|
|
14602
|
+
const networkName = _chunkQ4TOBBANcjs.getNetworkName.call(void 0, params.network);
|
|
14589
14603
|
const options = {
|
|
14590
14604
|
sender: userPkBytes,
|
|
14591
14605
|
receiver: lendaswapPkBytes,
|
|
@@ -14598,13 +14612,13 @@ function buildRefundScriptVhtlc(params) {
|
|
|
14598
14612
|
params.unilateralRefundWithoutReceiverDelay
|
|
14599
14613
|
)
|
|
14600
14614
|
};
|
|
14601
|
-
if (params.arkadeHtlcScriptVersion !== void 0 && params.arkadeHtlcScriptVersion !==
|
|
14615
|
+
if (params.arkadeHtlcScriptVersion !== void 0 && params.arkadeHtlcScriptVersion !== _chunkQ4TOBBANcjs.ARKADE_HTLC_SCRIPT_VERSION_STRICT) {
|
|
14602
14616
|
throw new Error(
|
|
14603
14617
|
`Unsupported Arkade HTLC script version: ${params.arkadeHtlcScriptVersion}`
|
|
14604
14618
|
);
|
|
14605
14619
|
}
|
|
14606
|
-
const vhtlc = new (0,
|
|
14607
|
-
const hrp =
|
|
14620
|
+
const vhtlc = new (0, _chunkQ4TOBBANcjs.StrictVhtlcScript)(options);
|
|
14621
|
+
const hrp = _chunkQ4TOBBANcjs.getNetworkHrp.call(void 0, networkName);
|
|
14608
14622
|
const computedAddress = vhtlc.address(hrp, serverPkBytes).encode();
|
|
14609
14623
|
if (computedAddress !== params.vhtlcAddress) {
|
|
14610
14624
|
throw new Error(
|
|
@@ -14615,7 +14629,7 @@ function buildRefundScriptVhtlc(params) {
|
|
|
14615
14629
|
}
|
|
14616
14630
|
async function collabRefundArkadeToEvmOffchain(params) {
|
|
14617
14631
|
const { vhtlc, networkName } = buildRefundScriptVhtlc(params);
|
|
14618
|
-
const serverUrl =
|
|
14632
|
+
const serverUrl = _chunkQ4TOBBANcjs.resolveArkadeServerUrlByName.call(void 0,
|
|
14619
14633
|
networkName,
|
|
14620
14634
|
params.arkadeServerUrl
|
|
14621
14635
|
);
|
|
@@ -14701,7 +14715,7 @@ async function collabRefundArkadeToEvmOffchain(params) {
|
|
|
14701
14715
|
}
|
|
14702
14716
|
async function collabRefundArkadeToEvmDelegate(params) {
|
|
14703
14717
|
const { vhtlc, networkName } = buildRefundScriptVhtlc(params);
|
|
14704
|
-
const serverUrl =
|
|
14718
|
+
const serverUrl = _chunkQ4TOBBANcjs.resolveArkadeServerUrlByName.call(void 0,
|
|
14705
14719
|
networkName,
|
|
14706
14720
|
params.arkadeServerUrl
|
|
14707
14721
|
);
|
|
@@ -14716,13 +14730,13 @@ async function collabRefundArkadeToEvmDelegate(params) {
|
|
|
14716
14730
|
}
|
|
14717
14731
|
const cosignerPkHex = cosignerRes.data.cosigner_pk;
|
|
14718
14732
|
const btcNetwork = _chunkBEW62OUTcjs.networks[networkName];
|
|
14719
|
-
const forfeitDecoded =
|
|
14733
|
+
const forfeitDecoded = _chunkQ4TOBBANcjs.Address.call(void 0, btcNetwork).decode(serverInfo.forfeitAddress);
|
|
14720
14734
|
if (!forfeitDecoded) {
|
|
14721
14735
|
throw new Error(
|
|
14722
14736
|
`Unrecognised forfeit address: ${serverInfo.forfeitAddress}`
|
|
14723
14737
|
);
|
|
14724
14738
|
}
|
|
14725
|
-
const forfeitPkScript =
|
|
14739
|
+
const forfeitPkScript = _chunkQ4TOBBANcjs.OutScript.encode(forfeitDecoded);
|
|
14726
14740
|
const vhtlcPkScript = _chunkRYZSWESUcjs.hex.encode(vhtlc.pkScript);
|
|
14727
14741
|
const { vtxos: allVtxos } = await indexerProvider.getVtxos({
|
|
14728
14742
|
scripts: [vhtlcPkScript]
|
|
@@ -14755,7 +14769,7 @@ async function collabRefundArkadeToEvmDelegate(params) {
|
|
|
14755
14769
|
amount: BigInt(v.value)
|
|
14756
14770
|
},
|
|
14757
14771
|
tapLeafScript: [tapLeafScript],
|
|
14758
|
-
sighashType:
|
|
14772
|
+
sighashType: _chunkQ4TOBBANcjs.SigHash.ALL
|
|
14759
14773
|
}));
|
|
14760
14774
|
const intentProof = _chunkBEW62OUTcjs.Proof.create(intentMessage, intentInputs, [
|
|
14761
14775
|
{ script: destination.pkScript, amount: totalAmount }
|
|
@@ -14781,7 +14795,7 @@ async function collabRefundArkadeToEvmDelegate(params) {
|
|
|
14781
14795
|
amount: vtxoAmount
|
|
14782
14796
|
},
|
|
14783
14797
|
tapLeafScript: [tapLeafScript],
|
|
14784
|
-
sighashType:
|
|
14798
|
+
sighashType: _chunkQ4TOBBANcjs.SigHash.ALL_ANYONECANPAY
|
|
14785
14799
|
});
|
|
14786
14800
|
forfeitTx.addOutput({
|
|
14787
14801
|
script: forfeitPkScript,
|
|
@@ -15453,10 +15467,10 @@ var DEFAULT_ELECTRUM_WS_URLS = {
|
|
|
15453
15467
|
mainnet: "wss://electrs.satora.io"
|
|
15454
15468
|
};
|
|
15455
15469
|
function defaultAaConfig() {
|
|
15456
|
-
if (!
|
|
15470
|
+
if (!_chunkQ4TOBBANcjs.DEFAULT_AA_BUNDLER_URL) return void 0;
|
|
15457
15471
|
return {
|
|
15458
|
-
bundlerUrl:
|
|
15459
|
-
...
|
|
15472
|
+
bundlerUrl: _chunkQ4TOBBANcjs.DEFAULT_AA_BUNDLER_URL,
|
|
15473
|
+
..._chunkQ4TOBBANcjs.DEFAULT_AA_POLICY_ID ? { paymasterPolicyId: _chunkQ4TOBBANcjs.DEFAULT_AA_POLICY_ID } : {}
|
|
15460
15474
|
};
|
|
15461
15475
|
}
|
|
15462
15476
|
var ClientBuilder = class {
|
|
@@ -15769,8 +15783,8 @@ var Client = class _Client {
|
|
|
15769
15783
|
}
|
|
15770
15784
|
#apiHeaders(extra) {
|
|
15771
15785
|
return {
|
|
15772
|
-
"X-Lendaswap-Client":
|
|
15773
|
-
...
|
|
15786
|
+
"X-Lendaswap-Client": _chunkQ4TOBBANcjs.CLIENT_AGENT,
|
|
15787
|
+
..._chunkQ4TOBBANcjs.PROTOCOL_HEADERS,
|
|
15774
15788
|
..._nullishCoalesce(this.#config.defaultHeaders, () => ( {})),
|
|
15775
15789
|
..._nullishCoalesce(extra, () => ( {}))
|
|
15776
15790
|
};
|
|
@@ -17439,12 +17453,7 @@ var Client = class _Client {
|
|
|
17439
17453
|
};
|
|
17440
17454
|
}
|
|
17441
17455
|
if (vtxoStatus === "spent") {
|
|
17442
|
-
|
|
17443
|
-
if (continued.success) return continued;
|
|
17444
|
-
return {
|
|
17445
|
-
success: false,
|
|
17446
|
-
message: "All VTXOs have already been spent."
|
|
17447
|
-
};
|
|
17456
|
+
return this.#continueArkadeClaim(claimParams, options);
|
|
17448
17457
|
}
|
|
17449
17458
|
if (vtxoStatus === "spendable") {
|
|
17450
17459
|
return this.#claimArkadeOffchain(claimParams, options);
|
|
@@ -17675,13 +17684,16 @@ var Client = class _Client {
|
|
|
17675
17684
|
message: `Expected an Arkade-destination swap, got ${swap.direction}.`
|
|
17676
17685
|
};
|
|
17677
17686
|
}
|
|
17678
|
-
|
|
17687
|
+
return this.#continueArkadeClaim(
|
|
17688
|
+
this.#extractArkadeClaimParams(id, storedSwap)
|
|
17689
|
+
);
|
|
17690
|
+
}
|
|
17691
|
+
async #continueArkadeClaim(claimParams, options) {
|
|
17679
17692
|
try {
|
|
17680
17693
|
const result = await continueArkadeClaim({
|
|
17681
17694
|
...claimParams,
|
|
17682
|
-
destinationAddress:
|
|
17683
|
-
|
|
17684
|
-
arkadeServerUrl: this.#config.arkadeServerUrl,
|
|
17695
|
+
destinationAddress: _optionalChain([options, 'optionalAccess', _200 => _200.destinationAddress]),
|
|
17696
|
+
arkadeServerUrl: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _201 => _201.arkadeServerUrl]), () => ( this.#config.arkadeServerUrl)),
|
|
17685
17697
|
logger: this.#config.logger,
|
|
17686
17698
|
logLevel: this.#config.logLevel
|
|
17687
17699
|
});
|
|
@@ -17799,7 +17811,7 @@ var Client = class _Client {
|
|
|
17799
17811
|
*/
|
|
17800
17812
|
async #claimArkadeDelegate(swapId, params, options) {
|
|
17801
17813
|
try {
|
|
17802
|
-
const result = await
|
|
17814
|
+
const result = await _chunkQ4TOBBANcjs.delegateClaim.call(void 0, {
|
|
17803
17815
|
...params,
|
|
17804
17816
|
destinationAddress: options.destinationAddress,
|
|
17805
17817
|
lendaswapApiUrl: this.#config.baseUrl,
|
|
@@ -17872,10 +17884,10 @@ var Client = class _Client {
|
|
|
17872
17884
|
}
|
|
17873
17885
|
if (direction === "evm_to_arkade" || direction === "evm_to_bitcoin" || direction === "evm_to_lightning") {
|
|
17874
17886
|
const evmOptions = options;
|
|
17875
|
-
if (_optionalChain([evmOptions, 'optionalAccess',
|
|
17887
|
+
if (_optionalChain([evmOptions, 'optionalAccess', _202 => _202.collaborative])) {
|
|
17876
17888
|
return this.#collabRefundEvm(id);
|
|
17877
17889
|
}
|
|
17878
|
-
return this.#buildEvmSourceRefund(id, storedSwap, _optionalChain([evmOptions, 'optionalAccess',
|
|
17890
|
+
return this.#buildEvmSourceRefund(id, storedSwap, _optionalChain([evmOptions, 'optionalAccess', _203 => _203.signer]));
|
|
17879
17891
|
}
|
|
17880
17892
|
return {
|
|
17881
17893
|
success: false,
|
|
@@ -17969,7 +17981,7 @@ var Client = class _Client {
|
|
|
17969
17981
|
}
|
|
17970
17982
|
const btcFundTxid = swap.btc_fund_txid;
|
|
17971
17983
|
const btcFundVout = swap.btc_fund_vout;
|
|
17972
|
-
const waitForFundingMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
17984
|
+
const waitForFundingMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _204 => _204.waitForFundingMs]), () => ( 3e4));
|
|
17973
17985
|
const htlcOutput = await this.#waitForOnchainHtlcOutput(
|
|
17974
17986
|
esploraUrls,
|
|
17975
17987
|
network,
|
|
@@ -17984,14 +17996,14 @@ var Client = class _Client {
|
|
|
17984
17996
|
message: `Could not find UTXO at HTLC address ${btcHtlcAddress} after waiting ${waitForFundingMs}ms. The server may not have funded the HTLC yet.`
|
|
17985
17997
|
};
|
|
17986
17998
|
}
|
|
17987
|
-
const destinationAddress = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
17999
|
+
const destinationAddress = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _205 => _205.destinationAddress]), () => ( storedPayoutTarget(storedSwap)));
|
|
17988
18000
|
if (!destinationAddress) {
|
|
17989
18001
|
return {
|
|
17990
18002
|
success: false,
|
|
17991
18003
|
message: 'Destination address is required to claim BTC. Provide it via options: { destinationAddress: "bc1p..." }'
|
|
17992
18004
|
};
|
|
17993
18005
|
}
|
|
17994
|
-
const feeRateSatPerVb = await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async
|
|
18006
|
+
const feeRateSatPerVb = await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async _206 => _206.feeRateSatPerVb]), async () => ( Math.max(2, await _asyncNullishCoalesce(await fetchFeeRateEstimate(esploraUrls, 2), async () => ( 0)))));
|
|
17995
18007
|
try {
|
|
17996
18008
|
const result = buildOnchainClaimTransaction({
|
|
17997
18009
|
fundingTxId: htlcOutput.txid,
|
|
@@ -18013,7 +18025,7 @@ var Client = class _Client {
|
|
|
18013
18025
|
esploraUrls,
|
|
18014
18026
|
network,
|
|
18015
18027
|
result.txHex,
|
|
18016
|
-
_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
18028
|
+
_nullishCoalesce(_optionalChain([options, 'optionalAccess', _207 => _207.broadcastRetries]), () => ( 5))
|
|
18017
18029
|
);
|
|
18018
18030
|
return {
|
|
18019
18031
|
success: true,
|
|
@@ -18043,7 +18055,7 @@ var Client = class _Client {
|
|
|
18043
18055
|
* @internal
|
|
18044
18056
|
*/
|
|
18045
18057
|
async #buildOnchainRefund(id, swap, options) {
|
|
18046
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
18058
|
+
if (!_optionalChain([options, 'optionalAccess', _208 => _208.destinationAddress])) {
|
|
18047
18059
|
return {
|
|
18048
18060
|
success: false,
|
|
18049
18061
|
message: 'Destination address is required for on-chain refunds. Provide it via the options parameter: { destinationAddress: "bc1q..." }'
|
|
@@ -18249,7 +18261,7 @@ network='${network}'`
|
|
|
18249
18261
|
* @internal
|
|
18250
18262
|
*/
|
|
18251
18263
|
async #buildArkadeRefund(id, swap, options) {
|
|
18252
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
18264
|
+
if (!_optionalChain([options, 'optionalAccess', _209 => _209.destinationAddress])) {
|
|
18253
18265
|
return {
|
|
18254
18266
|
success: false,
|
|
18255
18267
|
message: 'Destination address is required for Arkade refunds. Provide it via the options parameter: { destinationAddress: "ark1..." }'
|
|
@@ -18390,7 +18402,7 @@ network='${network}'`
|
|
|
18390
18402
|
*/
|
|
18391
18403
|
async #refundArkadeDelegate(params, options) {
|
|
18392
18404
|
try {
|
|
18393
|
-
const result = await
|
|
18405
|
+
const result = await _chunkQ4TOBBANcjs.delegateRefund.call(void 0, {
|
|
18394
18406
|
...params,
|
|
18395
18407
|
lendaswapApiUrl: this.#config.baseUrl,
|
|
18396
18408
|
arkadeServerUrl: _nullishCoalesce(options.arkadeServerUrl, () => ( this.#config.arkadeServerUrl)),
|
|
@@ -18485,7 +18497,7 @@ network='${network}'`
|
|
|
18485
18497
|
const call = decodeRefundCall(server.data);
|
|
18486
18498
|
const to = server.to.toLowerCase();
|
|
18487
18499
|
const htlc = leg.htlcAddress.toLowerCase();
|
|
18488
|
-
const coordinator = _optionalChain([leg, 'access',
|
|
18500
|
+
const coordinator = _optionalChain([leg, 'access', _210 => _210.coordinatorAddress, 'optionalAccess', _211 => _211.toLowerCase, 'call', _212 => _212()]);
|
|
18489
18501
|
const signer = check.signer;
|
|
18490
18502
|
let lockSender;
|
|
18491
18503
|
let recipient;
|
|
@@ -18506,7 +18518,7 @@ network='${network}'`
|
|
|
18506
18518
|
`The server's refund targets ${server.to}, not this swap's HTLC ${leg.htlcAddress}`
|
|
18507
18519
|
);
|
|
18508
18520
|
}
|
|
18509
|
-
lockSender = _optionalChain([signer, 'optionalAccess',
|
|
18521
|
+
lockSender = _optionalChain([signer, 'optionalAccess', _213 => _213.address, 'access', _214 => _214.toLowerCase, 'call', _215 => _215()]);
|
|
18510
18522
|
recipient = lockSender;
|
|
18511
18523
|
break;
|
|
18512
18524
|
case "refundTo":
|
|
@@ -18625,7 +18637,7 @@ network='${network}'`
|
|
|
18625
18637
|
}
|
|
18626
18638
|
#fundingExpectation(swapId, stored) {
|
|
18627
18639
|
const hashLock = this.#clientHashLock(swapId, stored);
|
|
18628
|
-
const terms = _optionalChain([stored, 'optionalAccess',
|
|
18640
|
+
const terms = _optionalChain([stored, 'optionalAccess', _216 => _216.evmFundingTerms]);
|
|
18629
18641
|
if (!terms) {
|
|
18630
18642
|
throw new Error(
|
|
18631
18643
|
`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 +18710,7 @@ network='${network}'`
|
|
|
18698
18710
|
if (!this.#swapStorage) return;
|
|
18699
18711
|
try {
|
|
18700
18712
|
const stored = await this.#swapStorage.get(swapId);
|
|
18701
|
-
if (_optionalChain([stored, 'optionalAccess',
|
|
18713
|
+
if (_optionalChain([stored, 'optionalAccess', _217 => _217.evmFundTxid, 'optionalAccess', _218 => _218.toLowerCase, 'call', _219 => _219()]) !== txid.toLowerCase()) return;
|
|
18702
18714
|
await this.#swapStorage.store({
|
|
18703
18715
|
...stored,
|
|
18704
18716
|
evmFundTxid: void 0,
|
|
@@ -18723,7 +18735,7 @@ network='${network}'`
|
|
|
18723
18735
|
* `hint` is appended to the error when neither is.
|
|
18724
18736
|
*/
|
|
18725
18737
|
#depositorOwnerSigner(swapResponse, walletSigner, hint) {
|
|
18726
|
-
const depositor = _optionalChain([swapResponse, 'access',
|
|
18738
|
+
const depositor = _optionalChain([swapResponse, 'access', _220 => _220.client_evm_address, 'optionalAccess', _221 => _221.toLowerCase, 'call', _222 => _222()]);
|
|
18727
18739
|
if (depositor === this.getEvmAddress().toLowerCase()) {
|
|
18728
18740
|
return this.#keyOwnerSigner();
|
|
18729
18741
|
}
|
|
@@ -18795,7 +18807,7 @@ network='${network}'`
|
|
|
18795
18807
|
stored.secretKey ? deriveEvmAddress(stored.secretKey) : void 0
|
|
18796
18808
|
]);
|
|
18797
18809
|
const expectedDepositors = uniqueAddresses([
|
|
18798
|
-
_optionalChain([signer, 'optionalAccess',
|
|
18810
|
+
_optionalChain([signer, 'optionalAccess', _223 => _223.address]),
|
|
18799
18811
|
...sdkAddresses,
|
|
18800
18812
|
stored.response.client_evm_address
|
|
18801
18813
|
]);
|
|
@@ -18821,7 +18833,7 @@ network='${network}'`
|
|
|
18821
18833
|
expectedDepositors
|
|
18822
18834
|
});
|
|
18823
18835
|
const coordinatorProved = !leg.depositorIsSender && refund.sender !== signer.address.toLowerCase() && stored.evmCoordinatorAddress === void 0;
|
|
18824
|
-
if (fundTxid.toLowerCase() !== _optionalChain([stored, 'access',
|
|
18836
|
+
if (fundTxid.toLowerCase() !== _optionalChain([stored, 'access', _224 => _224.evmFundTxid, 'optionalAccess', _225 => _225.toLowerCase, 'call', _226 => _226()]) || coordinatorProved) {
|
|
18825
18837
|
await this.#recordEvmFunding(id, {
|
|
18826
18838
|
txid: fundTxid,
|
|
18827
18839
|
coordinatorAddress: coordinatorProved ? refund.sender : void 0
|
|
@@ -18880,7 +18892,7 @@ network='${network}'`
|
|
|
18880
18892
|
async #serverFundTxid(id) {
|
|
18881
18893
|
const fresh = await this.getSwap(id);
|
|
18882
18894
|
try {
|
|
18883
|
-
await _optionalChain([this, 'access',
|
|
18895
|
+
await _optionalChain([this, 'access', _227 => _227.#swapStorage, 'optionalAccess', _228 => _228.update, 'call', _229 => _229(id, fresh)]);
|
|
18884
18896
|
} catch (error) {
|
|
18885
18897
|
this.#logger.warn({
|
|
18886
18898
|
event: "client.refundSwap.refreshNotStored",
|
|
@@ -18893,7 +18905,7 @@ network='${network}'`
|
|
|
18893
18905
|
}
|
|
18894
18906
|
async #refundFromFundingTx(signer, leg) {
|
|
18895
18907
|
const self2 = signer.address.toLowerCase();
|
|
18896
|
-
const coordinator = _optionalChain([leg, 'access',
|
|
18908
|
+
const coordinator = _optionalChain([leg, 'access', _230 => _230.coordinatorAddress, 'optionalAccess', _231 => _231.toLowerCase, 'call', _232 => _232()]);
|
|
18897
18909
|
const senders = leg.depositorIsSender ? uniqueAddresses([self2, ...leg.expectedDepositors]) : coordinator === void 0 ? void 0 : [self2, coordinator];
|
|
18898
18910
|
const { created, terms, hashLock } = await this.#lockFromFundingTx(signer, {
|
|
18899
18911
|
...leg,
|
|
@@ -19231,7 +19243,7 @@ network='${network}'`
|
|
|
19231
19243
|
*/
|
|
19232
19244
|
async collabRefundEvmSwap(swapId) {
|
|
19233
19245
|
const storedSwap = await this.getStoredSwap(swapId);
|
|
19234
|
-
if (!_optionalChain([storedSwap, 'optionalAccess',
|
|
19246
|
+
if (!_optionalChain([storedSwap, 'optionalAccess', _233 => _233.secretKey])) {
|
|
19235
19247
|
throw new Error(
|
|
19236
19248
|
"No secret key found for this swap. Cannot sign collab refund."
|
|
19237
19249
|
);
|
|
@@ -19390,11 +19402,11 @@ network='${network}'`
|
|
|
19390
19402
|
} else {
|
|
19391
19403
|
userOpHash = await client.sendUserOperation({ calls });
|
|
19392
19404
|
}
|
|
19393
|
-
await _optionalChain([hooks, 'access',
|
|
19405
|
+
await _optionalChain([hooks, 'access', _234 => _234.onSubmitted, 'optionalCall', _235 => _235(userOpHash)]);
|
|
19394
19406
|
const { receipt, success, reason } = await client.waitForUserOperationReceipt({
|
|
19395
19407
|
hash: userOpHash
|
|
19396
19408
|
});
|
|
19397
|
-
await _optionalChain([hooks, 'access',
|
|
19409
|
+
await _optionalChain([hooks, 'access', _236 => _236.onIncluded, 'optionalCall', _237 => _237(receipt.transactionHash, userOpHash)]);
|
|
19398
19410
|
if (!success) {
|
|
19399
19411
|
throw new Error(
|
|
19400
19412
|
`Sponsored UserOp ${userOpHash} reverted on-chain${reason ? `: ${reason}` : ""}`
|
|
@@ -19615,7 +19627,7 @@ network='${network}'`
|
|
|
19615
19627
|
* no AA config, not included, or the bundler cannot be reached).
|
|
19616
19628
|
*/
|
|
19617
19629
|
async #pendingRehashTx(rehash) {
|
|
19618
|
-
const bundlerUrl = _optionalChain([this, 'access',
|
|
19630
|
+
const bundlerUrl = _optionalChain([this, 'access', _238 => _238.#config, 'access', _239 => _239.aa, 'optionalAccess', _240 => _240.bundlerUrl]);
|
|
19619
19631
|
if (!rehash.userOpHash || !bundlerUrl) return void 0;
|
|
19620
19632
|
try {
|
|
19621
19633
|
const response = await fetch(bundlerUrl, {
|
|
@@ -19629,7 +19641,7 @@ network='${network}'`
|
|
|
19629
19641
|
})
|
|
19630
19642
|
});
|
|
19631
19643
|
const json = await response.json();
|
|
19632
|
-
return _nullishCoalesce(_optionalChain([json, 'access',
|
|
19644
|
+
return _nullishCoalesce(_optionalChain([json, 'access', _241 => _241.result, 'optionalAccess', _242 => _242.receipt, 'optionalAccess', _243 => _243.transactionHash]), () => ( void 0));
|
|
19633
19645
|
} catch (e25) {
|
|
19634
19646
|
return void 0;
|
|
19635
19647
|
}
|
|
@@ -19639,7 +19651,7 @@ network='${network}'`
|
|
|
19639
19651
|
if (!this.#swapStorage) return;
|
|
19640
19652
|
try {
|
|
19641
19653
|
const stored = await this.#swapStorage.get(swapId);
|
|
19642
|
-
const history = _optionalChain([stored, 'optionalAccess',
|
|
19654
|
+
const history = _optionalChain([stored, 'optionalAccess', _244 => _244.evmRehashes]);
|
|
19643
19655
|
if (!stored || !history) return;
|
|
19644
19656
|
let index = -1;
|
|
19645
19657
|
for (let i = history.length - 1; i >= 0; i--) {
|
|
@@ -19690,7 +19702,7 @@ network='${network}'`
|
|
|
19690
19702
|
}
|
|
19691
19703
|
const ownHash = this.#clientHashLock(swapId, stored);
|
|
19692
19704
|
const leg = evmSourceLeg(stored);
|
|
19693
|
-
const firstFrom = _optionalChain([leg, 'access',
|
|
19705
|
+
const firstFrom = _optionalChain([leg, 'access', _245 => _245.rehashes, 'optionalAccess', _246 => _246[0], 'optionalAccess', _247 => _247.fromHashLock]);
|
|
19694
19706
|
if (firstFrom !== void 0 && `0x${_chunkJZTF4JNHcjs.normalizeBytes32.call(void 0, firstFrom)}` !== ownHash) {
|
|
19695
19707
|
throw new Error(
|
|
19696
19708
|
`The rehash history of swap ${swapId} starts from ${firstFrom}, not from the payment hash this client fixed (${ownHash})`
|
|
@@ -19749,7 +19761,7 @@ network='${network}'`
|
|
|
19749
19761
|
* does not read the chain. Arbitrum only, like the paymaster.
|
|
19750
19762
|
*/
|
|
19751
19763
|
async #aaChainReader(owner) {
|
|
19752
|
-
const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access',
|
|
19764
|
+
const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access', _248 => _248.#config, 'access', _249 => _249.aa, 'optionalAccess', _250 => _250.rpcUrl]), () => ( _optionalChain([this, 'access', _251 => _251.#config, 'access', _252 => _252.aa, 'optionalAccess', _253 => _253.bundlerUrl])));
|
|
19753
19765
|
if (!rpcUrl) {
|
|
19754
19766
|
throw new Error(
|
|
19755
19767
|
"A sponsored rehash reads the lock over the AA RPC; call `.withAa({ bundlerUrl, paymasterPolicyId })` on the ClientBuilder before `.build()`."
|
|
@@ -19800,7 +19812,7 @@ network='${network}'`
|
|
|
19800
19812
|
*/
|
|
19801
19813
|
async retrySwapWithInvoice(swapId, invoice) {
|
|
19802
19814
|
const storedSwap = await this.getStoredSwap(swapId);
|
|
19803
|
-
if (!_optionalChain([storedSwap, 'optionalAccess',
|
|
19815
|
+
if (!_optionalChain([storedSwap, 'optionalAccess', _254 => _254.secretKey])) {
|
|
19804
19816
|
throw new Error(
|
|
19805
19817
|
"No secret key found for this swap. Cannot authorize the rehash."
|
|
19806
19818
|
);
|
|
@@ -19952,23 +19964,23 @@ network='${network}'`
|
|
|
19952
19964
|
updatedAt: Date.now(),
|
|
19953
19965
|
// The payout this client asked for; claims pay here, never to a
|
|
19954
19966
|
// server answer. Recovery rebuilding the swap keeps it.
|
|
19955
|
-
targetAddress: _nullishCoalesce(targetAddress, () => ( _optionalChain([existing, 'optionalAccess',
|
|
19956
|
-
bridgeRecipient: _optionalChain([bridge, 'optionalAccess',
|
|
19957
|
-
bridgeRecipientWallet: _optionalChain([bridge, 'optionalAccess',
|
|
19958
|
-
evmFundTxid: _optionalChain([existing, 'optionalAccess',
|
|
19959
|
-
evmFundingUserOpHash: _optionalChain([existing, 'optionalAccess',
|
|
19967
|
+
targetAddress: _nullishCoalesce(targetAddress, () => ( _optionalChain([existing, 'optionalAccess', _255 => _255.targetAddress]))),
|
|
19968
|
+
bridgeRecipient: _optionalChain([bridge, 'optionalAccess', _256 => _256.recipient]),
|
|
19969
|
+
bridgeRecipientWallet: _optionalChain([bridge, 'optionalAccess', _257 => _257.recipientWallet]),
|
|
19970
|
+
evmFundTxid: _optionalChain([existing, 'optionalAccess', _258 => _258.evmFundTxid]),
|
|
19971
|
+
evmFundingUserOpHash: _optionalChain([existing, 'optionalAccess', _259 => _259.evmFundingUserOpHash]),
|
|
19960
19972
|
// Fixed at creation and never taken from a server answer: recovery
|
|
19961
19973
|
// rebuilding the swap keeps it, and a fresh device has none.
|
|
19962
|
-
lightningPaymentHash: _nullishCoalesce(_optionalChain([commitments, 'optionalAccess',
|
|
19963
|
-
evmFundingTerms: _nullishCoalesce(_optionalChain([commitments, 'optionalAccess',
|
|
19964
|
-
evmCoordinatorAddress: _optionalChain([existing, 'optionalAccess',
|
|
19974
|
+
lightningPaymentHash: _nullishCoalesce(_optionalChain([commitments, 'optionalAccess', _260 => _260.lightningPaymentHash]), () => ( _optionalChain([existing, 'optionalAccess', _261 => _261.lightningPaymentHash]))),
|
|
19975
|
+
evmFundingTerms: _nullishCoalesce(_optionalChain([commitments, 'optionalAccess', _262 => _262.evmFundingTerms]), () => ( _optionalChain([existing, 'optionalAccess', _263 => _263.evmFundingTerms]))),
|
|
19976
|
+
evmCoordinatorAddress: _optionalChain([existing, 'optionalAccess', _264 => _264.evmCoordinatorAddress]),
|
|
19965
19977
|
// The rehashes this client sent are what let a refund find the lock
|
|
19966
19978
|
// that exists; the server's copy names only the current hash.
|
|
19967
|
-
evmRehashes: _optionalChain([existing, 'optionalAccess',
|
|
19979
|
+
evmRehashes: _optionalChain([existing, 'optionalAccess', _265 => _265.evmRehashes]),
|
|
19968
19980
|
// A CCTP-inbound burn is the only way to resume or recover once the
|
|
19969
19981
|
// USDC has left the source chain.
|
|
19970
|
-
cctpBurnTxid: _optionalChain([existing, 'optionalAccess',
|
|
19971
|
-
cctpBurnLastValidBlockHeight: _optionalChain([existing, 'optionalAccess',
|
|
19982
|
+
cctpBurnTxid: _optionalChain([existing, 'optionalAccess', _266 => _266.cctpBurnTxid]),
|
|
19983
|
+
cctpBurnLastValidBlockHeight: _optionalChain([existing, 'optionalAccess', _267 => _267.cctpBurnLastValidBlockHeight])
|
|
19972
19984
|
};
|
|
19973
19985
|
await this.#swapStorage.store(storedSwap);
|
|
19974
19986
|
}
|
|
@@ -20010,7 +20022,7 @@ network='${network}'`
|
|
|
20010
20022
|
const targetAsset = "token_id" in tgt ? { chain: tgt.chain, token_id: tgt.token_id } : { chain: tgt.chain, token_id: tgt.tokenId };
|
|
20011
20023
|
if (isTronToken(sourceAsset.chain))
|
|
20012
20024
|
throw new Error("Tron is a payout-only destination");
|
|
20013
|
-
const isTronTarget = isTronToken(targetAsset.chain) || _optionalChain([options, 'access',
|
|
20025
|
+
const isTronTarget = isTronToken(targetAsset.chain) || _optionalChain([options, 'access', _268 => _268.bridgeParams, 'optionalAccess', _269 => _269.targetChain]) === "Tron";
|
|
20014
20026
|
if (isTronTarget) {
|
|
20015
20027
|
if (isTronToken(targetAsset.chain) && targetAsset.token_id !== USDT0_ADDRESSES.Tron) {
|
|
20016
20028
|
throw new Error("Tron payouts require native USDT");
|
|
@@ -20050,7 +20062,7 @@ network='${network}'`
|
|
|
20050
20062
|
if (isTronTarget && bridgeParams) {
|
|
20051
20063
|
bridgeParams = { ...bridgeParams, recipient: options.targetAddress };
|
|
20052
20064
|
}
|
|
20053
|
-
const cctpPayout = !options.bridgeParams && bridgeParams != null && _optionalChain([bridgeParams, 'access',
|
|
20065
|
+
const cctpPayout = !options.bridgeParams && bridgeParams != null && _optionalChain([bridgeParams, 'access', _270 => _270.targetTokenAddress, 'optionalAccess', _271 => _271.toLowerCase, 'call', _272 => _272()]) === _optionalChain([_chunkTKFOVRJRcjs.USDC_ADDRESSES, 'access', _273 => _273[bridgeParams.targetChain], 'optionalAccess', _274 => _274.toLowerCase, 'call', _275 => _275()]);
|
|
20054
20066
|
if (cctpPayout && options.sourceAmount != null) {
|
|
20055
20067
|
const quote = await this.getQuote({
|
|
20056
20068
|
sourceChain: sourceAsset.chain,
|
|
@@ -20064,7 +20076,7 @@ network='${network}'`
|
|
|
20064
20076
|
});
|
|
20065
20077
|
if (BigInt(quote.net_target_amount) <= 0n) {
|
|
20066
20078
|
throw new Error(
|
|
20067
|
-
`Amount too small to bridge to ${_optionalChain([bridgeParams, 'optionalAccess',
|
|
20079
|
+
`Amount too small to bridge to ${_optionalChain([bridgeParams, 'optionalAccess', _276 => _276.targetChain])}: the CCTP fee (${_nullishCoalesce(quote.bridge_fee, () => ( "unknown"))} USDC units) leaves nothing to deliver. Increase the amount.`
|
|
20068
20080
|
);
|
|
20069
20081
|
}
|
|
20070
20082
|
}
|
|
@@ -20688,7 +20700,7 @@ network='${network}'`
|
|
|
20688
20700
|
swapId,
|
|
20689
20701
|
serverData,
|
|
20690
20702
|
chainId,
|
|
20691
|
-
_optionalChain([options, 'optionalAccess',
|
|
20703
|
+
_optionalChain([options, 'optionalAccess', _277 => _277.funding])
|
|
20692
20704
|
);
|
|
20693
20705
|
const nonceBytes = new Uint8Array(32);
|
|
20694
20706
|
crypto.getRandomValues(nonceBytes);
|
|
@@ -20830,7 +20842,7 @@ network='${network}'`
|
|
|
20830
20842
|
swapId,
|
|
20831
20843
|
serverData,
|
|
20832
20844
|
chainId,
|
|
20833
|
-
_optionalChain([options, 'optionalAccess',
|
|
20845
|
+
_optionalChain([options, 'optionalAccess', _278 => _278.funding])
|
|
20834
20846
|
);
|
|
20835
20847
|
const nonceBytes = new Uint8Array(32);
|
|
20836
20848
|
crypto.getRandomValues(nonceBytes);
|
|
@@ -20919,14 +20931,14 @@ network='${network}'`
|
|
|
20919
20931
|
*/
|
|
20920
20932
|
async fundSwap(swapId, signer, options) {
|
|
20921
20933
|
{
|
|
20922
|
-
const stored = await _optionalChain([this, 'access',
|
|
20923
|
-
const response = await _asyncNullishCoalesce(await _asyncOptionalChain([stored, 'optionalAccess', async
|
|
20934
|
+
const stored = await _optionalChain([this, 'access', _279 => _279.#swapStorage, 'optionalAccess', _280 => _280.get, 'call', _281 => _281(swapId)]);
|
|
20935
|
+
const response = await _asyncNullishCoalesce(await _asyncOptionalChain([stored, 'optionalAccess', async _282 => _282.response]), async () => ( await this.getSwap(swapId, { updateStorage: true })));
|
|
20924
20936
|
if ((response.direction === "evm_to_lightning" || response.direction === "evm_to_arkade" || response.direction === "evm_to_bitcoin") && response.evm_htlc_kind === "native") {
|
|
20925
20937
|
const txHash2 = await this.#fundNativeLock(
|
|
20926
20938
|
swapId,
|
|
20927
20939
|
response,
|
|
20928
20940
|
signer,
|
|
20929
|
-
_optionalChain([options, 'optionalAccess',
|
|
20941
|
+
_optionalChain([options, 'optionalAccess', _283 => _283.onQuote])
|
|
20930
20942
|
);
|
|
20931
20943
|
return { txHash: txHash2 };
|
|
20932
20944
|
}
|
|
@@ -20937,12 +20949,12 @@ network='${network}'`
|
|
|
20937
20949
|
}
|
|
20938
20950
|
}
|
|
20939
20951
|
if (isCctpOnlySource(signer.chainId)) {
|
|
20940
|
-
const stored = await _optionalChain([this, 'access',
|
|
20941
|
-
const swapResponse = await _asyncNullishCoalesce(await _asyncOptionalChain([stored, 'optionalAccess', async
|
|
20952
|
+
const stored = await _optionalChain([this, 'access', _284 => _284.#swapStorage, 'optionalAccess', _285 => _285.get, 'call', _286 => _286(swapId)]);
|
|
20953
|
+
const swapResponse = await _asyncNullishCoalesce(await _asyncOptionalChain([stored, 'optionalAccess', async _287 => _287.response]), async () => ( await this.getSwap(swapId, { updateStorage: true })));
|
|
20942
20954
|
const source = cctpMetaForChainId(signer.chainId);
|
|
20943
20955
|
const expected = {
|
|
20944
20956
|
...this.#fundingExpectation(swapId, stored),
|
|
20945
|
-
pins: _optionalChain([options, 'optionalAccess',
|
|
20957
|
+
pins: _optionalChain([options, 'optionalAccess', _288 => _288.funding])
|
|
20946
20958
|
};
|
|
20947
20959
|
await this.#ensureClientHashLock(
|
|
20948
20960
|
swapId,
|
|
@@ -20974,7 +20986,7 @@ network='${network}'`
|
|
|
20974
20986
|
}
|
|
20975
20987
|
const amount = BigInt(rawAmount);
|
|
20976
20988
|
const destination = cctpMetaForChainId(42161);
|
|
20977
|
-
const recordedBurn = _optionalChain([stored, 'optionalAccess',
|
|
20989
|
+
const recordedBurn = _optionalChain([stored, 'optionalAccess', _289 => _289.cctpBurnTxid]);
|
|
20978
20990
|
if (recordedBurn) {
|
|
20979
20991
|
const fresh = await this.getSwap(swapId, { updateStorage: true });
|
|
20980
20992
|
if (fresh.status !== "pending") {
|
|
@@ -20983,7 +20995,7 @@ network='${network}'`
|
|
|
20983
20995
|
);
|
|
20984
20996
|
}
|
|
20985
20997
|
}
|
|
20986
|
-
const maxFee = recordedBurn ? 0n : await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async
|
|
20998
|
+
const maxFee = recordedBurn ? 0n : await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async _290 => _290.maxFee]), async () => ( computeCctpFastFee(
|
|
20987
20999
|
await getCachedCctpFee({
|
|
20988
21000
|
sourceDomain: source.domain,
|
|
20989
21001
|
destinationDomain: destination.domain
|
|
@@ -21003,8 +21015,8 @@ network='${network}'`
|
|
|
21003
21015
|
onBurn: (burnTxHash) => this.#recordCctpBurn(swapId, burnTxHash),
|
|
21004
21016
|
amount,
|
|
21005
21017
|
maxFee,
|
|
21006
|
-
onProgress: _optionalChain([options, 'optionalAccess',
|
|
21007
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
21018
|
+
onProgress: _optionalChain([options, 'optionalAccess', _291 => _291.onProgress]),
|
|
21019
|
+
signal: _optionalChain([options, 'optionalAccess', _292 => _292.signal])
|
|
21008
21020
|
});
|
|
21009
21021
|
if (cctp.transactionHash) {
|
|
21010
21022
|
await this.#recordEvmFunding(swapId, { txid: cctp.transactionHash });
|
|
@@ -21015,9 +21027,9 @@ network='${network}'`
|
|
|
21015
21027
|
swapId,
|
|
21016
21028
|
signer.chainId,
|
|
21017
21029
|
signer.address,
|
|
21018
|
-
{ funding: _optionalChain([options, 'optionalAccess',
|
|
21030
|
+
{ funding: _optionalChain([options, 'optionalAccess', _293 => _293.funding]) }
|
|
21019
21031
|
);
|
|
21020
|
-
_optionalChain([options, 'optionalAccess',
|
|
21032
|
+
_optionalChain([options, 'optionalAccess', _294 => _294.onQuote, 'optionalCall', _295 => _295({
|
|
21021
21033
|
sourceAmount: funding.sourceAmount,
|
|
21022
21034
|
sourceTokenAddress: funding.sourceTokenAddress
|
|
21023
21035
|
})]);
|
|
@@ -21065,10 +21077,10 @@ network='${network}'`
|
|
|
21065
21077
|
swapId,
|
|
21066
21078
|
signer.chainId,
|
|
21067
21079
|
signer.address,
|
|
21068
|
-
{ funding: _optionalChain([options, 'optionalAccess',
|
|
21080
|
+
{ funding: _optionalChain([options, 'optionalAccess', _296 => _296.funding]) }
|
|
21069
21081
|
);
|
|
21070
21082
|
if (freshFunding.sourceAmount !== funding.sourceAmount) {
|
|
21071
|
-
_optionalChain([options, 'optionalAccess',
|
|
21083
|
+
_optionalChain([options, 'optionalAccess', _297 => _297.onQuote, 'optionalCall', _298 => _298({
|
|
21072
21084
|
sourceAmount: freshFunding.sourceAmount,
|
|
21073
21085
|
sourceTokenAddress: freshFunding.sourceTokenAddress
|
|
21074
21086
|
})]);
|
|
@@ -21144,17 +21156,17 @@ network='${network}'`
|
|
|
21144
21156
|
* @returns The Arbitrum settlement tx hash (or UserOp hash) and the burn
|
|
21145
21157
|
*/
|
|
21146
21158
|
async fundSwapFromSolana(swapId, signer, options) {
|
|
21147
|
-
const rpcUrl = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
21159
|
+
const rpcUrl = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _299 => _299.rpcUrl]), () => ( this.#config.solanaRpcUrl));
|
|
21148
21160
|
if (!rpcUrl) {
|
|
21149
21161
|
throw new Error(
|
|
21150
21162
|
"Funding from Solana needs a Solana RPC URL. Pass `rpcUrl` or call `.withSolanaRpcUrl(url)` on the ClientBuilder."
|
|
21151
21163
|
);
|
|
21152
21164
|
}
|
|
21153
|
-
const stored = await _optionalChain([this, 'access',
|
|
21154
|
-
const swapResponse = await _asyncNullishCoalesce(await _asyncOptionalChain([stored, 'optionalAccess', async
|
|
21165
|
+
const stored = await _optionalChain([this, 'access', _300 => _300.#swapStorage, 'optionalAccess', _301 => _301.get, 'call', _302 => _302(swapId)]);
|
|
21166
|
+
const swapResponse = await _asyncNullishCoalesce(await _asyncOptionalChain([stored, 'optionalAccess', async _303 => _303.response]), async () => ( await this.getSwap(swapId, { updateStorage: true })));
|
|
21155
21167
|
const expected = {
|
|
21156
21168
|
...this.#fundingExpectation(swapId, stored),
|
|
21157
|
-
pins: _optionalChain([options, 'optionalAccess',
|
|
21169
|
+
pins: _optionalChain([options, 'optionalAccess', _304 => _304.funding])
|
|
21158
21170
|
};
|
|
21159
21171
|
await this.#ensureClientHashLock(
|
|
21160
21172
|
swapId,
|
|
@@ -21178,7 +21190,7 @@ network='${network}'`
|
|
|
21178
21190
|
);
|
|
21179
21191
|
}
|
|
21180
21192
|
const amount = BigInt(bridge.source_amount);
|
|
21181
|
-
const recordedBurn = _optionalChain([stored, 'optionalAccess',
|
|
21193
|
+
const recordedBurn = _optionalChain([stored, 'optionalAccess', _305 => _305.cctpBurnTxid]);
|
|
21182
21194
|
if (recordedBurn) {
|
|
21183
21195
|
const fresh = await this.getSwap(swapId, { updateStorage: true });
|
|
21184
21196
|
if (fresh.status !== "pending") {
|
|
@@ -21187,7 +21199,7 @@ network='${network}'`
|
|
|
21187
21199
|
);
|
|
21188
21200
|
}
|
|
21189
21201
|
}
|
|
21190
|
-
const maxFee = recordedBurn ? 0n : await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async
|
|
21202
|
+
const maxFee = recordedBurn ? 0n : await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async _306 => _306.maxFee]), async () => ( computeCctpFastFee(
|
|
21191
21203
|
await getCachedCctpFee({
|
|
21192
21204
|
sourceDomain: _chunkTKFOVRJRcjs.CCTP_DOMAINS.Solana,
|
|
21193
21205
|
destinationDomain: _chunkTKFOVRJRcjs.CCTP_DOMAINS.Arbitrum
|
|
@@ -21209,13 +21221,13 @@ network='${network}'`
|
|
|
21209
21221
|
),
|
|
21210
21222
|
rpcUrl,
|
|
21211
21223
|
burnSignature: recordedBurn,
|
|
21212
|
-
burnLastValidBlockHeight: _optionalChain([stored, 'optionalAccess',
|
|
21224
|
+
burnLastValidBlockHeight: _optionalChain([stored, 'optionalAccess', _307 => _307.cctpBurnLastValidBlockHeight]),
|
|
21213
21225
|
onBurn: (burnSignature, lastValidBlockHeight) => this.#recordCctpBurn(swapId, burnSignature, lastValidBlockHeight),
|
|
21214
21226
|
amount,
|
|
21215
21227
|
maxFee,
|
|
21216
|
-
priorityFeeMicroLamports: _optionalChain([options, 'optionalAccess',
|
|
21217
|
-
onProgress: _optionalChain([options, 'optionalAccess',
|
|
21218
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
21228
|
+
priorityFeeMicroLamports: _optionalChain([options, 'optionalAccess', _308 => _308.priorityFeeMicroLamports]),
|
|
21229
|
+
onProgress: _optionalChain([options, 'optionalAccess', _309 => _309.onProgress]),
|
|
21230
|
+
signal: _optionalChain([options, 'optionalAccess', _310 => _310.signal])
|
|
21219
21231
|
}
|
|
21220
21232
|
);
|
|
21221
21233
|
if (cctp.transactionHash) {
|
|
@@ -21233,7 +21245,7 @@ network='${network}'`
|
|
|
21233
21245
|
* `withSolanaRpcUrl` on the builder
|
|
21234
21246
|
*/
|
|
21235
21247
|
async getSolanaUsdcBalance(owner, options) {
|
|
21236
|
-
const rpcUrl = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
21248
|
+
const rpcUrl = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _311 => _311.rpcUrl]), () => ( this.#config.solanaRpcUrl));
|
|
21237
21249
|
if (!rpcUrl) {
|
|
21238
21250
|
throw new Error(
|
|
21239
21251
|
"Reading a Solana balance needs a Solana RPC URL. Pass `rpcUrl` or call `.withSolanaRpcUrl(url)` on the ClientBuilder."
|
|
@@ -21269,7 +21281,7 @@ network='${network}'`
|
|
|
21269
21281
|
`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
21282
|
);
|
|
21271
21283
|
}
|
|
21272
|
-
_optionalChain([onQuote, 'optionalCall',
|
|
21284
|
+
_optionalChain([onQuote, 'optionalCall', _312 => _312({
|
|
21273
21285
|
sourceAmount: amount,
|
|
21274
21286
|
sourceTokenAddress: _chunkJZTF4JNHcjs.NATIVE_TOKEN_ADDRESS
|
|
21275
21287
|
})]);
|
|
@@ -21278,7 +21290,7 @@ network='${network}'`
|
|
|
21278
21290
|
"This legacy Rootstock swap requires coordinator funding. Create a new swap with the updated backend before funding."
|
|
21279
21291
|
);
|
|
21280
21292
|
}
|
|
21281
|
-
if (signer.address.toLowerCase() !== _optionalChain([swap, 'access',
|
|
21293
|
+
if (signer.address.toLowerCase() !== _optionalChain([swap, 'access', _313 => _313.client_evm_address, 'optionalAccess', _314 => _314.toLowerCase, 'call', _315 => _315()])) {
|
|
21282
21294
|
throw new Error(
|
|
21283
21295
|
"Connect the source wallet recorded on this swap to fund RBTC."
|
|
21284
21296
|
);
|
|
@@ -21309,7 +21321,7 @@ network='${network}'`
|
|
|
21309
21321
|
swapId,
|
|
21310
21322
|
signer,
|
|
21311
21323
|
[
|
|
21312
|
-
await _asyncOptionalChain([(await this.getStoredSwap(swapId)), 'optionalAccess', async
|
|
21324
|
+
await _asyncOptionalChain([(await this.getStoredSwap(swapId)), 'optionalAccess', async _316 => _316.evmFundTxid]),
|
|
21313
21325
|
swap.evm_fund_txid
|
|
21314
21326
|
],
|
|
21315
21327
|
hashLock
|
|
@@ -21378,7 +21390,7 @@ network='${network}'`
|
|
|
21378
21390
|
});
|
|
21379
21391
|
const receipt = await signer.waitForReceipt(txHash);
|
|
21380
21392
|
if (receipt.status !== "success") {
|
|
21381
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
21393
|
+
if (_optionalChain([options, 'optionalAccess', _317 => _317.forgetFailed])) await this.#forgetEvmFunding(swapId, txHash);
|
|
21382
21394
|
const reason = await _chunkTNZW35XAcjs.getRevertReason.call(void 0, signer, txHash, receipt.blockNumber);
|
|
21383
21395
|
throw new Error(`Funding transaction failed: ${reason}`);
|
|
21384
21396
|
}
|
|
@@ -21402,7 +21414,7 @@ network='${network}'`
|
|
|
21402
21414
|
}).length > 0;
|
|
21403
21415
|
}
|
|
21404
21416
|
if (!created && replaced) {
|
|
21405
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
21417
|
+
if (_optionalChain([options, 'optionalAccess', _318 => _318.forgetFailed]) && provesNoLockUnder(receipt, expected.preimageHash)) {
|
|
21406
21418
|
await this.#forgetEvmFunding(swapId, txHash);
|
|
21407
21419
|
}
|
|
21408
21420
|
throw new Error(
|
|
@@ -21592,7 +21604,7 @@ network='${network}'`
|
|
|
21592
21604
|
}
|
|
21593
21605
|
async #actualRefundTransfer(oldSwap, smartAccountAddress) {
|
|
21594
21606
|
const txHash = oldSwap.evm_claim_txid;
|
|
21595
|
-
const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access',
|
|
21607
|
+
const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access', _319 => _319.#config, 'access', _320 => _320.aa, 'optionalAccess', _321 => _321.rpcUrl]), () => ( _optionalChain([this, 'access', _322 => _322.#config, 'access', _323 => _323.aa, 'optionalAccess', _324 => _324.bundlerUrl])));
|
|
21596
21608
|
if (!txHash || !rpcUrl) return null;
|
|
21597
21609
|
const { createPublicClient: createPublicClient2, http: http2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./_esm-4ZKYBBIE-D33574DC.cjs")));
|
|
21598
21610
|
const { arbitrum: arbitrum2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./chains-D6LHJZMI-AAYKXZGC.cjs")));
|
|
@@ -21611,7 +21623,7 @@ network='${network}'`
|
|
|
21611
21623
|
const transferTopic = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
|
|
21612
21624
|
const paddedRecipient = smartAccountAddress.replace(/^0x/i, "").toLowerCase().padStart(64, "0");
|
|
21613
21625
|
const transfers = receipt.logs.filter(
|
|
21614
|
-
(log) => _optionalChain([log, 'access',
|
|
21626
|
+
(log) => _optionalChain([log, 'access', _325 => _325.topics, 'access', _326 => _326[0], 'optionalAccess', _327 => _327.toLowerCase, 'call', _328 => _328()]) === transferTopic && _optionalChain([log, 'access', _329 => _329.topics, 'access', _330 => _330[2], 'optionalAccess', _331 => _331.replace, 'call', _332 => _332(/^0x/i, ""), 'access', _333 => _333.toLowerCase, 'call', _334 => _334()]) === paddedRecipient
|
|
21615
21627
|
).map((log) => ({
|
|
21616
21628
|
tokenAddress: log.address,
|
|
21617
21629
|
amount: BigInt(log.data).toString()
|
|
@@ -21698,8 +21710,8 @@ network='${network}'`
|
|
|
21698
21710
|
{
|
|
21699
21711
|
chain: refundChain,
|
|
21700
21712
|
address: actualRefund.tokenAddress,
|
|
21701
|
-
symbol: _nullishCoalesce(_optionalChain([actualMeta, 'optionalAccess',
|
|
21702
|
-
decimals: _nullishCoalesce(_optionalChain([actualMeta, 'optionalAccess',
|
|
21713
|
+
symbol: _nullishCoalesce(_optionalChain([actualMeta, 'optionalAccess', _335 => _335.symbol]), () => ( "ERC-20")),
|
|
21714
|
+
decimals: _nullishCoalesce(_optionalChain([actualMeta, 'optionalAccess', _336 => _336.decimals]), () => ( 18)),
|
|
21703
21715
|
amount: actualRefund.amount
|
|
21704
21716
|
}
|
|
21705
21717
|
] : [],
|
|
@@ -21867,9 +21879,9 @@ network='${network}'`
|
|
|
21867
21879
|
}
|
|
21868
21880
|
const { client_evm_address: depositor, gasless } = stored.response;
|
|
21869
21881
|
let owner;
|
|
21870
|
-
if (_optionalChain([depositor, 'optionalAccess',
|
|
21882
|
+
if (_optionalChain([depositor, 'optionalAccess', _337 => _337.toLowerCase, 'call', _338 => _338()]) === this.getEvmAddress().toLowerCase()) {
|
|
21871
21883
|
owner = this.#keyOwnerSigner();
|
|
21872
|
-
} else if (gasless && _optionalChain([depositor, 'optionalAccess',
|
|
21884
|
+
} else if (gasless && _optionalChain([depositor, 'optionalAccess', _339 => _339.toLowerCase, 'call', _340 => _340()]) === deriveEvmAddress(stored.secretKey).toLowerCase()) {
|
|
21873
21885
|
owner = keyToKernelOwnerSigner(
|
|
21874
21886
|
_chunk5JR6AJ3Ycjs.hexToBytes.call(void 0, stored.secretKey.replace(/^0x/, "")),
|
|
21875
21887
|
42161
|
|
@@ -21908,7 +21920,7 @@ network='${network}'`
|
|
|
21908
21920
|
* with its key (whose signer does not read the chain).
|
|
21909
21921
|
*/
|
|
21910
21922
|
async #aaRpcCall() {
|
|
21911
|
-
const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access',
|
|
21923
|
+
const rpcUrl = _nullishCoalesce(_optionalChain([this, 'access', _341 => _341.#config, 'access', _342 => _342.aa, 'optionalAccess', _343 => _343.rpcUrl]), () => ( _optionalChain([this, 'access', _344 => _344.#config, 'access', _345 => _345.aa, 'optionalAccess', _346 => _346.bundlerUrl])));
|
|
21912
21924
|
if (!rpcUrl) {
|
|
21913
21925
|
throw new Error(
|
|
21914
21926
|
"Reading a refunded balance without a signer requires AA config (`.withAa(...)`)."
|
|
@@ -21949,7 +21961,7 @@ network='${network}'`
|
|
|
21949
21961
|
`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
21962
|
);
|
|
21951
21963
|
}
|
|
21952
|
-
if (!_optionalChain([this, 'access',
|
|
21964
|
+
if (!_optionalChain([this, 'access', _347 => _347.#config, 'access', _348 => _348.aa, 'access', _349 => _349.paymasterPolicyId, 'optionalAccess', _350 => _350.trim, 'call', _351 => _351()])) {
|
|
21953
21965
|
if (this.#config.aa.allowSelfPaidFunding) return { mode: "self-paid" };
|
|
21954
21966
|
throw new Error(
|
|
21955
21967
|
"Sponsored funding requires a paymasterPolicyId. Self-paid local tests must explicitly set allowSelfPaidFunding and prefund the account with ETH."
|
|
@@ -22029,7 +22041,7 @@ network='${network}'`
|
|
|
22029
22041
|
swapId,
|
|
22030
22042
|
serverData,
|
|
22031
22043
|
chainId,
|
|
22032
|
-
_optionalChain([options, 'optionalAccess',
|
|
22044
|
+
_optionalChain([options, 'optionalAccess', _352 => _352.funding])
|
|
22033
22045
|
);
|
|
22034
22046
|
const nonceBytes = new Uint8Array(32);
|
|
22035
22047
|
crypto.getRandomValues(nonceBytes);
|
|
@@ -22074,7 +22086,7 @@ network='${network}'`
|
|
|
22074
22086
|
delegated
|
|
22075
22087
|
);
|
|
22076
22088
|
let eip2612Permit;
|
|
22077
|
-
if (_optionalChain([serverData, 'access',
|
|
22089
|
+
if (_optionalChain([serverData, 'access', _353 => _353.eip2612, 'optionalAccess', _354 => _354.supported]) && !serverData.eip2612.already_approved) {
|
|
22078
22090
|
const maxUint256 = BigInt(
|
|
22079
22091
|
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
|
22080
22092
|
);
|
|
@@ -22182,7 +22194,7 @@ network='${network}'`
|
|
|
22182
22194
|
}
|
|
22183
22195
|
const expected = {
|
|
22184
22196
|
...this.#fundingExpectation(swapId, stored),
|
|
22185
|
-
pins: _optionalChain([options, 'optionalAccess',
|
|
22197
|
+
pins: _optionalChain([options, 'optionalAccess', _355 => _355.funding])
|
|
22186
22198
|
};
|
|
22187
22199
|
if (expected.terms.chainId !== AA_CHAIN_ID) {
|
|
22188
22200
|
throw new Error(
|
|
@@ -22194,7 +22206,7 @@ network='${network}'`
|
|
|
22194
22206
|
const { arbitrum: arbitrum2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./chains-D6LHJZMI-AAYKXZGC.cjs")));
|
|
22195
22207
|
const rpc = createPublicClient2({
|
|
22196
22208
|
chain: arbitrum2,
|
|
22197
|
-
transport: http2(_nullishCoalesce(_optionalChain([this, 'access',
|
|
22209
|
+
transport: http2(_nullishCoalesce(_optionalChain([this, 'access', _356 => _356.#config, 'access', _357 => _357.aa, 'optionalAccess', _358 => _358.rpcUrl]), () => ( _optionalChain([this, 'access', _359 => _359.#config, 'access', _360 => _360.aa, 'optionalAccess', _361 => _361.bundlerUrl]))))
|
|
22198
22210
|
});
|
|
22199
22211
|
const receipt = await rpc.getTransactionReceipt({
|
|
22200
22212
|
hash: stored.evmFundTxid
|
|
@@ -22260,7 +22272,7 @@ network='${network}'`
|
|
|
22260
22272
|
return { txHash };
|
|
22261
22273
|
}
|
|
22262
22274
|
async #setFundingUserOp(swapId, hash) {
|
|
22263
|
-
const current = await _optionalChain([this, 'access',
|
|
22275
|
+
const current = await _optionalChain([this, 'access', _362 => _362.#swapStorage, 'optionalAccess', _363 => _363.get, 'call', _364 => _364(swapId)]);
|
|
22264
22276
|
if (!current || !this.#swapStorage)
|
|
22265
22277
|
throw new Error("Cannot persist funding operation");
|
|
22266
22278
|
await this.#swapStorage.store({
|
|
@@ -22277,7 +22289,7 @@ network='${network}'`
|
|
|
22277
22289
|
* here.
|
|
22278
22290
|
*/
|
|
22279
22291
|
#gaslessDepositorKey(swapId, stored, swap) {
|
|
22280
|
-
const depositor = _optionalChain([swap, 'access',
|
|
22292
|
+
const depositor = _optionalChain([swap, 'access', _365 => _365.client_evm_address, 'optionalAccess', _366 => _366.toLowerCase, 'call', _367 => _367()]);
|
|
22281
22293
|
const sharedKey = this.#getEvmSigningKey();
|
|
22282
22294
|
if (!depositor || depositor === deriveEvmAddress(sharedKey).toLowerCase()) {
|
|
22283
22295
|
return sharedKey;
|
|
@@ -22318,7 +22330,7 @@ network='${network}'`
|
|
|
22318
22330
|
);
|
|
22319
22331
|
}
|
|
22320
22332
|
const response = storedSwap.response;
|
|
22321
|
-
const depositor = _optionalChain([response, 'access',
|
|
22333
|
+
const depositor = _optionalChain([response, 'access', _368 => _368.client_evm_address, 'optionalAccess', _369 => _369.toLowerCase, 'call', _370 => _370()]);
|
|
22322
22334
|
const sharedKey = this.#getEvmSigningKey();
|
|
22323
22335
|
const sharedAddress = deriveEvmAddress(sharedKey).toLowerCase();
|
|
22324
22336
|
const swapAddress = deriveEvmAddress(storedSwap.secretKey).toLowerCase();
|
|
@@ -22379,7 +22391,7 @@ network='${network}'`
|
|
|
22379
22391
|
if (!sourceChain) {
|
|
22380
22392
|
throw new Error(`Swap ${swapId} is not a CCTP-inbound swap.`);
|
|
22381
22393
|
}
|
|
22382
|
-
const burnTxHash = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
22394
|
+
const burnTxHash = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _371 => _371.burnTxHash]), () => ( stored.cctpBurnTxid));
|
|
22383
22395
|
if (!burnTxHash) {
|
|
22384
22396
|
throw new Error(
|
|
22385
22397
|
`No CCTP burn is recorded for swap ${swapId}; pass it as \`burnTxHash\`.`
|
|
@@ -22390,13 +22402,13 @@ network='${network}'`
|
|
|
22390
22402
|
{
|
|
22391
22403
|
signer: this.#depositorOwnerSigner(
|
|
22392
22404
|
stored.response,
|
|
22393
|
-
_optionalChain([options, 'optionalAccess',
|
|
22405
|
+
_optionalChain([options, 'optionalAccess', _372 => _372.ownerSigner])
|
|
22394
22406
|
),
|
|
22395
22407
|
burnTxHash,
|
|
22396
22408
|
sourceChain,
|
|
22397
22409
|
recipient,
|
|
22398
|
-
onProgress: _optionalChain([options, 'optionalAccess',
|
|
22399
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
22410
|
+
onProgress: _optionalChain([options, 'optionalAccess', _373 => _373.onProgress]),
|
|
22411
|
+
signal: _optionalChain([options, 'optionalAccess', _374 => _374.signal])
|
|
22400
22412
|
}
|
|
22401
22413
|
);
|
|
22402
22414
|
}
|
|
@@ -22540,14 +22552,14 @@ function b64Encode(u) {
|
|
|
22540
22552
|
return btoa(bin);
|
|
22541
22553
|
}
|
|
22542
22554
|
function isP2tr(script) {
|
|
22543
|
-
return _optionalChain([script, 'optionalAccess',
|
|
22555
|
+
return _optionalChain([script, 'optionalAccess', _375 => _375.length]) === 34 && script[0] === 81 && script[1] === 32;
|
|
22544
22556
|
}
|
|
22545
22557
|
function parseEscrowPsbt(psbt) {
|
|
22546
22558
|
const lenient = _chunkBEW62OUTcjs.Transaction2.fromPSBT(psbt, { disableScriptCheck: true });
|
|
22547
22559
|
let stripped = false;
|
|
22548
22560
|
for (let i = 0; i < lenient.inputsLength; i++) {
|
|
22549
22561
|
const input = lenient.getInput(i);
|
|
22550
|
-
if (input.witnessScript && isP2tr(_optionalChain([input, 'access',
|
|
22562
|
+
if (input.witnessScript && isP2tr(_optionalChain([input, 'access', _376 => _376.witnessUtxo, 'optionalAccess', _377 => _377.script]))) {
|
|
22551
22563
|
lenient.updateInput(i, { witnessScript: void 0 }, true);
|
|
22552
22564
|
stripped = true;
|
|
22553
22565
|
}
|
|
@@ -22679,11 +22691,11 @@ var IdbWalletStorage = class {
|
|
|
22679
22691
|
}
|
|
22680
22692
|
async getMnemonic() {
|
|
22681
22693
|
const record = await this.#db.wallet.get(MNEMONIC_KEY);
|
|
22682
|
-
if (_optionalChain([record, 'optionalAccess',
|
|
22694
|
+
if (_optionalChain([record, 'optionalAccess', _378 => _378.value])) {
|
|
22683
22695
|
return record.value;
|
|
22684
22696
|
}
|
|
22685
22697
|
const v2Wallet = await readV2Wallet();
|
|
22686
|
-
if (!_optionalChain([v2Wallet, 'optionalAccess',
|
|
22698
|
+
if (!_optionalChain([v2Wallet, 'optionalAccess', _379 => _379.mnemonic])) {
|
|
22687
22699
|
return null;
|
|
22688
22700
|
}
|
|
22689
22701
|
await this.setMnemonic(v2Wallet.mnemonic);
|
|
@@ -22698,7 +22710,7 @@ var IdbWalletStorage = class {
|
|
|
22698
22710
|
}
|
|
22699
22711
|
async getKeyIndex() {
|
|
22700
22712
|
const record = await this.#db.wallet.get(KEY_INDEX_KEY);
|
|
22701
|
-
return _nullishCoalesce(_optionalChain([record, 'optionalAccess',
|
|
22713
|
+
return _nullishCoalesce(_optionalChain([record, 'optionalAccess', _380 => _380.value]), () => ( 0));
|
|
22702
22714
|
}
|
|
22703
22715
|
async setKeyIndex(index) {
|
|
22704
22716
|
await this.#db.wallet.put({ key: KEY_INDEX_KEY, value: index });
|
|
@@ -22706,7 +22718,7 @@ var IdbWalletStorage = class {
|
|
|
22706
22718
|
async incrementKeyIndex() {
|
|
22707
22719
|
return this.#db.transaction("rw", this.#db.wallet, async () => {
|
|
22708
22720
|
const record = await this.#db.wallet.get(KEY_INDEX_KEY);
|
|
22709
|
-
const current = _nullishCoalesce(_optionalChain([record, 'optionalAccess',
|
|
22721
|
+
const current = _nullishCoalesce(_optionalChain([record, 'optionalAccess', _381 => _381.value]), () => ( 0));
|
|
22710
22722
|
await this.#db.wallet.put({ key: KEY_INDEX_KEY, value: current + 1 });
|
|
22711
22723
|
return current;
|
|
22712
22724
|
});
|
|
@@ -22762,7 +22774,7 @@ function readV2Wallet() {
|
|
|
22762
22774
|
}
|
|
22763
22775
|
const request = indexedDB.open(V2_DB_NAME);
|
|
22764
22776
|
request.onupgradeneeded = () => {
|
|
22765
|
-
_optionalChain([request, 'access',
|
|
22777
|
+
_optionalChain([request, 'access', _382 => _382.transaction, 'optionalAccess', _383 => _383.abort, 'call', _384 => _384()]);
|
|
22766
22778
|
};
|
|
22767
22779
|
request.onerror = () => {
|
|
22768
22780
|
resolve(null);
|
|
@@ -22993,4 +23005,4 @@ exports.createApiClient = createApiClient; exports.getVhtlcAmounts = getVhtlcAmo
|
|
|
22993
23005
|
@scure/bip39/index.js:
|
|
22994
23006
|
(*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
22995
23007
|
*/
|
|
22996
|
-
//# sourceMappingURL=chunk-
|
|
23008
|
+
//# sourceMappingURL=chunk-4NVWIR74.cjs.map
|