four-flap-meme-sdk 1.3.6 → 1.3.8

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.
@@ -171,16 +171,22 @@ export class MerkleClient {
171
171
  minTimestamp: options.minTimestamp,
172
172
  maxTimestamp: options.maxTimestamp,
173
173
  });
174
- // ✅ 优化:并行提取所有交易哈希
175
- const txHashes = options.transactions.map(rawTx => {
174
+ // 提取交易哈希(添加异常处理)
175
+ const txHashes = [];
176
+ for (let i = 0; i < options.transactions.length; i++) {
176
177
  try {
177
- const tx = Transaction.from(rawTx);
178
- return tx.hash || '';
178
+ const tx = Transaction.from(options.transactions[i]);
179
+ if (tx.hash) {
180
+ txHashes.push(tx.hash);
181
+ }
182
+ else {
183
+ txHashes.push('');
184
+ }
179
185
  }
180
- catch {
181
- return '';
186
+ catch (error) {
187
+ txHashes.push('');
182
188
  }
183
- });
189
+ }
184
190
  return {
185
191
  bundleHash,
186
192
  txHashes,
@@ -14,9 +14,9 @@ export interface MerkleSubmitConfig {
14
14
  customRpcUrl?: string;
15
15
  /** 链ID(可选,默认56=BSC) */
16
16
  chainId?: 56 | 1;
17
- /** Bundle区块偏移量(可选,默认1,BSC约3秒后打包) */
17
+ /** Bundle区块偏移量(可选,默认3 */
18
18
  bundleBlockOffset?: number;
19
- /** 最小区块偏移量(可选,默认1) */
19
+ /** 最小区块偏移量(可选,默认3) */
20
20
  minBlockOffset?: number;
21
21
  /** 是否自动重试(可选,默认false) */
22
22
  autoRetryBundle?: boolean;
@@ -6,21 +6,6 @@
6
6
  */
7
7
  import { MerkleClient } from '../../clients/merkle.js';
8
8
  import { ethers } from 'ethers';
9
- // ✅ MerkleClient 缓存,避免重复创建 Provider
10
- const merkleClientCache = new Map();
11
- function getMerkleClient(config) {
12
- const cacheKey = `${config.apiKey}-${config.chainId ?? 56}-${config.customRpcUrl ?? ''}`;
13
- let client = merkleClientCache.get(cacheKey);
14
- if (!client) {
15
- client = new MerkleClient({
16
- apiKey: config.apiKey,
17
- chainId: config.chainId ?? 56,
18
- customRpcUrl: config.customRpcUrl
19
- });
20
- merkleClientCache.set(cacheKey, client);
21
- }
22
- return client;
23
- }
24
9
  /**
25
10
  * 提交已签名的交易到Merkle(服务器端使用)
26
11
  *
@@ -67,17 +52,17 @@ export async function submitBundleToMerkle(signedTransactions, config) {
67
52
  error: 'apiKey is required in config'
68
53
  };
69
54
  }
70
- // ✅ 优化:使用缓存的 MerkleClient,避免重复创建 Provider
71
- const merkle = getMerkleClient(config);
72
- // ✅ 获取 Merkle RPC 当前区块,目标区块 = 当前区块 + 1(最快速度)
73
- const currentBlock = await merkle.getBlockNumber();
74
- const blockOffset = config.bundleBlockOffset ?? 1; // 默认偏移 1
75
- const targetBlock = currentBlock + blockOffset;
55
+ // 初始化Merkle客户端
56
+ const merkle = new MerkleClient({
57
+ apiKey: config.apiKey,
58
+ chainId: config.chainId ?? 56,
59
+ customRpcUrl: config.customRpcUrl
60
+ });
61
+ // 提交Bundle
76
62
  const bundleResult = await merkle.sendBundle({
77
63
  transactions: signedTransactions,
78
- targetBlock, // 直接指定目标区块
79
- blockOffset,
80
- minBlockOffset: config.minBlockOffset ?? 1,
64
+ blockOffset: config.bundleBlockOffset ?? 3,
65
+ minBlockOffset: config.minBlockOffset ?? 3,
81
66
  autoRetry: config.autoRetryBundle ?? false,
82
67
  maxRetries: config.maxBundleRetries ?? 2
83
68
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",