aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contract-wrappers')
-rw-r--r--packages/contract-wrappers/CHANGELOG.json10
-rw-r--r--packages/contract-wrappers/src/utils/transaction_encoder.ts19
-rw-r--r--packages/contract-wrappers/test/transaction_encoder_test.ts4
3 files changed, 20 insertions, 13 deletions
diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json
index 413563f80..ae3176537 100644
--- a/packages/contract-wrappers/CHANGELOG.json
+++ b/packages/contract-wrappers/CHANGELOG.json
@@ -1,10 +1,18 @@
[
{
- "version": "6.0.1",
+ "version": "7.0.0",
"changes": [
{
"note": "Fix OrderValidatorWrapper constructor to use the correct address",
"pr": 1568
+ },
+ {
+ "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 0cf08a8fe..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,23 +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, exchangeAddress);
- 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,