Skip to content
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

Bug/3137 token address crasher #3152

Merged
merged 8 commits into from
Sep 23, 2021
Merged

Conversation

Cal-L
Copy link
Contributor

@Cal-L Cal-L commented Sep 20, 2021

Description

#3137

Checklist

  • There is a related GitHub issue
  • Tests are included if applicable
  • Any added code is fully documented

Issue

Resolves #???

@Cal-L Cal-L requested a review from a team as a code owner September 20, 2021 22:23
@Cal-L Cal-L added No QA Needed Apply this label when your PR does not need any QA effort. needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) labels Sep 20, 2021
Comment on lines 79 to 83
try {
await TokensController.addToken(address, symbol, decimals);
} catch (error) {
Logger.log('Error while trying to add a custom token', error);
}
Copy link
Member

Choose a reason for hiding this comment

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

Do you think it would be better to create a method in a utils file since you use this code in multiple parts?

Comment on lines 215 to 228
const newAllTokens = {};
Object.entries(allTokens).forEach(([chainId, tokensByAccountAddress]) => {
Object.entries(tokensByAccountAddress).forEach(([accountAddress, tokens]) => {
const newTokens = tokens.filter(({ address }) => !!address);
if (newAllTokens[chainId] === undefined) {
newAllTokens[chainId] = { [accountAddress]: newTokens };
} else {
newAllTokens[chainId] = {
...newAllTokens[chainId],
[accountAddress]: newTokens,
};
}
});
});
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this logic its the same as the one between lines 229-242, it could be transferred to a new method to avoid repetition.

@Cal-L Cal-L removed No QA Needed Apply this label when your PR does not need any QA effort. needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) labels Sep 21, 2021
@Cal-L Cal-L added needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) No QA Needed Apply this label when your PR does not need any QA effort. labels Sep 22, 2021
Copy link
Member

@gantunesr gantunesr left a comment

Choose a reason for hiding this comment

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

lgtm

@Cal-L Cal-L removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Sep 23, 2021
@MetaMask MetaMask deleted a comment Sep 23, 2021
@MetaMask MetaMask deleted a comment Sep 23, 2021
@Cal-L Cal-L merged commit be101f8 into develop Sep 23, 2021
@Cal-L Cal-L deleted the bug/3137-token-address-crasher branch September 23, 2021 16:33
@Cal-L Cal-L removed the No QA Needed Apply this label when your PR does not need any QA effort. label Oct 1, 2021
rickycodes pushed a commit that referenced this pull request Jan 31, 2022
* Filter out tokens with missing address in migration. Catch and log token removal action.

* Attempt to catch and log failures when adding token

* Remove puncuations from removal error message

* Update migration

* Clean up migration to only apply for ignored tokens. Map into array of strings

* Revert "Attempt to catch and log failures when adding token"

This reverts commit 7e2752e.

* Update remove token catch log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants