diff --git a/packages/api/src/types/augment/rpc.ts b/packages/api/src/types/augment/rpc.ts index 9d54a1a020..e9bcf64f3a 100644 --- a/packages/api/src/types/augment/rpc.ts +++ b/packages/api/src/types/augment/rpc.ts @@ -3,7 +3,7 @@ import { AnyNumber, Codec, IExtrinsic } from '@polkadot/types/types'; import { Option, Vec } from '@polkadot/types/codec'; -import { Bytes, H256, StorageData, StorageKey, Text, u32, u64 } from '@polkadot/types/primitive'; +import { Bytes, H256, StorageData, StorageKey, Text, bool, u32, u64 } from '@polkadot/types/primitive'; import { Metadata } from '@polkadot/types'; import { AccountId, BlockNumber, Extrinsic, Hash, Header, Index, SignedBlock } from '@polkadot/types/interfaces/runtime'; import { ContractCallRequest, ContractExecResult } from '@polkadot/types/interfaces/contracts'; @@ -19,6 +19,14 @@ declare module '@polkadot/rpc-core/types.jsonrpc' { nextIndex(accountId: AccountId | string | Uint8Array): Observable; }; author: { + /** + * Returns true if the keystore has private keys for the given public key and key type. + **/ + hasKey(publicKey: Bytes | string | Uint8Array, keyType: Text | string): Observable; + /** + * Returns true if the keystore has private keys for the given session public keys. + **/ + hasSessionKeys(sessionKeys: Bytes | string | Uint8Array): Observable; /** * Insert a key into the keystore. **/ diff --git a/packages/type-jsonrpc/src/author.ts b/packages/type-jsonrpc/src/author.ts index faaea6f7ef..f0d010b55e 100644 --- a/packages/type-jsonrpc/src/author.ts +++ b/packages/type-jsonrpc/src/author.ts @@ -7,6 +7,23 @@ import { RpcMethodOpt } from './types'; import createMethod from './create/method'; import createParam from './create/param'; +const hasKey: RpcMethodOpt = { + description: 'Returns true if the keystore has private keys for the given public key and key type.', + params: [ + createParam('publicKey', 'Bytes'), + createParam('keyType', 'Text') + ], + type: 'bool' +}; + +const hasSessionKeys: RpcMethodOpt = { + description: 'Returns true if the keystore has private keys for the given session public keys.', + params: [ + createParam('sessionKeys', 'Bytes') + ], + type: 'bool' +}; + const removeExtrinsic: RpcMethodOpt = { description: 'Remove given extrinsic from the pool and temporarily ban it to prevent reimporting', params: [ @@ -71,6 +88,8 @@ export default { description: 'Authoring of network items', section, methods: { + hasKey: createMethod(section, 'hasKey', hasKey), + hasSessionKeys: createMethod(section, 'hasSessionKeys', hasSessionKeys), insertKey: createMethod(section, 'insertKey', insertKey), removeExtrinsic: createMethod(section, 'removeExtrinsic', removeExtrinsic), rotateKeys: createMethod(section, 'rotateKeys', rotateKeys),