Open Gudahtt opened 1 year ago
I propose we focus on the following libraries for Q3:
@metamask/utils
@metamask/json-rpc-engine
@metamask/eth-json-rpc-provider
(not in the list above because it was created after the above list was built)@metamask/json-rpc-middleware-stream
I went through the list of existing repos and found some that were omitted from the list above:
browser-passworder
— Is this because it's extension only?eth-snap-keyring
, keyring-snaps-registry
, snap-simple-keyring
, snaps-registry
) — is this because Snaps owns these?object-multiplex
(used by providers
) — Is it because it's not used directly by the wallet?post-message-stream
— Is this because it's extension only?ppom-validator
— Is this because it's extension only?rpc-errors
, safe-event-emitter
, eth-json-rpc-provider
, key-tree
, swappable-obj-proxy
— Are these missing because they were created after the list above was compiled?web3-stream-provider
— Is this because it's extension only?UPDATE October 17, 2023:
Before starting work on future library migrations, please make sure to consult @MajorLift's migration checklist here. The instructions here only cover step B.0 in this checklist.
One thing we want to absolutely make sure to do when we migrate a library to this repo is to preserve all of the Git history.
I experimented with this using @metamask/utils
and came up with a process. At a high level, we need to:
merged-packages/<library-name>
directory all along. (You will soon see why.)core
.core
's main
branch (ignoring unrelated history).Now we see why we performed step 2: because we want the library to initially be located in core
under merged-packages/<library-name>
. This directory is special in that ESLint and Prettier will ignore it. This allows us to follow up with another pull request that moves the library into packages
and incorporate it into the release workflow.
Here is a list of detailed steps:
git-filter-repo
. This tool is like Git's filter-branch
command, but much easier to use and much less error-prone.cd /tmp
git clone https://github.com/MetaMask/<repo-name>
(e.g. <repo-name>
= utils
). Do NOT use an existing clone.cd
into the newly cloned repo.git filter-repo --to-subdirectory-filter merged-packages/<package-name>
(e.g. <package-name>
= utils
). This will rewrite all history to move all files to merged-packages/<package-name>
. (This is why we're making a fresh clone in a temporary directory — this action is irreversible.)cd
to wherever you keep the core
repo on your machine.git remote add <package-name> /tmp/<package-name>
.git fetch <package-name> --no-tags
git checkout -b migrate-<package-name>
git merge --allow-unrelated-histories <package-name>/<primary-branch>
(e.g. <primary-branch>
= main
)The resulting pull request should look like this: https://github.com/MetaMask/core/pull/1520
browser-passworder, post-message-stream, web3-stream-provider — Not included because it's extension only Snap-related libraries (eth-snap-keyring, keyring-snaps-registry, snap-simple-keyring, snaps-registry) —not included because Snaps only. object-multiplex, swappable-obj-proxy, and safe-event-emitter - Not included because its not really wallet related, they are more general purpose ppom-validator — Team decided to keep out of core for now - maybe revisit
We would like to migrate most MetaMask libraries into this monorepo to make them easier to maintain. We may want to exclude libraries that are:
Here is the list of libraries that seem like a good fit today:
See https://github.com/MetaMask/core/issues/1079#issuecomment-1700126302 for instructions on accomplishing this.