four-flap-meme-sdk 1.2.73 → 1.2.74
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.
|
@@ -141,42 +141,83 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
141
141
|
}
|
|
142
142
|
nonceManager.clearTemp();
|
|
143
143
|
console.log(`✅ 总共生成了 ${signedTxs.length} 个交易签名 (1创建 + ${buyerKeys.length}买入 + 利润)`);
|
|
144
|
-
// ✅
|
|
145
|
-
console.log('📡
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
144
|
+
// ✅ 使用 48.club 的 eth_sendRawTransaction 捆绑提交
|
|
145
|
+
console.log('📡 开始通过 48.club 捆绑提交交易...');
|
|
146
|
+
const club48Endpoint = config.club48Endpoint || 'https://puissant-bsc.48.club';
|
|
147
|
+
const txHashes = [];
|
|
148
|
+
// ✅ 使用 eth_sendRawTransaction 逐个提交(48.club 会自动捆绑连续的交易)
|
|
149
|
+
for (let i = 0; i < signedTxs.length; i++) {
|
|
150
|
+
try {
|
|
151
|
+
const tx = signedTxs[i];
|
|
152
|
+
console.log(`📤 提交第 ${i + 1}/${signedTxs.length} 个交易...`);
|
|
153
|
+
const response = await axios.post(club48Endpoint, {
|
|
154
|
+
jsonrpc: "2.0",
|
|
155
|
+
id: i + 1,
|
|
156
|
+
method: "eth_sendRawTransaction",
|
|
157
|
+
params: [tx]
|
|
158
|
+
});
|
|
159
|
+
if (response.data.error) {
|
|
160
|
+
throw new Error(`交易 ${i + 1} 提交失败: ${response.data.error.message}`);
|
|
161
|
+
}
|
|
162
|
+
const txHash = response.data.result;
|
|
163
|
+
txHashes.push(txHash);
|
|
164
|
+
console.log(`✅ 交易 ${i + 1} 提交成功: ${txHash}`);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
console.error(`❌ 交易 ${i + 1} 提交失败:`, error.message);
|
|
168
|
+
throw new Error(`交易 ${i + 1} 提交失败: ${error.message}`);
|
|
169
|
+
}
|
|
151
170
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
throw new Error(`48.club bundle 提交失败: ${response.data.error.message}`);
|
|
171
|
+
console.log(`✅ 所有交易提交成功!共 ${txHashes.length} 笔`);
|
|
172
|
+
// 等待创建交易确认并解析代币地址
|
|
173
|
+
console.log('⏳ 等待创建交易确认并解析代币地址...');
|
|
174
|
+
const createTxHash = txHashes[0];
|
|
175
|
+
// 使用公共 RPC 查询交易收据(避免 CORS)
|
|
176
|
+
let receipt = null;
|
|
177
|
+
let retries = 0;
|
|
178
|
+
const maxRetries = 60; // 最多等待 60 秒
|
|
179
|
+
while (!receipt && retries < maxRetries) {
|
|
180
|
+
try {
|
|
181
|
+
receipt = await provider.getTransactionReceipt(createTxHash);
|
|
182
|
+
if (receipt)
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
catch (e) {
|
|
186
|
+
// 忽略查询错误
|
|
169
187
|
}
|
|
170
|
-
|
|
171
|
-
|
|
188
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
189
|
+
retries++;
|
|
190
|
+
if (retries % 5 === 0) {
|
|
191
|
+
console.log(`⏳ 等待交易确认... (${retries}/${maxRetries})`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (!receipt) {
|
|
195
|
+
throw new Error('等待交易确认超时');
|
|
196
|
+
}
|
|
197
|
+
console.log(`✅ 创建交易已确认,区块: ${receipt.blockNumber}`);
|
|
198
|
+
// 解析 TokenCreated 事件
|
|
199
|
+
let tokenAddress;
|
|
200
|
+
for (const log of receipt.logs) {
|
|
201
|
+
try {
|
|
202
|
+
// TokenCreated(address indexed token, ...)
|
|
203
|
+
if (log.topics[0] === ethers.id('TokenCreated(address,address,string,string,uint256,uint256,uint256)')) {
|
|
204
|
+
tokenAddress = ethers.getAddress('0x' + log.topics[1].slice(26));
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
catch (e) {
|
|
209
|
+
// 忽略解析错误
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (!tokenAddress) {
|
|
213
|
+
throw new Error('无法从交易收据中解析代币地址');
|
|
172
214
|
}
|
|
173
|
-
|
|
174
|
-
const tokenAddress = await waitAndParseTokenAddress(provider, signedTxs[0], bundleUuid);
|
|
215
|
+
console.log(`✅ 代币地址: ${tokenAddress}`);
|
|
175
216
|
return {
|
|
176
217
|
signedTransactions: signedTxs,
|
|
177
218
|
tokenAddress,
|
|
178
219
|
metadata,
|
|
179
|
-
|
|
220
|
+
txHashes
|
|
180
221
|
};
|
|
181
222
|
}
|
|
182
223
|
/**
|
|
@@ -70,8 +70,8 @@ export type MerkleSignedResult = {
|
|
|
70
70
|
metadata?: {
|
|
71
71
|
[key: string]: any;
|
|
72
72
|
};
|
|
73
|
-
/**
|
|
74
|
-
|
|
73
|
+
/** 交易哈希数组(内部提交时返回) */
|
|
74
|
+
txHashes?: string[];
|
|
75
75
|
};
|
|
76
76
|
/** ✅ 创建代币 + 购买参数(Merkle 版本 - 完整) */
|
|
77
77
|
export type FourCreateWithBundleBuyMerkleParams = {
|