0.2.1 • Published 6 months ago

@polkadot-api/wasm-executor v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@polkadot-api/wasm-executor

This package has been strongly influenced by Chopsticks. It can be used in both web and NodeJS environments.

At this point, it just exports a getMetadataFromRuntime function that runs WASM under the hood, and returns its metadata in string.

Examples

Web

// IMPORTANT to prefix it with `0x`!
const runtime = "0x" + fs.readFileSync("runtime.wasm").toString("hex");

// returns a `0x` prefixed OpaqueMetadata. It's as well prefixed by a compactInt of its length
const metadata = await import("@polkadot-api/wasm-executor/web").then(
  async ({ default: init, getMetadataFromRuntime }) => {
    await init();
    return getMetadataFromRuntime(runtime);
  },
);

Node

import { getMetadataFromRuntime } from "@polkadot-api/wasm-executor/node";

// IMPORTANT to prefix it with `0x`!
const runtime = "0x" + fs.readFileSync("runtime.wasm").toString("hex");

// returns a `0x` prefixed OpaqueMetadata. It's as well prefixed by a compactInt of its length
const metadata = getMetadataFromRuntime(runtime);
0.2.1

6 months ago

0.1.2

1 year ago

0.2.0

6 months ago

0.1.1

1 year ago

0.1.0

2 years ago