aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src/contract_wrappers
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-06-27 16:47:14 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-06-29 22:52:53 +0800
commit3aef323c1334e577905855cac50a6f41245563c6 (patch)
tree2d2f9be422fcaae0db97f71fe636ecc0eacf5547 /packages/contract-wrappers/src/contract_wrappers
parenta655cd046c79d53de69e71bf9217155a00a2ebe8 (diff)
downloaddexon-sol-tools-3aef323c1334e577905855cac50a6f41245563c6.tar
dexon-sol-tools-3aef323c1334e577905855cac50a6f41245563c6.tar.gz
dexon-sol-tools-3aef323c1334e577905855cac50a6f41245563c6.tar.bz2
dexon-sol-tools-3aef323c1334e577905855cac50a6f41245563c6.tar.lz
dexon-sol-tools-3aef323c1334e577905855cac50a6f41245563c6.tar.xz
dexon-sol-tools-3aef323c1334e577905855cac50a6f41245563c6.tar.zst
dexon-sol-tools-3aef323c1334e577905855cac50a6f41245563c6.zip
Refactor ERC20 token transfer proxy and it's tests
Diffstat (limited to 'packages/contract-wrappers/src/contract_wrappers')
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts (renamed from packages/contract-wrappers/src/contract_wrappers/token_transfer_proxy_wrapper.ts)48
1 files changed, 23 insertions, 25 deletions
diff --git a/packages/contract-wrappers/src/contract_wrappers/token_transfer_proxy_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts
index 5194931d7..d1ec5b08a 100644
--- a/packages/contract-wrappers/src/contract_wrappers/token_transfer_proxy_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts
@@ -1,75 +1,73 @@
import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import { ContractAbi } from '@0xproject/types';
+import { ContractAbi } from 'ethereum-types';
import * as _ from 'lodash';
import { artifacts } from '../artifacts';
import { assert } from '../utils/assert';
import { ContractWrapper } from './contract_wrapper';
-import { TokenTransferProxyContract } from './generated/token_transfer_proxy';
+import { ERC20ProxyContract } from './generated/erc20_proxy';
/**
- * This class includes the functionality related to interacting with the TokenTransferProxy contract.
+ * This class includes the functionality related to interacting with the ERC20Proxy contract.
*/
-export class TokenTransferProxyWrapper extends ContractWrapper {
- public abi: ContractAbi = artifacts.TokenTransferProxy.abi;
- private _tokenTransferProxyContractIfExists?: TokenTransferProxyContract;
+export class ERC20ProxyWrapper extends ContractWrapper {
+ public abi: ContractAbi = artifacts.ERC20Proxy.compilerOutput.abi;
+ private _erc20ProxyContractIfExists?: ERC20ProxyContract;
private _contractAddressIfExists?: string;
constructor(web3Wrapper: Web3Wrapper, networkId: number, contractAddressIfExists?: string) {
super(web3Wrapper, networkId);
this._contractAddressIfExists = contractAddressIfExists;
}
/**
- * Check if the Exchange contract address is authorized by the TokenTransferProxy contract.
+ * Check if the Exchange contract address is authorized by the ERC20Proxy contract.
* @param exchangeContractAddress The hex encoded address of the Exchange contract to call.
* @return Whether the exchangeContractAddress is authorized.
*/
public async isAuthorizedAsync(exchangeContractAddress: string): Promise<boolean> {
assert.isETHAddressHex('exchangeContractAddress', exchangeContractAddress);
const normalizedExchangeContractAddress = exchangeContractAddress.toLowerCase();
- const tokenTransferProxyContractInstance = await this._getTokenTransferProxyContractAsync();
- const isAuthorized = await tokenTransferProxyContractInstance.authorized.callAsync(
- normalizedExchangeContractAddress,
- );
+ const ERC20ProxyContractInstance = await this._getERC20ProxyContractAsync();
+ const isAuthorized = await ERC20ProxyContractInstance.authorized.callAsync(normalizedExchangeContractAddress);
return isAuthorized;
}
/**
- * Get the list of all Exchange contract addresses authorized by the TokenTransferProxy contract.
+ * Get the list of all Exchange contract addresses authorized by the ERC20Proxy contract.
* @return The list of authorized addresses.
*/
public async getAuthorizedAddressesAsync(): Promise<string[]> {
- const tokenTransferProxyContractInstance = await this._getTokenTransferProxyContractAsync();
- const authorizedAddresses = await tokenTransferProxyContractInstance.getAuthorizedAddresses.callAsync();
+ const ERC20ProxyContractInstance = await this._getERC20ProxyContractAsync();
+ const authorizedAddresses = await ERC20ProxyContractInstance.getAuthorizedAddresses.callAsync();
return authorizedAddresses;
}
/**
- * Retrieves the Ethereum address of the TokenTransferProxy contract deployed on the network
+ * 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 TokenTransferProxy contract being used.
+ * @returns The Ethereum address of the ERC20Proxy contract being used.
*/
public getContractAddress(): string {
- const contractAddress = this._getContractAddress(artifacts.TokenTransferProxy, this._contractAddressIfExists);
+ const contractAddress = this._getContractAddress(artifacts.ERC20Proxy, this._contractAddressIfExists);
return contractAddress;
}
// tslint:disable-next-line:no-unused-variable
private _invalidateContractInstance(): void {
- delete this._tokenTransferProxyContractIfExists;
+ delete this._erc20ProxyContractIfExists;
}
- private async _getTokenTransferProxyContractAsync(): Promise<TokenTransferProxyContract> {
- if (!_.isUndefined(this._tokenTransferProxyContractIfExists)) {
- return this._tokenTransferProxyContractIfExists;
+ private async _getERC20ProxyContractAsync(): Promise<ERC20ProxyContract> {
+ if (!_.isUndefined(this._erc20ProxyContractIfExists)) {
+ return this._erc20ProxyContractIfExists;
}
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
- artifacts.TokenTransferProxy,
+ artifacts.ERC20Proxy,
this._contractAddressIfExists,
);
- const contractInstance = new TokenTransferProxyContract(
+ const contractInstance = new ERC20ProxyContract(
abi,
address,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
- this._tokenTransferProxyContractIfExists = contractInstance;
- return this._tokenTransferProxyContractIfExists;
+ this._erc20ProxyContractIfExists = contractInstance;
+ return this._erc20ProxyContractIfExists;
}
}