MetaMask / MetaMask/metamask-extension

readAddressAsContract should not swallow errors when reading contract code

Open
#21,647 0 comments 0 reactions 0 assignees View on GitHub
external-contributor INVALID-ISSUE-TEMPLATE team-confirmations team-confirmations-system-deprecated Transactions
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

**Problem**
In the readAddressAsContract function, it’s using EthQuery to grab the contract code from a specific address, but it seems like it's catching all sorts of errors, not just the ones we want.

**Expected **
If there’s no contract at the address and an error pops up, that’s totally fine. We just set contractCode to null and move on. But if a different type of error comes up, we should be logging that to Sentry to keep track and fix it if needed.

See discussion here: https://github.com/MetaMask/metamask-extension/pull/21604/files/668054d989843814da2ee7c2fe7767a05487d703#diff-57e38278f8e09d93b0037ed8fdc648d9c9601a67854a17c454bd5b3ac1d94c3dR24

Contributor guide

Open the contributing guide

Research direction

Start at the readAddressAsContract entry point and inspect how EthQuery errors are handled. Review the linked pull request discussion, then verify that only the no-contract case is converted to null while other errors are reported to Sentry.

Written by the indexing model from the issue text.

Assessment

Tech stack
blockchain, typescript
Domain
api, blockchain
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.