four-flap-meme-sdk 1.3.78 → 1.3.79
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.
|
@@ -138,9 +138,9 @@ export interface IncentiveTransactionParams {
|
|
|
138
138
|
*/
|
|
139
139
|
export declare class BlockRazorClient {
|
|
140
140
|
private provider;
|
|
141
|
-
private builderProvider;
|
|
142
141
|
private chainId;
|
|
143
142
|
private apiKey?;
|
|
143
|
+
private builderUrl;
|
|
144
144
|
private blockNumberCache;
|
|
145
145
|
private static BLOCK_CACHE_TTL_MS;
|
|
146
146
|
constructor(config: BlockRazorConfig);
|
|
@@ -149,9 +149,9 @@ export declare class BlockRazorClient {
|
|
|
149
149
|
*/
|
|
150
150
|
getProvider(): JsonRpcProvider;
|
|
151
151
|
/**
|
|
152
|
-
* 获取 Builder
|
|
152
|
+
* 获取 Builder URL
|
|
153
153
|
*/
|
|
154
|
-
|
|
154
|
+
getBuilderUrl(): string;
|
|
155
155
|
/**
|
|
156
156
|
* 获取当前区块号(带缓存)
|
|
157
157
|
*/
|
|
@@ -172,6 +172,8 @@ export declare class BlockRazorClient {
|
|
|
172
172
|
/**
|
|
173
173
|
* 发送捆绑交易(底层方法)
|
|
174
174
|
*
|
|
175
|
+
* ✅ 使用 fetch 直接发送请求,支持 Authorization 头
|
|
176
|
+
*
|
|
175
177
|
* @param params Bundle 参数
|
|
176
178
|
* @returns Bundle Hash
|
|
177
179
|
*/
|
|
@@ -37,9 +37,10 @@ import { JsonRpcProvider, Transaction, ethers } from 'ethers';
|
|
|
37
37
|
export const BLOCKRAZOR_BUILDER_EOA = '0x1266C6bE60392A8Ff346E8d5ECCd3E69dD9c5F20';
|
|
38
38
|
/**
|
|
39
39
|
* BlockRazor BSC RPC 端点
|
|
40
|
+
* 来源: 测试文件 008_blockrazor_smoke_test.ts
|
|
40
41
|
*/
|
|
41
42
|
const BLOCKRAZOR_RPC_ENDPOINTS = {
|
|
42
|
-
BSC: 'https://
|
|
43
|
+
BSC: 'https://rpc.blockrazor.builders',
|
|
43
44
|
// 可以添加其他链的端点
|
|
44
45
|
};
|
|
45
46
|
/**
|
|
@@ -64,12 +65,9 @@ export class BlockRazorClient {
|
|
|
64
65
|
chainId: this.chainId,
|
|
65
66
|
name: 'bsc',
|
|
66
67
|
});
|
|
67
|
-
// Builder RPC(用于发送 Bundle)
|
|
68
|
-
|
|
69
|
-
this.
|
|
70
|
-
chainId: this.chainId,
|
|
71
|
-
name: 'bsc',
|
|
72
|
-
});
|
|
68
|
+
// Builder RPC URL(用于发送 Bundle)
|
|
69
|
+
// ✅ 正确的端点: https://rpc.blockrazor.builders
|
|
70
|
+
this.builderUrl = config.builderRpcUrl || BLOCKRAZOR_RPC_ENDPOINTS.BSC;
|
|
73
71
|
}
|
|
74
72
|
/**
|
|
75
73
|
* 获取 Provider
|
|
@@ -78,10 +76,10 @@ export class BlockRazorClient {
|
|
|
78
76
|
return this.provider;
|
|
79
77
|
}
|
|
80
78
|
/**
|
|
81
|
-
* 获取 Builder
|
|
79
|
+
* 获取 Builder URL
|
|
82
80
|
*/
|
|
83
|
-
|
|
84
|
-
return this.
|
|
81
|
+
getBuilderUrl() {
|
|
82
|
+
return this.builderUrl;
|
|
85
83
|
}
|
|
86
84
|
/**
|
|
87
85
|
* 获取当前区块号(带缓存)
|
|
@@ -137,6 +135,8 @@ export class BlockRazorClient {
|
|
|
137
135
|
/**
|
|
138
136
|
* 发送捆绑交易(底层方法)
|
|
139
137
|
*
|
|
138
|
+
* ✅ 使用 fetch 直接发送请求,支持 Authorization 头
|
|
139
|
+
*
|
|
140
140
|
* @param params Bundle 参数
|
|
141
141
|
* @returns Bundle Hash
|
|
142
142
|
*/
|
|
@@ -179,23 +179,48 @@ export class BlockRazorClient {
|
|
|
179
179
|
}
|
|
180
180
|
try {
|
|
181
181
|
console.log(`📦 [BlockRazor] 发送 Bundle: ${params.txs.length} 笔交易`);
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
// ✅ 使用 fetch 发送请求,支持 Authorization 头
|
|
183
|
+
const requestBody = {
|
|
184
|
+
jsonrpc: '2.0',
|
|
185
|
+
id: '1',
|
|
186
|
+
method: 'eth_sendBundle',
|
|
187
|
+
params: [bundleParams]
|
|
188
|
+
};
|
|
189
|
+
const headers = {
|
|
190
|
+
'Content-Type': 'application/json',
|
|
191
|
+
};
|
|
192
|
+
// 如果有 API Key,添加 Authorization 头
|
|
193
|
+
if (this.apiKey) {
|
|
194
|
+
headers['Authorization'] = this.apiKey;
|
|
187
195
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
+
const response = await fetch(this.builderUrl, {
|
|
197
|
+
method: 'POST',
|
|
198
|
+
headers,
|
|
199
|
+
body: JSON.stringify(requestBody),
|
|
200
|
+
});
|
|
201
|
+
if (!response.ok) {
|
|
202
|
+
const text = await response.text();
|
|
203
|
+
throw new Error(`HTTP ${response.status}: ${text}`);
|
|
204
|
+
}
|
|
205
|
+
const result = await response.json();
|
|
206
|
+
// 检查 JSON-RPC 错误
|
|
207
|
+
if (result.error) {
|
|
208
|
+
throw new Error(`RPC Error: ${result.error.message || JSON.stringify(result.error)}`);
|
|
209
|
+
}
|
|
210
|
+
// 提取 bundle hash
|
|
211
|
+
const bundleHash = result.result;
|
|
212
|
+
if (typeof bundleHash === 'string') {
|
|
213
|
+
console.log(`✅ [BlockRazor] Bundle 发送成功: ${bundleHash}`);
|
|
214
|
+
return bundleHash;
|
|
215
|
+
}
|
|
216
|
+
if (bundleHash && typeof bundleHash === 'object') {
|
|
217
|
+
if ('bundleHash' in bundleHash) {
|
|
218
|
+
console.log(`✅ [BlockRazor] Bundle 发送成功: ${bundleHash.bundleHash}`);
|
|
219
|
+
return String(bundleHash.bundleHash);
|
|
196
220
|
}
|
|
197
221
|
}
|
|
198
|
-
|
|
222
|
+
console.log(`✅ [BlockRazor] Bundle 发送成功:`, result);
|
|
223
|
+
return JSON.stringify(result.result || result);
|
|
199
224
|
}
|
|
200
225
|
catch (error) {
|
|
201
226
|
const errorMsg = error.message || String(error);
|
|
@@ -213,7 +238,7 @@ export class BlockRazorClient {
|
|
|
213
238
|
if (!options.transactions || options.transactions.length === 0) {
|
|
214
239
|
throw new Error('Transactions array cannot be empty');
|
|
215
240
|
}
|
|
216
|
-
const blockOffset = options.blockOffset ??
|
|
241
|
+
const blockOffset = options.blockOffset ?? 100;
|
|
217
242
|
const maxBlockOffset = options.maxBlockOffset ?? 100;
|
|
218
243
|
const autoRetry = options.autoRetry ?? false;
|
|
219
244
|
const maxRetries = options.maxRetries ?? 3;
|
|
@@ -204,7 +204,7 @@ export async function submitBundleToBlockRazor(signedTransactions, config) {
|
|
|
204
204
|
// 提交 Bundle
|
|
205
205
|
const bundleResult = await client.sendBundle({
|
|
206
206
|
transactions: signedTransactions,
|
|
207
|
-
blockOffset: config.blockOffset ??
|
|
207
|
+
blockOffset: config.blockOffset ?? 100,
|
|
208
208
|
maxBlockOffset: config.maxBlockOffset ?? 100,
|
|
209
209
|
noMerge: config.noMerge ?? false,
|
|
210
210
|
revertingTxHashes: config.revertingTxHashes,
|