Rename getTransactionHex to getTransactionHashHex for clarity
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[
|
||||
{
|
||||
"version": "6.0.1",
|
||||
"version": "7.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fix OrderValidatorWrapper constructor to use the correct address",
|
||||
@@ -9,6 +9,10 @@
|
||||
{
|
||||
"note": "Use new `ZeroExTransaction` interface",
|
||||
"pr": 1576
|
||||
},
|
||||
{
|
||||
"note": "Rename `getTransactionHex` to `getTransactionHashHex`",
|
||||
"pr": 1576
|
||||
}
|
||||
],
|
||||
"timestamp": 1549373905
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import { ExchangeContract } from '@0x/abi-gen-wrappers';
|
||||
|
||||
import { schemas } from '@0x/json-schemas';
|
||||
import { eip712Utils } from '@0x/order-utils';
|
||||
import { transactionHashUtils } from '@0x/order-utils';
|
||||
import { Order, SignedOrder } from '@0x/types';
|
||||
import { BigNumber, signTypedDataUtils } from '@0x/utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import _ = require('lodash');
|
||||
|
||||
import { assert } from './assert';
|
||||
@@ -19,24 +19,22 @@ export class TransactionEncoder {
|
||||
this._exchangeInstance = exchangeInstance;
|
||||
}
|
||||
/**
|
||||
* Encodes the transaction data for use with the Exchange contract.
|
||||
* Hashes the transaction data for use with the Exchange contract.
|
||||
* @param data The ABI Encoded 0x Exchange method. I.e fillOrder
|
||||
* @param salt A random value to provide uniqueness and prevent replay attacks.
|
||||
* @param signerAddress The address which will sign this transaction.
|
||||
* @return An unsigned hex encoded transaction for use in 0x Exchange executeTransaction.
|
||||
* @return The hash of the 0x transaction.
|
||||
*/
|
||||
public getTransactionHex(data: string, salt: BigNumber, signerAddress: string): string {
|
||||
public getTransactionHashHex(data: string, salt: BigNumber, signerAddress: string): string {
|
||||
const exchangeAddress = this._getExchangeContract().address;
|
||||
const executeTransactionData = {
|
||||
const transaction = {
|
||||
verifyingContractAddress: exchangeAddress,
|
||||
salt,
|
||||
signerAddress,
|
||||
data,
|
||||
};
|
||||
const typedData = eip712Utils.createZeroExTransactionTypedData(executeTransactionData);
|
||||
const eip712MessageBuffer = signTypedDataUtils.generateTypedDataHash(typedData);
|
||||
const messageHex = `0x${eip712MessageBuffer.toString('hex')}`;
|
||||
return messageHex;
|
||||
const hashHex = transactionHashUtils.getTransactionHashHex(transaction);
|
||||
return hashHex;
|
||||
}
|
||||
/**
|
||||
* Encodes a fillOrder transaction.
|
||||
|
@@ -83,8 +83,8 @@ describe('TransactionEncoder', () => {
|
||||
signerAddress: string = takerAddress,
|
||||
): Promise<void> => {
|
||||
const salt = generatePseudoRandomSalt();
|
||||
const encodedTransaction = encoder.getTransactionHex(data, salt, signerAddress);
|
||||
const signature = await signatureUtils.ecSignHashAsync(provider, encodedTransaction, signerAddress);
|
||||
const transactionHash = encoder.getTransactionHashHex(data, salt, signerAddress);
|
||||
const signature = await signatureUtils.ecSignHashAsync(provider, transactionHash, signerAddress);
|
||||
txHash = await contractWrappers.exchange.executeTransactionAsync(
|
||||
salt,
|
||||
signerAddress,
|
||||
|
Reference in New Issue
Block a user