aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_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_proxy_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_proxy_wrapper.ts')
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts39
1 files changed, 13 insertions, 26 deletions
diff --git a/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts
index 5900f0502..31b3b6755 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts
@@ -13,25 +13,25 @@ import { ContractWrapper } from './contract_wrapper';
*/
export class ERC20ProxyWrapper extends ContractWrapper {
public abi: ContractAbi = artifacts.ERC20Proxy.compilerOutput.abi;
+ public address: string;
private _erc20ProxyContractIfExists?: wrappers.ERC20ProxyContract;
- private _contractAddressIfExists?: string;
/**
* Instantiate ERC20ProxyWrapper
* @param web3Wrapper Web3Wrapper instance to use
- * @param networkId Desired networkId
- * @param contractAddressIfExists The contract address to use. This is usually pulled from
- * the artifacts but needs to be specified when using with your own custom testnet.
+ * @param address The address of the ERC20Proxy contract
*/
- constructor(web3Wrapper: Web3Wrapper, networkId: number, contractAddressIfExists?: string) {
- super(web3Wrapper, networkId);
- this._contractAddressIfExists = contractAddressIfExists;
+ // TODO(albrow): Make address optional and default to looking up the address
+ // based in a hard-coded mapping based on web3Wrapper network id.
+ constructor(web3Wrapper: Web3Wrapper, address: string) {
+ super(web3Wrapper);
+ this.address = address;
}
/**
* Get the 4 bytes ID of this asset proxy
* @return Proxy id
*/
public async getProxyIdAsync(): Promise<AssetProxyId> {
- const ERC20ProxyContractInstance = await this._getERC20ProxyContractAsync();
+ const ERC20ProxyContractInstance = this._getERC20ProxyContract();
const proxyId = (await ERC20ProxyContractInstance.getProxyId.callAsync()) as AssetProxyId;
return proxyId;
}
@@ -43,7 +43,7 @@ export class ERC20ProxyWrapper extends ContractWrapper {
public async isAuthorizedAsync(exchangeContractAddress: string): Promise<boolean> {
assert.isETHAddressHex('exchangeContractAddress', exchangeContractAddress);
const normalizedExchangeContractAddress = exchangeContractAddress.toLowerCase();
- const ERC20ProxyContractInstance = await this._getERC20ProxyContractAsync();
+ const ERC20ProxyContractInstance = this._getERC20ProxyContract();
const isAuthorized = await ERC20ProxyContractInstance.authorized.callAsync(normalizedExchangeContractAddress);
return isAuthorized;
}
@@ -52,36 +52,23 @@ export class ERC20ProxyWrapper extends ContractWrapper {
* @return The list of authorized addresses.
*/
public async getAuthorizedAddressesAsync(): Promise<string[]> {
- const ERC20ProxyContractInstance = await this._getERC20ProxyContractAsync();
+ const ERC20ProxyContractInstance = this._getERC20ProxyContract();
const authorizedAddresses = await ERC20ProxyContractInstance.getAuthorizedAddresses.callAsync();
return authorizedAddresses;
}
- /**
- * Retrieves the Ethereum address of the ERC20Proxy contract deployed on the network
- * that the user-passed web3 provider is connected to.
- * @returns The Ethereum address of the ERC20Proxy contract being used.
- */
- public getContractAddress(): string {
- const contractAddress = this._getContractAddress(artifacts.ERC20Proxy, this._contractAddressIfExists);
- return contractAddress;
- }
// HACK: We don't want this method to be visible to the other units within that package but not to the end user.
// TS doesn't give that possibility and therefore we make it private and access it over an any cast. Because of that tslint sees it as unused.
// tslint:disable-next-line:no-unused-variable
private _invalidateContractInstance(): void {
delete this._erc20ProxyContractIfExists;
}
- private async _getERC20ProxyContractAsync(): Promise<wrappers.ERC20ProxyContract> {
+ private _getERC20ProxyContract(): wrappers.ERC20ProxyContract {
if (!_.isUndefined(this._erc20ProxyContractIfExists)) {
return this._erc20ProxyContractIfExists;
}
- const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
- artifacts.ERC20Proxy,
- this._contractAddressIfExists,
- );
const contractInstance = new wrappers.ERC20ProxyContract(
- abi,
- address,
+ this.abi,
+ this.address,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);