Skip to content

Commit

Permalink
Safe property access / allow transaction with undefined to fields, in…
Browse files Browse the repository at this point in the history
… signTransaction (#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 #95
  • Loading branch information
danjm authored Aug 27, 2021
1 parent 6df72ed commit 3c22af7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class LedgerBridgeKeyring extends EventEmitter {

rawTxHex = tx.serialize().toString('hex')

return this._signTransaction(address, rawTxHex, tx.to, (payload) => {
return this._signTransaction(address, rawTxHex, (payload) => {
tx.v = Buffer.from(payload.v, 'hex')
tx.r = Buffer.from(payload.r, 'hex')
tx.s = Buffer.from(payload.s, 'hex')
Expand All @@ -256,7 +256,7 @@ class LedgerBridgeKeyring extends EventEmitter {
? 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, (payload) => {
// Because tx will be immutable, first get a plain javascript object that
// represents the transaction. Using txData here as it aligns with the
// nomenclature of ethereumjs/tx.
Expand All @@ -273,7 +273,7 @@ class LedgerBridgeKeyring extends EventEmitter {
})
}

_signTransaction (address, rawTxHex, toAddress, handleSigning) {
_signTransaction (address, rawTxHex, handleSigning) {

return new Promise((resolve, reject) => {
this.unlockAccountByAddress(address)
Expand All @@ -283,7 +283,6 @@ class LedgerBridgeKeyring extends EventEmitter {
params: {
tx: rawTxHex,
hdPath,
to: ethUtil.bufferToHex(toAddress).toLowerCase(),
},
},
({ success, payload }) => {
Expand Down
2 changes: 0 additions & 2 deletions test/test-eth-ledger-bridge-keyring.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ describe('LedgerBridgeKeyring', function () {
sandbox.on(keyring, '_sendMessage', (msg, cb) => {
assert.deepStrictEqual(msg.params, {
hdPath: "m/44'/60'/0'/0",
to: ethUtil.bufferToHex(fakeTx.to),
tx: fakeTx.serialize().toString('hex'),
})
cb({ success: true, payload: { v: '0x1', r: '0x0', s: '0x0' } })
Expand Down Expand Up @@ -471,7 +470,6 @@ describe('LedgerBridgeKeyring', function () {
sandbox.on(keyring, '_sendMessage', (msg, cb) => {
assert.deepStrictEqual(msg.params, {
hdPath: "m/44'/60'/0'/0",
to: ethUtil.bufferToHex(newFakeTx.to.buf),
tx: ethUtil.rlp.encode(newFakeTx.getMessageToSign(false)).toString('hex'),
})
cb({ success: true, payload: { v: '0x25', r: '0x0', s: '0x0' } })
Expand Down

0 comments on commit 3c22af7

Please sign in to comment.