aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2019-02-05 01:47:10 +0800
committerAmir Bandeali <abandeali1@gmail.com>2019-02-06 01:26:03 +0800
commit8246dec84342138319b9eaf4778862a8e4770851 (patch)
tree20edbf5a0785199a4fe12d6d39894e2f93b4c5fe
parent4514da0646983f5b6216e382ff3f61e816a6b451 (diff)
downloaddexon-0x-contracts-8246dec84342138319b9eaf4778862a8e4770851.tar.gz
dexon-0x-contracts-8246dec84342138319b9eaf4778862a8e4770851.tar.zst
dexon-0x-contracts-8246dec84342138319b9eaf4778862a8e4770851.zip
Rename getTransactionHex to getTransactionHashHex for clarity
-rw-r--r--packages/contract-wrappers/CHANGELOG.json6
-rw-r--r--packages/contract-wrappers/src/utils/transaction_encoder.ts18
-rw-r--r--packages/contract-wrappers/test/transaction_encoder_test.ts4
3 files changed, 15 insertions, 13 deletions
diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json
index 3d747b396..ae3176537 100644
--- a/packages/contract-wrappers/CHANGELOG.json
+++ b/packages/contract-wrappers/CHANGELOG.json
@@ -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
diff --git a/packages/contract-wrappers/src/utils/transaction_encoder.ts b/packages/contract-wrappers/src/utils/transaction_encoder.ts
index c674abbe5..307487a9b 100644
--- a/packages/contract-wrappers/src/utils/transaction_encoder.ts
+++ b/packages/contract-wrappers/src/utils/transaction_encoder.ts
@@ -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.
diff --git a/packages/contract-wrappers/test/transaction_encoder_test.ts b/packages/contract-wrappers/test/transaction_encoder_test.ts
index ef9eb2cf3..a996b9f08 100644
--- a/packages/contract-wrappers/test/transaction_encoder_test.ts
+++ b/packages/contract-wrappers/test/transaction_encoder_test.ts
@@ -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,