diff options
Diffstat (limited to 'contracts/test-utils')
-rw-r--r-- | contracts/test-utils/src/index.ts | 1 | ||||
-rw-r--r-- | contracts/test-utils/src/transaction_factory.ts | 26 | ||||
-rw-r--r-- | contracts/test-utils/src/types.ts | 8 |
3 files changed, 13 insertions, 22 deletions
diff --git a/contracts/test-utils/src/index.ts b/contracts/test-utils/src/index.ts index 7880de0bf..5ac927e47 100644 --- a/contracts/test-utils/src/index.ts +++ b/contracts/test-utils/src/index.ts @@ -31,7 +31,6 @@ export { MarketBuyOrders, MarketSellOrders, ERC721TokenIdsByOwner, - SignedTransaction, OrderStatus, AllowanceAmountScenario, AssetDataScenario, diff --git a/contracts/test-utils/src/transaction_factory.ts b/contracts/test-utils/src/transaction_factory.ts index dbab3ade4..e6cd4c23f 100644 --- a/contracts/test-utils/src/transaction_factory.ts +++ b/contracts/test-utils/src/transaction_factory.ts @@ -1,10 +1,8 @@ -import { eip712Utils, generatePseudoRandomSalt } from '@0x/order-utils'; -import { SignatureType } from '@0x/types'; -import { signTypedDataUtils } from '@0x/utils'; +import { generatePseudoRandomSalt, transactionHashUtils } from '@0x/order-utils'; +import { SignatureType, SignedZeroExTransaction } from '@0x/types'; import * as ethUtil from 'ethereumjs-util'; import { signingUtils } from './signing_utils'; -import { SignedTransaction } from './types'; export class TransactionFactory { private readonly _signerBuff: Buffer; @@ -15,23 +13,25 @@ export class TransactionFactory { this._exchangeAddress = exchangeAddress; this._signerBuff = ethUtil.privateToAddress(this._privateKey); } - public newSignedTransaction(data: string, signatureType: SignatureType = SignatureType.EthSign): SignedTransaction { + public newSignedTransaction( + data: string, + signatureType: SignatureType = SignatureType.EthSign, + ): SignedZeroExTransaction { const salt = generatePseudoRandomSalt(); const signerAddress = `0x${this._signerBuff.toString('hex')}`; - const executeTransactionData = { + const transaction = { salt, signerAddress, data, + verifyingContractAddress: this._exchangeAddress, }; - const typedData = eip712Utils.createZeroExTransactionTypedData(executeTransactionData, this._exchangeAddress); - const eip712MessageBuffer = signTypedDataUtils.generateTypedDataHash(typedData); - const signature = signingUtils.signMessage(eip712MessageBuffer, this._privateKey, signatureType); - const signedTx = { - exchangeAddress: this._exchangeAddress, + const transactionHashBuffer = transactionHashUtils.getTransactionHashBuffer(transaction); + const signature = signingUtils.signMessage(transactionHashBuffer, this._privateKey, signatureType); + const signedTransaction = { + ...transaction, signature: `0x${signature.toString('hex')}`, - ...executeTransactionData, }; - return signedTx; + return signedTransaction; } } diff --git a/contracts/test-utils/src/types.ts b/contracts/test-utils/src/types.ts index 60cb2b102..16c3a9f3d 100644 --- a/contracts/test-utils/src/types.ts +++ b/contracts/test-utils/src/types.ts @@ -107,14 +107,6 @@ export enum ContractName { BalanceThresholdFilter = 'BalanceThresholdFilter', } -export interface SignedTransaction { - exchangeAddress: string; - salt: BigNumber; - signerAddress: string; - data: string; - signature: string; -} - export interface TransferAmountsByMatchOrders { // Left Maker amountBoughtByLeftMaker: BigNumber; |