aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-03 00:00:37 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-03 00:00:37 +0800
commitabf2cf4c5e2ea6d09d862871adfa16ca108907e2 (patch)
tree576899e4e72b89e62300443e613735f3f5e70ba7 /src
parent54e8bf773091eb2c8587c72e50892afec42abb9d (diff)
downloaddexon-sol-tools-abf2cf4c5e2ea6d09d862871adfa16ca108907e2.tar.gz
dexon-sol-tools-abf2cf4c5e2ea6d09d862871adfa16ca108907e2.tar.zst
dexon-sol-tools-abf2cf4c5e2ea6d09d862871adfa16ca108907e2.zip
Move FillOrderValidatinErrs to ExchangeContractErrs
Diffstat (limited to 'src')
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts25
-rw-r--r--src/types.ts12
2 files changed, 15 insertions, 22 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 828994829..716f9c77a 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -5,7 +5,6 @@ import {
ExchangeContract,
ExchangeContractErrCodes,
ExchangeContractErrs,
- FillOrderValidationErrs,
OrderValues,
OrderAddresses,
SignedOrder,
@@ -126,14 +125,14 @@ export class ExchangeWrapper extends ContractWrapper {
fillTakerAmount: BigNumber.BigNumber,
senderAddress: string): Promise<void> {
if (fillTakerAmount.eq(0)) {
- throw new Error(FillOrderValidationErrs.FILL_AMOUNT_IS_ZERO);
+ throw new Error(ExchangeContractErrs.ORDER_REMAINING_FILL_AMOUNT_ZERO);
}
if (signedOrder.taker !== constants.NULL_ADDRESS && signedOrder.taker !== senderAddress) {
- throw new Error(FillOrderValidationErrs.TRANSACTION_SENDER_IS_NOT_FILL_ORDER_TAKER);
+ throw new Error(ExchangeContractErrs.TRANSACTION_SENDER_IS_NOT_FILL_ORDER_TAKER);
}
const currentUnixTimestampSec = Date.now() / 1000;
if (signedOrder.expirationUnixTimestampSec.lessThan(currentUnixTimestampSec)) {
- throw new Error(FillOrderValidationErrs.FILL_ORDER_EXPIRED);
+ throw new Error(ExchangeContractErrs.ORDER_FILL_EXPIRED);
}
const zrxTokenAddress = await this.getZRXTokenAddressAsync();
await this.validateFillOrderBalancesAndAllowancesAndThrowIfInvalidAsync(signedOrder, fillTakerAmount,
@@ -143,7 +142,7 @@ export class ExchangeWrapper extends ContractWrapper {
signedOrder.takerTokenAmount, fillTakerAmount, signedOrder.makerTokenAmount,
);
if (wouldRoundingErrorOccur) {
- throw new Error(FillOrderValidationErrs.ROUNDING_ERROR);
+ throw new Error(ExchangeContractErrs.ORDER_FILL_ROUNDING_ERROR);
}
}
private async validateFillOrderBalancesAndAllowancesAndThrowIfInvalidAsync(signedOrder: SignedOrder,
@@ -168,16 +167,16 @@ export class ExchangeWrapper extends ContractWrapper {
const fillMakerAmountInBaseUnits = fillTakerAmount.div(exchangeRate);
if (fillTakerAmount.greaterThan(takerBalance)) {
- throw new Error(FillOrderValidationErrs.NOT_ENOUGH_TAKER_BALANCE);
+ throw new Error(ExchangeContractErrs.NOT_ENOUGH_TAKER_BALANCE);
}
if (fillTakerAmount.greaterThan(takerAllowance)) {
- throw new Error(FillOrderValidationErrs.NOT_ENOUGH_TAKER_ALLOWANCE);
+ throw new Error(ExchangeContractErrs.NOT_ENOUGH_TAKER_ALLOWANCE);
}
if (fillMakerAmountInBaseUnits.greaterThan(makerBalance)) {
- throw new Error(FillOrderValidationErrs.NOT_ENOUGH_MAKER_BALANCE);
+ throw new Error(ExchangeContractErrs.NOT_ENOUGH_MAKER_BALANCE);
}
if (fillMakerAmountInBaseUnits.greaterThan(makerAllowance)) {
- throw new Error(FillOrderValidationErrs.NOT_ENOUGH_MAKER_ALLOWANCE);
+ throw new Error(ExchangeContractErrs.NOT_ENOUGH_MAKER_ALLOWANCE);
}
const makerFeeBalance = await this.tokenWrapper.getBalanceAsync(zrxTokenAddress,
@@ -189,16 +188,16 @@ export class ExchangeWrapper extends ContractWrapper {
senderAddress);
if (signedOrder.takerFee.greaterThan(takerFeeBalance)) {
- throw new Error(FillOrderValidationErrs.NOT_ENOUGH_TAKER_FEE_BALANCE);
+ throw new Error(ExchangeContractErrs.NOT_ENOUGH_TAKER_FEE_BALANCE);
}
if (signedOrder.takerFee.greaterThan(takerFeeAllowance)) {
- throw new Error(FillOrderValidationErrs.NOT_ENOUGH_TAKER_FEE_ALLOWANCE);
+ throw new Error(ExchangeContractErrs.NOT_ENOUGH_TAKER_FEE_ALLOWANCE);
}
if (signedOrder.makerFee.greaterThan(makerFeeBalance)) {
- throw new Error(FillOrderValidationErrs.NOT_ENOUGH_MAKER_FEE_BALANCE);
+ throw new Error(ExchangeContractErrs.NOT_ENOUGH_MAKER_FEE_BALANCE);
}
if (signedOrder.makerFee.greaterThan(makerFeeAllowance)) {
- throw new Error(FillOrderValidationErrs.NOT_ENOUGH_MAKER_FEE_ALLOWANCE);
+ throw new Error(ExchangeContractErrs.NOT_ENOUGH_MAKER_FEE_ALLOWANCE);
}
}
private throwErrorLogsAsErrors(logs: ContractEvent[]): void {
diff --git a/src/types.ts b/src/types.ts
index e4a7da5d7..6cd5a93fe 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -89,13 +89,6 @@ export const ExchangeContractErrs = strEnum([
'ORDER_REMAINING_FILL_AMOUNT_ZERO',
'ORDER_FILL_ROUNDING_ERROR',
'FILL_BALANCE_ALLOWANCE_ERROR',
-]);
-export type ExchangeContractErrs = keyof typeof ExchangeContractErrs;
-
-export const FillOrderValidationErrs = strEnum([
- 'FILL_AMOUNT_IS_ZERO',
- 'TRANSACTION_SENDER_IS_NOT_FILL_ORDER_TAKER',
- 'FILL_ORDER_EXPIRED',
'NOT_ENOUGH_TAKER_BALANCE',
'NOT_ENOUGH_TAKER_ALLOWANCE',
'NOT_ENOUGH_MAKER_BALANCE',
@@ -104,9 +97,10 @@ export const FillOrderValidationErrs = strEnum([
'NOT_ENOUGH_TAKER_FEE_ALLOWANCE',
'NOT_ENOUGH_MAKER_FEE_BALANCE',
'NOT_ENOUGH_MAKER_FEE_ALLOWANCE',
- 'ROUNDING_ERROR',
+ 'TRANSACTION_SENDER_IS_NOT_FILL_ORDER_TAKER',
+
]);
-export type FillOrderValidationErrs = keyof typeof FillOrderValidationErrs;
+export type ExchangeContractErrs = keyof typeof ExchangeContractErrs;
export interface ContractResponse {
logs: ContractEvent[];