Pass tokenWrapper to validateFillOrderBalancesAndAllowancesAndThrowIfInvalidAsync
This commit is contained in:
		| @@ -669,7 +669,7 @@ export class ExchangeWrapper extends ContractWrapper { | |||||||
|         } |         } | ||||||
|         const zrxTokenAddress = await this._getZRXTokenAddressAsync(signedOrder.exchangeContractAddress); |         const zrxTokenAddress = await this._getZRXTokenAddressAsync(signedOrder.exchangeContractAddress); | ||||||
|         await orderValidationUtils.validateFillOrderBalancesAndAllowancesAndThrowIfInvalidAsync( |         await orderValidationUtils.validateFillOrderBalancesAndAllowancesAndThrowIfInvalidAsync( | ||||||
|             signedOrder, fillTakerAmount, senderAddress, zrxTokenAddress, |             this._tokenWrapper, signedOrder, fillTakerAmount, senderAddress, zrxTokenAddress, | ||||||
|         ); |         ); | ||||||
|  |  | ||||||
|         const wouldRoundingErrorOccur = await this._isRoundingErrorAsync( |         const wouldRoundingErrorOccur = await this._isRoundingErrorAsync( | ||||||
|   | |||||||
| @@ -1,4 +1,5 @@ | |||||||
| import {ExchangeContractErrs, SignedOrder} from '../types'; | import {ExchangeContractErrs, SignedOrder} from '../types'; | ||||||
|  | import {TokenWrapper} from '../contract_wrappers/token_wrapper'; | ||||||
|  |  | ||||||
| export const orderValidationUtils = { | export const orderValidationUtils = { | ||||||
|     /** |     /** | ||||||
| @@ -11,15 +12,14 @@ export const orderValidationUtils = { | |||||||
|      * the callers gas costs. |      * the callers gas costs. | ||||||
|      */ |      */ | ||||||
|     async validateFillOrderBalancesAndAllowancesAndThrowIfInvalidAsync( |     async validateFillOrderBalancesAndAllowancesAndThrowIfInvalidAsync( | ||||||
|         signedOrder: SignedOrder, fillTakerAmount: BigNumber.BigNumber, senderAddress: string, zrxTokenAddress: string, |         tokenWrapper: TokenWrapper, signedOrder: SignedOrder, fillTakerAmount: BigNumber.BigNumber, | ||||||
|     ): Promise<void> { |         senderAddress: string, zrxTokenAddress: string): Promise<void> { | ||||||
|  |         const makerBalance = await tokenWrapper.getBalanceAsync(signedOrder.makerTokenAddress, | ||||||
|         const makerBalance = await this._tokenWrapper.getBalanceAsync(signedOrder.makerTokenAddress, |  | ||||||
|                                                                      signedOrder.maker); |                                                                      signedOrder.maker); | ||||||
|         const takerBalance = await this._tokenWrapper.getBalanceAsync(signedOrder.takerTokenAddress, senderAddress); |         const takerBalance = await tokenWrapper.getBalanceAsync(signedOrder.takerTokenAddress, senderAddress); | ||||||
|         const makerAllowance = await this._tokenWrapper.getProxyAllowanceAsync(signedOrder.makerTokenAddress, |         const makerAllowance = await tokenWrapper.getProxyAllowanceAsync(signedOrder.makerTokenAddress, | ||||||
|                                                                               signedOrder.maker); |                                                                               signedOrder.maker); | ||||||
|         const takerAllowance = await this._tokenWrapper.getProxyAllowanceAsync(signedOrder.takerTokenAddress, |         const takerAllowance = await tokenWrapper.getProxyAllowanceAsync(signedOrder.takerTokenAddress, | ||||||
|                                                                               senderAddress); |                                                                               senderAddress); | ||||||
|  |  | ||||||
|         // exchangeRate is the price of one maker token denominated in taker tokens |         // exchangeRate is the price of one maker token denominated in taker tokens | ||||||
| @@ -42,12 +42,12 @@ export const orderValidationUtils = { | |||||||
|             throw new Error(ExchangeContractErrs.InsufficientMakerAllowance); |             throw new Error(ExchangeContractErrs.InsufficientMakerAllowance); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         const makerFeeBalance = await this._tokenWrapper.getBalanceAsync(zrxTokenAddress, |         const makerFeeBalance = await tokenWrapper.getBalanceAsync(zrxTokenAddress, | ||||||
|                                                                         signedOrder.maker); |                                                                         signedOrder.maker); | ||||||
|         const takerFeeBalance = await this._tokenWrapper.getBalanceAsync(zrxTokenAddress, senderAddress); |         const takerFeeBalance = await tokenWrapper.getBalanceAsync(zrxTokenAddress, senderAddress); | ||||||
|         const makerFeeAllowance = await this._tokenWrapper.getProxyAllowanceAsync(zrxTokenAddress, |         const makerFeeAllowance = await tokenWrapper.getProxyAllowanceAsync(zrxTokenAddress, | ||||||
|                                                                                  signedOrder.maker); |                                                                                  signedOrder.maker); | ||||||
|         const takerFeeAllowance = await this._tokenWrapper.getProxyAllowanceAsync(zrxTokenAddress, |         const takerFeeAllowance = await tokenWrapper.getProxyAllowanceAsync(zrxTokenAddress, | ||||||
|                                                                                  senderAddress); |                                                                                  senderAddress); | ||||||
|  |  | ||||||
|         if (signedOrder.takerFee.greaterThan(takerFeeBalance)) { |         if (signedOrder.takerFee.greaterThan(takerFeeBalance)) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user