Explicit tie of metadata to registry (not implicit) (#2621)

* Explicit tie of metadata to registry (not implicit)

* Update type generation

* Test updates

* Revert non-problematic

* Cleanup mocks

* Updata metadata tests

* CHANGELOG

* linting
This commit is contained in:
Jaco Greeff
2020-09-17 23:15:09 +02:00
committed by GitHub
parent cdd6544e20
commit b56c1a8282
26 changed files with 84 additions and 50 deletions
+8 -3
View File
@@ -10,7 +10,8 @@ import { MockStateSubscriptions, MockStateSubscriptionCallback, MockStateDb } fr
import BN from 'bn.js';
import EventEmitter from 'eventemitter3';
import Metadata from '@polkadot/metadata/Decorated';
import Decorated from '@polkadot/metadata/Decorated';
import Metadata from '@polkadot/metadata/Metadata';
import rpcMetadata from '@polkadot/metadata/Metadata/static';
import jsonrpc from '@polkadot/types/interfaces/jsonrpc';
import testKeyring from '@polkadot/keyring/testing';
@@ -171,6 +172,10 @@ export default class Mock implements ProviderInterface {
const metadata = new Metadata(this.registry, rpcMetadata);
this.registry.setMetadata(metadata);
const decorated = new Decorated(this.registry, metadata);
// Do something every 1 seconds
setInterval((): void => {
if (!this.isUpdating) {
@@ -182,11 +187,11 @@ export default class Mock implements ProviderInterface {
// increment the balances and nonce for each account
keyring.getPairs().forEach(({ publicKey }, index): void => {
this.setStateBn(metadata.query.system.account(publicKey), newHead.number.toBn().addn(index));
this.setStateBn(decorated.query.system.account(publicKey), newHead.number.toBn().addn(index));
});
// set the timestamp for the current block
this.setStateBn(metadata.query.timestamp.now(), Math.floor(Date.now() / 1000));
this.setStateBn(decorated.query.timestamp.now(), Math.floor(Date.now() / 1000));
this.updateSubs('chain_subscribeNewHead', newHead);
// We emit connected/disconnected at intervals