-
Notifications
You must be signed in to change notification settings - Fork 21
Adjust transaction parameters and prefixed string normalizers #257
Conversation
@@ -248,7 +248,7 @@ export const transactionObjectValidator = ({ | |||
* Only check if the address (`to` prop) is in the correct | |||
* format, if one was provided in the initial transaction object | |||
*/ | |||
if (typeof to !== 'undefined') { | |||
if (to) { |
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.
A truthy check should suffice for to
; it can be null
or undefined
(or a string).
/* | ||
* Encrypted JSON Keystore | ||
*/ | ||
keystore: string; |
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.
Flow showed me that these had to be removed, because they conflicted with the getters (which are typed appropriately).
@@ -297,7 +297,7 @@ export const signMessage = async ({ | |||
const toSign = messageOrDataValidator({ message, messageData }); | |||
warning(messages.messageSignatureOnlyTrezor); | |||
try { | |||
const { signature: signedMessage } = await payloadListener({ | |||
const { signature: signedMessage = '' } = await payloadListener({ |
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.
Flow showed that this was necessary; signature
is optional in the return value, but I'm not sure whether this is a problem.
@@ -189,6 +193,9 @@ describe('`Trezor` Hardware Wallet Module Static Methods', () => { | |||
); | |||
}); | |||
test('Signs a transaction without a destination address', async () => { | |||
payloadListener.mockImplementation(() => ({ |
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.
This test was silently failing :/ (reported as RUNS
not PASS
)
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.
Nice catch!
* Fix Flow errors for string normalizers, require a string value * Use a bound function for address/hex sequence normalizers
* Adjust parameters for `ethereumjs-tx` transactions (recent breaking changes) and ensure that the chain ID is supplied; this fixes a bug where the recovery param wasn't validated correctly * Fix logic for supplying a `to` property for transactions (it can also be `null`, not just `undefined`) * Fix some Flow types * Fix some comments * Update/fix tests
f9acd9a
to
eea5398
Compare
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.
Once a again, very nice job @JamesLefrere 💯
/** | ||
* Nomalize an Ethereum address | ||
* Normalize an Ethereum address |
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.
Hey, you even spell checked my comments. Top marks 💯
@@ -189,6 +193,9 @@ describe('`Trezor` Hardware Wallet Module Static Methods', () => { | |||
); | |||
}); | |||
test('Signs a transaction without a destination address', async () => { | |||
payloadListener.mockImplementation(() => ({ |
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.
Nice catch!
* provided in the initial transaction object. | ||
*/ | ||
typeof to !== 'undefined' ? { to: addressNormalizer(to) } : {}, | ||
), | ||
...(to ? { to: addressNormalizer(to) } : {}), |
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'll need to manually check the Trezor service, since I remember it going crazy if we passed in values it didn't expect.
This PR makes some changes to transactions created with
ethereumjs-tx
such that thechain
andto
properties are supplied correctly; this fixes a bug where the recovery param wasn't validated correctly.Changes
ethereumjs-tx
transactions (recent breaking changes) and ensure that the chain ID is supplied; this fixes a bug where the recovery param wasn't validated correctlyto
property for transactions (it can also benull
, not justundefined
)