From cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 10 Oct 2017 11:48:42 +0300 Subject: Throw allowance errors first --- src/utils/exchange_transfer_simulator.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/utils/exchange_transfer_simulator.ts b/src/utils/exchange_transfer_simulator.ts index 71a9ed212..db12abd29 100644 --- a/src/utils/exchange_transfer_simulator.ts +++ b/src/utils/exchange_transfer_simulator.ts @@ -96,12 +96,12 @@ export class ExchangeTransferSimulator extends BalanceAndProxyAllowanceLazyStore transferType: TransferType): Promise { const balance = await this.getBalanceAsync(tokenAddress, from); const proxyAllowance = await this.getProxyAllowanceAsync(tokenAddress, from); - if (balance.lessThan(amountInBaseUnits)) { - this.throwValidationError(FailureReason.Balance, tradeSide, transferType); - } if (proxyAllowance.lessThan(amountInBaseUnits)) { this.throwValidationError(FailureReason.ProxyAllowance, tradeSide, transferType); } + if (balance.lessThan(amountInBaseUnits)) { + this.throwValidationError(FailureReason.Balance, tradeSide, transferType); + } await this.decreaseProxyAllowanceAsync(tokenAddress, from, amountInBaseUnits); await this.decreaseBalanceAsync(tokenAddress, from, amountInBaseUnits); await this.increaseBalanceAsync(tokenAddress, to, amountInBaseUnits); -- cgit v1.2.3