web3x
Version:
Typescript port of web3.js
121 lines (120 loc) • 3.72 kB
TypeScript
import { AbiInput } from '../abi/contract-abi-definition';
/**
* ABICoder prototype should be used to encode/decode solidity params of any type
*/
export declare class ABICoder {
private ethersAbiCoder;
constructor();
/**
* Encodes the function name to its ABI representation, which are the first 4 bytes of the sha3 of the function name including types.
*
* @method encodeFunctionSignature
* @param {String|Object} functionName
* @return {String} encoded function name
*/
encodeFunctionSignature(functionName: any): string;
/**
* Encodes the function name to its ABI representation, which are the first 4 bytes of the sha3 of the function name including types.
*
* @method encodeEventSignature
* @param {String|Object} functionName
* @return {String} encoded function name
*/
encodeEventSignature(functionName: any): string;
/**
* Should be used to encode plain param
*
* @method encodeParameter
* @param {String} type
* @param {Object} param
* @return {String} encoded plain param
*/
encodeParameter(type: any, param: any): string;
/**
* Should be used to encode list of params
*
* @method encodeParameters
* @param {Array} types
* @param {Array} params
* @return {String} encoded list of params
*/
encodeParameters(types: any, params: any): string;
/**
* Encodes a function call from its json interface and parameters.
*
* @method encodeFunctionCall
* @param {Array} jsonInterface
* @param {Array} params
* @return {String} The encoded ABI for this function call
*/
encodeFunctionCall(jsonInterface: any, params: any): string;
/**
* Should be used to decode bytes to plain param
*
* @method decodeParameter
* @param {String} type
* @param {String} bytes
* @return {Object} plain param
*/
decodeParameter(type: any, bytes: any): any;
/**
* Should be used to decode list of params
*
* @method decodeParameter
* @param {Array} outputs
* @param {String} bytes
* @return {Array} array of plain params
*/
decodeParameters(outputs: any, bytes: any): any;
/**
* Decodes events non- and indexed parameters.
*
* @method decodeLog
* @param {Object} inputs
* @param {String} data
* @param {Array} topics
* @return {Array} array of plain params
*/
decodeLog(inputs: AbiInput[], data: any, topics: any): any;
/**
* Map types if simplified format is used
*
* @method mapTypes
* @param {Array} types
* @return {Array}
*/
private mapTypes;
/**
* Check if type is simplified struct format
*
* @method isSimplifiedStructFormat
* @param {string | Object} type
* @returns {boolean}
*/
private isSimplifiedStructFormat;
/**
* Maps the correct tuple type and name when the simplified format in encode/decodeParameter is used
*
* @method mapStructNameAndType
* @param {string} structName
* @return {{type: string, name: *}}
*/
private mapStructNameAndType;
/**
* Maps the simplified format in to the expected format of the ABICoder
*
* @method mapStructToCoderFormat
* @param {Object} struct
* @return {Array}
*/
private mapStructToCoderFormat;
/**
* Should be used to create full function/event name from json abi
*
* @method jsonInterfaceMethodToString
* @param {Object} json
* @return {String} full function/event name
*/
abiMethodToString(json: any): any;
}
export declare const abiCoder: ABICoder;