jcc-moac-abi
Version:
Decoder and encoder for the MOAC ABI and decode events from MOAC transactions
90 lines (89 loc) • 2.21 kB
TypeScript
import { IABIItem, IDecoded, IDecodedLog, ILog } from "./model";
interface IChain3Contract {
abi: IABIItem[];
[method: string]: any;
}
/**
* decoder and encoder for moac
*
* @export
* @class MoacABI
*/
export default class MoacABI {
/**
* moac contract instance
*
* @private
* @type {Contract}
* @memberof MoacABI
*/
private _contract;
/**
* moac abi
*
* @private
* @type {IABIItem[]}
* @memberof MoacABI
*/
private _abi;
/**
* Creates an instance of MoacABI.
* @param {Contract} contract moac contract instance
* @memberof MoacABI
*/
constructor(contract: IChain3Contract);
/**
* get item of function meta data
*
* @param {string} name defined function name in the abi
* @param {*} args parameters according to the defined inputs
* @returns {IABIItem}
* @memberof MoacABI
*/
getAbiItem: (name: string, ...args: any[]) => IABIItem;
/**
* encode the input value by function name
*
* @param {string} name defined function name in the abi
* @param {*} args parameters according to the defined inputs
* @returns {string}
* @memberof MoacABI
*/
encode: (name: string, ...args: any[]) => string;
/**
* decode the input value
*
* @static
* @param {string} data
* @returns {IDecoded[]}
* @memberof MoacABI
*/
static decode(data: string): IDecoded[];
/**
* decode moac transaction logs
*
* @static
* @param {ILog[]} logs
* @returns {IDecodedLog[]} if event is defined and decode succeed, return log that contains
* events as input arguments and name as event's name, otherwise return itself.
* @memberof MoacABI
*/
static decodeLogs(logs: ILog[]): IDecodedLog[];
/**
* add abi to registry
*
* @static
* @param {IABIItem[]} abi
* @memberof MoacABI
*/
static addABI(abi: IABIItem[]): void;
/**
* remove all ABIs from registry
*
* @static
* @param {IABIItem[]} abi
* @memberof MoacABI
*/
static removeABI(_abi: IABIItem[]): void;
}
export { MoacABI };