npm package: @sovereign-sdk/metamask-snap
Description: Sovereign SDK universal snap, compitible with all Sovereign SDK built rollups.
Author: Sovereign Labs
Latest version: 0.2.0

# Sovereign Universal MetaMask Snap

[![npm version](https://img.shields.io/npm/v/@sovereign-sdk/metamask-snap.svg)](https://www.npmjs.com/package/@sovereign-sdk/metamask-snap)
[![Main](https://github.com/Sovereign-Labs/sovereign-universal-snap/actions/workflows/main.yml/badge.svg)](https://github.com/Sovereign-Labs/sovereign-universal-snap/actions/workflows/main.yml)
[![yarn](https://img.shields.io/badge/maintained%20with-yarn-cc00ff.svg)](https://yarnpkg.com/)

A universal MetaMask Snap for interacting with Sovereign SDK rollups. This snap provides secure key management and transaction signing capabilities for Sovereign rollup applications.

This repository contains the snap implementation that is installed in the MetaMask snap store.

Having a universal snap allows Sovereign SDK applications to be compatible with all Sovereign SDK rollups removing the need for developers to implement and audit their own snap.

## Features

- 🔐 Secure key derivation and management
- 📝 Verifiable human-readable transaction data display (No blind signing!)
- ✍️ Transaction signing for multiple curves (ed25519, secp256k1)
- 🔍 Schema validation for transaction safety
- 🔄 Seamless integration with Sovereign SDK applications

## Usage

The snap is typically used through the `@sovereign-sdk/signers` package, which provides a convenient interface for interacting with the snap:

```typescript
import { newMetaMaskSnapSigner } from '@sovereign-sdk/signers';

const signer = newMetaMaskSnapSigner({
  curve: 'ed25519',
  schema: yourSchema,
  snapId: 'local:http://localhost:8080', // Local snap id for development, run `yarn start` to serve a local version of the snap
});
// Get public key
const publicKey = await signer.publicKey();
// Sign a transaction
const signature = await signer.sign(message);
```

## Development

### Prerequisites

- Node.js LTS
- yarn
- [MetaMask Flask](https://docs.metamask.io/snaps/get-started/install-flask/) (for local development)

### Setup

```bash
# Install dependencies
yarn install
```

### Available Commands

- `yarn build` - Build the snap for production
- `yarn start` - Start development server for local testing
- `yarn test` - Run test suite
- `yarn lint` - Run linting
- `yarn lint:fix` - Fix linting and formatting issues
- `yarn clean` - Clean build artifacts

See the [DEVELOPMENT.md](./DEVELOPMENT.md) file for more information on how to develop on the snap.

## Snap Manifest

The snap manifest (`snap.manifest.json`) is a crucial configuration file that defines the snap's properties and permissions. Key configurations include:

- `version`: The snap's version number. This must match the version in the package.json file. Should be automatically managed via CI/CD pipeline.
- `proposedName`: The name shown to users in MetaMask
- `description`: A brief description of the snap
- `source`: The entry point of the snap
- `initialPermissions`: Required permissions for the snap to function:
  - `snap_dialog`: For displaying transaction information
  - `snap_getBip32Entropy`: For key derivation
  - `endowment:webassembly`: For running the snap's WebAssembly code. Required for universal wallet wasm support.

## Security

For security concerns, please open an issue or contact us directly. We take security issues seriously and will respond promptly.