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.
package/dist/clients/merkle.js
CHANGED
|
@@ -171,16 +171,22 @@ export class MerkleClient {
|
|
|
171
171
|
minTimestamp: options.minTimestamp,
|
|
172
172
|
maxTimestamp: options.maxTimestamp,
|
|
173
173
|
});
|
|
174
|
-
//
|
|
175
|
-
const txHashes =
|
|
174
|
+
// 提取交易哈希(添加异常处理)
|
|
175
|
+
const txHashes = [];
|
|
176
|
+
for (let i = 0; i < options.transactions.length; i++) {
|
|
176
177
|
try {
|
|
177
|
-
const tx = Transaction.from(
|
|
178
|
-
|
|
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
|
-
|
|
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区块偏移量(可选,默认
|
|
17
|
+
/** Bundle区块偏移量(可选,默认3) */
|
|
18
18
|
bundleBlockOffset?: number;
|
|
19
|
-
/** 最小区块偏移量(可选,默认
|
|
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
|
-
//
|
|
71
|
-
const merkle =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
79
|
-
|
|
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
|
});
|