aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-06 20:56:54 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-06 20:56:54 +0800
commit0dfc2b5f3b81e034a9c939f667383eb03c9a5561 (patch)
treec1ad14d297cb6c03d4b3b73668a467c4cd81f549 /src
parentef57dd22e29057e5bd84b9a0ad36a123126695df (diff)
downloaddexon-sol-tools-0dfc2b5f3b81e034a9c939f667383eb03c9a5561.tar
dexon-sol-tools-0dfc2b5f3b81e034a9c939f667383eb03c9a5561.tar.gz
dexon-sol-tools-0dfc2b5f3b81e034a9c939f667383eb03c9a5561.tar.bz2
dexon-sol-tools-0dfc2b5f3b81e034a9c939f667383eb03c9a5561.tar.lz
dexon-sol-tools-0dfc2b5f3b81e034a9c939f667383eb03c9a5561.tar.xz
dexon-sol-tools-0dfc2b5f3b81e034a9c939f667383eb03c9a5561.tar.zst
dexon-sol-tools-0dfc2b5f3b81e034a9c939f667383eb03c9a5561.zip
Add isAnyAddressAvailableAsync
Diffstat (limited to 'src')
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts1
-rw-r--r--src/contract_wrappers/token_wrapper.ts2
-rw-r--r--src/utils/assert.ts4
-rw-r--r--src/web3_wrapper.ts6
4 files changed, 7 insertions, 6 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 08e592729..e885b0e07 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -297,6 +297,7 @@ export class ExchangeWrapper extends ContractWrapper {
private async isRoundingErrorAsync(takerTokenAmount: BigNumber.BigNumber,
fillTakerAmount: BigNumber.BigNumber,
makerTokenAmount: BigNumber.BigNumber): Promise<boolean> {
+ await assert.isAnyAddressAvailableAsync(this.web3Wrapper);
const exchangeInstance = await this.getExchangeContractAsync();
const isRoundingError = await exchangeInstance.isRoundingError.call(
takerTokenAmount, fillTakerAmount, makerTokenAmount,
diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts
index d30645548..945f5caf1 100644
--- a/src/contract_wrappers/token_wrapper.ts
+++ b/src/contract_wrappers/token_wrapper.ts
@@ -25,6 +25,7 @@ export class TokenWrapper extends ContractWrapper {
public async getBalanceAsync(tokenAddress: string, ownerAddress: string): Promise<BigNumber.BigNumber> {
assert.isETHAddressHex('ownerAddress', ownerAddress);
assert.isETHAddressHex('tokenAddress', tokenAddress);
+ await assert.isAnyAddressAvailableAsync(this.web3Wrapper);
const tokenContract = await this.getTokenContractAsync(tokenAddress);
let balance = await tokenContract.balanceOf.call(ownerAddress);
@@ -60,6 +61,7 @@ export class TokenWrapper extends ContractWrapper {
public async getAllowanceAsync(tokenAddress: string, ownerAddress: string, spenderAddress: string) {
assert.isETHAddressHex('ownerAddress', ownerAddress);
assert.isETHAddressHex('tokenAddress', tokenAddress);
+ await assert.isAnyAddressAvailableAsync(this.web3Wrapper);
const tokenContract = await this.getTokenContractAsync(tokenAddress);
let allowanceInBaseUnits = await tokenContract.allowance.call(ownerAddress, spenderAddress);
diff --git a/src/utils/assert.ts b/src/utils/assert.ts
index 621c11eda..7ab1b7c62 100644
--- a/src/utils/assert.ts
+++ b/src/utils/assert.ts
@@ -37,6 +37,10 @@ export const assert = {
assert.assert(isSenderAddressAvailable, `Specified ${variableName} ${senderAddressHex} isn't available \
through the supplied web3 instance`);
},
+ async isAnyAddressAvailableAsync(web3Wrapper: Web3Wrapper): Promise<void> {
+ const availableAddresses = await web3Wrapper.getAvailableAddressesAsync();
+ this.assert(!_.isEmpty(availableAddresses), 'No addresses are available on the provided web3 instance');
+ },
isNumber(variableName: string, value: number): void {
this.assert(_.isFinite(value), this.typeAssertionMessage(variableName, 'number', value));
},
diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts
index e1bb29f85..05a8dc063 100644
--- a/src/web3_wrapper.ts
+++ b/src/web3_wrapper.ts
@@ -17,12 +17,6 @@ export class Web3Wrapper {
public isAddress(address: string): boolean {
return this.web3.isAddress(address);
}
- public getDefaultAddress(): string {
- return this.web3.eth.defaultAccount;
- }
- public setDefaultAddress(address: string): void {
- this.web3.eth.defaultAccount = address;
- }
public async isSenderAddressAvailableAsync(senderAddress: string): Promise<boolean> {
const addresses = await this.getAvailableAddressesAsync();
return _.includes(addresses, senderAddress);