aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-08-22 00:39:35 +0800
committerFabio Berger <me@fabioberger.com>2018-08-22 00:39:35 +0800
commitc00c477307e305e2d380779bb74fa29b31072c4c (patch)
tree725a1dadb424081f2871dbaeae33b1cbc4451ae2
parentcc90c806b09a83330c20816d1e7756f5c74e33d0 (diff)
downloaddexon-sol-tools-c00c477307e305e2d380779bb74fa29b31072c4c.tar
dexon-sol-tools-c00c477307e305e2d380779bb74fa29b31072c4c.tar.gz
dexon-sol-tools-c00c477307e305e2d380779bb74fa29b31072c4c.tar.bz2
dexon-sol-tools-c00c477307e305e2d380779bb74fa29b31072c4c.tar.lz
dexon-sol-tools-c00c477307e305e2d380779bb74fa29b31072c4c.tar.xz
dexon-sol-tools-c00c477307e305e2d380779bb74fa29b31072c4c.tar.zst
dexon-sol-tools-c00c477307e305e2d380779bb74fa29b31072c4c.zip
Add doc comments to AbiDecoder
-rw-r--r--packages/utils/src/abi_decoder.ts19
1 files changed, 18 insertions, 1 deletions
diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts
index 7f93e746e..58a58dea2 100644
--- a/packages/utils/src/abi_decoder.ts
+++ b/packages/utils/src/abi_decoder.ts
@@ -15,12 +15,25 @@ import * as _ from 'lodash';
import { addressUtils } from './address_utils';
import { BigNumber } from './configured_bignumber';
+/**
+ * AbiDecoder allows you to decode event logs given a set of supplied contract ABI's. It takes the contract's event
+ * signature from the ABI and attempts to decode the logs using it.
+ */
export class AbiDecoder {
private readonly _methodIds: { [signatureHash: string]: EventAbi } = {};
+ /**
+ * Instantiate an AbiDecoder
+ * @param abiArrays An array of contract ABI's
+ * @return AbiDecoder instance
+ */
constructor(abiArrays: AbiDefinition[][]) {
_.forEach(abiArrays, this.addABI.bind(this));
}
- // This method can only decode logs from the 0x & ERC20 smart contracts
+ /**
+ * Attempt to decode a log given the ABI's the AbiDecoder knows about.
+ * @param log The log to attempt to decode
+ * @return The decoded log if the requisite ABI was available. Otherwise the log unaltered.
+ */
public tryToDecodeLogOrNoop<ArgsType extends DecodedLogArgs>(log: LogEntry): LogWithDecodedArgs<ArgsType> | RawLog {
const methodId = log.topics[0];
const event = this._methodIds[methodId];
@@ -75,6 +88,10 @@ export class AbiDecoder {
};
}
}
+ /**
+ * Add additional ABI definitions to the AbiDecoder
+ * @param abiArray An array of ABI definitions to add to the AbiDecoder
+ */
public addABI(abiArray: AbiDefinition[]): void {
if (_.isUndefined(abiArray)) {
return;