UNPKG

@lunch-money/ethereum-to-lunch-money

Version:

A wrapper around Ethereum APIs for enabling Lunch Money to gather information about a user's wallet.

28 lines 1.24 kB
import * as ethscan from '@mycrypto/eth-scan'; import tokenList1inch from '../fixtures/1inch.json'; export const createEthereumWalletClient = (provider) => { // A custom ethscan provider implementation is needed to map `call` to `send` for ethscan to use the ethers client correctly. // This is a temporary solution until the ethscan library is updated to support ethers v6. const customProvider = { send(method, params) { // Type pulled from: https://github.com/MyCryptoHQ/eth-scan/blob/master/src/providers/provider.ts#L32 const typedParams = params; return provider.call({ to: typedParams[0].to, data: typedParams[0].data }); } }; return { async getChainId() { return (await provider.getNetwork()).chainId; }, async getWeiBalance(walletAddress) { return (await provider.getBalance(walletAddress)); }, async getTokensBalance(walletAddress, tokenContractAddresses) { return ethscan.getTokensBalance(customProvider, walletAddress, tokenContractAddresses); }, }; }; export const loadTokenList = async () => { return tokenList1inch.tokens; }; //# sourceMappingURL=client.js.map