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

@rainprotocol/meta

v3.0.7

Published

Utility library for Rain Protocol metadata

Downloads

7

Readme

Rain Protocol Meta

Utility library for Rain Protocol's metadata. Also provides the schemas generated from typescript types for Rain Protocol's metadata such as op meta and contract meta. (uses ts-json-schema-generator)

Usage

Install the package with following:

npm install @rainprotocol/meta

or

yarn add @rainprotocol/meta

Schemas can used in vscode to automatically validate a json file when you specify it in vscode workspace setting:

  • Create a folder .vscode in your workspace and make a new file settings.json. (skip this if these are already present)
  • Add the following to the settings.json:
{
  "json.schemas": [
    {
      "fileMatch": ["*.op.meta.json"],
      "url": "./node_modules/@rainprotocol/meta/schemas/op.meta.schema.json"
    },
    {
      "fileMatch": ["*.contract.meta.json"],
      "url": "./node_modules/@rainprotocol/meta/schemas/contract.meta.schema.json"
    }
  ]
}

you can specify what files will be validated automatically by providing a glob pattern for fileMatch. See the ./example folder content for some examples.

Schemas can also be imported and used programmatically:

import { OpMetaSchema, ContractMetaSchema } from "@rainprotocol/meta";

For getting an op meta from subgraph:

// importing
import { getOpMetaFromSg } from "@rainprotocol/meta";

// get opmeta
const opmeta = await getOpMetaFromSg(deployerAddress, networkOrChainIdOrSgUrl)

To validate a meta against generated schemas:

// importing
import { validateMeta, metaFromBytes, OpMetaSchema } from "@rainprotocol/meta";

// convert "opmeta" from previous guide which is is bytes from (hex string) to op meta as object
const opmetaObj = metaFromBytes(opmeta);

// to validate the opmeta object against the OpMetaSchema
validateMeta(opmetaObj, OpMetaSchema);

// alternatively "metaFromBytes()" can perform the validation internally if the schema is provided as second arg
const opmetaObj = metaFromBytes(opmeta, OpMetaSchema);

Developers Guide

Clone the repo and then install all the dependencies:

npm install

There is prepare hook that will compile and generate the schemas after installing the deps. Versions of the generated schemas (schema $id field) are specified at the beginning of their types file with the following form:

// specify the version of the meta in the following line
// version 0.0.0

Modify the digits for specifying the version for the generated schema.

To generate the schemas:

npm run gen-schema

To run the tests:

npm test