0.3.0 • Published 3 months ago

@sovereign-sdk/universal-wallet-wasm v0.3.0

Weekly downloads
-
License
-
Repository
-
Last release
3 months ago

@sovereign-sdk/universal-wallet-wasm

npm version CI

WebAssembly bindings for Sovereign SDK's universal wallet, providing schema validation and serialization utilities.

Installation

npm install @sovereign-sdk/universal-wallet-wasm

Features

  • šŸ”„ JSON to Borsh serialization of rollup types
  • šŸ“ Schema validation
  • šŸ“„ Human-readable display of Borsh bytes

Usage

import { Schema, KnownTypeId } from '@sovereign-sdk/universal-wallet-wasm';

// Initialize schema from JSON outputted during rollup compilation
const schema = Schema.fromJSON(JSON.stringify(yourSchemaJson));

// Convert JSON to Borsh bytes
const runtimeCall = { value_setter: { set_many_values: [4, 6] } };
const borshBytes = schema.jsonToBorsh(
  schema.knownTypeIndex(KnownTypeId.RuntimeCall),
  JSON.stringify(runtimeCall)
);

// Display Borsh bytes as human-readable string
const displayed = schema.display(
  schema.knownTypeIndex(KnownTypeId.RuntimeCall),
  borshBytes
);

Development Guide

This package uses wasm-pack to compile Rust code to WebAssembly and generate JavaScript bindings.

Prerequisites

  1. Install Rust (version 1.79 or later)
  2. Install Node.js dependencies: pnpm install

Build Commands

  • pnpm build - Builds both Node.js and ESM targets
  • pnpm compile:node - Builds Node.js target only
  • pnpm compile:esm - Builds ESM target only
  • pnpm test - Runs tests

Project Structure

universal-wallet-wasm/
ā”œā”€ā”€ src/           # Rust source code
ā”œā”€ā”€ tests/         # TypeScript tests
ā”œā”€ā”€ dist/         # Compiled outputs (generated)
│   ā”œā”€ā”€ node/     # Node.js target
│   └── esm/      # ESM target
└── Cargo.toml    # Rust dependencies
└── package.json  # NPM package configuration

Making Changes

  1. Edit Rust code in src/lib.rs
  2. Run pnpm build to compile
  3. Add tests in tests/ directory
  4. Run pnpm test to verify changes
0.1.10

7 months ago

0.1.11

5 months ago

0.1.12

5 months ago

0.3.0

3 months ago

0.2.0

5 months ago

0.1.8

7 months ago

0.1.7

8 months ago

0.1.9

7 months ago

0.1.6

9 months ago

0.1.5

9 months ago

0.1.4

10 months ago

0.1.3

10 months ago

0.1.2

10 months ago

0.1.1

10 months ago

0.1.0

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago