diff options
Diffstat (limited to 'packages/contract-wrappers')
-rw-r--r-- | packages/contract-wrappers/CHANGELOG.json | 22 | ||||
-rw-r--r-- | packages/contract-wrappers/CHANGELOG.md | 14 | ||||
-rw-r--r-- | packages/contract-wrappers/package.json | 40 | ||||
-rw-r--r-- | packages/contract-wrappers/src/utils/transaction_encoder.ts | 19 | ||||
-rw-r--r-- | packages/contract-wrappers/test/exchange_wrapper_test.ts | 19 | ||||
-rw-r--r-- | packages/contract-wrappers/test/transaction_encoder_test.ts | 4 |
6 files changed, 83 insertions, 35 deletions
diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index 9cea720c8..803863da3 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -1,12 +1,30 @@ [ { - "version": "6.0.1", + "timestamp": 1549504360, + "version": "7.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "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": 1549452781 }, { "version": "6.0.0", diff --git a/packages/contract-wrappers/CHANGELOG.md b/packages/contract-wrappers/CHANGELOG.md index 28cbf2ec6..fee13b218 100644 --- a/packages/contract-wrappers/CHANGELOG.md +++ b/packages/contract-wrappers/CHANGELOG.md @@ -5,6 +5,20 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v7.0.1 - _February 7, 2019_ + + * Dependencies updated + +## v7.0.0 - _February 6, 2019_ + + * Fix OrderValidatorWrapper constructor to use the correct address (#1568) + * Use new `ZeroExTransaction` interface (#1576) + * Rename `getTransactionHex` to `getTransactionHashHex` (#1576) + +## v6.0.0 - _Invalid date_ + + * Upgrade the bignumber.js to v8.0.2 (#1517) + ## v5.0.1 - _January 17, 2019_ * Dependencies updated diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index cc7dc1a3e..9fcf2a62d 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contract-wrappers", - "version": "5.0.1", + "version": "7.0.1", "description": "Smart TS wrappers for 0x smart contracts", "keywords": [ "0xproject", @@ -37,15 +37,15 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0x/dev-utils": "^1.0.24", - "@0x/migrations": "^2.4.0", - "@0x/subproviders": "^2.1.11", - "@0x/tslint-config": "^2.0.2", + "@0x/dev-utils": "^2.0.1", + "@0x/migrations": "^3.0.2", + "@0x/subproviders": "^3.0.1", + "@0x/tslint-config": "^3.0.0", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", "@types/node": "*", "@types/sinon": "^2.2.2", - "@types/uuid": "^3.4.2", + "@types/uuid": "^3.4.3", "@types/web3-provider-engine": "^14.0.0", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", @@ -65,26 +65,26 @@ "web3-provider-engine": "14.0.6" }, "dependencies": { - "@0x/abi-gen-wrappers": "^2.2.0", - "@0x/assert": "^1.0.23", - "@0x/contract-addresses": "^2.2.0", + "@0x/abi-gen-wrappers": "^3.0.1", + "@0x/assert": "^2.0.1", + "@0x/contract-addresses": "^2.2.1", "@0x/contract-artifacts": "^1.3.0", - "@0x/contracts-test-utils": "^2.0.1", - "@0x/fill-scenarios": "^1.1.2", - "@0x/json-schemas": "^2.1.7", - "@0x/order-utils": "^3.1.2", - "@0x/types": "^1.5.2", - "@0x/typescript-typings": "^3.0.8", - "@0x/utils": "^3.0.1", - "@0x/web3-wrapper": "^3.2.4", - "ethereum-types": "^1.1.6", + "@0x/contracts-test-utils": "^3.0.2", + "@0x/fill-scenarios": "^2.0.2", + "@0x/json-schemas": "^3.0.1", + "@0x/order-utils": "^6.0.0", + "@0x/types": "^2.0.1", + "@0x/typescript-typings": "^4.0.0", + "@0x/utils": "^4.0.2", + "@0x/web3-wrapper": "^4.0.1", + "ethereum-types": "^2.0.0", "ethereumjs-abi": "0.6.5", "ethereumjs-blockstream": "6.0.0", "ethereumjs-util": "^5.1.1", "ethers": "~4.0.4", "js-sha3": "^0.7.0", - "lodash": "^4.17.5", - "uuid": "^3.1.0" + "lodash": "^4.17.11", + "uuid": "^3.3.2" }, "publishConfig": { "access": "public" 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/exchange_wrapper_test.ts b/packages/contract-wrappers/test/exchange_wrapper_test.ts index a1d60dc6e..acd30495b 100644 --- a/packages/contract-wrappers/test/exchange_wrapper_test.ts +++ b/packages/contract-wrappers/test/exchange_wrapper_test.ts @@ -1,6 +1,6 @@ import { BlockchainLifecycle, callbackErrorReporter } from '@0x/dev-utils'; import { FillScenarios } from '@0x/fill-scenarios'; -import { assetDataUtils, orderHashUtils } from '@0x/order-utils'; +import { assetDataUtils, orderHashUtils, signatureUtils } from '@0x/order-utils'; import { DoneCallback, RevertReason, SignedOrder } from '@0x/types'; import { BigNumber } from '@0x/utils'; import * as chai from 'chai'; @@ -368,6 +368,23 @@ describe('ExchangeWrapper', () => { await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); isPreSigned = await contractWrappers.exchange.isPreSignedAsync(hash, signerAddress); expect(isPreSigned).to.be.true(); + + const preSignedSignature = '0x06'; + const isValidSignature = await contractWrappers.exchange.isValidSignatureAsync( + hash, + signerAddress, + preSignedSignature, + ); + expect(isValidSignature).to.be.true(); + + // Test our TS implementation of signature validation + const isValidSignatureInTs = await signatureUtils.isValidSignatureAsync( + provider, + hash, + preSignedSignature, + signerAddress, + ); + expect(isValidSignatureInTs).to.be.true(); }); }); describe('#getVersionAsync', () => { 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, |