Skip to content

Conversation

@dan437
Copy link
Contributor

@dan437 dan437 commented Apr 22, 2021

Explanation

Add contract address validation for token swaps before sending it to blockchain. That is done in 2 ways:

  • If it's ETH -> WETH or WETH -> ETH, we validate it against a specific contract address
  • For everything else, we check if a contract address matches an expected one for current chainId

Manual testing steps

Validation is triggered on the page with a quote:
image

It would be great to manually test scenarios that are covered in unit tests.

Screenshots and videos

Validation passed for TESTETH -> WETH on Testnet:
image

Contract address validation failed:
image

@dan437 dan437 requested a review from a team as a code owner April 22, 2021 21:03
@dan437 dan437 requested a review from danjm April 22, 2021 21:03
@github-actions
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[REQ] Could we add a jsdoc block to this function to describe its purpose briefly and expected parameters?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also because this doesn't interact with state or dispatch directly I think its better suited to be in the swaps utils file in the page folder. It can be directly exported from there instead of the testtables object

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@brad-decker brad-decker merged commit 9fa6fc9 into MetaMask:develop Apr 23, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Apr 23, 2021
@dan437 dan437 deleted the swaps-validation-weth branch July 24, 2023 11:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants