@sovereign-sdk/universal-wallet-wasm
v0.5.0
Published
[](https://www.npmjs.com/package/@sovereign-sdk/universal-wallet-wasm) [
Downloads
2,540
Readme
@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-wasmFeatures
- 🔄 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 configurationMaking Changes
- Edit Rust code in
src/lib.rs - Run
pnpm buildto compile - Add tests in
tests/directory - Run
pnpm testto verify changes
