From 43e863900f0a1fe7b73f29ff55f5348800e8a631 Mon Sep 17 00:00:00 2001 From: jyj545 Date: Fri, 25 Oct 2019 18:08:08 +0800 Subject: [PATCH] push jyj_new branch --- docs/API.md | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 docs/API.md diff --git a/docs/API.md b/docs/API.md new file mode 100644 index 0000000..9247ce9 --- /dev/null +++ b/docs/API.md @@ -0,0 +1,90 @@ +# API + +```javascript +/** + * Creates an instance of EthereumABI. + * @param {Contract} contract ethereum contract instance + * @memberof EthereumABI + */ + constructor(contract: Contract); +``` + + ```javascript + /** + * ethereum contract instance + * + * @private + * @type {Contract} + * @memberof EthereumABI + */ + private _contract; +/** + * ethereum abi + * + * @private + * @type {IABIItem[]} + * @memberof EthereumABI + */ + private _abi; + +/** + * 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 EthereumABI + */ + 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 EthereumABI + */ + encode(name: string, ...args: any[]): string; + +/** + * decode the input value + * + * @static + * @param {string} data + * @returns {IDecoded[]} + * @memberof EthereumABI + */ + static decode(data: string): IDecoded[]; + +/** + * decode ethereum transaction logs + * + * [Reference](https://github.com/ConsenSys/abi-decoder/blob/master/index.js#L130) + * + * @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 EthereumABI + */ + static decodeLogs(logs: ILog[]): IDecodedLog[]; + +/** + * add abi to abiDecoder + * + * @static + * @param {IABIItem[]} abi + * @memberof EthereumABI + */ + static addABI(abi: IABIItem[]): void; + +/** + * remove ABIs and methodIDs from abiDecoder + * + * @static + * @param {IABIItem[]} abi + * @memberof EthereumABI + */ + static removeABI(abi: IABIItem[]): void; +```