UNPKG

2.42 kBTypeScriptView Raw
1import { AbiDefinition, DecodedLogArgs, LogEntry, LogWithDecodedArgs, RawLog } from 'ethereum-types';
2import { DecodedCalldata } from './types';
3/**
4 * AbiDecoder allows you to decode event logs given a set of supplied contract ABI's. It takes the contract's event
5 * signature from the ABI and attempts to decode the logs using it.
6 */
7export declare class AbiDecoder {
8 private readonly _eventIds;
9 private readonly _selectorToFunctionInfo;
10 /**
11 * Retrieves the function selector from calldata.
12 * @param calldata hex-encoded calldata.
13 * @return hex-encoded function selector.
14 */
15 private static _getFunctionSelector;
16 /**
17 * Instantiate an AbiDecoder
18 * @param abiArrays An array of contract ABI's
19 * @return AbiDecoder instance
20 */
21 constructor(abiArrays: AbiDefinition[][]);
22 /**
23 * Attempt to decode a log given the ABI's the AbiDecoder knows about.
24 * @param log The log to attempt to decode
25 * @return The decoded log if the requisite ABI was available. Otherwise the log unaltered.
26 */
27 tryToDecodeLogOrNoop<ArgsType extends DecodedLogArgs>(log: LogEntry): LogWithDecodedArgs<ArgsType> | RawLog;
28 /**
29 * Decodes calldata for a known ABI.
30 * @param calldata hex-encoded calldata.
31 * @param contractName used to disambiguate similar ABI's (optional).
32 * @return Decoded calldata. Includes: function name and signature, along with the decoded arguments.
33 */
34 decodeCalldataOrThrow(calldata: string, contractName?: string): DecodedCalldata;
35 /**
36 * Adds a set of ABI definitions, after which calldata and logs targeting these ABI's can be decoded.
37 * Additional properties can be included to disambiguate similar ABI's. For example, if two functions
38 * have the same signature but different parameter names, then their ABI definitions can be disambiguated
39 * by specifying a contract name.
40 * @param abiDefinitions ABI definitions for a given contract.
41 * @param contractName Name of contract that encapsulates the ABI definitions (optional).
42 * This can be used when decoding calldata to disambiguate methods with
43 * the same signature but different parameter names.
44 */
45 addABI(abiArray: AbiDefinition[], contractName?: string): void;
46 private _addEventABI;
47 private _addMethodABI;
48}
49//# sourceMappingURL=abi_decoder.d.ts.map
\No newline at end of file