UNPKG

@ethereum-sourcify/contract-call-decoder

Version:

Library to decode Ethereum smart contract calls into human-readable descriptions using ABI and NatSpec

55 lines (54 loc) 2.12 kB
import { Transaction as TransactionRosette } from '@blossom-labs/rosette-radspec/dist/declarations/src/types/web3'; import { Fragment, FunctionFragment, JsonFragment } from '@ethersproject/abi'; import { Provider } from '@ethersproject/providers'; import { EthereumProvider } from 'ethereum-provider'; type Transaction = TransactionRosette & { readonly chainId?: number; }; export declare enum MetadataSources { Sourcify = 0, BytecodeMetadata = 1 } type GetMetadataOptions = { readonly source?: MetadataSources; readonly chainId?: number; readonly address?: string; readonly rpcProvider?: EthereumProvider; readonly ipfsGateway?: string; readonly sourcifyProvider?: string; }; export declare function getMetadataFromAddress(options: GetMetadataOptions): Promise<any>; export declare const evaluate: (expression: string, abi: string | ReadonlyArray<Fragment | JsonFragment | string>, transaction: Transaction, provider: Provider) => Promise<string | undefined>; export declare const findSelectorAndAbiItemFromSignatureHash: (functionSignatureHash: string, abi: string | ReadonlyArray<Fragment | JsonFragment | string>) => false | { selector: string; abi: FunctionFragment; }; type DecodedParam = unknown | { readonly [index: string]: unknown; }; type DecodedContractCall = { readonly contract: { readonly author?: string; readonly title?: string; readonly details?: string; readonly custom?: { readonly [index: string]: string; }; }; readonly method: { readonly selector: string; readonly abi: FunctionFragment; readonly decodedParams: readonly DecodedParam[]; readonly details?: string; readonly returns?: string; readonly notice?: string; readonly params?: { readonly [index: string]: unknown; }; readonly custom?: { readonly [index: string]: string; }; }; }; export declare const decodeContractCall: (tx: Transaction, options?: GetMetadataOptions) => Promise<DecodedContractCall | false>; export {};