diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-24 04:29:49 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-24 05:15:47 +0800 |
commit | c780d04ceea70bbe706bdd740b4dec01a34de00b (patch) | |
tree | 4678ba3dfd931a37a57d63217d27b1f15515d5df /packages/0x.js/src/web3_wrapper.ts | |
parent | 8c54e9a8731ccd831daf5533070302746af575e5 (diff) | |
download | dexon-0x-contracts-c780d04ceea70bbe706bdd740b4dec01a34de00b.tar.gz dexon-0x-contracts-c780d04ceea70bbe706bdd740b4dec01a34de00b.tar.zst dexon-0x-contracts-c780d04ceea70bbe706bdd740b4dec01a34de00b.zip |
Remove ContractDoesNotExist error and replace it with more specific errors
Diffstat (limited to 'packages/0x.js/src/web3_wrapper.ts')
-rw-r--r-- | packages/0x.js/src/web3_wrapper.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/packages/0x.js/src/web3_wrapper.ts b/packages/0x.js/src/web3_wrapper.ts index 557cd28e5..a031de486 100644 --- a/packages/0x.js/src/web3_wrapper.ts +++ b/packages/0x.js/src/web3_wrapper.ts @@ -4,7 +4,7 @@ import * as _ from 'lodash'; import * as Web3 from 'web3'; import {Contract} from './contract'; -import {Artifact, TransactionReceipt, ZeroExError} from './types'; +import {Artifact, ArtifactContractName, TransactionReceipt, ZeroExError} from './types'; interface RawLogEntry { logIndex: string|null; @@ -17,6 +17,15 @@ interface RawLogEntry { topics: string[]; } +const CONTRACT_NAME_TO_NOT_FOUND_ERROR: {[contractName: string]: ZeroExError} = { + ZRX: ZeroExError.ZRXContractDoesNotExist, + EtherToken: ZeroExError.EtherTokenContractDoesNotExist, + Token: ZeroExError.TokenContractDoesNotExist, + TokenRegistry: ZeroExError.TokenRegistryContractDoesNotExist, + TokenTransferProxy: ZeroExError.TokenTransferProxyContractDoesNotExist, + Exchange: ZeroExError.ExchangeContractDoesNotExist, +}; + export class Web3Wrapper { private web3: Web3; private networkId: number; @@ -77,7 +86,7 @@ export class Web3Wrapper { } const doesContractExist = await this.doesContractExistAtAddressAsync(contractAddress); if (!doesContractExist) { - throw new Error(ZeroExError.ContractDoesNotExist); + throw new Error(CONTRACT_NAME_TO_NOT_FOUND_ERROR[artifact.contract_name]); } const contractInstance = this.getContractInstance<A>( artifact.abi, contractAddress, |