Leszek Wiesner 5f196462ee Change proposal error type to Text hace 4 años
..
augment 5f196462ee Change proposal error type to Text hace 4 años
augment-codec 03bd123c9a joy-media upgrade hace 4 años
src 5f196462ee Change proposal error type to Text hace 4 años
.eslintignore ea9098d587 Full typegen support, tooling, linter fixes hace 4 años
.eslintrc.js bf24ab0d1c Update eslint dependencies + required adjustments hace 4 años
.gitignore be66c5e9fe @joystream/types - checks config, CI, linter fixes hace 4 años
.npmignore 639a9475cb @joystream/types: keep src/ in published npm packages, it gets built on install hace 4 años
.prettierignore 6d90afa998 Linter: Manual fixes hace 4 años
README.md 20e507081e update example code in @joystream/types README hace 4 años
package.json 5692090913 Merge pull request #1226 from Lezek123/resolutions-fix hace 4 años
tsconfig-augment-codec.json ea9098d587 Full typegen support, tooling, linter fixes hace 4 años
tsconfig-augment.json ea9098d587 Full typegen support, tooling, linter fixes hace 4 años
tsconfig-base.json ea9098d587 Full typegen support, tooling, linter fixes hace 4 años
tsconfig.json ecea87a58a Tooling for api.createType augmentation hace 4 años

README.md

@joystream/types

The types package is required to register the custom Substrate runtime types when working with @polkadot/api to communicate with a Joystream full node.

Installation

Add the package as a dependency in your project.

yarn add @joystream/types

# or

npm install --save @joystream/types

Registering the types

Call registerJoystreamTypes() before creating a Polkadot API client.

import { registerJoystreamTypes } from '@joystream/types';
import { ApiPromise, WsProvider } from '@polkadot/api';

async function main () {
  // Initialise the provider to connect to the local node
  const provider = new WsProvider('ws://127.0.0.1:9944');

  // Register types before creating the API
  registerJoystreamTypes();

  // Create the API and wait until ready
  const api = await ApiPromise.create({ provider });

  // Retrieve the chain & node information information via RPC calls
  const [chain, nodeName, nodeVersion] = await Promise.all([
    api.rpc.system.chain(),
    api.rpc.system.name(),
    api.rpc.system.version()
  ]);

  console.log(`Chain ${chain} using ${nodeName} v${nodeVersion}`);
}

main();

Examples

See joystream-api-examples for some additional examples on usage.