diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-23 05:43:17 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-24 05:13:37 +0800 |
commit | db2917b01caa49d74c9ebcae2d36e9c3946b94d8 (patch) | |
tree | 88aa341cb4dc02f1bfbc7d0d00d21966e1bbde20 /packages/0x.js/src/utils/abi_decoder.ts | |
parent | 87d34f9c7f3ccf22e01798c27c4a4d5d4f943816 (diff) | |
download | dexon-0x-contracts-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.tar.gz dexon-0x-contracts-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.tar.zst dexon-0x-contracts-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.zip |
Enable some new linter rules and fix the issues
Diffstat (limited to 'packages/0x.js/src/utils/abi_decoder.ts')
-rw-r--r-- | packages/0x.js/src/utils/abi_decoder.ts | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/packages/0x.js/src/utils/abi_decoder.ts b/packages/0x.js/src/utils/abi_decoder.ts index f027026da..f26b057f0 100644 --- a/packages/0x.js/src/utils/abi_decoder.ts +++ b/packages/0x.js/src/utils/abi_decoder.ts @@ -8,6 +8,15 @@ import {AbiType, ContractEventArgs, DecodedLogArgs, LogWithDecodedArgs, RawLog, export class AbiDecoder { private savedABIs: Web3.AbiDefinition[] = []; private methodIds: {[signatureHash: string]: Web3.EventAbi} = {}; + private static padZeros(address: string) { + let formatted = address; + if (_.startsWith(formatted, '0x')) { + formatted = formatted.slice(2); + } + + formatted = _.padStart(formatted, 40, '0'); + return `0x${formatted}`; + } constructor(abiArrays: Web3.AbiDefinition[][]) { _.map(abiArrays, this.addABI.bind(this)); } @@ -32,7 +41,7 @@ export class AbiDecoder { // Indexed parameters are stored in topics. Non-indexed ones in decodedData let value = param.indexed ? log.topics[topicsIndex++] : decodedData[dataIndex++]; if (param.type === SolidityTypes.Address) { - value = this.padZeros(new BigNumber(value).toString(16)); + value = AbiDecoder.padZeros(new BigNumber(value).toString(16)); } else if (param.type === SolidityTypes.Uint256 || param.type === SolidityTypes.Uint8 || param.type === SolidityTypes.Uint) { @@ -57,13 +66,4 @@ export class AbiDecoder { }); this.savedABIs = this.savedABIs.concat(abiArray); } - private padZeros(address: string) { - let formatted = address; - if (_.startsWith(formatted, '0x')) { - formatted = formatted.slice(2); - } - - formatted = _.padStart(formatted, 40, '0'); - return `0x${formatted}`; - } } |