aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contract-wrappers/src')
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts (renamed from packages/contract-wrappers/src/contract_wrappers/token_wrapper.ts)46
1 files changed, 23 insertions, 23 deletions
diff --git a/packages/contract-wrappers/src/contract_wrappers/token_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
index d9364715f..315b0314a 100644
--- a/packages/contract-wrappers/src/contract_wrappers/token_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
@@ -1,7 +1,7 @@
import { schemas } from '@0xproject/json-schemas';
-import { ContractAbi, LogWithDecodedArgs } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
import { artifacts } from '../artifacts';
@@ -17,23 +17,23 @@ import { assert } from '../utils/assert';
import { constants } from '../utils/constants';
import { ContractWrapper } from './contract_wrapper';
-import { TokenContract, TokenContractEventArgs, TokenEvents } from './generated/token';
-import { TokenTransferProxyWrapper } from './token_transfer_proxy_wrapper';
+import { ERC20ProxyWrapper } from './erc20_proxy_wrapper';
+import { ERC20TokenContract, ERC20TokenEventArgs, ERC20TokenEvents } from './generated/erc20_token';
/**
* This class includes all the functionality related to interacting with ERC20 token contracts.
* All ERC20 method calls are supported, along with some convenience methods for getting/setting allowances
- * to the 0x Proxy smart contract.
+ * to the 0x ERC20 Proxy smart contract.
*/
-export class TokenWrapper extends ContractWrapper {
- public abi: ContractAbi = artifacts.Token.abi;
+export class ERC20TokenWrapper extends ContractWrapper {
+ public abi: ContractAbi = artifacts.ERC20Token.compilerOutput.abi;
public UNLIMITED_ALLOWANCE_IN_BASE_UNITS = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
- private _tokenContractsByAddress: { [address: string]: TokenContract };
- private _tokenTransferProxyWrapper: TokenTransferProxyWrapper;
- constructor(web3Wrapper: Web3Wrapper, networkId: number, tokenTransferProxyWrapper: TokenTransferProxyWrapper) {
+ private _tokenContractsByAddress: { [address: string]: ERC20TokenContract };
+ private _erc20ProxyWrapper: ERC20ProxyWrapper;
+ constructor(web3Wrapper: Web3Wrapper, networkId: number, erc20ProxyWrapper: ERC20ProxyWrapper) {
super(web3Wrapper, networkId);
this._tokenContractsByAddress = {};
- this._tokenTransferProxyWrapper = tokenTransferProxyWrapper;
+ this._erc20ProxyWrapper = erc20ProxyWrapper;
}
/**
* Retrieves an owner's ERC20 token balance.
@@ -177,7 +177,7 @@ export class TokenWrapper extends ContractWrapper {
const normalizedTokenAddress = tokenAddress.toLowerCase();
const normalizedOwnerAddress = ownerAddress.toLowerCase();
- const proxyAddress = this._tokenTransferProxyWrapper.getContractAddress();
+ const proxyAddress = this._erc20ProxyWrapper.getContractAddress();
const allowanceInBaseUnits = await this.getAllowanceAsync(
normalizedTokenAddress,
normalizedOwnerAddress,
@@ -208,7 +208,7 @@ export class TokenWrapper extends ContractWrapper {
const normalizedOwnerAddress = ownerAddress.toLowerCase();
assert.isValidBaseUnitAmount('amountInBaseUnits', amountInBaseUnits);
- const proxyAddress = this._tokenTransferProxyWrapper.getContractAddress();
+ const proxyAddress = this._erc20ProxyWrapper.getContractAddress();
const txHash = await this.setAllowanceAsync(
normalizedTokenAddress,
normalizedOwnerAddress,
@@ -353,22 +353,22 @@ export class TokenWrapper extends ContractWrapper {
* @param callback Callback that gets called when a log is added/removed
* @return Subscription token used later to unsubscribe
*/
- public subscribe<ArgsType extends TokenContractEventArgs>(
+ public subscribe<ArgsType extends ERC20TokenEventArgs>(
tokenAddress: string,
- eventName: TokenEvents,
+ eventName: ERC20TokenEvents,
indexFilterValues: IndexedFilterValues,
callback: EventCallback<ArgsType>,
): string {
assert.isETHAddressHex('tokenAddress', tokenAddress);
const normalizedTokenAddress = tokenAddress.toLowerCase();
- assert.doesBelongToStringEnum('eventName', eventName, TokenEvents);
+ assert.doesBelongToStringEnum('eventName', eventName, ERC20TokenEvents);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
assert.isFunction('callback', callback);
const subscriptionToken = this._subscribe<ArgsType>(
normalizedTokenAddress,
eventName,
indexFilterValues,
- artifacts.Token.abi,
+ artifacts.ERC20Token.compilerOutput.abi,
callback,
);
return subscriptionToken;
@@ -395,15 +395,15 @@ export class TokenWrapper extends ContractWrapper {
* the value is the value you are interested in. E.g `{_from: aUserAddressHex}`
* @return Array of logs that match the parameters
*/
- public async getLogsAsync<ArgsType extends TokenContractEventArgs>(
+ public async getLogsAsync<ArgsType extends ERC20TokenEventArgs>(
tokenAddress: string,
- eventName: TokenEvents,
+ eventName: ERC20TokenEvents,
blockRange: BlockRange,
indexFilterValues: IndexedFilterValues,
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
assert.isETHAddressHex('tokenAddress', tokenAddress);
const normalizedTokenAddress = tokenAddress.toLowerCase();
- assert.doesBelongToStringEnum('eventName', eventName, TokenEvents);
+ assert.doesBelongToStringEnum('eventName', eventName, ERC20TokenEvents);
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
const logs = await this._getLogsAsync<ArgsType>(
@@ -411,7 +411,7 @@ export class TokenWrapper extends ContractWrapper {
eventName,
blockRange,
indexFilterValues,
- artifacts.Token.abi,
+ artifacts.ERC20Token.compilerOutput.abi,
);
return logs;
}
@@ -420,17 +420,17 @@ export class TokenWrapper extends ContractWrapper {
this.unsubscribeAll();
this._tokenContractsByAddress = {};
}
- private async _getTokenContractAsync(tokenAddress: string): Promise<TokenContract> {
+ private async _getTokenContractAsync(tokenAddress: string): Promise<ERC20TokenContract> {
const normalizedTokenAddress = tokenAddress.toLowerCase();
let tokenContract = this._tokenContractsByAddress[normalizedTokenAddress];
if (!_.isUndefined(tokenContract)) {
return tokenContract;
}
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
- artifacts.Token,
+ artifacts.ERC20Token,
normalizedTokenAddress,
);
- const contractInstance = new TokenContract(
+ const contractInstance = new ERC20TokenContract(
abi,
address,
this._web3Wrapper.getProvider(),