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

@polkadot-api/merkleize-metadata

v1.1.2

Published

This TS package provides utils for the merkleization of [`frame_metadata`](https://docs.rs/frame-metadata/latest/frame_metadata/) as described in [RFC78](https://polkadot-fellows.github.io/RFCs/approved/0078-merkleized-metadata.html).

Downloads

4,291

Readme

@polkadot-api/merkleize-metadata

This TS package provides utils for the merkleization of frame_metadata as described in RFC78.

Usage

import { merkleizeMetadata } from "@polkadot-api/merkleized-metadata"

const ksmMetadata = new Uint8Array(await readFile("ksm.bin"))
const merkleizedMetadata = merkleizeMetadata(ksmMetadata, {
  decimals: 12,
  specName: "kusama",
  base58Prefix: 2,
  specVersion: 1_002_006,
  tokenSymbol: "KSM",
})

// it returns the digest value of the metadata (aka its merkleized root-hash)
const rootHash = merkleizedMetadata.digest()

// given an extrinsic, it returns an encoded `Proof`
const proof1: Uint8Array = merkleizedMetadata.getProofForExtrinsic(
  // Hex for the transaction bytes
  "c10184008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a4801127d333c8f60c0d81dd0a6e2e20ea477a06f96aaca1811872c54c244f0935c60b1f8a38aabef3d3a4ef4050d8d078e35b57b3cf4f9545f8145ce98afb8755384550000000000001448656c6c6f",
  // Optionally, we can pass the tx additional signed data
  "386d0f001a000000143c3561eefac7bc66facd4f0a7ec31d33b64f1827932fb3fda0ce361def535f143c3561eefac7bc66facd4f0a7ec31d33b64f1827932fb3fda0ce361def535f00",
)

// given the extrinsic "parts", it returns an encoded `Proof`
const proof2: Uint8Array = merkleizedMetadata.getProofForExtrinsicParts(
  // Call data
  "0x040300648ad065ea416ca1725c29979cd41e288180f3e8aefde705cd3e0bab6cd212010bcb04fb711f01",
  // Signed Extension data included in the extrinsic
  "0x2503000000",
  // Signed Extension data included in the signature
  "0x164a0f001a000000b0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe878a023bcb37967b6ba0685d002bb74e6cf3b4fc4ae37eb85f756bd9b026bede00",
)

// The type `Proof` definition is as follows:
// interface Proof {
//   leaves: Array<LookupEntry>,
//   leafIdxs: Array<number>,
//   proofs: Array<Uint8Array>,
//   extrinsic: ExtrinsicMetadata,
//   info: ExtraInfo
// }