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

parse-cosmwasm-schema

v0.2.0

Published

Parser for JSON schemas generated from CosmWasm, useful for creating automated contract tooling.

Downloads

39

Readme

parse-cosmwasm-schema

Parser for JSON schemas generated from CosmWasm, useful for creating automated contract tooling.

Table of Contents

Quickstart

Add to your package.json by using Yarn or NPM.

$ yarn add parse-cosmwasm-schema

Then, in your program:

import parseSchema from "parse-cosmwasm-schema";

// any schema generated by CosmWasm
const schema = {
  ...
};

parseSchema(schema).then(parseTree => {
  // the resultant parse tree is JSON
  console.log(JSON.stringify(parseTree, null, 2));
})

Introduction

Smart contracts on Terra (powered by CosmWasm) use JSON messages to define interactions. Each smart contract defines its interface through a JSON schema which specifies the structure and expected format of the messages that it can respond to. By reading the JSON schema, we are able to extract information which can be used to automatically generate tools that would otherwise require tedious manual labor.

parse-cosmwasm-schema provides an algorithm that reads in a CosmWasm-generated JSON schema and produces a JSON-based parse tree of the original Rust data. Because it is written in TypeScript, it also provides a set of types that are helpful for walking the parse tree, for writing your own custom solutions.

Output Structure

The output is a parse tree represented as a JSON object, which can be one of several NodeType definitions.

All nodes follow the format:

{
  "type": "<node-type>",
  "value": {
    "title": "<node-title>", // or undefined
    "description": "<node-description>", // or undefined
    "ref": "<ref-name>" // if derived from a resolved reference, will be a string.
    ... // additional properties depending on node type
  }
}

Simple Nodes

None

  • type: none

Boolean

  • type: boolean

String

  • type: string

Integer

  • type: integer
  • properties:
    • size: type of integer (e.g. u32, u64, etc.)

Composite Nodes

The following node types can include other node types.

Enum

  • type: enum
  • properties:
    • variants: a list of possible other node types

Struct

  • type: struct
  • properties:
    • members: an object where keys are member names and values are nodes

Optional

  • type: optional
  • properties:
    • body: a node type

Array

  • type: array
  • properties:
    • contents: node type of array's elements
    • size: number size of array

Vec

  • type: vec
  • properties:
    • contents: node type of vector's elements

Tuple

  • type: tuple
  • properties:
    • contents: an array of node types

List of Tools

parse-cosmwasm-schema is used to power a number of useful contract tools.

By Terraform Labs

| Name | Description | | ------------------- | -------------------------------------------------------- | | gen-contract-docs | Generates documentation for smart contract messages | | gen-contract-sdk | Generates Python and JavaScript SDKs for smart contracts | | gen-contract-cli | Generates a command-line interface for smart contract | | gen-contract-ui | Web-based UI tool for interacting with smart contracts |

Community

Made something cool but not on here? Make a pull request to add it to the list.