npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@xops.net/snaps-openrpc-generator

v1.17.4

Published

Generate High end snaps in a snap.

Downloads

8

Readme

Snaps OpenRPC Generator

Generate High end snaps in a snap.

A Generator tool for creating Metamask Snaps using open-rpc APIs.

It does this via an OpenRPC Generator Custom Component.

Features:

  • Can generate:
    • Documentation
    • Snap Scaffold with strongly typed interfaces and service discovery via rpc.discover
    • Clients for accessing your snap (Not Implemented)

In a new project

Make a new folder for your Snap project

$ mkdir MySnap && cd MySnap
npm init

Install

$ npm install @xops.net/snaps-openrpc-generator @open-rpc/generator --save-dev

Usage

Create a generator config

open-rpc-generator-config.json
echo '{
  "openrpcDocument": "./openrpc.json",
  "outDir": "./generated",
  "components": [
      {
        "type": "custom",
        "name": "snap-openrpc-generator",
        "language": "typescript",
        "customComponent": "@xops.net/snaps-openrpc-generator/build/components/snap",
        "customType": "snap"
      },
      {
        "type": "custom",
        "name": "snap-docs-openrpc-generator",
        "language": "docs",
        "customComponent": "@xops.net/snaps-openrpc-generator/build/components/docs",
        "customType": "docs"
    }
  ]
}' > open-rpc-generator-config.json

Write an OpenRPC Document that describes your plugins interface, and includes any documentation, examples, etc you may want. You can start with one of the OpenRPC examples, write your own with the help of the OpenRPC Playground, or start from the hello world snap:

open-rpc.json
echo '{
  "openrpc": "1.2.4",
  "info": {
    "title": "MySnap",
    "version": "1.0.0"
  },
  "methods": [
    {
      "name": "hello",
      "description": "a method that returns world",
      "params": [],
      "result": {
        "name": "helloWorldResult",
        "schema": {
          "type": "string"
        }
      },
      "examples": [
        {
          "name": "helloWorldExample",
          "params": [],
          "result": {
            "name": "world",
            "value": "world"
          }
        }
      ]
    }
  ]
}' > openrpc.json

Run the OpenRPC Generator

$ npx open-rpc-generator generate -c open-rpc-generator-config.json

To run the generated snap:

cd generated/custom/typescript
npm install .
npm start

The resulting plugin is now at at http://localhost:8081 and which hosts the package.json and bundle.js needed for snaps.

To build the documentation:

cd into docs directory, install and start

cd generated/custom/docs
npm install .
npm start

you can now open http://localhost:8000 and view your generated, interactive documentation site.

and play around with the interactive api documentation at http://localhost:8000/api-documentation image

Resources