four-flap-meme-sdk 1.2.82 → 1.2.83
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.
|
@@ -86,30 +86,49 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
86
86
|
const tmBuyAddr = ADDRESSES.BSC.TokenManagerOriginal;
|
|
87
87
|
const b0AmountWei = ethers.parseEther(params.b0Amount ?? '0');
|
|
88
88
|
const preSaleWei = tokenInfo.preSale ? ethers.parseEther(tokenInfo.preSale) : 0n;
|
|
89
|
-
const
|
|
90
|
-
// ✅ 单笔交易: value = 创建费用 + b0Amount + preSale + 买入金额
|
|
91
|
-
const valueWei = PLATFORM_CREATE_FEE + b0AmountWei + preSaleWei + buyAmountWei;
|
|
89
|
+
const valueWei = PLATFORM_CREATE_FEE + b0AmountWei + preSaleWei;
|
|
92
90
|
const tmCreate = new ethers.Contract(tmCreateAddr, TM2_ABI, devWallet);
|
|
93
|
-
|
|
94
|
-
// Four.meme 合约会自动处理: 如果 value 大于创建费用,会自动买入
|
|
95
|
-
const createTxUnsigned = await tmCreate.createToken.populateTransaction(createResp.createArg, createResp.signature, { value: valueWei } // ✅ 包含买入金额
|
|
96
|
-
);
|
|
91
|
+
const createTxUnsigned = await tmCreate.createToken.populateTransaction(createResp.createArg, createResp.signature, { value: valueWei });
|
|
97
92
|
const createTxRequest = {
|
|
98
93
|
...createTxUnsigned,
|
|
99
94
|
from: devWallet.address,
|
|
100
95
|
nonce: await nonceManager.getNextNonce(devWallet),
|
|
101
|
-
gasLimit: getGasLimit(config
|
|
96
|
+
gasLimit: getGasLimit(config),
|
|
102
97
|
gasPrice,
|
|
103
98
|
chainId,
|
|
104
99
|
type: getTxType(config),
|
|
105
100
|
value: valueWei
|
|
106
101
|
};
|
|
107
102
|
signedTxs.push(await devWallet.signTransaction(createTxRequest));
|
|
103
|
+
// ✅ Four.meme Bundle 机制:使用 0x0 地址作为占位符
|
|
104
|
+
// ⚠️ 关键:这2笔交易必须在同一个 Bundle 中原子执行!
|
|
105
|
+
const predictedTokenAddress = ZERO_ADDRESS;
|
|
106
|
+
console.log('✅ 使用 Four.meme Bundle 机制:0x0 地址将在 Bundle 执行时被解析为新创建的代币地址');
|
|
107
|
+
// ✅ 生成创建者的买入交易
|
|
108
|
+
const creatorBuyAmountWei = ethers.parseEther(buyAmounts[0]);
|
|
109
|
+
const tmBuy = new ethers.Contract(tmBuyAddr, TM2_ABI, devWallet);
|
|
110
|
+
const buyTxUnsigned = await tmBuy.buyTokenAMAP.populateTransaction(0, // origin
|
|
111
|
+
predictedTokenAddress, // token (0x0 占位符)
|
|
112
|
+
devWallet.address, // to
|
|
113
|
+
creatorBuyAmountWei, // funds
|
|
114
|
+
0n, // minAmount
|
|
115
|
+
{ value: creatorBuyAmountWei });
|
|
116
|
+
const buyTxRequest = {
|
|
117
|
+
...buyTxUnsigned,
|
|
118
|
+
from: devWallet.address,
|
|
119
|
+
nonce: await nonceManager.getNextNonce(devWallet),
|
|
120
|
+
gasLimit: getGasLimit(config),
|
|
121
|
+
gasPrice,
|
|
122
|
+
chainId,
|
|
123
|
+
type: txType,
|
|
124
|
+
value: creatorBuyAmountWei
|
|
125
|
+
};
|
|
126
|
+
signedTxs.push(await devWallet.signTransaction(buyTxRequest));
|
|
108
127
|
nonceManager.clearTemp();
|
|
109
|
-
console.log(`✅
|
|
128
|
+
console.log(`✅ 总共生成了 ${signedTxs.length} 个交易签名 (1创建 + 1买入)`);
|
|
110
129
|
// ⚠️ 只返回签名交易,不提交
|
|
111
130
|
console.log('📦 交易已签名完成');
|
|
112
|
-
console.log('
|
|
131
|
+
console.log('⚠️ 重要: 这2笔交易必须通过 48.club Bundle 原子提交,不能单独提交!');
|
|
113
132
|
return {
|
|
114
133
|
signedTransactions: signedTxs,
|
|
115
134
|
tokenAddress: ZERO_ADDRESS, // ⚠️ 占位符,实际地址需要等交易确认后从事件解析
|