diff options
author | Leonid <logvinov.leon@gmail.com> | 2017-06-21 21:04:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-21 21:04:13 +0800 |
commit | 8af7d2303ecf9d4d3cdc967a81ef577b9f8739d3 (patch) | |
tree | 15b9aa5b849d896248541722b7f2dfed6c458749 /src/contract_wrappers/contract_wrapper.ts | |
parent | ef96c58b7f7d0ce678e8eb4f662b2f6a31e8799a (diff) | |
parent | a1c363a8af3cbfa2d843aaf7ddd05390db7b8f9b (diff) | |
download | dexon-sol-tools-8af7d2303ecf9d4d3cdc967a81ef577b9f8739d3.tar dexon-sol-tools-8af7d2303ecf9d4d3cdc967a81ef577b9f8739d3.tar.gz dexon-sol-tools-8af7d2303ecf9d4d3cdc967a81ef577b9f8739d3.tar.bz2 dexon-sol-tools-8af7d2303ecf9d4d3cdc967a81ef577b9f8739d3.tar.lz dexon-sol-tools-8af7d2303ecf9d4d3cdc967a81ef577b9f8739d3.tar.xz dexon-sol-tools-8af7d2303ecf9d4d3cdc967a81ef577b9f8739d3.tar.zst dexon-sol-tools-8af7d2303ecf9d4d3cdc967a81ef577b9f8739d3.zip |
Merge pull request #71 from 0xProject/lodash-tree-shake
Use different lodash import syntax which allows to include only used functions
Diffstat (limited to 'src/contract_wrappers/contract_wrapper.ts')
-rw-r--r-- | src/contract_wrappers/contract_wrapper.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/contract_wrappers/contract_wrapper.ts b/src/contract_wrappers/contract_wrapper.ts index f9c1bc1cf..f5d2cd4eb 100644 --- a/src/contract_wrappers/contract_wrapper.ts +++ b/src/contract_wrappers/contract_wrapper.ts @@ -1,4 +1,5 @@ -import * as _ from 'lodash'; +import includes = require('lodash/includes'); +import isUndefined = require('lodash/isUndefined'); import contract = require('truffle-contract'); import {Web3Wrapper} from '../web3_wrapper'; import {ZeroExError, Artifact, ContractInstance} from '../types'; @@ -15,17 +16,17 @@ export class ContractWrapper { c.setProvider(providerObj); const networkIdIfExists = await this._web3Wrapper.getNetworkIdIfExistsAsync(); - const artifactNetworkConfigs = _.isUndefined(networkIdIfExists) ? + const artifactNetworkConfigs = isUndefined(networkIdIfExists) ? undefined : artifact.networks[networkIdIfExists]; let contractAddress; - if (!_.isUndefined(address)) { + if (!isUndefined(address)) { contractAddress = address; - } else if (!_.isUndefined(artifactNetworkConfigs)) { + } else if (!isUndefined(artifactNetworkConfigs)) { contractAddress = artifactNetworkConfigs.address; } - if (!_.isUndefined(contractAddress)) { + if (!isUndefined(contractAddress)) { const doesContractExist = await this._web3Wrapper.doesContractExistAtAddressAsync(contractAddress); if (!doesContractExist) { throw new Error(ZeroExError.CONTRACT_DOES_NOT_EXIST); @@ -33,11 +34,11 @@ export class ContractWrapper { } try { - const contractInstance = _.isUndefined(address) ? await c.deployed() : await c.at(address); + const contractInstance = isUndefined(address) ? await c.deployed() : await c.at(address); return contractInstance; } catch (err) { const errMsg = `${err}`; - if (_.includes(errMsg, 'not been deployed to detected network')) { + if (includes(errMsg, 'not been deployed to detected network')) { throw new Error(ZeroExError.CONTRACT_DOES_NOT_EXIST); } else { utils.consoleLog(`Notice: Error encountered: ${err} ${err.stack}`); |