diff options
author | Francesco Agosti <francesco.agosti93@gmail.com> | 2018-07-07 02:46:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-07 02:46:03 +0800 |
commit | c4ab5bc65333204e7cf712e3330406120f163268 (patch) | |
tree | 7b6238c249db849d647e6679c0d1333cac317ef9 /packages | |
parent | 1d3bdfc3746255d4dfe28eabed884c7ef23bf1d8 (diff) | |
parent | 72fb1ee36f5ca7bceebb1ad2eac707295ccbe9c2 (diff) | |
download | dexon-sol-tools-c4ab5bc65333204e7cf712e3330406120f163268.tar dexon-sol-tools-c4ab5bc65333204e7cf712e3330406120f163268.tar.gz dexon-sol-tools-c4ab5bc65333204e7cf712e3330406120f163268.tar.bz2 dexon-sol-tools-c4ab5bc65333204e7cf712e3330406120f163268.tar.lz dexon-sol-tools-c4ab5bc65333204e7cf712e3330406120f163268.tar.xz dexon-sol-tools-c4ab5bc65333204e7cf712e3330406120f163268.tar.zst dexon-sol-tools-c4ab5bc65333204e7cf712e3330406120f163268.zip |
Merge pull request #829 from 0xProject/bug/web3-wrapper/fix-invalid-transaction-format
Fix invalid transaction format errors when going through `SingerSubprovider`
Diffstat (limited to 'packages')
-rw-r--r-- | packages/subproviders/src/subproviders/signer.ts | 5 | ||||
-rw-r--r-- | packages/web3-wrapper/CHANGELOG.json | 9 | ||||
-rw-r--r-- | packages/web3-wrapper/src/index.ts | 1 | ||||
-rw-r--r-- | packages/web3-wrapper/src/marshaller.ts | 13 |
4 files changed, 26 insertions, 2 deletions
diff --git a/packages/subproviders/src/subproviders/signer.ts b/packages/subproviders/src/subproviders/signer.ts index 08a9daceb..f7329e00c 100644 --- a/packages/subproviders/src/subproviders/signer.ts +++ b/packages/subproviders/src/subproviders/signer.ts @@ -1,4 +1,4 @@ -import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import { marshaller, Web3Wrapper } from '@0xproject/web3-wrapper'; import { JSONRPCRequestPayload, Provider } from 'ethereum-types'; import { Callback, ErrorCallback } from '../types'; @@ -51,7 +51,8 @@ export class SignerSubprovider extends Subprovider { case 'eth_sendTransaction': const [txParams] = payload.params; try { - const txHash = await this._web3Wrapper.sendTransactionAsync(txParams); + const txData = marshaller.unmarshalTxData(txParams); + const txHash = await this._web3Wrapper.sendTransactionAsync(txData); end(null, txHash); } catch (err) { end(err); diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index f8b1dab85..fcbedbbf2 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "version": "0.7.3", + "changes": [ + { + "note": "Export `marshaller` utility file.", + "pr": 829 + } + ] + }, + { "timestamp": 1529397769, "version": "0.7.2", "changes": [ diff --git a/packages/web3-wrapper/src/index.ts b/packages/web3-wrapper/src/index.ts index 66ef0a784..19fe0836c 100644 --- a/packages/web3-wrapper/src/index.ts +++ b/packages/web3-wrapper/src/index.ts @@ -1,2 +1,3 @@ export { Web3Wrapper, uniqueVersionIds, NodeType } from './web3_wrapper'; export { Web3WrapperErrors } from './types'; +export { marshaller } from './marshaller'; diff --git a/packages/web3-wrapper/src/marshaller.ts b/packages/web3-wrapper/src/marshaller.ts index e9fd35a11..15384417e 100644 --- a/packages/web3-wrapper/src/marshaller.ts +++ b/packages/web3-wrapper/src/marshaller.ts @@ -73,6 +73,19 @@ export const marshaller = { }; return tx; }, + unmarshalTxData(txDataRpc: TxDataRPC): TxData { + if (_.isUndefined(txDataRpc.from)) { + throw new Error(`txData must include valid 'from' value.`); + } + const txData = { + ...txDataRpc, + value: !_.isUndefined(txDataRpc.value) ? utils.convertHexToNumber(txDataRpc.value) : undefined, + gas: !_.isUndefined(txDataRpc.gas) ? utils.convertHexToNumber(txDataRpc.gas) : undefined, + gasPrice: !_.isUndefined(txDataRpc.gasPrice) ? utils.convertHexToNumber(txDataRpc.gasPrice) : undefined, + nonce: !_.isUndefined(txDataRpc.nonce) ? utils.convertHexToNumber(txDataRpc.nonce) : undefined, + }; + return txData; + }, marshalTxData(txData: Partial<TxData>): Partial<TxDataRPC> { if (_.isUndefined(txData.from)) { throw new Error(`txData must include valid 'from' value.`); |