aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/utils/order_factory.ts
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-07-17 09:28:47 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-07-17 09:41:37 +0800
commit9828fa335ea0e52da96c7339854970df33027d65 (patch)
treed837f0b642d7167acd6a702660f51fe44147e96a /packages/contracts/test/utils/order_factory.ts
parent01789e67509a2d87d9056f6b9ef9ff48eee88cdd (diff)
downloaddexon-sol-tools-9828fa335ea0e52da96c7339854970df33027d65.tar.gz
dexon-sol-tools-9828fa335ea0e52da96c7339854970df33027d65.tar.zst
dexon-sol-tools-9828fa335ea0e52da96c7339854970df33027d65.zip
Fix bugs having to do with block timestamps and order expirationTimes
Diffstat (limited to 'packages/contracts/test/utils/order_factory.ts')
-rw-r--r--packages/contracts/test/utils/order_factory.ts11
1 files changed, 6 insertions, 5 deletions
diff --git a/packages/contracts/test/utils/order_factory.ts b/packages/contracts/test/utils/order_factory.ts
index 009dbc396..c81aff269 100644
--- a/packages/contracts/test/utils/order_factory.ts
+++ b/packages/contracts/test/utils/order_factory.ts
@@ -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,