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

MetaMask Snap (unaudited) #107

Merged
merged 10 commits into from
Jan 8, 2024
Merged

MetaMask Snap (unaudited) #107

merged 10 commits into from
Jan 8, 2024

Conversation

codebycarson
Copy link
Collaborator

@codebycarson codebycarson commented Dec 13, 2023

MetaMask Snap

This PR contains the ready for audit MetaMask Snap as well as a helpful UI for testing the snap, and helper functions for using the snap from a dapp.

HIghlights

  • MetaMask snap added with 'getPrivateKey' 'signDirect' and 'signAmino' features
  • Adds helper functions to create SeiWallet interface for MM snap into /core
  • Helper UI to verify calls match that of Compass and other wallets
  • Has jest tests for every file in metamask snap

Testing

Can test this version of the snap yourself in production on https://evm.app.sei.io/stake?tab=allValidators with username 'warroom' and password 'clifford'. However, it is encouraged for you to download and run the test UI (as seen in video below) to fully test yourself

Note: You must have MetaMask flask installed to test this as it is an unofficial snap. https://chromewebstore.google.com/detail/metamask-flask-developmen/ljfoeinjpaedjfecbmggjgodbgkmjkjk

Validation performed

This library contains a helpful UI for testing out the metamask snap, particularly one that is being run on your local machine for development purposes. To test this yourself checkout this branch and navigate to the 'test-ui' folder, then run 'yarn install' and then 'yarn dev' to run the UI. You will also need to run 'yarn start' from within the sei-js/packages/metamask-snap directory (to run the snap locally). OR You can simply use the latest hosted version on NPM. Both of these are configurable through the .env.local file by adjusting the VITE_SNAP_ID variable

metamask-snap-testing.mov

Copy link

changeset-bot bot commented Dec 13, 2023

🦋 Changeset detected

Latest commit: c882bbb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@sei-js/metamask-snap Patch
@sei-js/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

- Made adjustments to the core mm snap functions to allow for a dynamically passed in snap id
- Improved the UI of the snap popups
@codebycarson codebycarson force-pushed the feature/mm-snap-release branch from 62edd87 to 5b327c1 Compare January 4, 2024 15:36
@codebycarson codebycarson requested a review from besated January 4, 2024 16:07
@codecov-commenter
Copy link

codecov-commenter commented Jan 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (27a9782) 76.51% compared to head (c882bbb) 76.51%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #107   +/-   ##
=======================================
  Coverage   76.51%   76.51%           
=======================================
  Files          35       35           
  Lines         511      511           
  Branches      121      121           
=======================================
  Hits          391      391           
  Misses        120      120           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- Added notice on Sign Arbitrary requests
- Added mock files (from cosmos-metamask-snap)
- Removed unused files from test ui
- Improved styles of test ui
- Exported helper function to create SeiWallet for MM Snap
@codebycarson codebycarson changed the title Pre-release MetaMask snap MetaMask Snap (unaudited) Jan 5, 2024
Copy link
Contributor

@besated besated left a comment

Choose a reason for hiding this comment

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

Left a couple comments and got a couple errors when running locally:
image

Are these errors expected? The snap seemed to work fine on the test UI though!

packages/core/CHANGELOG.md Outdated Show resolved Hide resolved
}

async getAccounts(): Promise<AccountData[]> {
const wallet = await getWallet(0);
const wallet = await getWallet(0, this.snapId);
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a case where we want to use an index other than 0 for getWallet?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Made CosmJSOfflineSigner take in an optional accountIndex and default it to index 0

@codebycarson
Copy link
Collaborator Author

Left a couple comments and got a couple errors when running locally: image

Are these errors expected? The snap seemed to work fine on the test UI though!

Just to be clear, you cd'd into packages/metamask-snap and then ran yarn start?

@besated
Copy link
Contributor

besated commented Jan 8, 2024

Looks good to me! For future reference, fixed the above error by building @sei-js/core locally

@codebycarson codebycarson merged commit 2d1b863 into main Jan 8, 2024
2 checks passed
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.

3 participants