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

feat: add ChainController #4227

Merged
merged 52 commits into from
May 20, 2024
Merged

feat: add ChainController #4227

merged 52 commits into from
May 20, 2024

Conversation

ccharly
Copy link
Contributor

@ccharly ccharly commented Apr 29, 2024

Explanation

This new controller will be responsible of exposing Snaps that implement the newly defined Chain API.

This controller also implements the chain API itself.

Reference: https://github.com/MetaMask/chain-api/

Changelog

@metamask/chain-controller

  • Added: New ChainController: exposes/interacts with chain API providers

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

Copy link

socket-security bot commented Apr 29, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

@ccharly ccharly marked this pull request as ready for review May 2, 2024 21:06
@ccharly ccharly requested a review from a team as a code owner May 2, 2024 21:06
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Hello! I am not sure whether more work was planned for this PR, but I made some suggestions based on how we've written controllers and tests for controllers in other places. One question I have is whether ChainController needs to be a controller? I didn't notice any state being set, but perhaps that was just left out for now.

packages/chain-controller/LICENSE Outdated Show resolved Hide resolved
packages/chain-controller/src/ChainController.test.ts Outdated Show resolved Hide resolved
packages/chain-controller/src/ChainController.test.ts Outdated Show resolved Hide resolved
packages/chain-controller/src/ChainController.ts Outdated Show resolved Hide resolved
packages/chain-controller/src/ChainController.ts Outdated Show resolved Hide resolved
packages/chain-controller/src/SnapHandlerClient.ts Outdated Show resolved Hide resolved
@ccharly
Copy link
Contributor Author

ccharly commented May 14, 2024

@mcmire I did update the README, but I had to hack the script locally because it was removing the accounts-controller from the README because of the .slice(1) here.

I didn't want to fix this in this PR, cause I'm not sure it's still required or not.

@ccharly
Copy link
Contributor Author

ccharly commented May 14, 2024

I've added the DO-NOT-MERGE label, cause I've added skipLibCheck=true for tsbuild temporarily, otherwise the CI complains (something the jsx-runtime, we faced that in another PR and that might be related to some Snaps dependencies, I'll wait for more info on this before removing it from the PR)

Copy link

socket-security bot commented May 15, 2024

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

Package New capabilities Transitives Size Publisher
npm/@metamask/chain-api@0.0.1 None +1 229 kB metamaskbot
npm/@metamask/chain-controller@0.0.0-use.local None 0 0 B

View full report↗︎

@ccharly
Copy link
Contributor Author

ccharly commented May 16, 2024

Removing the DO-NOT-MERGE label for now, to have a successful CI and allow preview builds

@ccharly
Copy link
Contributor Author

ccharly commented May 16, 2024

@metamaskbot publish-preview

Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "14.0.0-preview-699063fc",
  "@metamask-previews/address-book-controller": "4.0.1-preview-699063fc",
  "@metamask-previews/announcement-controller": "6.1.0-preview-699063fc",
  "@metamask-previews/approval-controller": "6.0.2-preview-699063fc",
  "@metamask-previews/assets-controllers": "29.0.0-preview-699063fc",
  "@metamask-previews/base-controller": "5.0.2-preview-699063fc",
  "@metamask-previews/build-utils": "2.0.1-preview-699063fc",
  "@metamask-previews/chain-controller": "0.0.0-preview-699063fc",
  "@metamask-previews/composable-controller": "6.0.1-preview-699063fc",
  "@metamask-previews/controller-utils": "9.1.0-preview-699063fc",
  "@metamask-previews/ens-controller": "10.0.1-preview-699063fc",
  "@metamask-previews/eth-json-rpc-provider": "3.0.2-preview-699063fc",
  "@metamask-previews/gas-fee-controller": "15.1.2-preview-699063fc",
  "@metamask-previews/json-rpc-engine": "8.0.2-preview-699063fc",
  "@metamask-previews/json-rpc-middleware-stream": "7.0.1-preview-699063fc",
  "@metamask-previews/keyring-controller": "16.0.0-preview-699063fc",
  "@metamask-previews/logging-controller": "3.0.1-preview-699063fc",
  "@metamask-previews/message-manager": "8.0.2-preview-699063fc",
  "@metamask-previews/name-controller": "6.0.1-preview-699063fc",
  "@metamask-previews/network-controller": "18.1.0-preview-699063fc",
  "@metamask-previews/notification-controller": "5.0.1-preview-699063fc",
  "@metamask-previews/permission-controller": "9.0.2-preview-699063fc",
  "@metamask-previews/permission-log-controller": "2.0.1-preview-699063fc",
  "@metamask-previews/phishing-controller": "9.0.2-preview-699063fc",
  "@metamask-previews/polling-controller": "6.0.2-preview-699063fc",
  "@metamask-previews/preferences-controller": "11.0.0-preview-699063fc",
  "@metamask-previews/profile-sync-controller": "0.0.0-preview-699063fc",
  "@metamask-previews/queued-request-controller": "0.10.0-preview-699063fc",
  "@metamask-previews/rate-limit-controller": "5.0.1-preview-699063fc",
  "@metamask-previews/selected-network-controller": "13.0.0-preview-699063fc",
  "@metamask-previews/signature-controller": "16.0.0-preview-699063fc",
  "@metamask-previews/transaction-controller": "29.0.0-preview-699063fc",
  "@metamask-previews/user-operation-controller": "10.0.0-preview-699063fc"
}

@mcmire
Copy link
Contributor

mcmire commented May 17, 2024

@ccharly Thank you for the changes! I agree it looks a lot better. Nothing jumps out at me, so feel free to get approval from your team and continue on with this PR :)

gantunesr
gantunesr previously approved these changes May 17, 2024
Copy link
Member

@gantunesr gantunesr left a comment

Choose a reason for hiding this comment

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

LGTM. Just one minor comment

@ccharly ccharly merged commit 2752a88 into main May 20, 2024
147 checks passed
@ccharly ccharly deleted the feature/chain-controller branch May 20, 2024 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants