aboutsummaryrefslogtreecommitdiffstats
path: root/test/utils
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-05-30 18:56:51 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-05-30 18:56:51 +0800
commitacd5fba1336659053be470e4041b803150588cc5 (patch)
tree1de3a7920488a2b2b389fb91f4af13d2562d3e17 /test/utils
parent76ddd12b4a0fc520b90d9f57f8f6534523d3691e (diff)
downloaddexon-sol-tools-acd5fba1336659053be470e4041b803150588cc5.tar
dexon-sol-tools-acd5fba1336659053be470e4041b803150588cc5.tar.gz
dexon-sol-tools-acd5fba1336659053be470e4041b803150588cc5.tar.bz2
dexon-sol-tools-acd5fba1336659053be470e4041b803150588cc5.tar.lz
dexon-sol-tools-acd5fba1336659053be470e4041b803150588cc5.tar.xz
dexon-sol-tools-acd5fba1336659053be470e4041b803150588cc5.tar.zst
dexon-sol-tools-acd5fba1336659053be470e4041b803150588cc5.zip
Add order utils
Diffstat (limited to 'test/utils')
-rw-r--r--test/utils/order.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/utils/order.ts b/test/utils/order.ts
new file mode 100644
index 000000000..dc0be670c
--- /dev/null
+++ b/test/utils/order.ts
@@ -0,0 +1,21 @@
+import {SignedOrder} from '../../lib/src/types';
+import * as BigNumber from 'bignumber.js';
+import * as _ from 'lodash';
+
+export function signedOrderFromJSON(signedOrderJSON: any): SignedOrder {
+ const signedOrder = {
+ maker: signedOrderJSON.maker.address,
+ taker: _.isEmpty(signedOrderJSON.taker.address) ? undefined : signedOrderJSON.taker.address,
+ makerTokenAddress: signedOrderJSON.maker.token.address,
+ takerTokenAddress: signedOrderJSON.taker.token.address,
+ makerTokenAmount: new BigNumber(signedOrderJSON.maker.amount),
+ takerTokenAmount: new BigNumber(signedOrderJSON.taker.amount),
+ makerFee: new BigNumber(signedOrderJSON.maker.feeAmount),
+ takerFee: new BigNumber(signedOrderJSON.taker.feeAmount),
+ expirationUnixTimestampSec: new BigNumber(signedOrderJSON.expiration),
+ feeRecipient: signedOrderJSON.feeRecipient,
+ ecSignature: signedOrderJSON.signature,
+ salt: new BigNumber(signedOrderJSON.salt),
+ };
+ return signedOrder;
+}