-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Ensure that addresses are properly hex-prefixed in the generate ERC token transfer functions #15064
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
8d0c269
to
70efd4b
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.
LGTM!
We should follow up with additional unit tests, an e2e test, and inline docs for these functions.
@@ -142,7 +142,7 @@ function generateERC20TransferData({ | |||
.call( | |||
abi.rawEncode( | |||
['address', 'uint256'], | |||
[toAddress, addHexPrefix(amount)], | |||
[addHexPrefix(toAddress), addHexPrefix(amount)], |
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.
Generally I'd prefer us blowing up for invalid inputs rather than normalizing them, to make the code simpler and easier to trace. I can see why this would be easier for now but longer term this adds unnecessary complexity.
Actually, maybe better to target this at develop instead of master. The unit test failure appears unrelated, it's one that intermittently fails. |
70efd4b
to
783a72d
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.
LGTM!
Needs unit test update, but I sent USDC on MainNet to an address without the |
eaa7599
Fixes #15058
This PR is currently comparing to the branch for #15063, we need to merge that PR first, and then rebase this PR's branch onto master.
we used to do this to create a token transfer transaction from the send screen:
https://github.com/MetaMask/metamask-extension/pull/14465/files#diff-bad76d7279418f3520a0ca93cfaeeb6fcbb1f0d4782f6ff942d422632a1c2780L1762-L1766
we now do this:
https://github.com/MetaMask/metamask-extension/pull/14465/files#diff-3c58b916cefff81e4927a9afd392acadbf4515f99f41783964a9851b7774791bR815-R833
previously we would create the token transfer via libraries that depend on this from ethjs-abi https://github.com/ethjs/ethjs-abi/blob/master/src/utils/index.js#L166, so validation of the hex string would fail there, and the user wouldn't be able to send the transaction, with the change referenced above, that validation stopped