diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-09-06 23:26:55 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-09-06 23:26:55 +0800 |
commit | b38aff8808db0ade04746f69bbb25b62147d17a4 (patch) | |
tree | 597dc99bdf7a659c841d934c0df14d24e45eeb59 | |
parent | 912d15cb73de0d44394c9d2e11e8dfdb248ade9c (diff) | |
download | dexon-sol-tools-b38aff8808db0ade04746f69bbb25b62147d17a4.tar dexon-sol-tools-b38aff8808db0ade04746f69bbb25b62147d17a4.tar.gz dexon-sol-tools-b38aff8808db0ade04746f69bbb25b62147d17a4.tar.bz2 dexon-sol-tools-b38aff8808db0ade04746f69bbb25b62147d17a4.tar.lz dexon-sol-tools-b38aff8808db0ade04746f69bbb25b62147d17a4.tar.xz dexon-sol-tools-b38aff8808db0ade04746f69bbb25b62147d17a4.tar.zst dexon-sol-tools-b38aff8808db0ade04746f69bbb25b62147d17a4.zip |
Fix log decoder to return correct types
-rw-r--r-- | src/utils/abi_decoder.ts | 5 | ||||
-rw-r--r-- | test/0x.js_test.ts | 8 |
2 files changed, 6 insertions, 7 deletions
diff --git a/src/utils/abi_decoder.ts b/src/utils/abi_decoder.ts index f988a5695..61c8eecd4 100644 --- a/src/utils/abi_decoder.ts +++ b/src/utils/abi_decoder.ts @@ -1,5 +1,6 @@ import * as Web3 from 'web3'; import * as _ from 'lodash'; +import * as BigNumber from 'bignumber.js'; import {AbiType, DecodedLogArgs, DecodedArgs} from '../types'; import * as SolidityCoder from 'web3/lib/solidity/coder'; @@ -31,9 +32,9 @@ export class AbiDecoder { dataIndex++; } if (param.type === 'address') { - value = this.padZeros(new Web3().toBigNumber(value).toString(16)); + value = this.padZeros(new BigNumber(value).toString(16)); } else if (param.type === 'uint256' || param.type === 'uint8' || param.type === 'int' ) { - value = new Web3().toBigNumber(value).toString(10); + value = new BigNumber(value); } decodedParams[param.name] = value; }); diff --git a/test/0x.js_test.ts b/test/0x.js_test.ts index 5182275a8..5461a7d3f 100644 --- a/test/0x.js_test.ts +++ b/test/0x.js_test.ts @@ -226,11 +226,9 @@ describe('ZeroEx library', () => { const txReceiptWithDecodedLogs = await zeroEx.awaitTransactionMinedAsync(txHash); const log = txReceiptWithDecodedLogs.logs[0] as LogWithDecodedArgs; expect(log.event).to.be.equal('Approval'); - expect(log.args).to.be.deep.equal({ - _owner: coinbase, - _spender: proxyAddress, - _value: zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS.toString(), - }); + expect(log.args._owner).to.be.equal(coinbase); + expect(log.args._spender).to.be.equal(proxyAddress); + expect(log.args._value).to.be.bignumber.equal(zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS); }); }); }); |