Skip to content

MetaMask/snap-7715-permissions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

7715 Permissions Snap Monorepo

Getting Started

  1. Fork the repository:

    • Click the "Fork" button at the top right of the repository page.
  2. Clone your fork:

    git clone https://github.com/<your-username>/snap-7715-permissions.git
  3. Create Working Branch:

    git checkout -b feat/example-branch

Overview

This mono-repository contains the @metamask/permissions-kernel-snap and @metamask/gator-permissions-snap that implement ERC-7715 and the Permissions registry. dApps may request a permission via the exposed JSON-RPC interface. A user can grant granular permissions as cryptographic capabilities to allow dApps to execute transactions on their behalf.

@metamask/permissions-kernel-snap

This Snap manages a permissions offer registry, which lists all the permissions a user is willing to grant via a ERC-7715 permissions request. When a dApp makes a 7715 request to the kernel, the kernel forwards it to a permissions provider Snap for user review and attenuation. If the dApp requests any permission not listed in the registry, the kernel automatically rejects the request.

@metamask/gator-permissions-snap

This Snap creates a DeleGator account and enables the site to request ERC-7715 permissions from that account. Users can review and adjust the granted permissions through a custom interactive confirmation dialog rendered by the Snap.

Read more on "@metamask/gator-permissions-snap" ->

Development

Prerequisites

Environment variables

site

The snap origin to use(defaults to local if not defined): ./packages/site/.env. Local development values can be found in ./packages/site/.env.example.

@metamask/permissions-kernel-snap

The snap will throw errors during build process if values are not defined: ./packages/permissions-kernel-snap/.env. Development values can be found in ./packages/permissions-kernel-snap/.env.example.

@metamask/gator-permissions-snap

The snap will throw errors during build process if values are not defined: ./packages/gator-permissions-snap/.env. Development values can be found in ./packages/gator-permissions-snap/.env.example.

Running snaps

Ensure the appropriate environment variables values are set:

  • ./packages/permissions-kernel-snap/.env
  • ./packages/gator-permissions-snap/.env
  • ./packages/site/.env

STORE_PERMISSIONS_ENABLED=false or removed from .env

# Install dependencies and sets up submodule
yarn prepare:snap

# Starts local @metamask/permissions-kernel-snap and @metamask/gator-permissions-snap
yarn start

The development site will start up on http://localhost:8000/

  • @metamask/permissions-kernel-snapis served from local:http://localhost:8081
  • @metamask/gator-permissions-snap is served from local:http://localhost:8082

STORE_PERMISSIONS_ENABLED=true to test storage features

# Install dependencies and sets up submodule
yarn prepare:snap

# Starts local @metamask/message-signing-snap
yarn start:message-signing-snap

# In new terminal window, start local @metamask/permissions-kernel-snap and @metamask/gator-permissions-snap
yarn start

The development site will start up on http://localhost:8000/

  • @metamask/message-signing-snap is served from local:http://localhost:8080
  • @metamask/permissions-kernel-snapis served from local:http://localhost:8081
  • @metamask/gator-permissions-snap is served from local:http://localhost:8082

Testing

Note: @metamask/snaps-jest assumes that the snap is built in the directory you're running Jest from. If you're using a different directory, you can specify the path to the snap using the root option, or by running your own HTTP server.

Right now it's not possible to use @metamask/snaps-jest with a snap that isn't built.

Ensure the appropriate environment variables values are set:

  • ./packages/permissions-kernel-snap/.env
  • ./packages/gator-permissions-snap/.env
yarn build

yarn test

Linting

To run the linter.

yarn lint

To run the linter and fix any automatically fixable issues.

yarn lint:fix

Using NPM packages with scripts

Scripts are disabled by default for security reasons. If you need to use NPM packages with scripts, you can run yarn allow-scripts auto, and enable the script in the lavamoat.allowScripts section of package.json.

See the documentation for @lavamoat/allow-scripts for more information.

Relevant Documents

About

ERC-7715 Permissions Snap monorepo

Resources

License

Apache-2.0, MIT-0 licenses found

Licenses found

Apache-2.0
LICENSE.APACHE2
MIT-0
LICENSE.MIT0

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

Languages