Attach constructed registry to metadata (#3723)

* Attach constructed registry to metadata

* Remove return

* CHANGELOG
This commit is contained in:
Jaco
2021-07-05 08:31:06 +02:00
committed by GitHub
parent 9d5ab4a2d6
commit f5c6c8a072
2 changed files with 6 additions and 5 deletions
+1
View File
@@ -11,6 +11,7 @@ Changes:
- Added `await api.at(<blockHash>)` to retrieve API instances at a point
- Added `fallbackType` for type classes (only struct, as defined)
- Allow `instances` API config to drive collective locations
- Ensure correct registry is attached to historic metadata
- Align static metadata with latest Substrate
+5 -5
View File
@@ -79,7 +79,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
/**
* @description Decorates a registry based on the runtime version
*/
private _initRegistry (registry: Registry, chain: Text, version: { specName: Text, specVersion: BN }, metadata: Metadata, chainProps?: ChainProperties): Registry {
private _initRegistry (registry: Registry, chain: Text, version: { specName: Text, specVersion: BN }, metadata: Metadata, chainProps?: ChainProperties): void {
registry.setChainProperties(chainProps || this.registry.getChainProperties());
registry.setKnownTypes(this._options);
registry.register(getSpecTypes(registry, chain, version.specName, version.specVersion));
@@ -94,8 +94,6 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
...getSpecExtensions(registry, chain, version.specName),
...(this._options.signedExtensions || {})
});
return registry;
}
/**
@@ -165,10 +163,12 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
}
// nothing has been found, construct new
const metadata = new Metadata(this.registry,
const registry = new TypeRegistry(blockHash);
const metadata = new Metadata(registry,
await (this._rpcCore.state.getMetadata as RpcInterfaceMethod).raw(header.parentHash).toPromise()
);
const registry = this._initRegistry(new TypeRegistry(blockHash), this._runtimeChain as Text, version, metadata);
this._initRegistry(registry, this._runtimeChain as Text, version, metadata);
// add our new registry
const result = { lastBlockHash: blockHash, metadata, registry, specVersion: version.specVersion };