aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src/contract_wrappers/ether_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/ether_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/ether_token_wrapper.ts')
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts37
1 files changed, 11 insertions, 26 deletions
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 30653adf2..526324abd 100644
--- a/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts
@@ -30,13 +30,8 @@ export class EtherTokenWrapper extends ContractWrapper {
* @param erc20TokenWrapper The ERC20TokenWrapper instance to use
* @param blockPollingIntervalMs The block polling interval to use for active subscriptions
*/
- constructor(
- web3Wrapper: Web3Wrapper,
- networkId: number,
- erc20TokenWrapper: ERC20TokenWrapper,
- blockPollingIntervalMs?: number,
- ) {
- super(web3Wrapper, networkId, blockPollingIntervalMs);
+ constructor(web3Wrapper: Web3Wrapper, erc20TokenWrapper: ERC20TokenWrapper, blockPollingIntervalMs?: number) {
+ super(web3Wrapper, blockPollingIntervalMs);
this._erc20TokenWrapper = erc20TokenWrapper;
}
/**
@@ -191,19 +186,6 @@ export class EtherTokenWrapper extends ContractWrapper {
public unsubscribeAll(): void {
super._unsubscribeAll();
}
- /**
- * Retrieves the Ethereum address of the EtherToken contract deployed on the network
- * that the user-passed web3 provider is connected to. If it's not Kovan, Ropsten, Rinkeby, Mainnet or TestRPC
- * (networkId: 50), it will return undefined (e.g a private network).
- * @returns The Ethereum address of the EtherToken contract or undefined.
- */
- public getContractAddressIfExists(): string | undefined {
- const networkSpecificArtifact = artifacts.WETH9.networks[this._networkId];
- const contractAddressIfExists = _.isUndefined(networkSpecificArtifact)
- ? undefined
- : networkSpecificArtifact.address;
- return contractAddressIfExists;
- }
// tslint:disable-next-line:no-unused-variable
private _invalidateContractInstance(): void {
this.unsubscribeAll();
@@ -214,13 +196,16 @@ export class EtherTokenWrapper extends ContractWrapper {
if (!_.isUndefined(etherTokenContract)) {
return etherTokenContract;
}
- const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
- artifacts.WETH9,
- etherTokenAddress,
- );
+ // 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 wrappers.WETH9Contract(
- abi,
- address,
+ this.abi,
+ etherTokenAddress,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);