four-flap-meme-sdk 4.4.0 → 4.4.1
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/utils/wallet.js +10 -9
- package/package.json +1 -1
package/dist/utils/wallet.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Wallet, Interface,
|
|
1
|
+
import { Wallet, Interface, formatEther, formatUnits, isHexString } from 'ethers';
|
|
2
|
+
import { createProvider } from './provider-factory.js';
|
|
2
3
|
import { CHAIN_ID_MAP, ADDRESSES } from '../core/constants/index.js';
|
|
3
4
|
import { ERC20_ABI, MULTICALL3_ABI } from '../abis/common.js';
|
|
4
5
|
import { getErrorMessageFromUnknown } from '../core/index.js';
|
|
@@ -247,7 +248,14 @@ async function getMulticallAddress(provider, chainId) {
|
|
|
247
248
|
* ✅ 统一实现(精简版,复用内部函数)
|
|
248
249
|
*/
|
|
249
250
|
export async function getTokenBalancesWithMulticall(rpcUrl, a, b, c) {
|
|
250
|
-
|
|
251
|
+
let chainId;
|
|
252
|
+
if (Array.isArray(b) && Array.isArray(c)) {
|
|
253
|
+
if (typeof a === 'number')
|
|
254
|
+
chainId = a;
|
|
255
|
+
else if (typeof a === 'string')
|
|
256
|
+
chainId = CHAIN_ID_MAP[a];
|
|
257
|
+
}
|
|
258
|
+
const provider = chainId != null ? createProvider(rpcUrl, chainId) : createProvider(rpcUrl);
|
|
251
259
|
// ✅ 分支 1:rpcUrl, tokenAddresses[], holders[]
|
|
252
260
|
if (Array.isArray(a) && Array.isArray(b) && typeof c === 'undefined') {
|
|
253
261
|
const multicallAddress = await getMulticallAddress(provider);
|
|
@@ -255,13 +263,6 @@ export async function getTokenBalancesWithMulticall(rpcUrl, a, b, c) {
|
|
|
255
263
|
}
|
|
256
264
|
// ✅ 分支 2:rpcUrl, chain/chainId, tokenAddresses[], holders[]
|
|
257
265
|
if (Array.isArray(b) && Array.isArray(c)) {
|
|
258
|
-
let chainId;
|
|
259
|
-
if (typeof a === 'number') {
|
|
260
|
-
chainId = a;
|
|
261
|
-
}
|
|
262
|
-
else if (typeof a === 'string') {
|
|
263
|
-
chainId = CHAIN_ID_MAP[a];
|
|
264
|
-
}
|
|
265
266
|
const multicallAddress = await getMulticallAddress(provider, chainId);
|
|
266
267
|
return _queryMultiTokenBalances(provider, multicallAddress, b, c);
|
|
267
268
|
}
|