Skip to content

Commit

Permalink
Ensure the immutability of function signTransaction input parameter (
Browse files Browse the repository at this point in the history
…web3#3119)

* Ensure the immutability of function `signTransaction` input parameter

* Replace `JSON.parse(JSON.stringify(tx))` with `_.clone(tx)`

* Update CHANGELOG.md
  • Loading branch information
barakman authored and nachomazzara committed Jun 4, 2020
1 parent 78a7ac3 commit 44b6e81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,5 @@ Released with 1.0.0-beta.37 code base.
- Fix accessing event.name where event is undefined (#3014)
- Fix bubbling up tx signing errors (#2063, #3105)
- HttpProvider: CORS issue with Firefox and Safari (#2978)
- Ensure the immutability of the `tx` object passed to function `signTransaction` (#2190)
- Gas check fixed (#2381)
12 changes: 5 additions & 7 deletions packages/web3-eth-accounts/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,11 @@ Accounts.prototype.signTransaction = function signTransaction(tx, privateKey, ca
}

try {
tx = helpers.formatters.inputCallFormatter(tx);

var transaction = tx;
transaction.to = tx.to || '0x';
transaction.data = tx.data || '0x';
transaction.value = tx.value || '0x';
transaction.chainId = utils.numberToHex(tx.chainId);
var transaction = helpers.formatters.inputCallFormatter(_.clone(tx));
transaction.to = transaction.to || '0x';
transaction.data = transaction.data || '0x';
transaction.value = transaction.value || '0x';
transaction.chainId = utils.numberToHex(transaction.chainId);

var rlpEncoded = RLP.encode([
Bytes.fromNat(transaction.nonce),
Expand Down

0 comments on commit 44b6e81

Please sign in to comment.