From 260def1aefc65fd1b5ae19c86f9c361c795630ed Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 29 Jun 2017 11:02:52 -0700 Subject: Check that artefacts by networkId are not undefined before getting the address --- src/contract_wrappers/exchange_wrapper.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 7f67346ce..a121d524c 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -609,9 +609,12 @@ export class ExchangeWrapper extends ContractWrapper { if (_.isUndefined(networkId)) { return []; } else { + const exchangeArtifacts = _.values(ExchangeArtifactsByName); + const networkSpecificExchangeArtifacts = _.compact(_.map( + exchangeArtifacts, exchangeArtifact => exchangeArtifact.networks[networkId])); const exchangeAddresses = _.map( - _.values(ExchangeArtifactsByName), - exchangeArtifact => exchangeArtifact.networks[networkId].address, + networkSpecificExchangeArtifacts, + networkSpecificExchangeArtifact => networkSpecificExchangeArtifact.address, ); return exchangeAddresses; } -- cgit