Set runtimeChain from source (#2595)

* Set runtimeChain from source

* Update packages/api/src/base/index.ts

* Update CHANGELOG.md
This commit is contained in:
Jaco Greeff
2020-09-09 18:44:47 +02:00
committed by GitHub
parent 373eb06713
commit c2705bdfda
3 changed files with 10 additions and 1 deletions
+1
View File
@@ -4,6 +4,7 @@
Changes:
- When cloning an API instance the runtimeChain is now properly set from source
- Allow `paymentInfo` on any extrinsic (already signed) with optional `{ blockHash: <hash> }` param for historic queries
- Optimize derive `receivedHeartbeats` to not re-create the full object
- Add `staking.stakerPrefs` derive to retrieve validatorPrefs over a range of eras
+1
View File
@@ -161,6 +161,7 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
// eslint-disable-next-line @typescript-eslint/require-await
private async _metaFromSource (source: ApiBase<any>): Promise<Metadata> {
this._extrinsicType = source.extrinsicVersion;
this._runtimeChain = source.runtimeChain;
this._runtimeVersion = source.runtimeVersion;
this._genesisHash = source.genesisHash;
this.registry.setChainProperties(source.registry.getChainProperties());
+8 -1
View File
@@ -7,7 +7,7 @@ import { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import { CallFunction, RegistryError, SignerPayloadRawBase } from '@polkadot/types/types';
import { ApiInterfaceRx, ApiOptions, ApiTypes, DecoratedRpc, DecorateMethod, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics, Signer } from '../types';
import { Metadata } from '@polkadot/types';
import { Metadata, Text } from '@polkadot/types';
import { assert, isString, isUndefined, u8aToHex, u8aToU8a } from '@polkadot/util';
import Init from './Init';
@@ -193,6 +193,13 @@ export default abstract class ApiBase<ApiType extends ApiTypes> extends Init<Api
return assertResult(this._rpc);
}
/**
* @description Contains the chain information for the current node.
*/
public get runtimeChain (): Text {
return assertResult(this._runtimeChain);
}
/**
* @description Yields the current attached runtime metadata. Generally this is only used to construct extrinsics & storage, but is useful for current runtime inspection.
*/