@celo/explorer
Version:
Celo's block explorer consumer
116 lines (115 loc) • 5.41 kB
TypeScript
import { ABIDefinition, Address, Block, CeloTxPending } from '@celo/connect';
import { CeloContract, ContractKit } from '@celo/contractkit';
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: CeloTxPending;
}
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: CeloTxPending): Promise<ParsedTx | null>;
tryParseTxInput(address: string, input: string): Promise<CallDetails | null>;
private getContractMethodAbiFromMapping;
/**
* @deprecated use getContractMappingWithSelector instead
* Returns the contract name and ABI of the method by looking up
* the contract address either in all possible contract mappings.
* @param address
* @param selector
* @param onlyCoreContracts
* @returns The contract name and ABI of the method or null if not found
*/
getContractMethodAbi: (address: string, selector: string, onlyCoreContracts?: boolean) => Promise<ContractNameAndMethodAbi | null>;
/**
* Returns the contract name and ABI of the method by looking up
* the contract address but only in core contracts
* @param address
* @param selector
* @returns The contract name and ABI of the method or null if not found
*/
getContractMethodAbiFromCore: (address: string, selector: string) => Promise<ContractNameAndMethodAbi | null>;
/**
* @deprecated use getContractMappingWithSelector instead
* Returns the contract name and ABI of the method by looking up
* the contract address in Sourcify.
* @param address
* @param selector
* @returns The contract name and ABI of the method or null if not found
*/
getContractMethodAbiFromSourcify: (address: string, selector: string) => Promise<ContractNameAndMethodAbi | null>;
/**
* @deprecated use getContractMappingWithSelector instead
* Returns the contract name and ABI of the method by looking up
* the selector in a list of known functions.
* @param address
* @param selector
* @param onlyCoreContracts
* @returns The contract name and ABI of the method or null if not found
*/
getContractMethodAbiFallback: (address: string, selector: string) => ContractNameAndMethodAbi | 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>;
/**
* 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>;
}