UNPKG

@celo/explorer

Version:
98 lines 4.68 kB
import { ABIDefinition, Address } from '@celo/connect'; import { CeloContract, ContractKit } from '@celo/contractkit'; import type { Block, Transaction } from 'viem'; import { ContractDetails, ContractMapping } from './base'; export interface ContractNameAndMethodAbi { abi: ABIDefinition; contract: string; contractName?: string; } export interface CallDetails { contract: string; contractAddress: Address; isCoreContract: boolean; function: string; paramMap: Record<string, any>; argList: any[]; } export interface ParsedTx { callDetails: CallDetails; tx: Transaction; } export interface ParsedBlock { block: Block; parsedTx: ParsedTx[]; } export declare function newBlockExplorer(kit: ContractKit): Promise<BlockExplorer>; export declare class BlockExplorer { private kit; readonly contractDetails: ContractDetails[]; private addressMapping; private proxyImplementationOverride; constructor(kit: ContractKit, contractDetails: ContractDetails[]); updateContractDetailsMapping(name: CeloContract, address: string): Promise<void>; setProxyOverride(proxyAddress: Address, implementationAddress: Address): Promise<void>; fetchBlockByHash(blockHash: string): Promise<Block>; fetchBlock(blockNumber: number): Promise<Block>; fetchBlockRange(from: number, to: number): Promise<Block[]>; parseBlock(block: Block): Promise<ParsedBlock>; tryParseTx(tx: Transaction): Promise<ParsedTx | null>; tryParseTxInput(address: string, input: string): Promise<CallDetails | null>; buildCallDetails(contract: ContractDetails, abi: ABIDefinition, input: string): CallDetails; /** * Returns the ContractMapping for the contract at that address, or undefined * by looking up the contract address in the core mappings. * @param address * @returns The ContractMapping for the contract at that address, or undefined */ getContractMappingFromCore: (address: string) => Promise<ContractMapping | undefined>; /** * Returns the ContractMapping for the contract at that address, or undefined * by looking up the contract address in Sourcify. * @param address * @returns The ContractMapping for the contract at that address, or undefined */ getContractMappingFromSourcify: (address: string) => Promise<ContractMapping | undefined>; /** * Returns the ContractMapping for the contract at that address, or undefined * by looking up the contract address in Sourcify but using heuristis to treat * it as a proxy. * * This function is also included by the proxyImplementationOverrides map, * which can be used to override the implementation address for a given proxy. * This is exceptionally useful for parsing governence proposals that either * initialize a proxy or upgrade it, and then calls methods on the new implementation. * @param address * @returns The ContractMapping for the contract at that address, or undefined */ getContractMappingFromSourcifyAsProxy: (address: string) => Promise<ContractMapping | undefined>; /** * Returns the ContractMapping for the contract at that address by looking up * its verified ABI on the chain's block explorer (Blockscout / Celoscan). * * Useful when Sourcify does not have the contract (or its v1 API is * unavailable) but the contract is verified on the canonical celo explorer. * @param address * @returns The ContractMapping for the contract at that address, or undefined */ getContractMappingFromExplorer: (address: string) => Promise<ContractMapping | undefined>; /** * Like getContractMappingFromExplorer, but treats the address as a proxy and * resolves the implementation ABI. Honors proxyImplementationOverride, so a * proxy upgraded earlier in the same proposal resolves to its new * implementation's ABI. * @param address * @returns The ContractMapping for the contract at that address, or undefined */ getContractMappingFromExplorerAsProxy: (address: string) => Promise<ContractMapping | undefined>; /** * Uses all of the strategies available to find a contract mapping that contains * the given method selector. * @param address * @param selector * @param strategies * @returns The ContractMapping for the contract which has the function selector, or undefined */ getContractMappingWithSelector(address: string, selector: string, strategies?: ((address: string) => Promise<ContractMapping | undefined>)[]): Promise<ContractMapping | undefined>; } //# sourceMappingURL=block-explorer.d.ts.map