four-flap-meme-sdk 1.4.57 → 1.4.58
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.
|
@@ -669,13 +669,14 @@ export async function fourQuickBatchSwapMerkle(params) {
|
|
|
669
669
|
}
|
|
670
670
|
else {
|
|
671
671
|
// ✅ 有多跳:构建多跳转账链
|
|
672
|
+
// ✅ 修复:payer 每次只发送 1 笔交易(到第一个hop钱包),hop钱包用自己的nonce=0
|
|
672
673
|
const hopChains = await Promise.all(hopPaths.map((path, i) => {
|
|
673
674
|
const finalAmount = transferAmountsWei[i] + reserveGas + buyerGasCost;
|
|
674
|
-
const payerNonce = sellerNonce + i
|
|
675
|
+
const payerNonce = sellerNonce + i; // ✅ payer 每个 buyer 只用 1 个 nonce
|
|
675
676
|
return buildNativeHopChain(seller, path, finalAmount, gasPrice, chainIdNum, txType, payerNonce);
|
|
676
677
|
}));
|
|
677
678
|
transferTxs = hopChains.flat();
|
|
678
|
-
sellerNonce += buyers.length
|
|
679
|
+
sellerNonce += buyers.length; // ✅ payer 只增加 buyers.length 个 nonce
|
|
679
680
|
}
|
|
680
681
|
console.log(`[fourQuickBatchSwapMerkle] ${transferTxs.length} 笔转账交易已签名 (多跳数=${disperseHopCount})`);
|
|
681
682
|
// ==================== 4. 买入交易 ====================
|
|
@@ -1091,31 +1091,33 @@ export async function flapQuickBatchSwapMerkle(params) {
|
|
|
1091
1091
|
// ✅ 有多跳:构建多跳转账链
|
|
1092
1092
|
if (useNativeToken) {
|
|
1093
1093
|
// 原生代币多跳转账
|
|
1094
|
+
// ✅ 修复:payer 每次只发送 1 笔交易(到第一个hop钱包),hop钱包用自己的nonce=0
|
|
1094
1095
|
const hopChains = await Promise.all(hopPaths.map((path, i) => {
|
|
1095
1096
|
const finalAmount = transferAmountsWei[i] + reserveGas + buyerGasCost;
|
|
1096
|
-
const payerNonce = sellerNonce + i
|
|
1097
|
+
const payerNonce = sellerNonce + i; // ✅ payer 每个 buyer 只用 1 个 nonce
|
|
1097
1098
|
return buildNativeHopChain(seller, path, finalAmount, gasPrice, chainContext.chainId, txType, payerNonce);
|
|
1098
1099
|
}));
|
|
1099
1100
|
transferTxs = hopChains.flat();
|
|
1100
|
-
sellerNonce += buyers.length
|
|
1101
|
+
sellerNonce += buyers.length; // ✅ payer 只增加 buyers.length 个 nonce
|
|
1101
1102
|
}
|
|
1102
1103
|
else {
|
|
1103
1104
|
// ERC20 多跳转账:先转 BNB(给中间钱包 gas),再转 ERC20
|
|
1105
|
+
// ✅ 修复:payer 每次只发送 1 笔交易(到第一个hop钱包),hop钱包用自己的nonce=0/1
|
|
1104
1106
|
// 1. 构建 BNB 多跳链
|
|
1105
1107
|
const bnbHopChains = await Promise.all(hopPaths.map((path, i) => {
|
|
1106
1108
|
const finalGasAmount = buyerGasCost;
|
|
1107
|
-
const payerNonce = sellerNonce + i
|
|
1109
|
+
const payerNonce = sellerNonce + i; // ✅ payer 每个 buyer 只用 1 个 nonce
|
|
1108
1110
|
return buildBNBHopChainForERC20(seller, path, finalGasAmount, gasPrice, chainContext.chainId, txType, payerNonce);
|
|
1109
1111
|
}));
|
|
1110
1112
|
const bnbTxs = bnbHopChains.flat();
|
|
1111
|
-
sellerNonce += buyers.length
|
|
1113
|
+
sellerNonce += buyers.length; // ✅ payer 只增加 buyers.length 个 nonce
|
|
1112
1114
|
// 2. 构建 ERC20 多跳链
|
|
1113
1115
|
const erc20HopChains = await Promise.all(hopPaths.map((path, i) => {
|
|
1114
|
-
const payerNonce = sellerNonce + i
|
|
1116
|
+
const payerNonce = sellerNonce + i; // ✅ payer 每个 buyer 只用 1 个 nonce
|
|
1115
1117
|
return buildERC20HopChain(seller, path, quoteToken, transferAmountsWei[i], gasPrice, chainContext.chainId, txType, payerNonce);
|
|
1116
1118
|
}));
|
|
1117
1119
|
const erc20Txs = erc20HopChains.flat();
|
|
1118
|
-
sellerNonce += buyers.length
|
|
1120
|
+
sellerNonce += buyers.length; // ✅ payer 只增加 buyers.length 个 nonce
|
|
1119
1121
|
transferTxs = [...bnbTxs, ...erc20Txs];
|
|
1120
1122
|
}
|
|
1121
1123
|
}
|
|
@@ -1316,33 +1316,34 @@ export async function pancakeQuickBatchSwapMerkle(params) {
|
|
|
1316
1316
|
// ✅ 有多跳:构建多跳转账链
|
|
1317
1317
|
if (useNativeToken) {
|
|
1318
1318
|
// BNB 多跳转账
|
|
1319
|
+
// ✅ 修复:payer 每次只发送 1 笔交易(到第一个hop钱包),hop钱包用自己的nonce=0
|
|
1319
1320
|
const hopChains = await Promise.all(hopPaths.map((path, i) => {
|
|
1320
1321
|
const finalAmount = transferAmountsWei[i] + FLAT_FEE + buyerGasCost;
|
|
1321
|
-
const payerNonce = sellerNonce + i
|
|
1322
|
+
const payerNonce = sellerNonce + i; // ✅ payer 每个 buyer 只用 1 个 nonce
|
|
1322
1323
|
return buildNativeHopChain(seller, path, finalAmount, gasPrice, context.chainId, txType, payerNonce);
|
|
1323
1324
|
}));
|
|
1324
1325
|
transferTxs = hopChains.flat();
|
|
1325
|
-
sellerNonce += buyers.length
|
|
1326
|
+
sellerNonce += buyers.length; // ✅ payer 只增加 buyers.length 个 nonce
|
|
1326
1327
|
}
|
|
1327
1328
|
else {
|
|
1328
1329
|
// ERC20 多跳转账:先转 BNB(给中间钱包 gas),再转 ERC20
|
|
1329
|
-
//
|
|
1330
|
+
// ✅ 修复:payer 每次只发送 1 笔交易(到第一个hop钱包),hop钱包用自己的nonce=0/1
|
|
1330
1331
|
// 1. 构建 BNB 多跳链(为中间钱包和最终钱包预留 gas)
|
|
1331
1332
|
const bnbHopChains = await Promise.all(hopPaths.map((path, i) => {
|
|
1332
1333
|
// 最终钱包需要的 gas(用于买入交易)
|
|
1333
1334
|
const finalGasAmount = buyerGasCost;
|
|
1334
|
-
const payerNonce = sellerNonce + i
|
|
1335
|
+
const payerNonce = sellerNonce + i; // ✅ payer 每个 buyer 只用 1 个 nonce
|
|
1335
1336
|
return buildBNBHopChainForERC20(seller, path, finalGasAmount, gasPrice, context.chainId, txType, payerNonce);
|
|
1336
1337
|
}));
|
|
1337
1338
|
const bnbTxs = bnbHopChains.flat();
|
|
1338
|
-
sellerNonce += buyers.length
|
|
1339
|
+
sellerNonce += buyers.length; // ✅ payer 只增加 buyers.length 个 nonce
|
|
1339
1340
|
// 2. 构建 ERC20 多跳链
|
|
1340
1341
|
const erc20HopChains = await Promise.all(hopPaths.map((path, i) => {
|
|
1341
|
-
const payerNonce = sellerNonce + i
|
|
1342
|
+
const payerNonce = sellerNonce + i; // ✅ payer 每个 buyer 只用 1 个 nonce
|
|
1342
1343
|
return buildERC20HopChain(seller, path, quoteToken, transferAmountsWei[i], gasPrice, context.chainId, txType, payerNonce);
|
|
1343
1344
|
}));
|
|
1344
1345
|
const erc20Txs = erc20HopChains.flat();
|
|
1345
|
-
sellerNonce += buyers.length
|
|
1346
|
+
sellerNonce += buyers.length; // ✅ payer 只增加 buyers.length 个 nonce
|
|
1346
1347
|
transferTxs = [...bnbTxs, ...erc20Txs];
|
|
1347
1348
|
}
|
|
1348
1349
|
}
|