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

Enhance transaction validation with standardized RPC errors #1690

Merged
merged 14 commits into from
Sep 27, 2023

Conversation

vinistevam
Copy link
Contributor

@vinistevam vinistevam commented Sep 20, 2023

Explanation

This PR aims to update the TransactionController to throw standardised rpcErrors.invalidParams errors using the @metamask/rpc-errors package that will ensure they are standardised and more easily parsed and recognised by the dApps.

Context
The extension TransactionController uses the eth-rpc-errors package to throw standardised errors when validation fails. This update is a part of the ongoing TransactionController unification effort.

Note: As the colleagues pointed out in this PR eth-rpc-errors is deprecated so for equivalence the @metamask/rpc-errors package was added in the TransactionController and usages in the code was replaced accordingly.

Bump @metamask/rpc-errors to v6 in transaction-controller and assets-controller.

References

Changelog

@metamask/transaction-controller

  • CHANGED: update validateTxParams to throw standardised errors using the @metamask/rpc-errors package.
    • add @metamask/rpc-errors package.
    • remove eth-rpc-errors and replace usage with the new package.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@vinistevam vinistevam changed the title Refactor: Throw standardized RPC errors using eth-rpc-errors when validation fails adding transaction Throw standardized RPC errors using eth-rpc-errors when validation fails adding transaction Sep 20, 2023
@vinistevam vinistevam changed the title Throw standardized RPC errors using eth-rpc-errors when validation fails adding transaction Enhance transaction validation with standardized RPC errors using eth-rpc-errors Sep 20, 2023
@vinistevam vinistevam marked this pull request as ready for review September 20, 2023 10:19
@vinistevam vinistevam requested a review from a team as a code owner September 20, 2023 10:19
OGPoyraz
OGPoyraz previously approved these changes Sep 20, 2023
@legobeat
Copy link
Contributor

legobeat commented Sep 20, 2023

eth-rpc-errors is deprecated - would it be possible to standardize directly on updated and maintained @metamask/rpc-errors?

There is an open draft PR for @metamask/rpc-errors update here:

@matthewwalsh0
Copy link
Member

eth-rpc-errors is deprecated - would it be possible to standardize directly on updated and maintained @metamask/rpc-errors?

There is an open draft PR for @metamask/rpc-errors update here:

This makes sense to me assuming it's functionally identical and the resulting exception are the same?

The goal here is to align with the extension so if this diverges further, it may be best to update the package down the line.

@legobeat
Copy link
Contributor

legobeat commented Sep 21, 2023

@matthewwalsh0 Yes, the direction is that all active use of eth-rpc-errors must be actively removed/replaced with @metamask/rpc-errors including in MetaMask libraries, extension, and mobile. v4 and v6 are not completely identical.

The changelog is here: https://github.com/MetaMask/rpc-errors/blob/main/CHANGELOG.md

See esp v5.0.0 for API changes in the package.

The major thing here is the version upgrade - it's an associated package rename, not a change of dependencies per se.

Mrtenz
Mrtenz previously requested changes Sep 22, 2023
Copy link
Member

@Mrtenz Mrtenz left a comment

Choose a reason for hiding this comment

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

Please use @metamask/rpc-errors.

@vinistevam vinistevam changed the title Enhance transaction validation with standardized RPC errors using eth-rpc-errors Enhance transaction validation with standardized RPC errors Sep 22, 2023
@vinistevam
Copy link
Contributor Author

Please use @metamask/rpc-errors.

Thanks for the heads up @legobeat and @Mrtenz 🙏 I pushed the changes to use @metamask/rpc-errors instead of eth-rpc-errors

Copy link
Contributor

@legobeat legobeat left a comment

Choose a reason for hiding this comment

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

v6 has compatibility fixes in types

packages/transaction-controller/package.json Outdated Show resolved Hide resolved
@vinistevam vinistevam force-pushed the refactor/973-throw-rpc-error-validation branch from 1c098a1 to 919d77b Compare September 25, 2023 08:46
@socket-security
Copy link

Removed dependencies detected. Learn more about Socket for GitHub ↗︎

🚮 Removed packages: @metamask/rpc-errors@5.1.1

@legobeat legobeat dismissed their stale review September 26, 2023 09:52

this now uses @metamask/rpc-errors@6.0.0

Copy link
Contributor

@legobeat legobeat left a comment

Choose a reason for hiding this comment

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

LGTM

@vinistevam vinistevam merged commit 762882d into main Sep 27, 2023
107 checks passed
@vinistevam vinistevam deleted the refactor/973-throw-rpc-error-validation branch September 27, 2023 07:08
legobeat added a commit that referenced this pull request Oct 2, 2023
## Explanation

This replaces obsolete `eth-rpc-errors` with `@metamask/rpc-errors` in
`@metamask/approval-controller`. This should be coupled with #1639 and
can be merged before or after.

## References

#### Broken out from
- #1731 

#### Blocking
- #1724 

#### Related
- #1690

## Changelog


### `@metamask/approval-controller`

- **Changed**: Replaced `eth-rpc-errors` with `@metamask/rpc-errors`

### `@metamask/controller-utils`

- **Fixed**: Removed unused dependency `eth-rpc-errors`

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
## Explanation

This PR aims to update the `TransactionController` to throw standardised
`rpcErrors.invalidParams` errors using the `@metamask/rpc-errors`
package that will ensure they are standardised and more easily parsed
and recognised by the dApps.

**Context**
The extension `TransactionController` uses the `eth-rpc-errors` package
to throw standardised errors when validation fails. This update is a
part of the ongoing TransactionController unification effort.

Note: As the colleagues pointed out in this PR `eth-rpc-errors` is
deprecated so for equivalence the `@metamask/rpc-errors` package was
added in the `TransactionController` and usages in the code was replaced
accordingly.

Bump `@metamask/rpc-errors` to v6 in `transaction-controller` and
`assets-controller`.

### `@metamask/transaction-controller`

- **CHANGED**: update `validateTxParams` to throw standardised errors
using the `@metamask/rpc-errors` package.
     - add `@metamask/rpc-errors` package.
     - remove `eth-rpc-errors` and replace usage with the new package.
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
## Explanation

This replaces obsolete `eth-rpc-errors` with `@metamask/rpc-errors` in
`@metamask/approval-controller`. This should be coupled with #1639 and
can be merged before or after.

## References

#### Broken out from
- #1731 

#### Blocking
- #1724 

#### Related
- #1690

## Changelog


### `@metamask/approval-controller`

- **Changed**: Replaced `eth-rpc-errors` with `@metamask/rpc-errors`

### `@metamask/controller-utils`

- **Fixed**: Removed unused dependency `eth-rpc-errors`

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
## Explanation

This PR aims to update the `TransactionController` to throw standardised
`rpcErrors.invalidParams` errors using the `@metamask/rpc-errors`
package that will ensure they are standardised and more easily parsed
and recognised by the dApps.

**Context**
The extension `TransactionController` uses the `eth-rpc-errors` package
to throw standardised errors when validation fails. This update is a
part of the ongoing TransactionController unification effort.

Note: As the colleagues pointed out in this PR `eth-rpc-errors` is
deprecated so for equivalence the `@metamask/rpc-errors` package was
added in the `TransactionController` and usages in the code was replaced
accordingly.

Bump `@metamask/rpc-errors` to v6 in `transaction-controller` and
`assets-controller`.

### `@metamask/transaction-controller`

- **CHANGED**: update `validateTxParams` to throw standardised errors
using the `@metamask/rpc-errors` package.
     - add `@metamask/rpc-errors` package.
     - remove `eth-rpc-errors` and replace usage with the new package.
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
## Explanation

This replaces obsolete `eth-rpc-errors` with `@metamask/rpc-errors` in
`@metamask/approval-controller`. This should be coupled with #1639 and
can be merged before or after.

## References

#### Broken out from
- #1731 

#### Blocking
- #1724 

#### Related
- #1690

## Changelog


### `@metamask/approval-controller`

- **Changed**: Replaced `eth-rpc-errors` with `@metamask/rpc-errors`

### `@metamask/controller-utils`

- **Fixed**: Removed unused dependency `eth-rpc-errors`

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
MajorLift pushed a commit that referenced this pull request Oct 12, 2023
## Explanation

This replaces obsolete `eth-rpc-errors` with `@metamask/rpc-errors` in
`@metamask/approval-controller`. This should be coupled with #1639 and
can be merged before or after.

## References

#### Broken out from
- #1731 

#### Blocking
- #1724 

#### Related
- #1690

## Changelog


### `@metamask/approval-controller`

- **Changed**: Replaced `eth-rpc-errors` with `@metamask/rpc-errors`

### `@metamask/controller-utils`

- **Fixed**: Removed unused dependency `eth-rpc-errors`

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
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.

6 participants