aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src/utils/exchange_transfer_simulator.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-11-23 05:43:17 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-11-24 05:13:37 +0800
commitdb2917b01caa49d74c9ebcae2d36e9c3946b94d8 (patch)
tree88aa341cb4dc02f1bfbc7d0d00d21966e1bbde20 /packages/0x.js/src/utils/exchange_transfer_simulator.ts
parent87d34f9c7f3ccf22e01798c27c4a4d5d4f943816 (diff)
downloaddexon-sol-tools-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.tar
dexon-sol-tools-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.tar.gz
dexon-sol-tools-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.tar.bz2
dexon-sol-tools-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.tar.lz
dexon-sol-tools-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.tar.xz
dexon-sol-tools-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.tar.zst
dexon-sol-tools-db2917b01caa49d74c9ebcae2d36e9c3946b94d8.zip
Enable some new linter rules and fix the issues
Diffstat (limited to 'packages/0x.js/src/utils/exchange_transfer_simulator.ts')
-rw-r--r--packages/0x.js/src/utils/exchange_transfer_simulator.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/packages/0x.js/src/utils/exchange_transfer_simulator.ts b/packages/0x.js/src/utils/exchange_transfer_simulator.ts
index c3a2d1585..00a0efd3f 100644
--- a/packages/0x.js/src/utils/exchange_transfer_simulator.ts
+++ b/packages/0x.js/src/utils/exchange_transfer_simulator.ts
@@ -36,6 +36,11 @@ const ERR_MSG_MAPPING = {
export class ExchangeTransferSimulator {
private store: BalanceAndProxyAllowanceLazyStore;
private UNLIMITED_ALLOWANCE_IN_BASE_UNITS: BigNumber;
+ private static throwValidationError(failureReason: FailureReason, tradeSide: TradeSide,
+ transferType: TransferType): never {
+ const errMsg = ERR_MSG_MAPPING[failureReason][tradeSide][transferType];
+ throw new Error(errMsg);
+ }
constructor(token: TokenWrapper) {
this.store = new BalanceAndProxyAllowanceLazyStore(token);
this.UNLIMITED_ALLOWANCE_IN_BASE_UNITS = token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
@@ -55,10 +60,10 @@ export class ExchangeTransferSimulator {
const balance = await this.store.getBalanceAsync(tokenAddress, from);
const proxyAllowance = await this.store.getProxyAllowanceAsync(tokenAddress, from);
if (proxyAllowance.lessThan(amountInBaseUnits)) {
- this.throwValidationError(FailureReason.ProxyAllowance, tradeSide, transferType);
+ ExchangeTransferSimulator.throwValidationError(FailureReason.ProxyAllowance, tradeSide, transferType);
}
if (balance.lessThan(amountInBaseUnits)) {
- this.throwValidationError(FailureReason.Balance, tradeSide, transferType);
+ ExchangeTransferSimulator.throwValidationError(FailureReason.Balance, tradeSide, transferType);
}
await this.decreaseProxyAllowanceAsync(tokenAddress, from, amountInBaseUnits);
await this.decreaseBalanceAsync(tokenAddress, from, amountInBaseUnits);
@@ -81,9 +86,4 @@ export class ExchangeTransferSimulator {
const balance = await this.store.getBalanceAsync(tokenAddress, userAddress);
this.store.setBalance(tokenAddress, userAddress, balance.minus(amountInBaseUnits));
}
- private throwValidationError(failureReason: FailureReason, tradeSide: TradeSide,
- transferType: TransferType): never {
- const errMsg = ERR_MSG_MAPPING[failureReason][tradeSide][transferType];
- throw new Error(errMsg);
- }
}