Add a Decorated class, which will be offline decorated Metadata (#1463)
* Move Metadata to api-metadata * Make tests in api-metadata pass * Make tests in api-metadata pass * Refactor fromMetadata into decorated * Fix some linting * Replace headers * Fix all tests * Small lint * Fix tests * Fix metadata docs scripts * Fix import ordering * Add line breaks * Grumbles * Fix forgotten import * rpcMetadata everywhere * Fixlint * s/api-metadata/metadata * Fix latest tests * Fix lint * Fix tests
This commit is contained in:
committed by
Jaco Greeff
parent
c87ba33893
commit
16e0ea9315
@@ -4,7 +4,8 @@
|
||||
|
||||
import { BlockNumber, Index, SignedBlock } from '@polkadot/types/interfaces';
|
||||
|
||||
import storage from '@polkadot/api-metadata/storage/static';
|
||||
import Metadata from '@polkadot/metadata';
|
||||
import rpcMetadata from '@polkadot/metadata/Metadata/static';
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
import { ClassOf } from '@polkadot/types';
|
||||
|
||||
@@ -13,6 +14,7 @@ import Rpc from '@polkadot/rpc-core';
|
||||
import { describeE2E } from '../../util';
|
||||
|
||||
const randomAccount = '5HTqyWJHAVUieZnpb1V8gK4T1E4mnhkrUVSSzWBQd6kYgsVJ';
|
||||
const metadata = new Metadata(rpcMetadata);
|
||||
|
||||
describeE2E({
|
||||
only: [
|
||||
@@ -29,8 +31,8 @@ describeE2E({
|
||||
it('subscribes to storage', (done): void => {
|
||||
rpc.state
|
||||
.subscribeStorage<[BlockNumber, Index]>([
|
||||
[storage.system.accountNonce, randomAccount],
|
||||
[storage.session.currentIndex]
|
||||
[metadata.query.system.accountNonce, randomAccount],
|
||||
[metadata.query.session.currentIndex]
|
||||
])
|
||||
.subscribe((data): void => {
|
||||
expect(data).toHaveLength(2);
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
import { Balance, Moment, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
|
||||
import storage from '@polkadot/api-metadata/storage/static';
|
||||
import DecorateMeta from '@polkadot/metadata';
|
||||
import rpcMetadata from '@polkadot/metadata/Metadata/static';
|
||||
import Rpc from '@polkadot/rpc-core';
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
import { Bytes, ClassOf, Metadata, StorageKey } from '@polkadot/types';
|
||||
@@ -13,6 +14,7 @@ import { describeE2E } from '../../util';
|
||||
|
||||
const BOB_STASH = '5HpG9w8EBLe5XCrbczpwq5TSXvedjrBGCwqxK1iQ7qUsSWFc';
|
||||
const CODE = '0x3a636f6465'; // :code
|
||||
const metadata = new DecorateMeta(rpcMetadata);
|
||||
|
||||
describeE2E({
|
||||
except: [
|
||||
@@ -59,7 +61,7 @@ describeE2E({
|
||||
it('retrieves code', (done): void => {
|
||||
rpc.state
|
||||
.getStorage<Bytes>([
|
||||
storage.substrate.code
|
||||
metadata.query.substrate.code
|
||||
])
|
||||
.subscribe((code: Bytes): void => {
|
||||
expect(code).toBeDefined();
|
||||
@@ -71,7 +73,7 @@ describeE2E({
|
||||
it('retrieves balances', (done): void => {
|
||||
rpc.state
|
||||
.getStorage<Balance>([
|
||||
storage.balances.freeBalance, BOB_STASH
|
||||
metadata.query.balances.freeBalance, BOB_STASH
|
||||
])
|
||||
.subscribe((balance): void => {
|
||||
expect(balance.isZero()).not.toEqual(true);
|
||||
@@ -82,7 +84,7 @@ describeE2E({
|
||||
it('retrieves timestamp', (done): void => {
|
||||
rpc.state
|
||||
.getStorage<Moment>([
|
||||
storage.timestamp.now
|
||||
metadata.query.timestamp.now
|
||||
])
|
||||
.subscribe((moment: Moment): void => {
|
||||
expect(moment.toNumber()).not.toEqual(0);
|
||||
|
||||
@@ -2,15 +2,18 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Metadata from '@polkadot/metadata';
|
||||
import rpcMetadata from '@polkadot/metadata/Metadata/static';
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
import storage from '@polkadot/api-metadata/storage/static';
|
||||
import Rpc from '@polkadot/rpc-core';
|
||||
import { Index, Moment, SessionIndex } from '@polkadot/types/interfaces';
|
||||
import { ClassOf } from '@polkadot/types';
|
||||
|
||||
import { describeE2E } from '../../util';
|
||||
|
||||
const metadata = new Metadata(rpcMetadata);
|
||||
|
||||
describeE2E({
|
||||
except: [
|
||||
'remote-polkadot-alexander',
|
||||
@@ -28,8 +31,8 @@ describeE2E({
|
||||
it('subscribes to storage', (done): void => {
|
||||
rpc.state
|
||||
.subscribeStorage<[Index, SessionIndex]>([
|
||||
[storage.system.accountNonce, keyring.eve.address],
|
||||
[storage.session.currentIndex]
|
||||
[metadata.query.system.accountNonce, keyring.eve.address],
|
||||
[metadata.query.session.currentIndex]
|
||||
])
|
||||
.subscribe((data): void => {
|
||||
expect(data).toHaveLength(2);
|
||||
@@ -48,7 +51,7 @@ describeE2E({
|
||||
let count = 0;
|
||||
|
||||
rpc.state
|
||||
.subscribeStorage<Moment>([[storage.timestamp.now]])
|
||||
.subscribeStorage<Moment>([[metadata.query.timestamp.now]])
|
||||
.subscribe((data): void => {
|
||||
expect(data).toBeDefined();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user