aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-10-04 07:21:17 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-10-16 04:36:59 +0800
commit3a7bb97ad1182eb9c718797bda8dca5eb5d7f9cd (patch)
tree15d4c7df95fd96d6aedb712738cd18bfb213b1f1 /packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
parent2aa73fc83962d421eae4447108a07a5d952b569d (diff)
downloaddexon-sol-tools-3a7bb97ad1182eb9c718797bda8dca5eb5d7f9cd.tar
dexon-sol-tools-3a7bb97ad1182eb9c718797bda8dca5eb5d7f9cd.tar.gz
dexon-sol-tools-3a7bb97ad1182eb9c718797bda8dca5eb5d7f9cd.tar.bz2
dexon-sol-tools-3a7bb97ad1182eb9c718797bda8dca5eb5d7f9cd.tar.lz
dexon-sol-tools-3a7bb97ad1182eb9c718797bda8dca5eb5d7f9cd.tar.xz
dexon-sol-tools-3a7bb97ad1182eb9c718797bda8dca5eb5d7f9cd.tar.zst
dexon-sol-tools-3a7bb97ad1182eb9c718797bda8dca5eb5d7f9cd.zip
Remove artifacts from migrations package and update contract-wrappers accordingly
Diffstat (limited to 'packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts')
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts28
1 files changed, 12 insertions, 16 deletions
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 3be5bcaee..53cda5d08 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
@@ -36,17 +36,11 @@ export class ERC20TokenWrapper extends ContractWrapper {
/**
* Instantiate ERC20TokenWrapper
* @param web3Wrapper Web3Wrapper instance to use
- * @param networkId Desired networkId
* @param erc20ProxyWrapper The ERC20ProxyWrapper instance to use
* @param blockPollingIntervalMs The block polling interval to use for active subscriptions
*/
- constructor(
- web3Wrapper: Web3Wrapper,
- networkId: number,
- erc20ProxyWrapper: ERC20ProxyWrapper,
- blockPollingIntervalMs?: number,
- ) {
- super(web3Wrapper, networkId, blockPollingIntervalMs);
+ constructor(web3Wrapper: Web3Wrapper, erc20ProxyWrapper: ERC20ProxyWrapper, blockPollingIntervalMs?: number) {
+ super(web3Wrapper, blockPollingIntervalMs);
this._tokenContractsByAddress = {};
this._erc20ProxyWrapper = erc20ProxyWrapper;
}
@@ -188,7 +182,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
ownerAddress: string,
methodOpts: MethodOpts = {},
): Promise<BigNumber> {
- const proxyAddress = this._erc20ProxyWrapper.getContractAddress();
+ const proxyAddress = this._erc20ProxyWrapper.address;
const allowanceInBaseUnits = await this.getAllowanceAsync(tokenAddress, ownerAddress, proxyAddress, methodOpts);
return allowanceInBaseUnits;
}
@@ -208,7 +202,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
amountInBaseUnits: BigNumber,
txOpts: TransactionOpts = {},
): Promise<string> {
- const proxyAddress = this._erc20ProxyWrapper.getContractAddress();
+ const proxyAddress = this._erc20ProxyWrapper.address;
const txHash = await this.setAllowanceAsync(
tokenAddress,
ownerAddress,
@@ -434,13 +428,15 @@ export class ERC20TokenWrapper extends ContractWrapper {
if (!_.isUndefined(tokenContract)) {
return tokenContract;
}
- const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
- artifacts.ERC20Token,
- normalizedTokenAddress,
- );
+ // 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 wrappers.ERC20TokenContract(
- abi,
- address,
+ this.abi,
+ normalizedTokenAddress,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);