This repository has been archived by the owner on Apr 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving helper functions from
dex-react
(#69)
* Moving assert form dex-react * Added isNeverExpiresOrder function
- Loading branch information
1 parent
1739ff1
commit 5d90fa6
Showing
4 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { AssertionError } from 'assert' | ||
|
||
export function assert<T>(val: T, message: string): asserts val is NonNullable<T> { | ||
if (!val) { | ||
throw new AssertionError({ message }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
import { MAX_BATCH_ID } from 'const' | ||
|
||
/** | ||
* Epoch in seconds | ||
*/ | ||
export function getEpoch(): number { | ||
return Math.floor(Date.now() / 1000) | ||
} | ||
|
||
/** | ||
* Checks whether batchId is `never expires` | ||
* Using the convention which the fronted creates orders with expiration date set | ||
* to max uint32 when placing orders active indefinitely. | ||
* | ||
* @param batchId The expiration batch id to check | ||
*/ | ||
export function isNeverExpiresOrder(batchId: number): boolean { | ||
return MAX_BATCH_ID === batchId | ||
} |