add user additional rpcs during api.clone() (#3764)

This commit is contained in:
Ian He
2021-07-13 08:35:46 +02:00
committed by GitHub
parent b317a8eb9b
commit 8d6bd931f3
2 changed files with 4 additions and 6 deletions
+2 -4
View File
@@ -4,7 +4,7 @@
import type { Observable } from 'rxjs';
import type { RpcInterface } from '@polkadot/rpc-core/types';
import type { Option, Raw, StorageKey, Text, u64 } from '@polkadot/types';
import type { Call, Hash, RpcMethods, RuntimeVersion } from '@polkadot/types/interfaces';
import type { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
import type { StorageEntry } from '@polkadot/types/primitive/types';
import type { AnyFunction, AnyTuple, CallFunction, Codec, CodecArg as Arg, DefinitionRpc, DefinitionRpcSub, IMethod, InterfaceTypes, IStorageKey, Registry, RegistryTypes } from '@polkadot/types/types';
@@ -265,9 +265,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
// manner to cater for both old and new:
// - when the number of entries are 0, only remove the ones with isOptional (account & contracts)
// - when non-zero, remove anything that is not in the array (we don't do this)
protected _filterRpc (rpcMethods: RpcMethods, additional: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>): void {
const methods = rpcMethods.methods.map((t) => t.toString());
protected _filterRpc (methods: string[], additional: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>): void {
// add any specific user-base RPCs
if (Object.keys(additional).length !== 0) {
this._rpcCore.addUserInterfaces(additional);
+2 -2
View File
@@ -213,7 +213,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
});
});
this._filterRpcMethods(methods);
this._filterRpc(methods, getSpecRpc(this.registry, source.runtimeChain, source.runtimeVersion.specName));
return [source.genesisHash, source.runtimeMetadata];
}
@@ -296,7 +296,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
// initializes the registry & RPC
this._initRegistry(this.registry, chain, runtimeVersion, metadata, chainProps);
this._filterRpc(rpcMethods, getSpecRpc(this.registry, chain, runtimeVersion.specName));
this._filterRpc(rpcMethods.methods.map((t) => t.toString()), getSpecRpc(this.registry, chain, runtimeVersion.specName));
this._subscribeUpdates();
// setup the initial registry, when we have none