aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-06 22:57:13 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-06 22:57:13 +0800
commitfa910bca0ebcc71e5fd7aa656972d77bec08c9e5 (patch)
treea61e05a0c580c32e222b5eca20b510945d99cf8a /src
parent5412e803159a1d944297ab1fe1a49896651cedd6 (diff)
downloaddexon-0x-contracts-fa910bca0ebcc71e5fd7aa656972d77bec08c9e5.tar
dexon-0x-contracts-fa910bca0ebcc71e5fd7aa656972d77bec08c9e5.tar.gz
dexon-0x-contracts-fa910bca0ebcc71e5fd7aa656972d77bec08c9e5.tar.bz2
dexon-0x-contracts-fa910bca0ebcc71e5fd7aa656972d77bec08c9e5.tar.lz
dexon-0x-contracts-fa910bca0ebcc71e5fd7aa656972d77bec08c9e5.tar.xz
dexon-0x-contracts-fa910bca0ebcc71e5fd7aa656972d77bec08c9e5.tar.zst
dexon-0x-contracts-fa910bca0ebcc71e5fd7aa656972d77bec08c9e5.zip
Add checks and tests for expired order and zero fill amount
Diffstat (limited to 'src')
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts8
-rw-r--r--src/types.ts2
2 files changed, 9 insertions, 1 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 982a8c0c1..b5d5152dd 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -274,7 +274,13 @@ export class ExchangeWrapper extends ContractWrapper {
}
private async validateCancelOrderAndThrowIfInvalidAsync(order: Order,
cancelAmount: BigNumber.BigNumber): Promise<void> {
- // TODO
+ if (cancelAmount.eq(0)) {
+ throw new Error(ExchangeContractErrs.ORDER_CANCEL_AMOUNT_ZERO);
+ }
+ const currentUnixTimestampSec = Date.now() / 1000;
+ if (order.expirationUnixTimestampSec.lessThan(currentUnixTimestampSec)) {
+ throw new Error(ExchangeContractErrs.ORDER_CANCEL_EXPIRED);
+ }
}
/**
diff --git a/src/types.ts b/src/types.ts
index f2214ba6b..32148df7e 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -121,6 +121,8 @@ export enum ExchangeContractErrCodes {
export const ExchangeContractErrs = strEnum([
'ORDER_FILL_EXPIRED',
+ 'ORDER_CANCEL_EXPIRED',
+ 'ORDER_CANCEL_AMOUNT_ZERO',
'ORDER_REMAINING_FILL_AMOUNT_ZERO',
'ORDER_FILL_ROUNDING_ERROR',
'FILL_BALANCE_ALLOWANCE_ERROR',