four-flap-meme-sdk 1.2.71 → 1.2.72
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.
|
@@ -2,6 +2,7 @@ import { ethers, Wallet } from 'ethers';
|
|
|
2
2
|
import { NonceManager, getOptimizedGasPrice } from '../../utils/bundle-helpers.js';
|
|
3
3
|
import { ADDRESSES } from '../../utils/constants.js';
|
|
4
4
|
import { FourClient, buildLoginMessage } from '../../clients/four.js';
|
|
5
|
+
import { sendBatchPrivateTransactions } from '../../clients/club48.js';
|
|
5
6
|
import { getErrorMessage, getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, getProfitRecipient } from './config.js';
|
|
6
7
|
import { batchCheckAllowances } from '../../utils/erc20.js';
|
|
7
8
|
import { trySell } from '../tm.js';
|
|
@@ -142,23 +143,34 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
142
143
|
console.log(`✅ 总共生成了 ${signedTxs.length} 个交易签名 (1创建 + ${buyerKeys.length}买入 + 利润)`);
|
|
143
144
|
// ✅ 内部提交到 48.club Bundle
|
|
144
145
|
console.log('📡 开始提交到 48.club Bundle...');
|
|
145
|
-
|
|
146
|
+
let bundleUuid;
|
|
146
147
|
if (config.customSubmitFn) {
|
|
147
|
-
//
|
|
148
|
-
|
|
148
|
+
// ✅ 方式 1:使用自定义提交函数(通过服务器代理)
|
|
149
|
+
bundleUuid = await config.customSubmitFn(signedTxs);
|
|
149
150
|
console.log(`✅ Bundle 提交成功!UUID: ${bundleUuid}`);
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
};
|
|
151
|
+
}
|
|
152
|
+
else if (config.spPrivateKey) {
|
|
153
|
+
// ✅ 方式 2:使用 48SP 批量提交(支持浏览器直接调用)
|
|
154
|
+
console.log('📡 使用 48SP 批量提交...');
|
|
155
|
+
await sendBatchPrivateTransactions(signedTxs, config.spPrivateKey, config.club48Endpoint || 'https://puissant-bsc.48.club', {
|
|
156
|
+
spMode: config.spMode,
|
|
157
|
+
spVMode: config.spVMode
|
|
158
|
+
});
|
|
159
|
+
// 批量提交不返回 bundleUuid,使用第一笔交易的 hash 作为标识
|
|
160
|
+
bundleUuid = ethers.keccak256(signedTxs[0]);
|
|
161
|
+
console.log(`✅ 48SP 批量提交成功!`);
|
|
158
162
|
}
|
|
159
163
|
else {
|
|
160
|
-
throw new Error('❌ 浏览器环境必须提供 customSubmitFn
|
|
164
|
+
throw new Error('❌ 浏览器环境必须提供 customSubmitFn 或 spPrivateKey 来提交 Bundle(避免 CORS 限制)');
|
|
161
165
|
}
|
|
166
|
+
// 等待交易上链并解析代币地址
|
|
167
|
+
const tokenAddress = await waitAndParseTokenAddress(provider, signedTxs[0], bundleUuid);
|
|
168
|
+
return {
|
|
169
|
+
signedTransactions: signedTxs,
|
|
170
|
+
tokenAddress,
|
|
171
|
+
metadata,
|
|
172
|
+
bundleUuid
|
|
173
|
+
};
|
|
162
174
|
}
|
|
163
175
|
/**
|
|
164
176
|
* 等待交易上链并解析代币地址
|
|
@@ -12,6 +12,9 @@ export type FourSignConfig = {
|
|
|
12
12
|
prefer21000ForNative?: boolean;
|
|
13
13
|
checkBnbForErc20NoHop?: boolean;
|
|
14
14
|
customSubmitFn?: (signedTxs: string[]) => Promise<string>;
|
|
15
|
+
spPrivateKey?: string;
|
|
16
|
+
spMode?: 'none' | 'timestampPersonalSign' | 'concatTxHash' | 'rawTimestamp';
|
|
17
|
+
spVMode?: '27_28' | '0_1';
|
|
15
18
|
};
|
|
16
19
|
export type FourBundleMerkleConfig = {
|
|
17
20
|
apiKey: string;
|
|
@@ -304,10 +304,20 @@ export async function createTokenWithBundleBuy(params) {
|
|
|
304
304
|
// ✅ 使用自定义提交函数(通过服务器代理)
|
|
305
305
|
bundleUuid = await config.customSubmitFn(signedTxs);
|
|
306
306
|
}
|
|
307
|
+
else if (config.spPrivateKey) {
|
|
308
|
+
// ✅ 使用 48SP 批量提交(支持浏览器直接调用)
|
|
309
|
+
console.log('📡 使用 48SP 批量提交...');
|
|
310
|
+
await sendBatchPrivateTransactions(signedTxs, config.spPrivateKey, config.club48Endpoint || 'https://puissant-bsc.48.club', {
|
|
311
|
+
spMode: config.spMode ?? 'timestampPersonalSign',
|
|
312
|
+
spVMode: config.spVMode
|
|
313
|
+
});
|
|
314
|
+
// 批量提交不返回 bundleUuid,使用第一笔交易的 hash 作为标识
|
|
315
|
+
bundleUuid = ethers.keccak256(signedTxs[0]);
|
|
316
|
+
}
|
|
307
317
|
else {
|
|
308
|
-
// ✅ 直接提交到 48.club(仅服务器端可用)
|
|
318
|
+
// ✅ 直接提交到 48.club Bundle(仅服务器端可用)
|
|
309
319
|
if (!club48) {
|
|
310
|
-
throw new Error('❌
|
|
320
|
+
throw new Error('❌ 浏览器环境必须提供 customSubmitFn 或 spPrivateKey 来提交 Bundle(避免 CORS 限制)');
|
|
311
321
|
}
|
|
312
322
|
bundleUuid = await club48.sendBundle({
|
|
313
323
|
txs: signedTxs,
|