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
- // ✅ 内部提交到 48.club Bundle
145
- console.log('📡 开始提交到 48.club Bundle...');
146
- let bundleUuid;
147
- if (config.customSubmitFn) {
148
- // ✅ 方式 1:使用自定义提交函数(通过服务器代理)
149
- bundleUuid = await config.customSubmitFn(signedTxs);
150
- console.log(`✅ Bundle 提交成功!UUID: ${bundleUuid}`);
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
- else {
153
- // ✅ 方式 2:使用免费的 eth_sendBundle(不需要 48SP 签名)
154
- console.log('📡 使用免费 Bundle 提交...');
155
- const endpoint = config.club48Endpoint || 'https://puissant-bsc.48.club';
156
- const bundleParams = {
157
- txs: signedTxs,
158
- maxTimestamp: Math.floor(Date.now() / 1000) + 300, // 5 分钟有效期
159
- revertingTxHashes: []
160
- };
161
- const response = await axios.post(endpoint, {
162
- jsonrpc: "2.0",
163
- id: 1,
164
- method: "eth_sendBundle",
165
- params: [bundleParams]
166
- });
167
- if (response.data.error) {
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
- bundleUuid = response.data.result;
171
- console.log(`✅ 免费 Bundle 提交成功!UUID: ${bundleUuid}`);
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
- bundleUuid
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
- /** Bundle UUID(内部提交时返回) */
74
- bundleUuid?: string;
73
+ /** 交易哈希数组(内部提交时返回) */
74
+ txHashes?: string[];
75
75
  };
76
76
  /** ✅ 创建代币 + 购买参数(Merkle 版本 - 完整) */
77
77
  export type FourCreateWithBundleBuyMerkleParams = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.2.73",
3
+ "version": "1.2.74",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",