MetaMask / MetaMask/metamask-mobile

Generalize BackgroundBridge

Open
#14,172 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

INVALID-ISSUE-TEMPLATE snaps-unrefined-backlog
Dominant language
TypeScript
Stars
3k
Forks
1.7k
Avg merge
1d 14h
Merged PRs (30d)
669

Description

**What is this about?**

The BackgroundBridge file is a core piece of functionality that holds the JSON RPC engine stack, which contains many RPC middlewares including the RPCMethodMiddleware. Since this file is shared across subjects, this file should not contain any feature specific code. Instead, any feature specific code should be passed in as an option instead. This approach maintains the manageability as well as scaleability of the file. This task is to abstract and if possible, remove any feature specific code from the `BackgroundBridge` file.

**Technical Details**

- Generalize the `BackgroundBridge` file to be feature agnostic
- Ex. SDK, WC, Snaps, Browser specific logic should be abstracted and/or removed
- Ex. Pull out the Port and pass in as an option instead
- Sync with @MetaMask/wallet-api-platform-engineers on why `SelectedNetworkController` needs access to domain. Is this similar to permission system subject ID? Can it be replaced with subject ID?

**Acceptance Criteria**

- JSON RPC calls are still working
- Middlewares are still responding
- RPC methods still work when interacting with subjects such as WC, SDK, Browser, and Snaps

**Stakeholder review needed before the work gets merged**

- [ ] Engineering (needed in most cases)
- [ ] Design
- [ ] Product
- [ ] QA (automation tests are required to pass before merging PRs but not all changes are covered by automation tests - please review if QA is needed beyond automation tests)
- [ ] Security
- [ ] Legal
- [ ] Marketing
- [ ] Management (please specify)
- [ ] Other (please specify)

**References**

- Old WIP PR - https://github.com/MetaMask/metamask-mobile/pull/13698

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the BackgroundBridge file and inspect the JSON RPC middleware stack, including RPCMethodMiddleware, along with the old WIP PR #13698. Review the SDK, WC, Snaps, Browser, Port, and SelectedNetworkController references before coordinating the domain question with the wallet API platform engineers. Done means JSON RPC calls, middleware responses, and RPC methods continue working for all listed subjects.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend-api-design
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.