four-flap-meme-sdk 1.5.59 → 1.5.61

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.
@@ -32,8 +32,8 @@ function getCachedProvider(rpcUrl, chainId, chainName) {
32
32
  if (cachedProvider && (now - timestamp) < PROVIDER_CACHE_TTL) {
33
33
  return cachedProvider;
34
34
  }
35
- // 创建新 Provider 并缓存
36
- const provider = new JsonRpcProvider(rpcUrl, { chainId, name: chainName });
35
+ // 禁用 ENS: 避免 "network does not support ENS" 错误
36
+ const provider = new JsonRpcProvider(rpcUrl, { chainId, name: chainName, ensAddress: undefined });
37
37
  providerCache.set(cacheKey, provider);
38
38
  providerCacheTimestamps.set(cacheKey, now);
39
39
  return provider;
@@ -385,9 +385,10 @@ function createMerkleContext(chain, config) {
385
385
  throw new Error(`Chain ${chain} (chainId: ${chainId}) does not support Merkle bundle service. Please provide customRpcUrl.`);
386
386
  }
387
387
  const { JsonRpcProvider } = require('ethers');
388
+ // ✅ 禁用 ENS: 避免 "network does not support ENS" 错误
388
389
  return {
389
390
  chainId,
390
- provider: new JsonRpcProvider(config.customRpcUrl, { chainId, name: chain.toLowerCase() })
391
+ provider: new JsonRpcProvider(config.customRpcUrl, { chainId, name: chain.toLowerCase(), ensAddress: undefined })
391
392
  };
392
393
  }
393
394
  const merkle = new MerkleClient({
@@ -6,7 +6,7 @@ import { ADDRESSES } from './constants.js';
6
6
  * 自动使用正确的代理合约地址
7
7
  */
8
8
  export function getTokenManagerV1(chain, rpcUrl) {
9
- const provider = new JsonRpcProvider(rpcUrl);
9
+ const provider = new JsonRpcProvider(rpcUrl, undefined); // ✅ 禁用 ENS
10
10
  const chainAddresses = ADDRESSES[chain];
11
11
  const address = 'TokenManagerV1' in chainAddresses ? chainAddresses.TokenManagerV1 : undefined;
12
12
  if (!address) {
@@ -19,7 +19,7 @@ export function getTokenManagerV1(chain, rpcUrl) {
19
19
  * 自动使用正确的代理合约地址
20
20
  */
21
21
  export function getTokenManagerV2(chain, rpcUrl) {
22
- const provider = new JsonRpcProvider(rpcUrl);
22
+ const provider = new JsonRpcProvider(rpcUrl, undefined); // ✅ 禁用 ENS
23
23
  const chainAddresses = ADDRESSES[chain];
24
24
  const address = 'TokenManagerV2' in chainAddresses ? chainAddresses.TokenManagerV2 : undefined;
25
25
  if (!address) {
@@ -32,7 +32,7 @@ export function getTokenManagerV2(chain, rpcUrl) {
32
32
  * 自动使用正确的代理合约地址
33
33
  */
34
34
  export function getTokenManagerHelper3(chain, rpcUrl) {
35
- const provider = new JsonRpcProvider(rpcUrl);
35
+ const provider = new JsonRpcProvider(rpcUrl, undefined); // ✅ 禁用 ENS
36
36
  const address = ADDRESSES[chain].TokenManagerHelper3;
37
37
  if (!address) {
38
38
  throw new Error(`TokenManagerHelper3 not deployed on ${chain}`);
@@ -44,7 +44,7 @@ export function getTokenManagerHelper3(chain, rpcUrl) {
44
44
  * 自动使用正确的代理合约地址
45
45
  */
46
46
  export function getTokenManagerV1Writer(chain, rpcUrl, privateKey) {
47
- const provider = new JsonRpcProvider(rpcUrl);
47
+ const provider = new JsonRpcProvider(rpcUrl, undefined); // ✅ 禁用 ENS
48
48
  const signer = new Wallet(privateKey, provider);
49
49
  const chainAddresses = ADDRESSES[chain];
50
50
  const address = 'TokenManagerV1' in chainAddresses ? chainAddresses.TokenManagerV1 : undefined;
@@ -58,7 +58,7 @@ export function getTokenManagerV1Writer(chain, rpcUrl, privateKey) {
58
58
  * 自动使用正确的代理合约地址
59
59
  */
60
60
  export function getTokenManagerV2Writer(chain, rpcUrl, privateKey) {
61
- const provider = new JsonRpcProvider(rpcUrl);
61
+ const provider = new JsonRpcProvider(rpcUrl, undefined); // ✅ 禁用 ENS
62
62
  const signer = new Wallet(privateKey, provider);
63
63
  const chainAddresses = ADDRESSES[chain];
64
64
  const address = 'TokenManagerV2' in chainAddresses ? chainAddresses.TokenManagerV2 : undefined;
@@ -72,7 +72,7 @@ export function getTokenManagerV2Writer(chain, rpcUrl, privateKey) {
72
72
  * 自动使用正确的代理合约地址
73
73
  */
74
74
  export function getTokenManagerHelper3Writer(chain, rpcUrl, privateKey) {
75
- const provider = new JsonRpcProvider(rpcUrl);
75
+ const provider = new JsonRpcProvider(rpcUrl, undefined); // ✅ 禁用 ENS
76
76
  const signer = new Wallet(privateKey, provider);
77
77
  const address = ADDRESSES[chain].TokenManagerHelper3;
78
78
  if (!address) {
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Provider 工厂函数 - 统一创建 JsonRpcProvider 并禁用 ENS
3
+ *
4
+ * 目的:
5
+ * 1. 避免 "network does not support ENS" 错误
6
+ * 2. 统一 Provider 创建逻辑
7
+ * 3. 提升性能 (跳过 ENS 解析)
8
+ */
9
+ import { JsonRpcProvider } from 'ethers';
10
+ /**
11
+ * 创建 JsonRpcProvider (自动禁用 ENS)
12
+ *
13
+ * @param rpcUrl RPC URL
14
+ * @param chainId 链 ID (可选)
15
+ * @param chainName 链名称 (可选,用于日志)
16
+ * @param options 额外选项
17
+ * @returns JsonRpcProvider 实例
18
+ */
19
+ export declare function createProvider(rpcUrl: string, chainId?: number, chainName?: string, options?: {
20
+ batchMaxCount?: number;
21
+ batchStallTime?: number;
22
+ }): JsonRpcProvider;
23
+ export declare function createCachedProvider(rpcUrl: string, chainId: number, chainName?: string): JsonRpcProvider;
24
+ /**
25
+ * 清除 Provider 缓存
26
+ */
27
+ export declare function clearProviderCache(): void;
28
+ /**
29
+ * XLayer 专用 Provider 创建函数
30
+ */
31
+ export declare function createXLayerProvider(rpcUrl: string): JsonRpcProvider;
32
+ /**
33
+ * BSC 专用 Provider 创建函数
34
+ */
35
+ export declare function createBscProvider(rpcUrl: string): JsonRpcProvider;
36
+ /**
37
+ * Monad 专用 Provider 创建函数
38
+ */
39
+ export declare function createMonadProvider(rpcUrl: string): JsonRpcProvider;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Provider 工厂函数 - 统一创建 JsonRpcProvider 并禁用 ENS
3
+ *
4
+ * 目的:
5
+ * 1. 避免 "network does not support ENS" 错误
6
+ * 2. 统一 Provider 创建逻辑
7
+ * 3. 提升性能 (跳过 ENS 解析)
8
+ */
9
+ import { JsonRpcProvider } from 'ethers';
10
+ /**
11
+ * 创建 JsonRpcProvider (自动禁用 ENS)
12
+ *
13
+ * @param rpcUrl RPC URL
14
+ * @param chainId 链 ID (可选)
15
+ * @param chainName 链名称 (可选,用于日志)
16
+ * @param options 额外选项
17
+ * @returns JsonRpcProvider 实例
18
+ */
19
+ export function createProvider(rpcUrl, chainId, chainName, options) {
20
+ // 构建网络配置
21
+ const networkConfig = chainId
22
+ ? {
23
+ chainId,
24
+ name: chainName || `chain-${chainId}`,
25
+ ensAddress: undefined, // ✅ 禁用 ENS 解析
26
+ }
27
+ : undefined;
28
+ // 构建批处理选项
29
+ const batchOptions = options
30
+ ? {
31
+ batchMaxCount: options.batchMaxCount ?? 20,
32
+ batchStallTime: options.batchStallTime ?? 30,
33
+ }
34
+ : undefined;
35
+ // 创建 Provider
36
+ if (networkConfig && batchOptions) {
37
+ return new JsonRpcProvider(rpcUrl, networkConfig, batchOptions);
38
+ }
39
+ else if (networkConfig) {
40
+ return new JsonRpcProvider(rpcUrl, networkConfig);
41
+ }
42
+ else if (batchOptions) {
43
+ return new JsonRpcProvider(rpcUrl, undefined, batchOptions);
44
+ }
45
+ else {
46
+ return new JsonRpcProvider(rpcUrl);
47
+ }
48
+ }
49
+ /**
50
+ * 创建带缓存的 Provider
51
+ *
52
+ * @param rpcUrl RPC URL
53
+ * @param chainId 链 ID
54
+ * @param chainName 链名称
55
+ * @returns JsonRpcProvider 实例
56
+ */
57
+ const providerCache = new Map();
58
+ export function createCachedProvider(rpcUrl, chainId, chainName) {
59
+ const key = `${rpcUrl}:${chainId}`;
60
+ if (!providerCache.has(key)) {
61
+ const provider = createProvider(rpcUrl, chainId, chainName, {
62
+ batchMaxCount: 20,
63
+ batchStallTime: 30,
64
+ });
65
+ providerCache.set(key, provider);
66
+ }
67
+ return providerCache.get(key);
68
+ }
69
+ /**
70
+ * 清除 Provider 缓存
71
+ */
72
+ export function clearProviderCache() {
73
+ providerCache.clear();
74
+ }
75
+ /**
76
+ * XLayer 专用 Provider 创建函数
77
+ */
78
+ export function createXLayerProvider(rpcUrl) {
79
+ return createProvider(rpcUrl, 196, 'xlayer', {
80
+ batchMaxCount: 20,
81
+ batchStallTime: 30,
82
+ });
83
+ }
84
+ /**
85
+ * BSC 专用 Provider 创建函数
86
+ */
87
+ export function createBscProvider(rpcUrl) {
88
+ return createProvider(rpcUrl, 56, 'bsc', {
89
+ batchMaxCount: 20,
90
+ batchStallTime: 30,
91
+ });
92
+ }
93
+ /**
94
+ * Monad 专用 Provider 创建函数
95
+ */
96
+ export function createMonadProvider(rpcUrl) {
97
+ return createProvider(rpcUrl, 143, 'monad', {
98
+ batchMaxCount: 20,
99
+ batchStallTime: 30,
100
+ });
101
+ }
@@ -249,10 +249,11 @@ export class DexExecutor {
249
249
  });
250
250
  // 执行 handleOps
251
251
  const provider = this.aaManager.getProvider();
252
- const entryPoint = this.aaManager.getEntryPoint();
252
+ const entryPointAddress = this.aaManager.getEntryPointAddress(); // ✅ 直接使用地址,避免 ENS
253
253
  const feeData = await provider.getFeeData();
254
254
  // 使用新 Contract 实例避免 TypeScript 类型问题
255
- const entryPointWithSigner = new Contract(await entryPoint.getAddress(), ['function handleOps((address sender,uint256 nonce,bytes initCode,bytes callData,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas,bytes paymasterAndData,bytes signature)[] ops, address payable beneficiary) external'], wallet);
255
+ const entryPointWithSigner = new Contract(entryPointAddress, // 直接使用地址字符串,避免 getAddress() 触发 ENS
256
+ ['function handleOps((address sender,uint256 nonce,bytes initCode,bytes callData,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas,bytes paymasterAndData,bytes signature)[] ops, address payable beneficiary) external'], wallet);
256
257
  const tx = await entryPointWithSigner.handleOps([signedOp.userOp], wallet.address, { gasPrice: feeData.gasPrice ?? 100000000n });
257
258
  const receipt = await tx.wait();
258
259
  return {
@@ -270,7 +271,7 @@ export class DexExecutor {
270
271
  const wallet = createWallet(privateKey, this.config);
271
272
  const accountInfo = await this.aaManager.getAccountInfo(wallet.address);
272
273
  const provider = this.aaManager.getProvider();
273
- const entryPoint = this.aaManager.getEntryPoint();
274
+ const entryPointAddress = this.aaManager.getEntryPointAddress(); // ✅ 直接使用地址,避免 ENS
274
275
  const feeData = await provider.getFeeData();
275
276
  const path = [tokenAddress, this.wokb];
276
277
  const deadline = this.getDeadline();
@@ -307,7 +308,8 @@ export class DexExecutor {
307
308
  const signedSwap = await this.aaManager.signUserOp(swapOp.userOp, wallet);
308
309
  ops.push(signedSwap.userOp);
309
310
  // 执行(使用新 Contract 实例避免 TypeScript 类型问题)
310
- const entryPointWithSigner = new Contract(await entryPoint.getAddress(), ['function handleOps((address sender,uint256 nonce,bytes initCode,bytes callData,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas,bytes paymasterAndData,bytes signature)[] ops, address payable beneficiary) external'], wallet);
311
+ const entryPointWithSigner = new Contract(entryPointAddress, // 直接使用地址字符串,避免 getAddress() 触发 ENS
312
+ ['function handleOps((address sender,uint256 nonce,bytes initCode,bytes callData,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas,bytes paymasterAndData,bytes signature)[] ops, address payable beneficiary) external'], wallet);
311
313
  const tx = await entryPointWithSigner.handleOps(ops, wallet.address, { gasPrice: feeData.gasPrice ?? 100000000n });
312
314
  const receipt = await tx.wait();
313
315
  return {
@@ -326,7 +328,7 @@ export class DexExecutor {
326
328
  const wallet = createWallet(privateKey, this.config);
327
329
  const accountInfo = await this.aaManager.getAccountInfo(wallet.address);
328
330
  const provider = this.aaManager.getProvider();
329
- const entryPoint = this.aaManager.getEntryPoint();
331
+ const entryPointAddress = this.aaManager.getEntryPointAddress(); // ✅ 直接使用地址,避免 ENS
330
332
  const feeData = await provider.getFeeData();
331
333
  const token = new Contract(quoteTokenAddress, ERC20_ABI, provider);
332
334
  const allowance = await token.allowance(accountInfo.sender, this.routerAddress);
@@ -358,7 +360,8 @@ export class DexExecutor {
358
360
  });
359
361
  const signedSwap = await this.aaManager.signUserOp(swapOp.userOp, wallet);
360
362
  ops.push(signedSwap.userOp);
361
- const entryPointWithSigner = new Contract(await entryPoint.getAddress(), ['function handleOps((address sender,uint256 nonce,bytes initCode,bytes callData,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas,bytes paymasterAndData,bytes signature)[] ops, address payable beneficiary) external'], wallet);
363
+ const entryPointWithSigner = new Contract(entryPointAddress, // 直接使用地址字符串,避免 getAddress() 触发 ENS
364
+ ['function handleOps((address sender,uint256 nonce,bytes initCode,bytes callData,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas,bytes paymasterAndData,bytes signature)[] ops, address payable beneficiary) external'], wallet);
362
365
  const tx = await entryPointWithSigner.handleOps(ops, wallet.address, { gasPrice: feeData.gasPrice ?? 100000000n });
363
366
  const receipt = await tx.wait();
364
367
  return {
@@ -100,6 +100,7 @@ export class PortalQuery {
100
100
  constructor(config = {}) {
101
101
  const rpcUrl = config.rpcUrl ?? DEFAULT_RPC_URL;
102
102
  const chainId = config.chainId ?? XLAYER_CHAIN_ID;
103
+ // ✅ 禁用 ENS: XLayer 不支持 ENS,显式设置 ensAddress: undefined 避免解析错误
103
104
  this.provider = new JsonRpcProvider(rpcUrl, { chainId, name: 'xlayer', ensAddress: undefined }, {
104
105
  batchMaxCount: 20,
105
106
  batchStallTime: 30,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.5.59",
3
+ "version": "1.5.61",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",