1.5.4-3 • Published 3 years ago

@plasm/types v1.5.4-3

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

@plasm/types

NPM

This is a substrate type definitions made with @polkadot-js/typegen. It is meant for developers working with TypeScript to interact with the Plasm node. This package is meant to be used with the @polakdot-js/api library.

Usage

Importing Types

You can use the ApiOptions interface to set the node configuration before initializing the Polkadot API instance.

import { WsProvider, ApiPromise } from '@polkadot/api';
import { ApiOptions } from '@polkadot/api/types';
import { plasmDefinitions} from '@plasm/types';

// using ApiOptions interface
const options: ApiOptions = {
    provider: new WsProvider('ws://localhost:9944'),
    types: {
        ...plasmDefinitions,
    },
};

const api = new ApiRx(options);

Or, you can pass the node types directly when initializing the API instance.

import { WsProvider, ApiPromise } from '@polkadot/api';
import { plasmDefinitions} from '@plasm/types';

// using the ApiPromise class
const api = await ApiPromise.create({
    provider: new WsProvider('ws://localhost:9944'),
    types: {
        ...plasmDefinitions,
    }
});

await api.isReady;

Finally, you can register the types after the API instance has already been created.

import { plasmDefinitions} from '@plasm/types';

// already initialized api instance
await api.registerTypes(dustyDefinitions);

Generating Types

First, you'll have to manually define chain specific types for each pallets from the src/interfaces/<module-name>/definitions.ts file.

The script should export an object that looks something like this:

export default {
    types: {
        StructA: {
            id: 'u8',
            value_hash: 'H256',
        },
        TypeA: 'H256',
        ...
    },
};
1.5.4

3 years ago

1.5.4-3

3 years ago

1.5.4-2

3 years ago

1.5.1-alpha.3

3 years ago

1.5.1-alpha.2

3 years ago

1.5.3

3 years ago

1.5.2

3 years ago

1.4.0

4 years ago

1.3.0

4 years ago