Giter VIP home page Giter VIP logo

crust.js's Introduction

license npm

crust.js

This library provides additional typing information for users to access Crust Network by using polkadot.js

Getting Started

More documentation and examples on Crust Wiki

  1. Install dependencies
yarn add @polkadot/api @crustio/type-definitions
  1. Create API instance
import {ApiPromise, WsProvider} from '@polkadot/api';
import {typesBundleForPolkadot} from '@crustio/type-definitions';

async function main() {
    const api = new ApiPromise({
      provider: new WsProvider('wss://api.crust.network'),
      typesBundle: typesBundleForPolkadot,
    });
    await api.isReady;

    // Use api
}

main();
  1. Interact with chain
// Query file info
const fileInfo = await api.query.market.files('QmRaknS23vXEcdJezkrVC5WrApQNUkUDdTpbRdvh5fuJHc');
console.log(fileInfo.toHuman());

Crust Types

  • Use crust types
import {crustTypes} from '@crustio/type-definitions';

// Define FileInfo
export type FileInfo = typeof crustTypes.market.types.FileInfo;

// Use FileInfo as `interface`

Contribution

Please send a PR(Pull Request) to contribute this repo and read the following rules:

  1. No --force pushes or modifying the master branch history in any way. If you need to rebase, ensure you do it in your own repo.
  2. Non-main branches, prefixed with a short name moniker (e.g. zik/my-feature) must be used for ongoing work.
  3. All modifications must be made in pull-request to solicit feedback from other contributors.
  4. A pull-request must not be merged until CI has finished successfully.
  5. Contributors should adhere to the Google Typescript Style Guide.

crust.js's People

Contributors

badkk avatar lowentropybody avatar mmyyrroonn avatar tonycode2012 avatar yashirooooo avatar ziboilihua avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

crust.js's Issues

`market.placeStorageOrder` was broken by breaking changes introduced from @polkadot/api v4

market.placeStorageOrder works fine on @polkadot/api ^3.11.1 but throws the following error on @polkadot/api ^4+

2021-05-20 18:39:02             DRR: Unable to decode storage system.account: entry 0:: createType(AccountInfo):: {"nonce":"Index","consumers":"RefCount","providers":"RefCount","sufficients":"RefCount","data":"AccountData"}:: Decoded input doesn't match input, received 0x0000000000000000000000000000000000000000000000000000000000000000…0000000000000000000000000000000000000000000000000000000000000000 (72 bytes), created 0x0000000000000000000000000000000000000000000000000000000000000000…0000000000000000000000000000000000000000000000000000000000000000 (80 bytes)
2021-05-20 18:39:02             DRR: Unable to decode storage system.account: entry 0:: createType(AccountInfo):: {"nonce":"Index","consumers":"RefCount","providers":"RefCount","sufficients":"RefCount","data":"AccountData"}:: Decoded input doesn't match input, received 0x0000000000000000000000000000000000000000000000000000000000000000…0000000000000000000000000000000000000000000000000000000000000000 (72 bytes), created 0x0000000000000000000000000000000000000000000000000000000000000000…0000000000000000000000000000000000000000000000000000000000000000 (80 bytes)
Error happens on calling Crust Chain, details: Unable to decode storage system.account: entry 0:: createType(AccountInfo):: {"nonce":"Index","consumers":"RefCount","providers":"RefCount","sufficients":"RefCount","data":"AccountData"}:: Decoded input doesn't match input, received 0x0000000000000000000000000000000000000000000000000000000000000000…0000000000000000000000000000000000000000000000000000000000000000 (72 bytes), created 0x0000000000000000000000000000000000000000000000000000000000000000…0000000000000000000000000000000000000000000000000000000000000000 (80 bytes)

@crustio/type-definitions v0.0.6 - Unknown Type warning on Rocky testnet

It should be a minor thing that breaks nothing.

Mainnet does not display such warning.

I assume it's because of the testnet has deleted (or added) some functionalities from the mainnet and the @crustio/type-definitions package is configured to fit the mainnet env.

To reproduce the error:

const chain_ws_url = "wss://rocky-api.crust.network"
  const api = new ApiPromise({
    provider: new WsProvider(chain_ws_url),
    typesBundle: typesBundleForPolkadot,
  });

  await api.isReady
  const health = await api.rpc.system.health()
  console.log(health.toHuman())

Console displays the following warning. The RPC call runs well.
METADATA: Unknown types found, no types for CSMLedger, EraBenefits, FeeReductionBenefit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.