-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Safe property access / allow transaction with undefined to fields, in signTransaction #98
Conversation
index.js
Outdated
@@ -255,8 +255,7 @@ class LedgerBridgeKeyring extends EventEmitter { | |||
rawTxHex = tx.type === 0 || !tx.type | |||
? ethUtil.rlp.encode(tx.getMessageToSign(false)).toString('hex') | |||
: tx.getMessageToSign(false).toString('hex') | |||
|
|||
return this._signTransaction(address, rawTxHex, tx.to.buf, (payload) => { | |||
return this._signTransaction(address, rawTxHex, tx.to && tx.to.buf, (payload) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks to me like passing in nothing for toAddress
will result in the to
field passed to the Ledger device being set to 0x0
. That doesn't seem right 🤔 . Should _signTransaction
omit the to
field instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️
Actually, after merging #95, the to
field isn't even needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have simply removed the to
parameter in 8f2195c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works! Though if you wanted to remove the dependency on #95, I think this would also be safe to merge if to
was omitted for contract deployments, but passed in otherwise.
…elds, in signTransaction" This reverts commit 3c148ba.
Adding a DO NOT MERGE label, as this now depends on #95 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
… signTransaction (MetaMask#98) * Safe property access / allow transaction with undefined to fields, in signTransaction * Revert "Safe property access / allow transaction with undefined to fields, in signTransaction" This reverts commit 3c148ba. * Remove passage of to param to ledger bridge, which will not be needed after PR MetaMask#95
With #68, we started directly accessing a
.buf
property ontx.to
insignTransaction
. This was necessary given changes in ethereumjs-txThe problem is that the
to
field can be undefined. This is necessary for deploying contracts. Currently, in prod, if you attempt to create a contract deployment transaction with ledger in metamask, you will see an error because oftx.to.buf
andtx.to
being undefined.This PR fixes that.