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

cosmwasm-vm

v0.1.0

Published

**THIS IS STILL UNDER DEVELOPMENT! Contributions are welcome.**

Downloads

4

Readme

Run CosmWasm in JavaScript

THIS IS STILL UNDER DEVELOPMENT! Contributions are welcome.

NOTE: This was built for Terra-specific applications and thus is only supported for CosmWasm v0.16. However, this implementation probably can be easily adapted to support CosmWasm v1.0+.

This package implements a pure JavaScript (no Rust bindings / WASM needed) VM capable of executing compiled CosmWasm .wasm binaries in environments such as Node.js and compatible web browsers.

Setup

Add the cosmwasm-vm package as a dependency in your package.json.

npm install -S cosmwasm-vm

or

yarn add cosmwasm-vm

Usage

Please refer to the test in this repository for an example. I include a test contract based on cosmwasm/cw-template that has been augmented with additional ExecuteMsg variants for testing the various WASM imports.

yarn
yarn test
import { CosmWasmVM } from '../src';
import { readFileSync } from 'fs';

const wasm_byte_code = readFileSync('./cosmwasm_vm_test.wasm');
const vm = new CosmWasmVM(wasm_byte_code);

const mock_env = {
  block: {
    height: 1,
    time: '2000000000',
    chain_id: 'columbus-5',
  },
  contract: {
    address: 'contract',
  },
};

const mock_info = {
  sender: 'sender',
  funds: [],
};

describe('CosmWasmVM', () => {
  it('instantiates', () => {
    let res = vm.instantiate(mock_env, mock_info, { count: 20 });
    console.log(res.json);
    console.log(vm.store);
  });

  it('execute', () => {
    let res = vm.instantiate(mock_env, mock_info, { count: 20 });
    res = vm.execute(mock_env, mock_info, { increment: {} });
    console.log(res.json);
    console.log(vm.store);
  });
});