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

Refactor RPC getAccounts usage #5620

Merged
merged 2 commits into from
Apr 6, 2023
Merged

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Jan 26, 2023

Development & PR Process

  1. Follow MetaMask Mobile Coding Standards
  2. Add release-xx label to identify the PR slated for a upcoming release (will be used in release discussion)
  3. Add needs-dev-review label when work is completed
  4. Add needs-qa label when dev review is completed
  5. Add QA Passed label when QA has signed off

Description

The getAccounts function is defined and used in two different places in the RPC pipeline: RPCMethodMiddleware.ts and
web3-provider-engine. The second one has been removed, so now all usage is in RPCMethodMiddleware.ts.

getAccounts is passed into web3-provider-engine and used in the HookedWalletSubprovider: https://github.com/MetaMask/web3-provider-engine/blob/cf612f898002833c36730d23972fe4c4dd483c76/subproviders/hooked-wallet.js

It is used in these methods:

  • eth_coinbase
  • eth_accounts
  • parity_defaultAccount

It's also called to validate the sender, for the following methods:

  • eth_signTypedData
  • eth_signTypedData_v3
  • eth_signTypedData_v4
  • encryption_public_key
  • eth_decryptMessage
  • personal_sign
  • eth_sign
  • eth_signTransaction
  • eth_sendTransaction

Of these methods, most of them are intercepted in
RPCMethodMiddleware.ts, so the requests never make it to web3-provider-engine.

These three methods will make their way there: parity_defaultAccount, encryption_public_key, and eth_decryptMessage. The decryption- related messages rely on constructor parameters that mobile does not pass in, so those always throw an error. The only method this hook is used for in practice is parity_defaultAccount.

The parity_defaultAccount method was added to
RPCMethodMiddleware.ts, so now that method won't make it to web3-provider-engine either. Functionally it is the same as eth_coinbase, so the same implementation has been used.

This should have no functional changes.

Issue

This relates to #5513

Checklist

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

@Gudahtt Gudahtt force-pushed the refactor-rpc-get-accounts-usage branch from a43e181 to 2c47bef Compare January 26, 2023 21:53
@Gudahtt Gudahtt marked this pull request as ready for review January 26, 2023 22:03
@Gudahtt Gudahtt requested a review from a team as a code owner January 26, 2023 22:03
@Gudahtt Gudahtt added the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Jan 26, 2023
@Gudahtt Gudahtt marked this pull request as draft March 8, 2023 03:09
@Gudahtt Gudahtt force-pushed the refactor-rpc-get-accounts-usage branch from 2c47bef to c823904 Compare March 16, 2023 01:53
@Gudahtt Gudahtt marked this pull request as ready for review March 16, 2023 01:54
@Gudahtt Gudahtt force-pushed the refactor-rpc-get-accounts-usage branch from c823904 to c0ac2a6 Compare March 29, 2023 03:51
The `getAccounts` function is defined and used in two different places
in the RPC pipeline: `RPCMethodMiddleware.ts` and
`web3-provider-engine`. The second one has been removed, so now all
usage is in `RPCMethodMiddleware.ts`.

`getAccounts` is passed into `web3-provider-engine` and used in the
`HookedWalletSubprovider`: https://github.com/MetaMask/web3-provider-engine/blob/cf612f898002833c36730d23972fe4c4dd483c76/subproviders/hooked-wallet.js

It is used in these methods:
* `eth_coinbase`
* `eth_accounts`
* `parity_defaultAccount`

It's also called to validate the sender, for the following methods:
* `eth_signTypedData`
* `eth_signTypedData_v3`
* `eth_signTypedData_v4`
* `encryption_public_key`
* `eth_decryptMessage`
* `personal_sign`
* `eth_sign`
* `eth_signTransaction`
* `eth_sendTransaction`

Of these methods, most of them are intercepted in
`RPCMethodMiddleware.ts`, so the requests never make it to
`web3-provider-engine`.

These three methods will make their way there: `parity_defaultAccount`,
`encryption_public_key`, and `eth_decryptMessage`. The decryption-
related messages rely on constructor parameters that mobile does not
pass in, so those always throw an error. The only method this hook is
used for in practice is `parity_defaultAccount`.

The `parity_defaultAccount` method was added to
`RPCMethodMiddleware.ts, so now that method won't make it to
`web3-provider-engine` either. Functionally it is the same as
`eth_coinbase`, so the same implementation has been used.

This relates to #5513
@Gudahtt Gudahtt force-pushed the refactor-rpc-get-accounts-usage branch from c0ac2a6 to ecc33fc Compare April 5, 2023 23:17
Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

Nice, it looks like like this change will enable Permission system for parity_defaultAccount as well. LGTM

@Cal-L Cal-L added team-mobile-client team-wallet-framework Spot Check on the Release Build If a ticket doesn't require feature QA, but does require some form of manual spot checking and removed needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) labels Apr 6, 2023
@Gudahtt Gudahtt merged commit 1f24769 into main Apr 6, 2023
13 checks passed
@Gudahtt Gudahtt deleted the refactor-rpc-get-accounts-usage branch April 6, 2023 17:48
@github-actions github-actions bot locked and limited conversation to collaborators Apr 6, 2023
@Cal-L
Copy link
Contributor

Cal-L commented Apr 6, 2023

Also applied spot check on release since no functional changes

@Cal-L Cal-L added the release-6.4.0 PR for release 6.4.0 label Apr 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-6.4.0 PR for release 6.4.0 Spot Check on the Release Build If a ticket doesn't require feature QA, but does require some form of manual spot checking team-mobile-platform team-wallet-framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants