aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-07-18 05:52:34 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-07-26 04:25:56 +0800
commitd9a8b961542dfbde0a736e1caea2de41d0e350cd (patch)
treecb629a00d6295f355d7860f4f3a309e2b7c3b5b8 /src
parentc7d89d98f3b6a95f41bcdf4f09aa7aa516a0fa64 (diff)
downloaddexon-sol-tools-d9a8b961542dfbde0a736e1caea2de41d0e350cd.tar
dexon-sol-tools-d9a8b961542dfbde0a736e1caea2de41d0e350cd.tar.gz
dexon-sol-tools-d9a8b961542dfbde0a736e1caea2de41d0e350cd.tar.bz2
dexon-sol-tools-d9a8b961542dfbde0a736e1caea2de41d0e350cd.tar.lz
dexon-sol-tools-d9a8b961542dfbde0a736e1caea2de41d0e350cd.tar.xz
dexon-sol-tools-d9a8b961542dfbde0a736e1caea2de41d0e350cd.tar.zst
dexon-sol-tools-d9a8b961542dfbde0a736e1caea2de41d0e350cd.zip
Pass tokenWrapper to validateFillOrderBalancesAndAllowancesAndThrowIfInvalidAsync
Diffstat (limited to 'src')
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts2
-rw-r--r--src/utils/order_validation_utils.ts22
2 files changed, 12 insertions, 12 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 8895c5000..232531a83 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -669,7 +669,7 @@ export class ExchangeWrapper extends ContractWrapper {
}
const zrxTokenAddress = await this._getZRXTokenAddressAsync(signedOrder.exchangeContractAddress);
await orderValidationUtils.validateFillOrderBalancesAndAllowancesAndThrowIfInvalidAsync(
- signedOrder, fillTakerAmount, senderAddress, zrxTokenAddress,
+ this._tokenWrapper, signedOrder, fillTakerAmount, senderAddress, zrxTokenAddress,
);
const wouldRoundingErrorOccur = await this._isRoundingErrorAsync(
diff --git a/src/utils/order_validation_utils.ts b/src/utils/order_validation_utils.ts
index 05c284ac3..924e9aebd 100644
--- a/src/utils/order_validation_utils.ts
+++ b/src/utils/order_validation_utils.ts
@@ -1,4 +1,5 @@
import {ExchangeContractErrs, SignedOrder} from '../types';
+import {TokenWrapper} from '../contract_wrappers/token_wrapper';
export const orderValidationUtils = {
/**
@@ -11,15 +12,14 @@ export const orderValidationUtils = {
* the callers gas costs.
*/
async validateFillOrderBalancesAndAllowancesAndThrowIfInvalidAsync(
- signedOrder: SignedOrder, fillTakerAmount: BigNumber.BigNumber, senderAddress: string, zrxTokenAddress: string,
- ): Promise<void> {
-
- const makerBalance = await this._tokenWrapper.getBalanceAsync(signedOrder.makerTokenAddress,
+ tokenWrapper: TokenWrapper, signedOrder: SignedOrder, fillTakerAmount: BigNumber.BigNumber,
+ senderAddress: string, zrxTokenAddress: string): Promise<void> {
+ const makerBalance = await tokenWrapper.getBalanceAsync(signedOrder.makerTokenAddress,
signedOrder.maker);
- const takerBalance = await this._tokenWrapper.getBalanceAsync(signedOrder.takerTokenAddress, senderAddress);
- const makerAllowance = await this._tokenWrapper.getProxyAllowanceAsync(signedOrder.makerTokenAddress,
+ const takerBalance = await tokenWrapper.getBalanceAsync(signedOrder.takerTokenAddress, senderAddress);
+ const makerAllowance = await tokenWrapper.getProxyAllowanceAsync(signedOrder.makerTokenAddress,
signedOrder.maker);
- const takerAllowance = await this._tokenWrapper.getProxyAllowanceAsync(signedOrder.takerTokenAddress,
+ const takerAllowance = await tokenWrapper.getProxyAllowanceAsync(signedOrder.takerTokenAddress,
senderAddress);
// exchangeRate is the price of one maker token denominated in taker tokens
@@ -42,12 +42,12 @@ export const orderValidationUtils = {
throw new Error(ExchangeContractErrs.InsufficientMakerAllowance);
}
- const makerFeeBalance = await this._tokenWrapper.getBalanceAsync(zrxTokenAddress,
+ const makerFeeBalance = await tokenWrapper.getBalanceAsync(zrxTokenAddress,
signedOrder.maker);
- const takerFeeBalance = await this._tokenWrapper.getBalanceAsync(zrxTokenAddress, senderAddress);
- const makerFeeAllowance = await this._tokenWrapper.getProxyAllowanceAsync(zrxTokenAddress,
+ const takerFeeBalance = await tokenWrapper.getBalanceAsync(zrxTokenAddress, senderAddress);
+ const makerFeeAllowance = await tokenWrapper.getProxyAllowanceAsync(zrxTokenAddress,
signedOrder.maker);
- const takerFeeAllowance = await this._tokenWrapper.getProxyAllowanceAsync(zrxTokenAddress,
+ const takerFeeAllowance = await tokenWrapper.getProxyAllowanceAsync(zrxTokenAddress,
senderAddress);
if (signedOrder.takerFee.greaterThan(takerFeeBalance)) {