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

@frequency-chain/api-augment

v1.15.0

Published

RPC configuration for Frequency for use with Polkadotjs API

Downloads

65,712

Readme

Javascript Custom RPC

Contributors Forks Stargazers Issues MIT License NPM @latest NPM @next

Frequency Custom RPC and Types for Polkadot JS API

An easy way to get all the custom rpc and types config to be able to easily use Frequency with the Polkadot JS API library with TypeScript.

Getting Started

  • npm install @frequency-chain/api-augment (API Augmentation Library)
  • npm install @polkadot/api (Polkadot API Library)

Upgrades and Matching Versions

Assuming you are using no deprecated methods, any release version should work against a release version of @frequency-chain/api-augment. If you are working against a development version it is suggested that you match against the commit hash using v0.0.0-[First 6 of the commit hash].

Changelog is maintained in the releases for Frequency.

Usage

For details on use, see the Polkadot API library documentation.

import { options } from "@frequency-chain/api-augment";
import { ApiPromise } from "@polkadot/api";
// ...

const api = await ApiPromise.create({
  ...options,
  // ...
});

Contributing

See CONTRIBUTING.md for more information.

Updating Definitions

Update ./definitions if you have changed any types or RPC calls.

To generate the JS api definitions, run

make js

This command will start a Frequency node in the background and fetch API definitions from it. To stop the Frequency process, use the PID output by the command.

Helpful Notes

Fails to Resolve Custom RPCs

The api augmentation declares the modules used by @polkadot/api. Thus the import for @frequency-chain/api-augment must come before any @polkadot/api so that the Frequency declarations resolve first.

import { options } from "@frequency-chain/api-augment";
// Or
import "@frequency-chain/api-augment";
// Must come BEFORE any imports from @polkadot/api
import { ApiPromise } from "@polkadot/api";

Caches can also wreck this even if you reorder, so watch out.

  • Yarn cache can sometimes cause issues (if you are using yarn): yarn cache clear
  • Sometimes I have found blowing away the node_modules helps as well: rm -Rf node_modules

Option

Optional responses are not mapped to null and instead return an object with a few properties. For more details see the code for the Option class.

const optionalExample = await api.rpc.schemas.getBySchemaId(1);
// Does the Option have a value?
if (!optionalExample.isEmpty) {
  // Get the value
  return optionalExample.value;
}
return null;

Vec

Vector responses are not mapped directly to a JavaScript Array. Instead they are mapped to the Vec class which does extend Array. Thus, you can still use map, forEach, etc... with responses or access the values directing via .values().

License

Distributed under the Apache 2.0 License. See LICENSE for more information.