aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-06-02 15:39:05 +0800
committerFabio Berger <me@fabioberger.com>2017-06-02 15:39:05 +0800
commit293ce6f4b2e495589ae3675eb293fb9948f22dbb (patch)
treedf1607c86c4961cc757ce7b78d885843435d82cd
parent3e0c2ad7530927fa1c9019bbc311a88d327e2306 (diff)
downloaddexon-sol-tools-293ce6f4b2e495589ae3675eb293fb9948f22dbb.tar
dexon-sol-tools-293ce6f4b2e495589ae3675eb293fb9948f22dbb.tar.gz
dexon-sol-tools-293ce6f4b2e495589ae3675eb293fb9948f22dbb.tar.bz2
dexon-sol-tools-293ce6f4b2e495589ae3675eb293fb9948f22dbb.tar.lz
dexon-sol-tools-293ce6f4b2e495589ae3675eb293fb9948f22dbb.tar.xz
dexon-sol-tools-293ce6f4b2e495589ae3675eb293fb9948f22dbb.tar.zst
dexon-sol-tools-293ce6f4b2e495589ae3675eb293fb9948f22dbb.zip
Always wrap BigNumbers returned by web3 with our own version and add comment
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts12
-rw-r--r--src/contract_wrappers/token_wrapper.ts4
2 files changed, 11 insertions, 5 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 8b20d2b4d..2894c5a9f 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -70,7 +70,9 @@ export class ExchangeWrapper extends ContractWrapper {
assert.isValidOrderHash('orderHashHex', orderHashHex);
const exchangeContract = await this.getExchangeContractAsync();
- const unavailableAmountInBaseUnits = await exchangeContract.getUnavailableValueT.call(orderHashHex);
+ let unavailableAmountInBaseUnits = await exchangeContract.getUnavailableValueT.call(orderHashHex);
+ // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
+ unavailableAmountInBaseUnits = new BigNumber(unavailableAmountInBaseUnits);
return unavailableAmountInBaseUnits;
}
/**
@@ -80,7 +82,9 @@ export class ExchangeWrapper extends ContractWrapper {
assert.isValidOrderHash('orderHashHex', orderHashHex);
const exchangeContract = await this.getExchangeContractAsync();
- const fillAmountInBaseUnits = await exchangeContract.filled.call(orderHashHex);
+ let fillAmountInBaseUnits = await exchangeContract.filled.call(orderHashHex);
+ // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
+ fillAmountInBaseUnits = new BigNumber(fillAmountInBaseUnits);
return fillAmountInBaseUnits;
}
/**
@@ -90,7 +94,9 @@ export class ExchangeWrapper extends ContractWrapper {
assert.isValidOrderHash('orderHashHex', orderHashHex);
const exchangeContract = await this.getExchangeContractAsync();
- const cancelledAmountInBaseUnits = await exchangeContract.cancelled.call(orderHashHex);
+ let cancelledAmountInBaseUnits = await exchangeContract.cancelled.call(orderHashHex);
+ // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
+ cancelledAmountInBaseUnits = new BigNumber(cancelledAmountInBaseUnits);
return cancelledAmountInBaseUnits;
}
/**
diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts
index cedbfbdae..69bcc9024 100644
--- a/src/contract_wrappers/token_wrapper.ts
+++ b/src/contract_wrappers/token_wrapper.ts
@@ -28,8 +28,7 @@ export class TokenWrapper extends ContractWrapper {
const tokenContract = await this.getTokenContractAsync(tokenAddress);
let balance = await tokenContract.balanceOf.call(ownerAddress);
- // The BigNumber instance returned by Web3 is of a much older version then our own, we therefore
- // should always re-instantiate the returned BigNumber after retrieval.
+ // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
balance = new BigNumber(balance);
return balance;
}
@@ -44,6 +43,7 @@ export class TokenWrapper extends ContractWrapper {
const tokenContract = await this.getTokenContractAsync(tokenAddress);
const proxyAddress = await this.getProxyAddressAsync();
let allowanceInBaseUnits = await tokenContract.allowance.call(ownerAddress, proxyAddress);
+ // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
allowanceInBaseUnits = new BigNumber(allowanceInBaseUnits);
return allowanceInBaseUnits;
}