Mokhtar Naamani 696542ba8a Merge pull request #912 from Lezek123/nicaea-proposals-lead-opening %!s(int64=4) %!d(string=hai) anos
..
src 696542ba8a Merge pull request #912 from Lezek123/nicaea-proposals-lead-opening %!s(int64=4) %!d(string=hai) anos
.editorconfig f601921d95 Update @joystream/types for Nicaea %!s(int64=4) %!d(string=hai) anos
.gitignore 7d2cf90f9c types: explicit .gitignore of role.schema.json %!s(int64=4) %!d(string=hai) anos
.npmignore 639a9475cb @joystream/types: keep src/ in published npm packages, it gets built on install %!s(int64=4) %!d(string=hai) anos
.prettierignore 643c08c7a0 Pioneer workspaces config etc. %!s(int64=4) %!d(string=hai) anos
README.md ba5f54b697 Pioneer webpack/tsconfig for "@joystream/types" %!s(int64=4) %!d(string=hai) anos
package.json 3c2414f4bb types: add explicit dependency on moment %!s(int64=4) %!d(string=hai) anos
tsconfig.json 40e490536f @joystream/types: build in root folder to avoid need for /lib/ in import path %!s(int64=4) %!d(string=hai) anos

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();

Publishing Instructions

The package is published with typescipt sources pre-compiled, automated with prepublish hook in package.json

npm publish

Users

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