Fix contract not deployed on network bug in ContractWrapper class

This commit is contained in:
Brandon Millman
2018-08-29 21:36:20 -07:00
parent 397fefa8d7
commit 01685b7622
2 changed files with 8 additions and 1 deletions

View File

@@ -4,6 +4,10 @@
"changes": [
{
"note": "Add `OrderValidatorWrapper`"
},
{
"note":
"Fix bug where contracts not deployed on a network showed an `EXCHANGE_CONTRACT_DOES_NOT_EXIST` error instead of `CONTRACT_NOT_DEPLOYED_ON_NETWORK`"
}
]
},

View File

@@ -145,9 +145,12 @@ export abstract class ContractWrapper {
}
protected _getContractAddress(artifact: ContractArtifact, addressIfExists?: string): string {
if (_.isUndefined(addressIfExists)) {
if (_.isUndefined(artifact.networks[this._networkId])) {
throw new Error(ContractWrappersError.ContractNotDeployedOnNetwork);
}
const contractAddress = artifact.networks[this._networkId].address;
if (_.isUndefined(contractAddress)) {
throw new Error(ContractWrappersError.ExchangeContractDoesNotExist);
throw new Error(CONTRACT_NAME_TO_NOT_FOUND_ERROR[artifact.contractName]);
}
return contractAddress;
} else {