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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tananetwork/tana-validation

v0.1.1

Published

Shared validation logic for Tana smart contracts with WASM support

Downloads

7

Readme

tana-validation

Shared validation and error formatting logic for Tana smart contracts.

Features

  • Single source of truth - Write error formatting logic once in Rust
  • Works everywhere - Compiles to native Rust and WebAssembly
  • Beautiful errors - Rust/Gleam-style error messages with precise location info
  • Tiny bundle - Only ~21KB WASM + 5KB JS wrapper
  • Zero dependencies - Fully self-contained

Usage

TypeScript/JavaScript (via WASM)

npm install @tananetwork/tana-validation
# or
bun add @tananetwork/tana-validation
import init, { format_validation_error } from '@tananetwork/tana-validation';

// Initialize WASM module
await init();

// Format an error
const error = format_validation_error(
  "import { console } from 'tana/invalid';",  // code
  "contract.ts",                               // file_path
  "Invalid Import",                            // error_kind
  1,                                          // line_num
  26,                                         // col_num
  "Module 'tana/invalid' not found",         // message
  "Available modules: tana/core, tana/kv",   // help
  12                                          // underline_length
);

console.log(error);

Rust

[dependencies]
tana-validation = "0.1"
use tana_validation::format_validation_error;

let error = format_validation_error(
    "import { console } from 'tana/invalid';",
    "contract.ts",
    "Invalid Import",
    1,
    26,
    "Module 'tana/invalid' not found",
    "Available modules: tana/core, tana/kv",
    12,
);

println!("{}", error);

Output Format

Both Rust and TypeScript/WASM produce identical output:

Validation Error
❌ Invalid Import

┌─ contract.ts:1:26
│
  1 │ import { console } from 'tana/invalid';
    │                          ^^^^^^^^^^^^ Module 'tana/invalid' not found
│
= help: Available modules: tana/core, tana/kv
│

Why WASM?

By writing the error formatter once in Rust and compiling to WASM for TypeScript, we get:

  1. Guaranteed consistency - Same code = same output
  2. No drift - Impossible for implementations to diverge
  3. Native performance - WASM is fast
  4. Small bundle - Rust compiles to efficient WASM
  5. Type safety - TypeScript definitions generated automatically

Used By

  • tana-runtime - On-chain contract execution (native Rust)
  • tana-edge - HTTP contract server (native Rust)
  • playground - Browser-based contract testing (WASM)
  • CLI tools - Command-line validation (WASM via Bun)

Development

# Test Rust code
cargo test

# Build WASM package
wasm-pack build --target bundler --scope tananetwork

# Test WASM in browser
cd pkg && npm link
cd your-project && npm link @tananetwork/tana-validation

License

Dual-licensed under MIT OR Apache-2.0.