aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-11-10 05:30:14 +0800
committerFabio Berger <me@fabioberger.com>2017-11-10 05:30:14 +0800
commitecc54b07c70c9f191a0eb0dece8137f088250a41 (patch)
tree73a1cd5f5fdbf241818fab6ab9b5706470342712
parentce11a38d700a89ae5cda5810dff34a0efd2068ba (diff)
downloaddexon-sol-tools-ecc54b07c70c9f191a0eb0dece8137f088250a41.tar
dexon-sol-tools-ecc54b07c70c9f191a0eb0dece8137f088250a41.tar.gz
dexon-sol-tools-ecc54b07c70c9f191a0eb0dece8137f088250a41.tar.bz2
dexon-sol-tools-ecc54b07c70c9f191a0eb0dece8137f088250a41.tar.lz
dexon-sol-tools-ecc54b07c70c9f191a0eb0dece8137f088250a41.tar.xz
dexon-sol-tools-ecc54b07c70c9f191a0eb0dece8137f088250a41.tar.zst
dexon-sol-tools-ecc54b07c70c9f191a0eb0dece8137f088250a41.zip
Use _.get for optional configs
-rw-r--r--src/0x.ts17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/0x.ts b/src/0x.ts
index 313f723d7..51744d2d6 100644
--- a/src/0x.ts
+++ b/src/0x.ts
@@ -1,5 +1,6 @@
import * as _ from 'lodash';
import BigNumber from 'bignumber.js';
+import * as Web3 from 'web3';
import {SchemaValidator, schemas} from '0x-json-schemas';
import {bigNumberConfigs} from './bignumber_config';
import * as ethUtil from 'ethereumjs-util';
@@ -187,7 +188,7 @@ export class ZeroEx {
const artifactJSONs = _.values(artifacts);
const abiArrays = _.map(artifactJSONs, artifact => artifact.abi);
this._abiDecoder = new AbiDecoder(abiArrays);
- const gasPrice = _.isUndefined(config) ? undefined : config.gasPrice;
+ const gasPrice: number|undefined = _.get(config, 'gasPrice');
const defaults = {
gasPrice,
};
@@ -197,7 +198,7 @@ export class ZeroEx {
this._abiDecoder,
this._getTokenTransferProxyAddressAsync.bind(this),
);
- const exchageContractAddressIfExists = _.isUndefined(config) ? undefined : config.exchangeContractAddress;
+ const exchageContractAddressIfExists: string|undefined = _.get(config, 'exchangeContractAddress');
this.exchange = new ExchangeWrapper(
this._web3Wrapper,
this._abiDecoder,
@@ -208,13 +209,11 @@ export class ZeroEx {
this._web3Wrapper,
this._getTokenTransferProxyAddressAsync.bind(this),
);
- const tokenRegistryContractAddressIfExists = _.isUndefined(config) ?
- undefined :
- config.tokenRegistryContractAddress;
- this.tokenRegistry = new TokenRegistryWrapper(this._web3Wrapper, tokenRegistryContractAddressIfExists);
- const etherTokenContractAddressIfExists = _.isUndefined(config) ? undefined : config.etherTokenContractAddress;
- this.etherToken = new EtherTokenWrapper(this._web3Wrapper, this.token, etherTokenContractAddressIfExists);
- const mempoolPollingIntervalMs = _.isUndefined(config) ? undefined : config.mempoolPollingIntervalMs;
+ const tokenRegistryContractAddressIfExists = _.get(config, 'tokenRegistryContractAddress');
+ this.tokenRegistry = new TokenRegistryWrapper(this._web3Wrapper, 'tokenRegistryContractAddressIfExists');
+ const etherTokenContractAddressIfExists = _.get(config, 'etherTokenContractAddress');
+ this.etherToken = new EtherTokenWrapper(this._web3Wrapper, this.token, 'etherTokenContractAddressIfExists');
+ const mempoolPollingIntervalMs: number|undefined = _.get(config, 'mempoolPollingIntervalMs');
const orderStateUtils = new OrderStateUtils(this.token, this.exchange);
this.orderStateWatcher = new OrderStateWatcher(
this._web3Wrapper, this._abiDecoder, orderStateUtils, mempoolPollingIntervalMs,