aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers/token_wrapper.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-10 21:36:52 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-10 21:36:52 +0800
commitd727bed6ab6fef90717a45845c544b409657e3c2 (patch)
tree9a232b7764d80726acf5f4dd91d19c0c06ae0439 /src/contract_wrappers/token_wrapper.ts
parent8b9d8ad1b625967fe264fe87e617af1089e1d0e9 (diff)
downloaddexon-sol-tools-d727bed6ab6fef90717a45845c544b409657e3c2.tar
dexon-sol-tools-d727bed6ab6fef90717a45845c544b409657e3c2.tar.gz
dexon-sol-tools-d727bed6ab6fef90717a45845c544b409657e3c2.tar.bz2
dexon-sol-tools-d727bed6ab6fef90717a45845c544b409657e3c2.tar.lz
dexon-sol-tools-d727bed6ab6fef90717a45845c544b409657e3c2.tar.xz
dexon-sol-tools-d727bed6ab6fef90717a45845c544b409657e3c2.tar.zst
dexon-sol-tools-d727bed6ab6fef90717a45845c544b409657e3c2.zip
Prefix private vars with _
Diffstat (limited to 'src/contract_wrappers/token_wrapper.ts')
-rw-r--r--src/contract_wrappers/token_wrapper.ts30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts
index bb79cac47..b0101c0da 100644
--- a/src/contract_wrappers/token_wrapper.ts
+++ b/src/contract_wrappers/token_wrapper.ts
@@ -11,13 +11,13 @@ import {TokenContract, ZeroExError} from '../types';
const ALLOWANCE_TO_ZERO_GAS_AMOUNT = 45730;
export class TokenWrapper extends ContractWrapper {
- private tokenContractsByAddress: {[address: string]: TokenContract};
+ private _tokenContractsByAddress: {[address: string]: TokenContract};
constructor(web3Wrapper: Web3Wrapper) {
super(web3Wrapper);
- this.tokenContractsByAddress = {};
+ this._tokenContractsByAddress = {};
}
public invalidateContractInstances() {
- this.tokenContractsByAddress = {};
+ this._tokenContractsByAddress = {};
}
/**
* Retrieves an owner's ERC20 token balance.
@@ -29,7 +29,7 @@ export class TokenWrapper extends ContractWrapper {
assert.isETHAddressHex('tokenAddress', tokenAddress);
await assert.isUserAddressAvailableAsync(this.web3Wrapper);
- const tokenContract = await this.getTokenContractAsync(tokenAddress);
+ const tokenContract = await this._getTokenContractAsync(tokenAddress);
let balance = await tokenContract.balanceOf.call(ownerAddress);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
balance = new BigNumber(balance);
@@ -51,7 +51,7 @@ export class TokenWrapper extends ContractWrapper {
assert.isETHAddressHex('tokenAddress', tokenAddress);
assert.isBigNumber('amountInBaseUnits', amountInBaseUnits);
- const tokenContract = await this.getTokenContractAsync(tokenAddress);
+ const tokenContract = await this._getTokenContractAsync(tokenAddress);
// Hack: for some reason default estimated gas amount causes `base fee exceeds gas limit` exception
// on testrpc. Probably related to https://github.com/ethereumjs/testrpc/issues/294
// TODO: Debug issue in testrpc and submit a PR, then remove this hack
@@ -74,7 +74,7 @@ export class TokenWrapper extends ContractWrapper {
assert.isETHAddressHex('tokenAddress', tokenAddress);
await assert.isUserAddressAvailableAsync(this.web3Wrapper);
- const tokenContract = await this.getTokenContractAsync(tokenAddress);
+ const tokenContract = await this._getTokenContractAsync(tokenAddress);
let allowanceInBaseUnits = await tokenContract.allowance.call(ownerAddress, spenderAddress);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
allowanceInBaseUnits = new BigNumber(allowanceInBaseUnits);
@@ -89,7 +89,7 @@ export class TokenWrapper extends ContractWrapper {
assert.isETHAddressHex('ownerAddress', ownerAddress);
assert.isETHAddressHex('tokenAddress', tokenAddress);
- const proxyAddress = await this.getProxyAddressAsync();
+ const proxyAddress = await this._getProxyAddressAsync();
const allowanceInBaseUnits = await this.getAllowanceAsync(tokenAddress, ownerAddress, proxyAddress);
return allowanceInBaseUnits;
}
@@ -107,7 +107,7 @@ export class TokenWrapper extends ContractWrapper {
assert.isETHAddressHex('tokenAddress', tokenAddress);
assert.isBigNumber('amountInBaseUnits', amountInBaseUnits);
- const proxyAddress = await this.getProxyAddressAsync();
+ const proxyAddress = await this._getProxyAddressAsync();
await this.setAllowanceAsync(tokenAddress, ownerAddress, proxyAddress, amountInBaseUnits);
}
/**
@@ -124,7 +124,7 @@ export class TokenWrapper extends ContractWrapper {
assert.isETHAddressHex('toAddress', toAddress);
assert.isBigNumber('amountInBaseUnits', amountInBaseUnits);
- const tokenContract = await this.getTokenContractAsync(tokenAddress);
+ const tokenContract = await this._getTokenContractAsync(tokenAddress);
const fromAddressBalance = await this.getBalanceAsync(tokenAddress, fromAddress);
if (fromAddressBalance.lessThan(amountInBaseUnits)) {
@@ -155,7 +155,7 @@ export class TokenWrapper extends ContractWrapper {
await assert.isSenderAddressAsync('senderAddress', senderAddress, this.web3Wrapper);
assert.isBigNumber('amountInBaseUnits', amountInBaseUnits);
- const tokenContract = await this.getTokenContractAsync(tokenAddress);
+ const tokenContract = await this._getTokenContractAsync(tokenAddress);
const fromAddressAllowance = await this.getAllowanceAsync(tokenAddress, fromAddress, senderAddress);
if (fromAddressAllowance.lessThan(amountInBaseUnits)) {
@@ -171,17 +171,17 @@ export class TokenWrapper extends ContractWrapper {
from: senderAddress,
});
}
- private async getTokenContractAsync(tokenAddress: string): Promise<TokenContract> {
- let tokenContract = this.tokenContractsByAddress[tokenAddress];
+ private async _getTokenContractAsync(tokenAddress: string): Promise<TokenContract> {
+ let tokenContract = this._tokenContractsByAddress[tokenAddress];
if (!_.isUndefined(tokenContract)) {
return tokenContract;
}
- const contractInstance = await this.instantiateContractIfExistsAsync((TokenArtifacts as any), tokenAddress);
+ const contractInstance = await this._instantiateContractIfExistsAsync((TokenArtifacts as any), tokenAddress);
tokenContract = contractInstance as TokenContract;
- this.tokenContractsByAddress[tokenAddress] = tokenContract;
+ this._tokenContractsByAddress[tokenAddress] = tokenContract;
return tokenContract;
}
- private async getProxyAddressAsync() {
+ private async _getProxyAddressAsync() {
const networkIdIfExists = await this.web3Wrapper.getNetworkIdIfExistsAsync();
const proxyNetworkConfigsIfExists = _.isUndefined(networkIdIfExists) ?
undefined :