Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

KILTprotocol/type-definitions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repo is archived since type definitions have been moved under the KILT SDK repository.

type-definitions

KILT's type definitions for Polkadot.js

Example usage

Depending on which chain you connect to, the spec name changes. You can check the spec name using api.runtimeVersion.specName. The polkadot.js API will select the correct types matching the spec name of the chain to the keys inside the spec object.

const {
  typeBundleForPolkadot,
} = require('@kiltprotocol/type-definitions')
const { ApiPromise, WsProvider } = require('@polkadot/api')

const api = await ApiPromise.create({
    provider: new WsProvider('wss://peregrine.kilt.io/parachain-public-ws'),
    typesBundle: {
        spec: {
            'mashnet-node': typeBundleForPolkadot,
            'kilt-spiritnet': typeBundleForPolkadot,
        },
    },
})

console.log(`Spec: ${api.runtimeVersion.specName.toString()}`)

Generate the type definitions

To generate the type definitions, run yarn generate-types from the project root. It will generate all the type definitions and save them in the types directory each with the name types/types<min_version>-<max_version>.json, for examples types/types23-24.json.

About

KILT's type definitions for Polkadot.js

Resources

License

Stars

Watchers

Forks

Contributors