0.3.0 ⢠Published 2 months ago
@sovereign-sdk/universal-wallet-wasm v0.3.0
@sovereign-sdk/universal-wallet-wasm
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
- Install Rust (version 1.79 or later)
- Install Node.js dependencies:
pnpm install
Build Commands
pnpm build
- Builds both Node.js and ESM targetspnpm compile:node
- Builds Node.js target onlypnpm compile:esm
- Builds ESM target onlypnpm 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
- Edit Rust code in
src/lib.rs
- Run
pnpm build
to compile - Add tests in
tests/
directory - Run
pnpm test
to verify changes
0.1.10
6 months ago
0.1.11
4 months ago
0.1.12
4 months ago
0.3.0
2 months ago
0.2.0
4 months ago
0.1.8
6 months ago
0.1.7
7 months ago
0.1.9
6 months ago
0.1.6
8 months ago
0.1.5
8 months ago
0.1.4
9 months ago
0.1.3
9 months ago
0.1.2
9 months ago
0.1.1
9 months ago
0.1.0
9 months ago
0.0.3
9 months ago
0.0.2
9 months ago
0.0.1
9 months ago