four-flap-meme-sdk 1.6.59 → 1.6.60

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.
@@ -17,7 +17,7 @@ import { createAAAccountManager, encodeExecute, createWallet } from './aa-accoun
17
17
  import { encodeBuyCall, encodeSellCall } from './portal-ops.js';
18
18
  import { encodeSwapExactETHForTokensSupportingFee, encodeSwapExactTokensForETHSupportingFee, encodeSwapExactETHForTokensV3, encodeSwapExactTokensForETHV3, } from './dex.js';
19
19
  import { encodeApproveCall } from './portal-ops.js';
20
- import { FLAP_PORTAL, WOKB, } from './constants.js';
20
+ import { FLAP_PORTAL, WOKB, XLAYER_CHAIN_ID, DEFAULT_RPC_URL, ENTRYPOINT_V06, SIMPLE_ACCOUNT_FACTORY, PARTICLE_BUNDLER_URL, } from './constants.js';
21
21
  import { PROFIT_CONFIG } from '../utils/constants.js';
22
22
  import { mapWithConcurrency } from '../utils/concurrency.js';
23
23
  // ============================================================================
@@ -41,6 +41,27 @@ function toBigIntSalt(v) {
41
41
  }
42
42
  return 0n;
43
43
  }
44
+ /**
45
+ * 归一化 XLayer AA 配置,填充默认值
46
+ * 与前端的 normalizeXLayerAAConfig 保持一致
47
+ */
48
+ function normalizeConfig(cfg) {
49
+ const rpcUrl = String(cfg?.rpcUrl || DEFAULT_RPC_URL).trim();
50
+ if (!rpcUrl)
51
+ throw new Error('[buildBundleOps] rpcUrl 为空');
52
+ return {
53
+ rpcUrl,
54
+ bundlerUrl: cfg?.bundlerUrl || PARTICLE_BUNDLER_URL,
55
+ chainId: cfg?.chainId ?? XLAYER_CHAIN_ID,
56
+ entryPoint: cfg?.entryPoint || ENTRYPOINT_V06,
57
+ factory: cfg?.factory || SIMPLE_ACCOUNT_FACTORY,
58
+ salt: toBigIntSalt(cfg?.salt),
59
+ paymaster: cfg?.paymaster,
60
+ paymasterData: cfg?.paymasterData,
61
+ timeoutMs: cfg?.timeoutMs,
62
+ gasLimitMultiplier: cfg?.gasLimitMultiplier,
63
+ };
64
+ }
44
65
  // ============================================================================
45
66
  // 买入 UserOps 构建
46
67
  // ============================================================================
@@ -61,12 +82,8 @@ export async function buildBundleBuyOps(params) {
61
82
  if (params.ownerPrivateKeys.length !== params.buyAmountsOkb.length) {
62
83
  throw new Error('[buildBundleBuyOps] 私钥数量与买入金额数量不一致');
63
84
  }
64
- // ✅ 确保 salt 类型正确(bigint)
65
- const rawConfig = params.config ?? {};
66
- const config = {
67
- ...rawConfig,
68
- salt: toBigIntSalt(rawConfig.salt),
69
- };
85
+ // ✅ 归一化配置,填充默认值(与前端 normalizeXLayerAAConfig 保持一致)
86
+ const config = normalizeConfig(params.config);
70
87
  const aaManager = createAAAccountManager(config);
71
88
  const ownerWallets = params.ownerPrivateKeys.map(pk => createWallet(pk, config));
72
89
  const owners = ownerWallets.map(w => w.address);
@@ -218,12 +235,8 @@ export async function buildBundleSellOps(params) {
218
235
  if (params.ownerPrivateKeys.length !== params.sellAmounts.length) {
219
236
  throw new Error('[buildBundleSellOps] 私钥数量与卖出金额数量不一致');
220
237
  }
221
- // ✅ 确保 salt 类型正确(bigint)
222
- const rawConfig = params.config ?? {};
223
- const config = {
224
- ...rawConfig,
225
- salt: toBigIntSalt(rawConfig.salt),
226
- };
238
+ // ✅ 归一化配置,填充默认值(与前端 normalizeXLayerAAConfig 保持一致)
239
+ const config = normalizeConfig(params.config);
227
240
  const aaManager = createAAAccountManager(config);
228
241
  const ownerWallets = params.ownerPrivateKeys.map(pk => createWallet(pk, config));
229
242
  const owners = ownerWallets.map(w => w.address);
@@ -324,12 +337,8 @@ export async function buildBundleSellOps(params) {
324
337
  export async function buildBundleProfitOp(params) {
325
338
  if (params.profitWei <= 0n)
326
339
  return null;
327
- // ✅ 确保 salt 类型正确(bigint)
328
- const rawConfig = params.config ?? {};
329
- const config = {
330
- ...rawConfig,
331
- salt: toBigIntSalt(rawConfig.salt),
332
- };
340
+ // ✅ 归一化配置,填充默认值(与前端 normalizeXLayerAAConfig 保持一致)
341
+ const config = normalizeConfig(params.config);
333
342
  const aaManager = createAAAccountManager(config);
334
343
  const ownerWallet = createWallet(params.ownerPrivateKey, config);
335
344
  const accountInfo = await aaManager.getAccountInfo(ownerWallet.address);
@@ -16,7 +16,7 @@ import { ethers } from 'ethers';
16
16
  import { createAAAccountManager, encodeExecute, createWallet } from './aa-account.js';
17
17
  import { encodeBuyCall, encodeSellCall, PortalQuery } from './portal-ops.js';
18
18
  import { encodeSwapExactETHForTokensSupportingFee, encodeSwapExactTokensForETHSupportingFee, encodeSwapExactETHForTokensV3, encodeSwapExactTokensForETHV3, DexQuery, } from './dex.js';
19
- import { FLAP_PORTAL, WOKB, } from './constants.js';
19
+ import { FLAP_PORTAL, WOKB, XLAYER_CHAIN_ID, DEFAULT_RPC_URL, ENTRYPOINT_V06, SIMPLE_ACCOUNT_FACTORY, PARTICLE_BUNDLER_URL, } from './constants.js';
20
20
  import { PROFIT_CONFIG } from '../utils/constants.js';
21
21
  import { mapWithConcurrency } from '../utils/concurrency.js';
22
22
  // ============================================================================
@@ -40,6 +40,27 @@ function toBigIntSalt(v) {
40
40
  }
41
41
  return 0n;
42
42
  }
43
+ /**
44
+ * 归一化 XLayer AA 配置,填充默认值
45
+ * 与前端的 normalizeXLayerAAConfig 保持一致
46
+ */
47
+ function normalizeConfig(cfg) {
48
+ const rpcUrl = String(cfg?.rpcUrl || DEFAULT_RPC_URL).trim();
49
+ if (!rpcUrl)
50
+ throw new Error('[buildWashOps] rpcUrl 为空');
51
+ return {
52
+ rpcUrl,
53
+ bundlerUrl: cfg?.bundlerUrl || PARTICLE_BUNDLER_URL,
54
+ chainId: cfg?.chainId ?? XLAYER_CHAIN_ID,
55
+ entryPoint: cfg?.entryPoint || ENTRYPOINT_V06,
56
+ factory: cfg?.factory || SIMPLE_ACCOUNT_FACTORY,
57
+ salt: toBigIntSalt(cfg?.salt),
58
+ paymaster: cfg?.paymaster,
59
+ paymasterData: cfg?.paymasterData,
60
+ timeoutMs: cfg?.timeoutMs,
61
+ gasLimitMultiplier: cfg?.gasLimitMultiplier,
62
+ };
63
+ }
43
64
  // ============================================================================
44
65
  // 核心实现
45
66
  // ============================================================================
@@ -73,12 +94,8 @@ export async function buildWashOps(params) {
73
94
  if (params.ownerPrivateKeys.length !== params.buyAmountsOkb.length) {
74
95
  throw new Error('[buildWashOps] 私钥数量与买入金额数量不一致');
75
96
  }
76
- // ✅ 确保 salt 类型正确(bigint)
77
- const rawConfig = params.config ?? {};
78
- const config = {
79
- ...rawConfig,
80
- salt: toBigIntSalt(rawConfig.salt), // 转换 salt 为 bigint
81
- };
97
+ // ✅ 归一化配置,填充默认值(与前端 normalizeXLayerAAConfig 保持一致)
98
+ const config = normalizeConfig(params.config);
82
99
  const aaManager = createAAAccountManager(config);
83
100
  // ✅ 预先过滤无效私钥并保持索引对应
84
101
  const validEntries = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.6.59",
3
+ "version": "1.6.60",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",