@lunch-money/ethereum-to-lunch-money
Version:
A wrapper around Ethereum APIs for enabling Lunch Money to gather information about a user's wallet.
50 lines (49 loc) • 2.04 kB
TypeScript
import * as ethscan from '@mycrypto/eth-scan';
import { type Provider, type AbstractProvider } from 'ethers';
import { EthersProviderLike } from '@mycrypto/eth-scan/typings/src/providers/ethers.js';
import type { LunchMoneyCryptoConnectionBalances } from './types.js';
export type ProviderInfo = {
type: 'Service Provider' | 'API Provider';
name: string;
status: 'SUCCESS' | 'FAILED';
apiKey?: string;
provider?: Provider | AbstractProvider;
customProvider?: EthersProviderLike;
error?: string;
network?: string;
balance?: string;
};
/**
* Debug function that logs to console.log if DEBUG_ETHEREUM environment variable is set
*/
export declare const debug: (...args: unknown[]) => void;
export interface EthereumWalletClient {
getBalances(walletAddress: string, negligibleBalanceThreshold: number): Promise<LunchMoneyCryptoConnectionBalances>;
getWeiBalance(walletAddress: string, provider: AbstractProvider): Promise<bigint>;
getChainId(provider: AbstractProvider): Promise<bigint>;
getTokensBalance(walletAddress: string, tokenContractAddresses: string[], providerInfo: ProviderInfo): Promise<ethscan.BalanceMap<bigint>>;
discoverTokensHybrid(walletAddress: string, chainId: bigint): Promise<string[]>;
}
export declare class EtherscanProvider {
private apiKey;
private baseUrl;
constructor(apiKey: string);
discoverTokensForWallet(address: string, chainId?: bigint): Promise<string[]>;
}
export declare class MoralisProvider {
private apiKey;
private baseUrl;
constructor(apiKey: string);
discoverTokensForWallet(address: string, chainId?: bigint): Promise<string[]>;
}
export declare const createEthereumWalletClient: (serviceProviderInfo?: ProviderInfo[], walletAPIProviderInfo?: ProviderInfo[]) => EthereumWalletClient;
interface Token {
address: string;
chainId: number;
name: string;
symbol: string;
decimals: number;
logoURI: string | null;
}
export declare const loadTokenList: () => Promise<Token[]>;
export {};