How to use the @polkadot/metadata 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 / rpc-core / src / formatting.spec.ts View on Github external
return done();
      }

      api.state
        .subscribeStorage([[decorated.query.staking.validators, '0x00']])
        .subscribe(([value]: Codec[]): void => {
          expect(value).toBeDefined();
          // console.error('linked falklback', value);

          done();
        });
    });
  });
}

formattingTests('v3', new Metadata(registry, rpcMetadataV3), [
  '0x4af2c53fce3ec33c6ccccf22e926f1a7',
  '0x3e62f7ed6e788e1337bce2a97b68a12a',
  '0x777519cd81f845abdb40d253923d6098'
]);

formattingTests('v4', new Metadata(registry, rpcMetadataV4), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v5', new Metadata(registry, rpcMetadataV5), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);
github polkadot-js / api / packages / rpc-core / src / formatting.spec.ts View on Github external
expect(value).toBeDefined();
          // console.error('linked falklback', value);

          done();
        });
    });
  });
}

formattingTests('v3', new Metadata(registry, rpcMetadataV3), [
  '0x4af2c53fce3ec33c6ccccf22e926f1a7',
  '0x3e62f7ed6e788e1337bce2a97b68a12a',
  '0x777519cd81f845abdb40d253923d6098'
]);

formattingTests('v4', new Metadata(registry, rpcMetadataV4), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v5', new Metadata(registry, rpcMetadataV5), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v6', new Metadata(registry, rpcMetadataV6), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);
github polkadot-js / api / packages / rpc-provider / src / mock / index.ts View on Github external
private init (): void {
    const emitEvents: ProviderInterfaceEmitted[] = ['connected', 'disconnected'];
    let emitIndex = 0;
    let newHead = this.makeBlockHeader(new BN(-1));
    let counter = -1;

    const metadata = new Metadata(this.registry, rpcMetadata);

    // Do something every 1 seconds
    setInterval((): void => {
      if (!this.isUpdating) {
        return;
      }

      // create a new header (next block)
      newHead = this.makeBlockHeader(newHead.number.toBn());

      // increment the balances and nonce for each account
      keyring.getPairs().forEach(({ publicKey }, index): void => {
        this.setStateBn(metadata.query.balances.freeBalance(publicKey), newHead.number.toBn().muln(3).iaddn(index));
        this.setStateBn(metadata.query.system.accountNonce(publicKey), newHead.number.toBn().addn(index));
      });
github polkadot-js / api / packages / rpc-core / src / formatting.spec.ts View on Github external
});
}

formattingTests('v3', new Metadata(registry, rpcMetadataV3), [
  '0x4af2c53fce3ec33c6ccccf22e926f1a7',
  '0x3e62f7ed6e788e1337bce2a97b68a12a',
  '0x777519cd81f845abdb40d253923d6098'
]);

formattingTests('v4', new Metadata(registry, rpcMetadataV4), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v5', new Metadata(registry, rpcMetadataV5), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v6', new Metadata(registry, rpcMetadataV6), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v7', new Metadata(registry, rpcMetadataV7), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);
github polkadot-js / api / packages / rpc-core / src / formatting.spec.ts View on Github external
'0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v5', new Metadata(registry, rpcMetadataV5), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v6', new Metadata(registry, rpcMetadataV6), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v7', new Metadata(registry, rpcMetadataV7), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v8', new Metadata(registry, rpcMetadataV8), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);
github polkadot-js / api / packages / rpc-core / src / formatting.spec.ts View on Github external
'0x777519cd81f845abdb40d253923d6098'
]);

formattingTests('v4', new Metadata(registry, rpcMetadataV4), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v5', new Metadata(registry, rpcMetadataV5), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v6', new Metadata(registry, rpcMetadataV6), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v7', new Metadata(registry, rpcMetadataV7), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v8', new Metadata(registry, rpcMetadataV8), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);
github polkadot-js / api / packages / types / src / scripts / MetadataMd.ts View on Github external
const options = { flags: 'r', encoding: 'utf8' };
  const data = fs.readFileSync('docs/substrate/storage-known.md', options);

  writeFile('docs/substrate/storage.md', addStorage(metadata), data);
}

function writeToExtrinsicsMd (metadata: MetadataV8): void {
  writeFile('docs/substrate/extrinsics.md', addExtrinsics(metadata));
}

function writeToEventsMd (metadata: MetadataV8): void {
  writeFile('docs/substrate/events.md', addEvents(metadata));
}

const registry = new TypeRegistry();
const metadata = new Metadata(registry, rpcdata).metadata.asLatest;

writeToRpcMd();
writeToConstantsMd(metadata);
writeToStorageMd(metadata);
writeToExtrinsicsMd(metadata);
writeToEventsMd(metadata);
github polkadot-js / api / packages / rpc-core / src / formatting.spec.ts View on Github external
'0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v6', new Metadata(registry, rpcMetadataV6), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v7', new Metadata(registry, rpcMetadataV7), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

formattingTests('v8', new Metadata(registry, rpcMetadataV8), [
  '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
  '0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
  '0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
]);

@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