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

moonbeam-types-bundle

v2.0.10

Published

Bundled types to instantiate the Polkadot JS api with a Moonbeam network

Downloads

38,614

Readme

Moonbeam Types Bundle

Exports npm package moonbeam-types-bundle, formated as per polkadot-js specification to use with the app or the API.

⚠️Warning: Types deprecation⚠️

Following runtime upgrade 900 (include substrate v0.9.11), types are now retrieved from the node, in a camelCase format

A new version has been released [email protected].

The default export typesBundle has been removed to avoid confusion.

2 new typesBundles are available:

  • import { typesBundlePre900 } from "moonbeam-types-bundle" to use the new naming convention
  • import { typesBundleDeprecated } from "moonbeam-types-bundle" to keep using old naming convention that isn't camelCase (This will break at runtime 1000)

The following package versions have been tested:

"@polkadot/api": "^6.9.1",
"moonbeam-types-bundle": "^2.0.1",
"typescript": "4.3.2"

Running the latest TypeScript version will not work.

Breaking changes in typesBundlePre900

Those types are being changed:

  AssetRegistrarMetadata: {
    ...
    isFrozen: "bool", // was is_frozen
  },
  RewardInfo: {
    totalReward: "Balance", // was total_reward
    claimedReward: "Balance", // was claimed_reward
    contributedRelayAddresses: "Vec<RelayChainAccountId>", // was contributed_relay_addresses
  },
  Nominator2: {
    ...
    scheduledRevocationsCount: "u32", // was scheduled_revocations_count
    scheduledRevocationsTotal: "Balance", // was scheduled_revocations_total
  },
  ExitQ: {
    ...
    nominatorsLeaving: "Vec<AccountId>", // was nominators_leaving
    candidateSchedule: "Vec<(AccountId, RoundIndex)>", // was candidate_schedule
    nominatorSchedule: "Vec<(AccountId, Option<AccountId>, RoundIndex)>", // was nominator_schedule
  },
  Collator2: {
    ...
    topNominators: "Vec<Bond>", // was top_nominators
    bottomNominators: "Vec<Bond>", // was bottom_nominators
    totalCounted: "Balance", // was total_counted
    totalBacking: "Balance", // was total_backing
  }

How to upgrade your tools/scripts using moonbeam-types-bundle

(If your tool/script is not requesting past blocks, you can use the typesBundleDeprecated for now and fully remove it once the network has been upgraded to runtime 900, around Nov 18th 2021)

The following package versions have been tested:

"@polkadot/api": "^6.9.1",
"moonbeam-types-bundle": "^2.0.1",
"typescript": "4.3.2"

Running the latest TypeScript version will not work.

Ultimately it is necessary to use the new type naming as the previous one won't be supported, but you can import typesBundleDeprecated to buy yourself some time.

  • moonbeam-types-bundle v1.x.x will break on runtime upgrade 900 (planned Thursday 18th November 2021 on Moonriver)
  • moonbeam-types-bundle v2.x.x typesBundleDeprecated (using previous naming case) will break on runtime 1000
  • moonbeam-types-bundle v2.x.x typesBundlePre900 (using new naming case) will be maintained.

Step 1: Install new package

npm install moonbeam-types-bundle@2

Step 2: Change your import

import { typesBundlePre900 } from "moonbeam-types-bundle"

const api = await ApiPromise.create({
    provider: wsProvider,
    typesBundle: typesBundlePre900,
});

Step 3: Updates the object property names

For example:

console.log(collatorState2.unwrap().top_nominators);
                                    ^^^^^^^^^^^^^^

Becomes:

console.log(collatorState2.unwrap().topNominators);
                                    ^^^^^^^^^^^^^

All changes were listed previously.

Support for ethereum encoded (MiXedCaSe) addresses

In runtime 900, addresses are represented in lower case by PolkadotJs SDK (this should be fixed in runtime 1000).
However it is possible to manually encode the address in Ethereum encoded (MiXedCaSe) format using:

import { ethereumEncode } from "@polkadot/util-crypto";

...
console.log(address);
// 0xb5af23c862df4ba2114276594a6ac851674cdf1e

console.log(ethereumEncode(address));
// 0xB5Af23c862dF4ba2114276594a6AC851674cDf1e

Development

typesBundlePre900 is of type OverrideBundleType to associate runtime names with correct definitions.

moonbeamDefinitions is of types OverrideBundleDefinition and returns a different set of types for each runtime version.

Print Types

To print and save types JSON for a specific version run: ts-node generateJSON.ts <verison number>

To print and save the latest: ts-node generateJSON.ts latest