fix(deps): update from eth-rpc-errors to @metamask/rpc-errors#22871
fix(deps): update from eth-rpc-errors to @metamask/rpc-errors#22871legobeat wants to merge 17 commits intoMetaMask:developfrom
eth-rpc-errors to @metamask/rpc-errors#22871Conversation
|
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. |
31e4a2a to
b075fa9
Compare
|
🎉 |
FrederikBolding
left a comment
There was a problem hiding this comment.
Code LGTM, but looks to be some problems in CI.
Addressed in c81c5033101e32f68b011d9ab91db76db39eff5d by updating tests to expect underlying error message in |
5d38fdd to
4284831
Compare
79e9598 to
7f3572e
Compare
eth-rpc-errors to @metamask/rpc-errorseth-rpc-errors to @metamask/rpc-errors
b82f0e9 to
d09d8f7
Compare
d09d8f7 to
892b0cc
Compare
59af259 to
a385eb3
Compare
shared/modules/error.ts
Outdated
There was a problem hiding this comment.
Hmm, wouldn't this be the correct type? It's one or the other, not necessarily both
| ): error is { message: string } & { data: { cause: { message: string } } } { | |
| ): error is { message: string } | { data: { cause: { message: string } } } { |
shared/modules/error.ts
Outdated
There was a problem hiding this comment.
We can avoid using any by using our hasProperty and isObject functions from @metamask/utils:
| ('message' in error || | |
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | |
| typeof (error as any)?.data?.cause?.message === 'string') | |
| (hasProperty(error, 'message') || | |
| (hasProperty(error, 'data') && | |
| isObject(error.data) && | |
| hasProperty(error.data, 'cause') && | |
| isObject(error.data.cause) && | |
| hasProperty(error.data.cause, 'message') && | |
| typeof error.data.cause.message === 'string')) |
There was a problem hiding this comment.
Nice, will update accordingly!
There was a problem hiding this comment.
Looping back: Why is the suggestion preferred, actually? In this case it doesn't give us any further benefits wrt types or guarantees from the type system (I think?), and the ?. is a lot easier to read. If it's just because "any bad", I'd actually think it's actually intended for situations like this? Unless I'm indeed overlooking something!
(Looks like this part will still be rewritten anyway, though, as consequence of properly fixing types)
There was a problem hiding this comment.
any will disable type checking completely, anywhere the value set to any is used (including any derived types). It can easily "infect" the rest of the codebase in subtle ways, preventing type checking where we might otherwise expect it. I don't think there are any situations where we found any to be the best choice for a parameter/value/etc (the only "non-harmful" case we found was in generic type constraints, where it can't spread any further).
See more on recommended escape hatches here: https://github.com/MetaMask/contributor-docs/blob/main/docs/typescript.md#escape-hatches
Though in this case, it does add type safety. This statement wasn't typed before, now it is.
I see your point about ?. being a lot easier to read. This has been one of my biggest frustrations with TypeScript, that it makes it difficult and verbose to interact with data structures that you don't know the contents of ahead of time. Any reference to an unrecognized property causes complaint, you need to first hold TypeScript's hand through the process of looking for that property first (hence the hasProperty type guard). There is probably a better way of doing this that I'm not aware of.
There was a problem hiding this comment.
Def agree in the general, but here it's "enclosed" and the line has the same out-and-in types as those 6 lines...
Regardless of approach, the equivalent in my currently preferred approach over this one becomes a bit less lengthy: https://github.com/MetaMask/metamask-extension/pull/24496/files#diff-b9515eba7ccebd6c2cb33172f8f348816351594c12a5eebe825a573c9b8f59b0R22
There was a problem hiding this comment.
This could make the test more flaky, as we're introducing two new async steps in between finding the element and asserting. The element could be found, then removed from the DOM or had its contents changed.
There was a problem hiding this comment.
While true, if this is the case, wouldn't that be indicative of an actual error we do want to fail (ideally consistently, since that should never happen right?)
But anyway, I can take a look at if this can work again with only a single async like before.
There was a problem hiding this comment.
It's true that the type of page behavior that would trigger flakiness in this case is probably undesirable.
But we do have UI that is meant to refresh (e.g. gas estimates, balances, the activity list, etc.). And we have a lot of janky UI that rerenders when it shouldn't, causing flakiness in cases like this, where it would be helpful for the test to assert something about the UI behavior even in the face of this problem.
Hmm. Tricky problem. Maybe you're right that having tests that are less-tolerant of jankyness would encourage us to fix the jankyness. But given the current state of our e2e test suite, my intuition is that it would do more harm than good in the short/medium term because we don't have capacity to do a good job of fixing janky UI everywhere right now, and we desperately need our tests to be less flaky. But I am definitely open to being convinced otherwise here.
There was a problem hiding this comment.
Hmm, it's not clear what could have necessitated this change
There was a problem hiding this comment.
Leftover from WIP attempts, I think. Will see if these can be reverted to keep the changes relevant.
ui/store/actions.ts
Outdated
There was a problem hiding this comment.
Nit: We should be able to avoid a cast here as well, by using hasProperty and isObject from @metamask/utils
This reverts commit e5ae79be58cf22b873ede78ac8edac08832bcaac.
|
This PR has been automatically marked as stale because it has not had recent activity in the last 60 days. It will be closed in 14 days. Thank you for your contributions. |
|
This PR was closed because there has been no follow up activity in the last 14 days. Thank you for your contributions. |
Description
The package
eth-rpc-errorshas been renamed to@metamask/rpc-errorsstarting with version 5. Many controllers and libraries used in extension already use the releases. This updates the direct dependency frometh-rpc-errors@4.0.2to@metamask/rpc-errors@6.0.1.Related issues
@metamask/signature-controllerand related packages #22861@metamask/address-book-controller#22863Blocking
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist