diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-05-30 23:35:17 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-05-30 23:35:17 +0800 |
commit | be13cf127c00c762d03c5eaf17a11c2775701530 (patch) | |
tree | cda26032d212f7c08c72965813e17de8ed1c03d4 /test/utils | |
parent | 843ec2d4cf4bbc9061ba6dc5a09fc6d694c3083a (diff) | |
download | dexon-sol-tools-be13cf127c00c762d03c5eaf17a11c2775701530.tar dexon-sol-tools-be13cf127c00c762d03c5eaf17a11c2775701530.tar.gz dexon-sol-tools-be13cf127c00c762d03c5eaf17a11c2775701530.tar.bz2 dexon-sol-tools-be13cf127c00c762d03c5eaf17a11c2775701530.tar.lz dexon-sol-tools-be13cf127c00c762d03c5eaf17a11c2775701530.tar.xz dexon-sol-tools-be13cf127c00c762d03c5eaf17a11c2775701530.tar.zst dexon-sol-tools-be13cf127c00c762d03c5eaf17a11c2775701530.zip |
Refactor getOrderHash to accept order as an object
Diffstat (limited to 'test/utils')
-rw-r--r-- | test/utils/order.ts | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/test/utils/order.ts b/test/utils/order.ts index 690f50ef5..a69c1b62f 100644 --- a/test/utils/order.ts +++ b/test/utils/order.ts @@ -1,21 +1,28 @@ import {SignedOrder} from '../../src/types'; import * as BigNumber from 'bignumber.js'; import * as _ from 'lodash'; +import {ZeroEx} from '../../src/0x.js'; +import {constants} from './constants'; -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), +export async function createSignedOrder(zeroEx: ZeroEx): Promise<SignedOrder> { + // TODO: fetch properly + const EXCHANGE_ADDRESS = '0xb69e673309512a9d726f87304c6984054f87a93b'; + const INF_TIMESTAMP = 2524604400; + const order = { + maker: '0x5409ed021d9299bf6814279a6a1411a7e866a631', + taker: undefined, + makerFee: new BigNumber(0), + takerFee: new BigNumber(0), + makerTokenAmount: new BigNumber(5000000000000000000), + takerTokenAmount: new BigNumber(42000000000000000000), + makerTokenAddress: '0x07f96aa816c1f244cbc6ef114bb2b023ba54a2eb', + takerTokenAddress: '0x1e2f9e10d02a6b8f8f69fcbf515e75039d2ea30d', + salt: ZeroEx.generatePseudoRandomSalt(), + feeRecipient: constants.NULL_ADDRESS, + expirationUnixTimestampSec: new BigNumber(INF_TIMESTAMP), }; + const orderHash = ZeroEx.getOrderHashHex(EXCHANGE_ADDRESS, order); + const ecSignature = await zeroEx.signOrderHashAsync(orderHash); + const signedOrder: SignedOrder = _.assign(order, {ecSignature}); return signedOrder; } |