How to use the @polkadot/metadata/Decorated function in @polkadot/metadata

To help you get started, we’ve selected a few @polkadot/metadata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github polkadot-js / api / packages / types / src / primitive / Extrinsic / v3 / Extrinsic.spec.ts View on Github external
// Copyright 2017-2019 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import BN from 'bn.js';
import Decorated from '@polkadot/metadata/Decorated';
import Metadata from '@polkadot/metadata/Metadata';
import rpcMetadata from '@polkadot/metadata/Metadata/static';
import testingPairs from '@polkadot/keyring/testingPairs';

import { TypeRegistry } from '../../../codec';
import Extrinsic from './Extrinsic';

const registry = new TypeRegistry();
const decorated = new Decorated(registry, rpcMetadata);
const keyring = testingPairs({ type: 'ed25519' }, false);

// eslint-disable-next-line no-new
new Metadata(registry, rpcMetadata);

describe('ExtrinsicV3', (): void => {
  it('constructs a sane Uint8Array (default)', (): void => {
    expect(
      new Extrinsic(registry).toU8a()
    ).toEqual(new Uint8Array([0, 0]));
  });

  it('creates a unsigned extrinsic', (): void => {
    expect(
      new Extrinsic(
        registry,
github polkadot-js / api / packages / types / src / primitive / Extrinsic / v4 / Extrinsic.spec.ts View on Github external
// Copyright 2017-2019 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import BN from 'bn.js';
import testingPairs from '@polkadot/keyring/testingPairs';
import Decorated from '@polkadot/metadata/Decorated';
import Metadata from '@polkadot/metadata/Metadata';
import metadataStatic from '@polkadot/metadata/Metadata/static';

import { TypeRegistry } from '../../../codec/create';
import Extrinsic from './Extrinsic';

const registry = new TypeRegistry();
const decorated = new Decorated(registry, metadataStatic);
const keyring = testingPairs({ type: 'ed25519' }, false);

// eslint-disable-next-line no-new
new Metadata(registry, metadataStatic);

describe('ExtrinsicV4', (): void => {
  it('constructs a sane Uint8Array (default)', (): void => {
    expect(
      new Extrinsic(registry).toU8a()
    ).toEqual(new Uint8Array([0, 0]));
  });

  it('creates a unsigned extrinsic', (): void => {
    expect(
      new Extrinsic(
        registry,
github polkadot-js / api / packages / types / src / primitive / Extrinsic / v2 / Extrinsic.spec.ts View on Github external
// Copyright 2017-2019 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import BN from 'bn.js';
import Decorated from '@polkadot/metadata/Decorated';
import Metadata from '@polkadot/metadata/Metadata';
import rpcMetadata from '@polkadot/metadata/Metadata/static';
import testingPairs from '@polkadot/keyring/testingPairs';

import { TypeRegistry } from '../../../codec';
import Extrinsic from './Extrinsic';

const registry = new TypeRegistry();
const decorated = new Decorated(registry, rpcMetadata);
const keyring = testingPairs({ type: 'ed25519' }, false);

// eslint-disable-next-line no-new
new Metadata(registry, rpcMetadata);

describe('ExtrinsicV2', (): void => {
  it('constructs a sane Uint8Array (default)', (): void => {
    expect(
      new Extrinsic(registry).toU8a()
    ).toEqual(new Uint8Array([0, 0]));
  });

  it('creates a unsigned extrinsic', (): void => {
    expect(
      new Extrinsic(
        registry,
github polkadot-js / api / packages / types / src / primitive / StorageKey.spec.ts View on Github external
describe('with MetadataV3 (uses xxHash by default)', (): void => {
    const metadata = new Metadata(registry, rpcDataV3);

    it('should correctly get Alice\'s freeBalance storage key (hex)', (): void => {
      expect(
        new StorageKey(
          registry,
          metadata
            .query
            .balances
            .freeBalance('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY')
        )
          .toHex()
      ).toBe('0xc99f5446efa57788f39ab529311f4550'); // FIXME OK this should be length-prefixed in reality
    });

    it('should correctly get Alice\'s freeBalance storage key (u8a)', (): void => {
      expect(
github polkadot-js / api / packages / types / src / primitive / StorageKey.spec.ts View on Github external
describe('with MetadataV5', (): void => {
    const metadata = new Metadata(registry, rpcDataV5);

    it('should correctly get the EventTopics double map storage key (hex)', (): void => {
      expect(
        new StorageKey(registry, [
          metadata
            .query
            .system
            .eventTopics,
          ['any', [1, 2, 3]]
        ])
          .toHex()
      ).toBe('0x3007c9ff7027f65900abcdfca4fdb107ead47e2a9e3558e01b691b0f4a5f8518d487326614f066416308bf6aa4e5041d1949928e4b26ede98e3cebb36a3b1726');
    });

    it('should correctly get the EventTopics double map storage key (u8a)', (): void => {
      expect(
github polkadot-js / api / packages / types / src / primitive / StorageKey.spec.ts View on Github external
describe('with MetadataV6', (): void => {
    const metadata = new Metadata(registry, rpcDataV6);

    it('should correctly get the EventTopics double map storage key (hex)', (): void => {
      expect(
        new StorageKey(registry, [
          metadata
            .query
            .system
            .eventTopics,
          ['any', [1, 2, 3]]
        ])
          .toHex()
      ).toBe('0x3007c9ff7027f65900abcdfca4fdb107ead47e2a9e3558e01b691b0f4a5f8518d487326614f066416308bf6aa4e5041d1949928e4b26ede98e3cebb36a3b1726');
    });

    it('should correctly get the EventTopics double map storage key (u8a)', (): void => {
      expect(
github polkadot-js / api / packages / types / src / primitive / StorageKey.spec.ts View on Github external
describe('with MetadataV4 (uses xxHash by default)', (): void => {
    const metadata = new Metadata(registry, rpcDataV4);

    it('should correctly get Alice\'s freeBalance storage key (hex)', (): void => {
      expect(
        new StorageKey(
          registry,
          metadata
            .query
            .balances
            .freeBalance('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY')
        )
          .toHex()
      ).toBe('0x7f864e18e3dd8b58386310d2fe0919eef27c6e558564b7f67f22d99d20f587bb');
    });

    it('should correctly get Alice\'s freeBalance storage key (u8a)', (): void => {
      expect(
github polkadot-js / api / packages / types / src / primitive / StorageKey.spec.ts View on Github external
describe('with MetadataV8', (): void => {
    const metadata = new Metadata(registry, rpcDataV8);

    it('should correctly get the EventTopics double map storage key (hex)', (): void => {
      expect(
        new StorageKey(registry, [
          metadata
            .query
            .system
            .eventTopics,
          ['any', [1, 2, 3]]
        ])
          .toHex()
      ).toBe('0x3007c9ff7027f65900abcdfca4fdb107ead47e2a9e3558e01b691b0f4a5f8518d487326614f066416308bf6aa4e5041d1949928e4b26ede98e3cebb36a3b1726');
    });

    it('should correctly get the EventTopics double map storage key (u8a)', (): void => {
      expect(
github polkadot-js / api / packages / types / src / primitive / StorageKey.spec.ts View on Github external
describe('with MetadataV7', (): void => {
    const metadata = new Metadata(registry, rpcDataV7);

    it('should correctly get the EventTopics double map storage key (hex)', (): void => {
      expect(
        new StorageKey(registry, [
          metadata
            .query
            .system
            .eventTopics,
          ['any', [1, 2, 3]]
        ])
          .toHex()
      ).toBe('0x3007c9ff7027f65900abcdfca4fdb107ead47e2a9e3558e01b691b0f4a5f8518d487326614f066416308bf6aa4e5041d1949928e4b26ede98e3cebb36a3b1726');
    });

    it('should correctly get the EventTopics double map storage key (u8a)', (): void => {
      expect(

@polkadot/metadata

Helpers to extract information from runtime metadata

Apache-2.0
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis

Similar packages