diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-10-10 16:48:42 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-10-10 16:48:42 +0800 |
commit | cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a (patch) | |
tree | fa100d6806256cc17721c1ffc087248ec81901cc /src | |
parent | 468a20c9ea0dda89376f638f4ff30804046b7fef (diff) | |
download | dexon-sol-tools-cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a.tar dexon-sol-tools-cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a.tar.gz dexon-sol-tools-cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a.tar.bz2 dexon-sol-tools-cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a.tar.lz dexon-sol-tools-cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a.tar.xz dexon-sol-tools-cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a.tar.zst dexon-sol-tools-cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a.zip |
Throw allowance errors first
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/exchange_transfer_simulator.ts | 6 |
1 files changed, 3 insertions, 3 deletions
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<void> { 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); |