diff options
author | Leonid <logvinov.leon@gmail.com> | 2017-09-07 00:32:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-07 00:32:02 +0800 |
commit | c56724981970f90dfe68212d0447e8c7c9866b07 (patch) | |
tree | 0d57265a1d2a405987a6764e0c3c858fc87f26c0 /src/utils | |
parent | 912d15cb73de0d44394c9d2e11e8dfdb248ade9c (diff) | |
parent | d2dc4d18be93fd04f237bef7fe7e29e4a9447517 (diff) | |
download | dexon-sol-tools-c56724981970f90dfe68212d0447e8c7c9866b07.tar dexon-sol-tools-c56724981970f90dfe68212d0447e8c7c9866b07.tar.gz dexon-sol-tools-c56724981970f90dfe68212d0447e8c7c9866b07.tar.bz2 dexon-sol-tools-c56724981970f90dfe68212d0447e8c7c9866b07.tar.lz dexon-sol-tools-c56724981970f90dfe68212d0447e8c7c9866b07.tar.xz dexon-sol-tools-c56724981970f90dfe68212d0447e8c7c9866b07.tar.zst dexon-sol-tools-c56724981970f90dfe68212d0447e8c7c9866b07.zip |
Merge pull request #157 from 0xProject/feature/throw-for-exchange-errors
Feature/throw for exchange errors
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/abi_decoder.ts | 5 | ||||
-rw-r--r-- | src/utils/interval_utils.ts | 20 |
2 files changed, 23 insertions, 2 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/src/utils/interval_utils.ts b/src/utils/interval_utils.ts new file mode 100644 index 000000000..1656318e6 --- /dev/null +++ b/src/utils/interval_utils.ts @@ -0,0 +1,20 @@ +import * as _ from 'lodash'; + +export const intervalUtils = { + setAsyncExcludingInterval(fn: () => Promise<void>, intervalMs: number) { + let locked = false; + const intervalId = setInterval(async () => { + if (locked) { + return; + } else { + locked = true; + await fn(); + locked = false; + } + }); + return intervalId; + }, + clearAsyncExcludingInterval(intervalId: number): void { + clearInterval(intervalId); + }, +}; |