merge v2-prototype
This commit is contained in:
@@ -29,3 +29,12 @@ export async function increaseTimeAndMineBlockAsync(seconds: number): Promise<nu
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the timestamp of the latest block in seconds since the Unix epoch.
|
||||
* @returns a new Promise which will resolve with the timestamp in seconds.
|
||||
*/
|
||||
export async function getLatestBlockTimestampAsync(): Promise<number> {
|
||||
const currentBlock = await web3Wrapper.getBlockAsync('latest');
|
||||
return currentBlock.timestamp;
|
||||
}
|
||||
@@ -223,6 +223,10 @@ export class ExchangeWrapper {
|
||||
const orderInfo = (await this._exchange.getOrderInfo.callAsync(signedOrder)) as OrderInfo;
|
||||
return orderInfo;
|
||||
}
|
||||
public async getOrdersInfoAsync(signedOrders: SignedOrder[]): Promise<OrderInfo[]> {
|
||||
const ordersInfo = (await this._exchange.getOrdersInfo.callAsync(signedOrders)) as OrderInfo[];
|
||||
return ordersInfo;
|
||||
}
|
||||
public async matchOrdersAsync(
|
||||
signedOrderLeft: SignedOrder,
|
||||
signedOrderRight: SignedOrder,
|
||||
|
||||
@@ -2,6 +2,7 @@ import { generatePseudoRandomSalt, orderHashUtils } from '@0xproject/order-utils
|
||||
import { Order, SignatureType, SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
import { getLatestBlockTimestampAsync } from './block_timestamp';
|
||||
import { constants } from './constants';
|
||||
import { signingUtils } from './signing_utils';
|
||||
|
||||
@@ -12,15 +13,15 @@ export class OrderFactory {
|
||||
this._defaultOrderParams = defaultOrderParams;
|
||||
this._privateKey = privateKey;
|
||||
}
|
||||
public newSignedOrder(
|
||||
public async newSignedOrderAsync(
|
||||
customOrderParams: Partial<Order> = {},
|
||||
signatureType: SignatureType = SignatureType.EthSign,
|
||||
): SignedOrder {
|
||||
const tenMinutes = 10 * 60 * 1000;
|
||||
const randomExpiration = new BigNumber(Date.now() + tenMinutes);
|
||||
): Promise<SignedOrder> {
|
||||
const tenMinutesInSeconds = 10 * 60;
|
||||
const currentBlockTimestamp = await getLatestBlockTimestampAsync();
|
||||
const order = ({
|
||||
senderAddress: constants.NULL_ADDRESS,
|
||||
expirationTimeSeconds: randomExpiration,
|
||||
expirationTimeSeconds: new BigNumber(currentBlockTimestamp).add(tenMinutesInSeconds),
|
||||
salt: generatePseudoRandomSalt(),
|
||||
takerAddress: constants.NULL_ADDRESS,
|
||||
...this._defaultOrderParams,
|
||||
|
||||
Reference in New Issue
Block a user