aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-10-16 15:11:58 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-10-16 15:23:43 +0800
commit5bdfad9b415fc183102d5f5a7f3a08782921f003 (patch)
treedbb5635bf678e59126f07bd69364cfda43374a1c
parent3c5812c5d20e98475ef8ce47b949596656f46a0d (diff)
downloaddexon-sol-tools-5bdfad9b415fc183102d5f5a7f3a08782921f003.tar
dexon-sol-tools-5bdfad9b415fc183102d5f5a7f3a08782921f003.tar.gz
dexon-sol-tools-5bdfad9b415fc183102d5f5a7f3a08782921f003.tar.bz2
dexon-sol-tools-5bdfad9b415fc183102d5f5a7f3a08782921f003.tar.lz
dexon-sol-tools-5bdfad9b415fc183102d5f5a7f3a08782921f003.tar.xz
dexon-sol-tools-5bdfad9b415fc183102d5f5a7f3a08782921f003.tar.zst
dexon-sol-tools-5bdfad9b415fc183102d5f5a7f3a08782921f003.zip
Remove ContractNotFound errors in contract-wrappers
-rw-r--r--packages/contract-wrappers/CHANGELOG.json5
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts6
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts6
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts7
-rw-r--r--packages/contract-wrappers/src/types.ts7
-rw-r--r--packages/contract-wrappers/test/erc20_wrapper_test.ts33
-rw-r--r--packages/contract-wrappers/test/erc721_wrapper_test.ts13
-rw-r--r--packages/website/ts/utils/utils.ts7
8 files changed, 5 insertions, 79 deletions
diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json
index 8c9a717c7..9bb5e5fc5 100644
--- a/packages/contract-wrappers/CHANGELOG.json
+++ b/packages/contract-wrappers/CHANGELOG.json
@@ -32,6 +32,11 @@
"note":
"Some properties and methods have been renamed. For example, some methods that previously could throw no longer can, and so their names have been updated accordingly.",
"pr": 1105
+ },
+ {
+ "note":
+ "Removed ContractNotFound errors. Checking for this error was somewhat ineffecient. Relevant methods/functions now return the default error from web3-wrapper, which we feel provides enough information.",
+ "pr": 1105
}
]
},
diff --git a/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
index 97043bd19..192eaf0a7 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
@@ -428,12 +428,6 @@ export class ERC20TokenWrapper extends ContractWrapper {
if (!_.isUndefined(tokenContract)) {
return tokenContract;
}
- // TODO(albrow): Do we really still need this check? The default error
- // looks okay to me.
- const doesContractExist = await this._web3Wrapper.doesContractExistAtAddressAsync(tokenAddress);
- if (!doesContractExist) {
- throw new Error(ContractWrappersError.ERC20TokenContractDoesNotExist);
- }
const contractInstance = new ERC20TokenContract(
this.abi,
normalizedTokenAddress,
diff --git a/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts
index a59801b41..d92d7087c 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts
@@ -455,12 +455,6 @@ export class ERC721TokenWrapper extends ContractWrapper {
if (!_.isUndefined(tokenContract)) {
return tokenContract;
}
- // TODO(albrow): Do we really still need this check? The default error
- // looks okay to me.
- const doesContractExist = await this._web3Wrapper.doesContractExistAtAddressAsync(tokenAddress);
- if (!doesContractExist) {
- throw new Error(ContractWrappersError.ERC721TokenContractDoesNotExist);
- }
const contractInstance = new ERC721TokenContract(
this.abi,
normalizedTokenAddress,
diff --git a/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts
index 8bb27369f..d5775208e 100644
--- a/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts
@@ -197,13 +197,6 @@ export class EtherTokenWrapper extends ContractWrapper {
if (!_.isUndefined(etherTokenContract)) {
return etherTokenContract;
}
- // TODO(albrow): Do we really still need this check? The default error
- // looks okay to me.
- // TODO(albrow): Should we normalize the token address here?
- const doesContractExist = await this._web3Wrapper.doesContractExistAtAddressAsync(etherTokenAddress);
- if (!doesContractExist) {
- throw new Error(ContractWrappersError.EtherTokenContractDoesNotExist);
- }
const contractInstance = new WETH9Contract(
this.abi,
etherTokenAddress,
diff --git a/packages/contract-wrappers/src/types.ts b/packages/contract-wrappers/src/types.ts
index e70adb991..895a47cc1 100644
--- a/packages/contract-wrappers/src/types.ts
+++ b/packages/contract-wrappers/src/types.ts
@@ -19,13 +19,6 @@ export enum ExchangeWrapperError {
}
export enum ContractWrappersError {
- ExchangeContractDoesNotExist = 'EXCHANGE_CONTRACT_DOES_NOT_EXIST',
- ZRXContractDoesNotExist = 'ZRX_CONTRACT_DOES_NOT_EXIST',
- EtherTokenContractDoesNotExist = 'ETHER_TOKEN_CONTRACT_DOES_NOT_EXIST',
- ERC20ProxyContractDoesNotExist = 'ERC20_PROXY_CONTRACT_DOES_NOT_EXIST',
- ERC721ProxyContractDoesNotExist = 'ERC721_PROXY_CONTRACT_DOES_NOT_EXIST',
- ERC20TokenContractDoesNotExist = 'ERC20_TOKEN_CONTRACT_DOES_NOT_EXIST',
- ERC721TokenContractDoesNotExist = 'ERC721_TOKEN_CONTRACT_DOES_NOT_EXIST',
ContractNotDeployedOnNetwork = 'CONTRACT_NOT_DEPLOYED_ON_NETWORK',
InsufficientAllowanceForTransfer = 'INSUFFICIENT_ALLOWANCE_FOR_TRANSFER',
InsufficientBalanceForTransfer = 'INSUFFICIENT_BALANCE_FOR_TRANSFER',
diff --git a/packages/contract-wrappers/test/erc20_wrapper_test.ts b/packages/contract-wrappers/test/erc20_wrapper_test.ts
index 2cfa9f0b2..c065f4d63 100644
--- a/packages/contract-wrappers/test/erc20_wrapper_test.ts
+++ b/packages/contract-wrappers/test/erc20_wrapper_test.ts
@@ -80,19 +80,6 @@ describe('ERC20Wrapper', () => {
contractWrappers.erc20Token.transferAsync(tokenAddress, fromAddress, toAddress, transferAmount),
).to.be.rejectedWith(ContractWrappersError.InsufficientBalanceForTransfer);
});
- it('should throw a CONTRACT_DOES_NOT_EXIST error for a non-existent token contract', async () => {
- const nonExistentTokenAddress = '0x9dd402f14d67e001d8efbe6583e51bf9706aa065';
- const fromAddress = coinbase;
- const toAddress = coinbase;
- return expect(
- contractWrappers.erc20Token.transferAsync(
- nonExistentTokenAddress,
- fromAddress,
- toAddress,
- transferAmount,
- ),
- ).to.be.rejectedWith(ContractWrappersError.ERC20TokenContractDoesNotExist);
- });
});
describe('#transferFromAsync', () => {
let tokenAddress: string;
@@ -197,19 +184,6 @@ describe('ERC20Wrapper', () => {
const postBalance = await contractWrappers.erc20Token.getBalanceAsync(tokenAddress, toAddress);
return expect(postBalance).to.be.bignumber.equal(transferAmount);
});
- it('should throw a CONTRACT_DOES_NOT_EXIST error for a non-existent token contract', async () => {
- const fromAddress = coinbase;
- const nonExistentTokenAddress = '0x9dd402f14d67e001d8efbe6583e51bf9706aa065';
- return expect(
- contractWrappers.erc20Token.transferFromAsync(
- nonExistentTokenAddress,
- fromAddress,
- toAddress,
- senderAddress,
- new BigNumber(42),
- ),
- ).to.be.rejectedWith(ContractWrappersError.ERC20TokenContractDoesNotExist);
- });
});
describe('#getBalanceAsync', () => {
describe('With provider with accounts', () => {
@@ -220,13 +194,6 @@ describe('ERC20Wrapper', () => {
const expectedBalance = new BigNumber('1000000000000000000000000000');
return expect(balance).to.be.bignumber.equal(expectedBalance);
});
- it('should throw a CONTRACT_DOES_NOT_EXIST error for a non-existent token contract', async () => {
- const nonExistentTokenAddress = '0x9dd402f14d67e001d8efbe6583e51bf9706aa065';
- const ownerAddress = coinbase;
- return expect(
- contractWrappers.erc20Token.getBalanceAsync(nonExistentTokenAddress, ownerAddress),
- ).to.be.rejectedWith(ContractWrappersError.ERC20TokenContractDoesNotExist);
- });
it('should return a balance of 0 for a non-existent owner address', async () => {
const tokenAddress = tokens[0];
const nonExistentOwner = '0x198c6ad858f213fb31b6fe809e25040e6b964593';
diff --git a/packages/contract-wrappers/test/erc721_wrapper_test.ts b/packages/contract-wrappers/test/erc721_wrapper_test.ts
index c57370b7b..1efbb37c7 100644
--- a/packages/contract-wrappers/test/erc721_wrapper_test.ts
+++ b/packages/contract-wrappers/test/erc721_wrapper_test.ts
@@ -115,12 +115,6 @@ describe('ERC721Wrapper', () => {
tokenCount = await contractWrappers.erc721Token.getTokenCountAsync(tokenAddress, ownerAddress);
expect(tokenCount).to.be.bignumber.equal(1);
});
- it('should throw a CONTRACT_DOES_NOT_EXIST error for a non-existent token contract', async () => {
- const nonExistentTokenAddress = '0x9dd402f14d67e001d8efbe6583e51bf9706aa065';
- return expect(
- contractWrappers.erc721Token.getTokenCountAsync(nonExistentTokenAddress, ownerAddress),
- ).to.be.rejectedWith(ContractWrappersError.ERC721TokenContractDoesNotExist);
- });
it('should return a balance of 0 for a non-existent owner address', async () => {
const nonExistentOwner = '0x198c6ad858f213fb31b6fe809e25040e6b964593';
const balance = await contractWrappers.erc721Token.getTokenCountAsync(tokenAddress, nonExistentOwner);
@@ -149,13 +143,6 @@ describe('ERC721Wrapper', () => {
const tokenOwner = await contractWrappers.erc721Token.getOwnerOfAsync(tokenAddress, tokenId);
expect(tokenOwner).to.be.bignumber.equal(ownerAddress);
});
- it('should throw a CONTRACT_DOES_NOT_EXIST error for a non-existent token contract', async () => {
- const nonExistentTokenAddress = '0x9dd402f14d67e001d8efbe6583e51bf9706aa065';
- const fakeTokenId = new BigNumber(42);
- return expect(
- contractWrappers.erc721Token.getOwnerOfAsync(nonExistentTokenAddress, fakeTokenId),
- ).to.be.rejectedWith(ContractWrappersError.ERC721TokenContractDoesNotExist);
- });
it('should return undefined not 0 for a non-existent ERC721', async () => {
const fakeTokenId = new BigNumber(42);
return expect(contractWrappers.erc721Token.getOwnerOfAsync(tokenAddress, fakeTokenId)).to.be.rejectedWith(
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index d083e0ffc..d1628bc52 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -231,13 +231,6 @@ export const utils = {
},
zeroExErrToHumanReadableErrMsg(error: ContractWrappersError | ExchangeContractErrs, takerAddress: string): string {
const ContractWrappersErrorToHumanReadableError: { [error: string]: string } = {
- [ContractWrappersError.ExchangeContractDoesNotExist]: 'Exchange contract does not exist',
- [ContractWrappersError.EtherTokenContractDoesNotExist]: 'EtherToken contract does not exist',
- [ContractWrappersError.ERC20ProxyContractDoesNotExist]: 'ERC20 proxy contract des not exist',
- [ContractWrappersError.ERC721ProxyContractDoesNotExist]: 'ERC721 proxy contract des not exist',
- [ContractWrappersError.ERC20TokenContractDoesNotExist]: 'ERC20 token contract does not exist',
- [ContractWrappersError.ERC721TokenContractDoesNotExist]: 'ERC721 token contract does not exist',
- [ContractWrappersError.ZRXContractDoesNotExist]: 'ZRX contract does not exist',
[BlockchainCallErrs.UserHasNoAssociatedAddresses]: 'User has no addresses available',
[OrderError.InvalidSignature]: 'Order signature is not valid',
[ContractWrappersError.ContractNotDeployedOnNetwork]: 'Contract is not deployed on the detected network',