aboutsummaryrefslogtreecommitdiffstats
path: root/test/utils/order.ts
blob: dc0be670c3babcf427de0ca4617acd9683be249f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;
}