diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-10-10 08:04:54 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-10-10 08:04:54 +0800 |
commit | 8155d311af04339c105f1a29b74f1ddbced85197 (patch) | |
tree | 9b345f05561e806b6d89cec26b371aadafb109ed /packages/contract-wrappers | |
parent | cd8e6d9cdf7d6aa1e811bb7d9d7017da342907ed (diff) | |
parent | bd06ebde8d1a5caf138ad3b36f9a5c5f255f2312 (diff) | |
download | dexon-sol-tools-8155d311af04339c105f1a29b74f1ddbced85197.tar dexon-sol-tools-8155d311af04339c105f1a29b74f1ddbced85197.tar.gz dexon-sol-tools-8155d311af04339c105f1a29b74f1ddbced85197.tar.bz2 dexon-sol-tools-8155d311af04339c105f1a29b74f1ddbced85197.tar.lz dexon-sol-tools-8155d311af04339c105f1a29b74f1ddbced85197.tar.xz dexon-sol-tools-8155d311af04339c105f1a29b74f1ddbced85197.tar.zst dexon-sol-tools-8155d311af04339c105f1a29b74f1ddbced85197.zip |
Merge branch 'development' into feature/asset-buyer/api-tweaks
* development:
Define bundlewatch.ci.repoBranchBase
Stop accesing ethers private methods
Fix merge conflicts
Fix ethers build issue
Upgrade ethers.js version
Fix branch name
Add max sizes
Use bundlewatch instead of bundlesize
Move Metamask Error to OrderErrors
Update the exported types for the packages which touch RPC providers
Throw and handle errors from Providers.
Clarifies use of schemas outside of Javascript/TypeScript.
Detect MM on signature validation failure.
Return SignedOrder from signing utils.
Update 0x.js Changelog
Add eth_signTypedData support to our wallet subproviders
Move SignTypedData to utils package
Introduce Metamask Subprovider.
Expose eth_signTypedData functionality for order signing
Diffstat (limited to 'packages/contract-wrappers')
4 files changed, 9 insertions, 25 deletions
diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index e83caad97..35f27d77c 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -84,7 +84,7 @@ "ethereum-types": "^1.0.11", "ethereumjs-blockstream": "6.0.0", "ethereumjs-util": "^5.1.1", - "ethers": "4.0.0-beta.14", + "ethers": "~4.0.4", "js-sha3": "^0.7.0", "lodash": "^4.17.5", "uuid": "^3.1.0" diff --git a/packages/contract-wrappers/src/index.ts b/packages/contract-wrappers/src/index.ts index 2fcdd2ddb..e8a53170e 100644 --- a/packages/contract-wrappers/src/index.ts +++ b/packages/contract-wrappers/src/index.ts @@ -39,6 +39,7 @@ export { JSONRPCRequestPayload, JSONRPCResponsePayload, JSONRPCErrorCallback, + JSONRPCResponseError, AbiDefinition, LogWithDecodedArgs, FunctionAbi, diff --git a/packages/contract-wrappers/src/utils/transaction_encoder.ts b/packages/contract-wrappers/src/utils/transaction_encoder.ts index 87cbb43fd..33086944b 100644 --- a/packages/contract-wrappers/src/utils/transaction_encoder.ts +++ b/packages/contract-wrappers/src/utils/transaction_encoder.ts @@ -1,22 +1,13 @@ import { schemas } from '@0xproject/json-schemas'; -import { EIP712Schema, EIP712Types, eip712Utils } from '@0xproject/order-utils'; +import { eip712Utils } from '@0xproject/order-utils'; import { Order, SignedOrder } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; +import { BigNumber, signTypedDataUtils } from '@0xproject/utils'; import _ = require('lodash'); import { ExchangeContract } from '../contract_wrappers/generated/exchange'; import { assert } from './assert'; -const EIP712_ZEROEX_TRANSACTION_SCHEMA: EIP712Schema = { - name: 'ZeroExTransaction', - parameters: [ - { name: 'salt', type: EIP712Types.Uint256 }, - { name: 'signerAddress', type: EIP712Types.Address }, - { name: 'data', type: EIP712Types.Bytes }, - ], -}; - /** * Transaction Encoder. Transaction messages exist for the purpose of calling methods on the Exchange contract * in the context of another address. For example, UserA can encode and sign a fillOrder transaction and UserB @@ -41,12 +32,9 @@ export class TransactionEncoder { signerAddress, data, }; - const executeTransactionHashBuff = eip712Utils.structHash( - EIP712_ZEROEX_TRANSACTION_SCHEMA, - executeTransactionData, - ); - const eip721MessageBuffer = eip712Utils.createEIP712Message(executeTransactionHashBuff, exchangeAddress); - const messageHex = `0x${eip721MessageBuffer.toString('hex')}`; + const typedData = eip712Utils.createZeroExTransactionTypedData(executeTransactionData, exchangeAddress); + const eip712MessageBuffer = signTypedDataUtils.generateTypedDataHash(typedData); + const messageHex = `0x${eip712MessageBuffer.toString('hex')}`; return messageHex; } /** diff --git a/packages/contract-wrappers/test/transaction_encoder_test.ts b/packages/contract-wrappers/test/transaction_encoder_test.ts index a397e43a8..9da8fe2ca 100644 --- a/packages/contract-wrappers/test/transaction_encoder_test.ts +++ b/packages/contract-wrappers/test/transaction_encoder_test.ts @@ -1,7 +1,7 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; import { FillScenarios } from '@0xproject/fill-scenarios'; import { assetDataUtils, generatePseudoRandomSalt, orderHashUtils, signatureUtils } from '@0xproject/order-utils'; -import { SignedOrder, SignerType } from '@0xproject/types'; +import { SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import 'mocha'; @@ -80,12 +80,7 @@ describe('TransactionEncoder', () => { ): Promise<void> => { const salt = generatePseudoRandomSalt(); const encodedTransaction = encoder.getTransactionHex(data, salt, signerAddress); - const signature = await signatureUtils.ecSignOrderHashAsync( - provider, - encodedTransaction, - signerAddress, - SignerType.Default, - ); + const signature = await signatureUtils.ecSignHashAsync(provider, encodedTransaction, signerAddress); txHash = await contractWrappers.exchange.executeTransactionAsync( salt, signerAddress, |