Fix exchange package build

This commit is contained in:
Amir Bandeali
2019-05-23 18:56:03 -05:00
parent 7cff9ba86a
commit c96a81e319
4 changed files with 57 additions and 44 deletions

View File

@@ -1,7 +1,9 @@
import { generatePseudoRandomSalt, transactionHashUtils } from '@0x/order-utils';
import { SignatureType, SignedZeroExTransaction } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as ethUtil from 'ethereumjs-util';
import { getLatestBlockTimestampAsync } from './block_timestamp';
import { signingUtils } from './signing_utils';
export class TransactionFactory {
@@ -16,16 +18,19 @@ export class TransactionFactory {
this._chainId = chainId;
this._signerBuff = ethUtil.privateToAddress(this._privateKey);
}
public newSignedTransaction(
public async newSignedTransactionAsync(
data: string,
signatureType: SignatureType = SignatureType.EthSign,
): SignedZeroExTransaction {
): Promise<SignedZeroExTransaction> {
const tenMinutesInSeconds = 10 * 60;
const currentBlockTimestamp = await getLatestBlockTimestampAsync();
const salt = generatePseudoRandomSalt();
const signerAddress = `0x${this._signerBuff.toString('hex')}`;
const transaction = {
salt,
signerAddress,
data,
expirationTimeSeconds: new BigNumber(currentBlockTimestamp).plus(tenMinutesInSeconds),
domain: {
verifyingContractAddress: this._exchangeAddress,
chainId: this._chainId,