From f837fdc201290241bfb970169f72ca7e090e0301 Mon Sep 17 00:00:00 2001 From: Francis O'Brien <42175565+F-OBrien@users.noreply.github.com> Date: Fri, 17 Jul 2026 22:43:56 +0100 Subject: [PATCH] Add missing RPC methods for author_rotateKeysWithOwner and mmr_generateAncestryProof (#6263) * Add rotateKeysWithOwner RPC method and GeneratedSessionKeys type * Add MmrAncestryProof type and generateAncestryProof RPC method --- packages/rpc-augment/src/augment/jsonrpc.ts | 12 ++++++++-- .../types-augment/src/registry/interfaces.ts | 6 +++-- .../src/interfaces/author/definitions.ts | 7 ++++++ packages/types/src/interfaces/author/rpc.ts | 11 ++++++++++ packages/types/src/interfaces/author/types.ts | 8 ++++++- .../types/src/interfaces/mmr/definitions.ts | 6 +++++ packages/types/src/interfaces/mmr/rpc.ts | 22 +++++++++++++++++++ packages/types/src/interfaces/mmr/types.ts | 9 ++++++++ 8 files changed, 76 insertions(+), 5 deletions(-) diff --git a/packages/rpc-augment/src/augment/jsonrpc.ts b/packages/rpc-augment/src/augment/jsonrpc.ts index 797772d173..11568b32cc 100644 --- a/packages/rpc-augment/src/augment/jsonrpc.ts +++ b/packages/rpc-augment/src/augment/jsonrpc.ts @@ -9,7 +9,7 @@ import type { AugmentedRpc } from '@polkadot/rpc-core/types'; import type { Metadata, StorageKey } from '@polkadot/types'; import type { Bytes, HashMap, Json, Null, Option, Text, U256, U64, Vec, bool, f64, u32, u64 } from '@polkadot/types-codec'; import type { AnyNumber, Codec } from '@polkadot/types-codec/types'; -import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author'; +import type { ExtrinsicOrHash, ExtrinsicStatus, GeneratedSessionKeys } from '@polkadot/types/interfaces/author'; import type { EpochAuthorship } from '@polkadot/types/interfaces/babe'; import type { BeefyVersionedFinalityProof } from '@polkadot/types/interfaces/beefy'; import type { BlockHash } from '@polkadot/types/interfaces/chain'; @@ -21,7 +21,7 @@ import type { CreatedBlock } from '@polkadot/types/interfaces/engine'; import type { EthAccount, EthCallRequest, EthFeeHistory, EthFilter, EthFilterChanges, EthLog, EthReceipt, EthRichBlock, EthSubKind, EthSubParams, EthSyncStatus, EthTransaction, EthTransactionRequest, EthWork } from '@polkadot/types/interfaces/eth'; import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics'; import type { EncodedFinalityProofs, JustificationNotification, ReportedRoundStates } from '@polkadot/types/interfaces/grandpa'; -import type { MmrHash, MmrLeafBatchProof } from '@polkadot/types/interfaces/mmr'; +import type { MmrAncestryProof, MmrHash, MmrLeafBatchProof } from '@polkadot/types/interfaces/mmr'; import type { StorageKind } from '@polkadot/types/interfaces/offchain'; import type { FeeDetails, RuntimeDispatchInfoV1 } from '@polkadot/types/interfaces/payment'; import type { RpcMethods } from '@polkadot/types/interfaces/rpc'; @@ -59,6 +59,10 @@ declare module '@polkadot/rpc-core/types/jsonrpc' { * Generate new session keys and returns the corresponding public keys **/ rotateKeys: AugmentedRpc<() => Observable>; + /** + * Generate new session keys and returns the corresponding public keys and owner proof + **/ + rotateKeysWithOwner: AugmentedRpc<(owner: Bytes | string | Uint8Array) => Observable>; /** * Submit and subscribe to watch an extrinsic until unsubscribed **/ @@ -372,6 +376,10 @@ declare module '@polkadot/rpc-core/types/jsonrpc' { subscribeJustifications: AugmentedRpc<() => Observable>; }; mmr: { + /** + * Generate an MMR ancestry proof for the given block number. + **/ + generateAncestryProof: AugmentedRpc<(prevBlockNumber: u64 | AnyNumber | Uint8Array, bestKnownBlockNumber?: u64 | AnyNumber | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable>; /** * Generate MMR proof for the given block numbers. **/ diff --git a/packages/types-augment/src/registry/interfaces.ts b/packages/types-augment/src/registry/interfaces.ts index 0e36efcfca..f074005499 100644 --- a/packages/types-augment/src/registry/interfaces.ts +++ b/packages/types-augment/src/registry/interfaces.ts @@ -11,7 +11,7 @@ import type { TAssetConversion } from '@polkadot/types/interfaces/assetConversio import type { AssetApproval, AssetApprovalKey, AssetBalance, AssetDestroyWitness, AssetDetails, AssetMetadata, TAssetBalance, TAssetDepositBalance } from '@polkadot/types/interfaces/assets'; import type { BlockAttestations, IncludedBlocks, MoreAttestations } from '@polkadot/types/interfaces/attestations'; import type { RawAuraPreDigest } from '@polkadot/types/interfaces/aura'; -import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author'; +import type { ExtrinsicOrHash, ExtrinsicStatus, GeneratedSessionKeys } from '@polkadot/types/interfaces/author'; import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship'; import type { AllowedSlots, BabeAuthorityWeight, BabeBlockWeight, BabeEpochConfiguration, BabeEquivocationProof, BabeGenesisConfiguration, BabeGenesisConfigurationV1, BabeWeight, Epoch, EpochAuthorship, MaybeRandomness, MaybeVrf, NextConfigDescriptor, NextConfigDescriptorV1, OpaqueKeyOwnershipProof, Randomness, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondaryPlain, RawBabePreDigestSecondaryTo159, RawBabePreDigestSecondaryVRF, RawBabePreDigestTo159, SlotNumber, VrfData, VrfOutput, VrfProof } from '@polkadot/types/interfaces/babe'; import type { AccountData, BalanceLock, BalanceLockTo212, BalanceStatus, Reasons, ReserveData, ReserveIdentifier, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances'; @@ -46,7 +46,7 @@ import type { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMu import type { CallIndex, LotteryConfig } from '@polkadot/types/interfaces/lottery'; import type { CustomMetadata15, CustomValueMetadata15, EnumDeprecationInfoV16, ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV13, ErrorMetadataV14, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV13, EventMetadataV14, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, ExtrinsicMetadataV13, ExtrinsicMetadataV14, ExtrinsicMetadataV15, ExtrinsicMetadataV16, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV13, FunctionArgumentMetadataV14, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV13, FunctionMetadataV14, FunctionMetadataV9, ItemDeprecationInfoV16, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV13, MetadataV14, MetadataV15, MetadataV16, MetadataV9, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV13, ModuleConstantMetadataV9, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV13, ModuleMetadataV9, OpaqueMetadata, OuterEnums15, PalletAssociatedTypeMetadataV16, PalletCallMetadataLatest, PalletCallMetadataV14, PalletCallMetadataV16, PalletConstantMetadataLatest, PalletConstantMetadataV14, PalletConstantMetadataV16, PalletErrorMetadataLatest, PalletErrorMetadataV14, PalletErrorMetadataV16, PalletEventMetadataLatest, PalletEventMetadataV14, PalletEventMetadataV16, PalletMetadataLatest, PalletMetadataV14, PalletMetadataV15, PalletMetadataV16, PalletStorageMetadataLatest, PalletStorageMetadataV14, PalletStorageMetadataV16, PalletViewFunctionMetadataV16, PortableType, PortableTypeV14, RuntimeApiMetadataLatest, RuntimeApiMetadataV15, RuntimeApiMetadataV16, RuntimeApiMethodMetadataV15, RuntimeApiMethodMetadataV16, RuntimeApiMethodParamMetadataV15, SignedExtensionMetadataLatest, SignedExtensionMetadataV14, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV13, StorageEntryMetadataV14, StorageEntryMetadataV16, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV13, StorageEntryModifierV14, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV13, StorageEntryTypeV14, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV13, StorageHasherV14, StorageHasherV9, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV13, StorageMetadataV9, TransactionExtensionMetadataLatest, TransactionExtensionMetadataV16, VariantDeprecationInfoV16 } from '@polkadot/types/interfaces/metadata'; import type { Mixnode, MixnodesErr, SessionPhase, SessionStatus } from '@polkadot/types/interfaces/mixnet'; -import type { MmrBatchProof, MmrEncodableOpaqueLeaf, MmrError, MmrHash, MmrLeafBatchProof, MmrLeafIndex, MmrLeafProof, MmrNodeIndex, MmrProof } from '@polkadot/types/interfaces/mmr'; +import type { MmrAncestryProof, MmrBatchProof, MmrEncodableOpaqueLeaf, MmrError, MmrHash, MmrLeafBatchProof, MmrLeafIndex, MmrLeafProof, MmrNodeIndex, MmrProof } from '@polkadot/types/interfaces/mmr'; import type { NftCollectionId, NftItemId } from '@polkadot/types/interfaces/nfts'; import type { NpApiError, NpPoolId } from '@polkadot/types/interfaces/nompools'; import type { StorageKind } from '@polkadot/types/interfaces/offchain'; @@ -569,6 +569,7 @@ declare module '@polkadot/types/types/registry' { FungibilityV5: FungibilityV5; FungiblesAccessError: FungiblesAccessError; Gas: Gas; + GeneratedSessionKeys: GeneratedSessionKeys; GenesisBuildErr: GenesisBuildErr; GiltBid: GiltBid; GlobalValidationData: GlobalValidationData; @@ -735,6 +736,7 @@ declare module '@polkadot/types/types/registry' { MigrationStatusResult: MigrationStatusResult; Mixnode: Mixnode; MixnodesErr: MixnodesErr; + MmrAncestryProof: MmrAncestryProof; MmrBatchProof: MmrBatchProof; MmrEncodableOpaqueLeaf: MmrEncodableOpaqueLeaf; MmrError: MmrError; diff --git a/packages/types/src/interfaces/author/definitions.ts b/packages/types/src/interfaces/author/definitions.ts index 759db716d4..99a385292d 100644 --- a/packages/types/src/interfaces/author/definitions.ts +++ b/packages/types/src/interfaces/author/definitions.ts @@ -30,6 +30,13 @@ export default { Dropped: 'Null', Invalid: 'Null' } + }, + GeneratedSessionKeys: { + _alias: { + sessionKeys: 'keys' + }, + sessionKeys: 'Bytes', + proof: 'Option' } } } as Definitions; diff --git a/packages/types/src/interfaces/author/rpc.ts b/packages/types/src/interfaces/author/rpc.ts index c03fc06d4a..db0010eb5b 100644 --- a/packages/types/src/interfaces/author/rpc.ts +++ b/packages/types/src/interfaces/author/rpc.ts @@ -71,6 +71,17 @@ export const rpc: DefinitionsRpc = { params: [], type: 'Bytes' }, + rotateKeysWithOwner: { + description: 'Generate new session keys and returns the corresponding public keys and owner proof', + isUnsafe: true, + params: [ + { + name: 'owner', + type: 'Bytes' + } + ], + type: 'GeneratedSessionKeys' + }, submitAndWatchExtrinsic: { description: 'Submit and subscribe to watch an extrinsic until unsubscribed', isSigned: true, diff --git a/packages/types/src/interfaces/author/types.ts b/packages/types/src/interfaces/author/types.ts index 80fe225419..10cb5013bd 100644 --- a/packages/types/src/interfaces/author/types.ts +++ b/packages/types/src/interfaces/author/types.ts @@ -1,7 +1,7 @@ // Auto-generated via `yarn polkadot-types-from-defs`, do not edit /* eslint-disable */ -import type { Bytes, Enum, Text, Vec } from '@polkadot/types-codec'; +import type { Bytes, Enum, Option, Struct, Text, Vec } from '@polkadot/types-codec'; import type { Hash } from '@polkadot/types/interfaces/runtime'; /** @name ExtrinsicOrHash */ @@ -34,4 +34,10 @@ export interface ExtrinsicStatus extends Enum { readonly type: 'Future' | 'Ready' | 'Broadcast' | 'InBlock' | 'Retracted' | 'FinalityTimeout' | 'Finalized' | 'Usurped' | 'Dropped' | 'Invalid'; } +/** @name GeneratedSessionKeys */ +export interface GeneratedSessionKeys extends Struct { + readonly sessionKeys: Bytes; + readonly proof: Option; +} + export type PHANTOM_AUTHOR = 'author'; diff --git a/packages/types/src/interfaces/mmr/definitions.ts b/packages/types/src/interfaces/mmr/definitions.ts index 6c9b6e9b47..7e148f89c3 100644 --- a/packages/types/src/interfaces/mmr/definitions.ts +++ b/packages/types/src/interfaces/mmr/definitions.ts @@ -13,6 +13,12 @@ export default { rpc, runtime, types: { + MmrAncestryProof: { + prevPeaks: 'Vec', + prevLeafCount: 'MmrNodeIndex', + leafCount: 'MmrNodeIndex', + items: 'Vec<(MmrNodeIndex, MmrHash)>' + }, MmrBatchProof: { leafIndices: 'Vec', leafCount: 'MmrNodeIndex', diff --git a/packages/types/src/interfaces/mmr/rpc.ts b/packages/types/src/interfaces/mmr/rpc.ts index 7723769374..414a95d0ad 100644 --- a/packages/types/src/interfaces/mmr/rpc.ts +++ b/packages/types/src/interfaces/mmr/rpc.ts @@ -4,6 +4,28 @@ import type { DefinitionsRpc } from '../../types/index.js'; export const rpc: DefinitionsRpc = { + generateAncestryProof: { + description: 'Generate an MMR ancestry proof for the given block number.', + params: [ + { + name: 'prevBlockNumber', + type: 'u64' + }, + { + isOptional: true, + name: 'bestKnownBlockNumber', + type: 'u64' + }, + { + isHistoric: true, + isOptional: true, + name: 'at', + type: 'BlockHash' + } + ], + type: 'MmrAncestryProof' + }, + generateProof: { description: 'Generate MMR proof for the given block numbers.', params: [ diff --git a/packages/types/src/interfaces/mmr/types.ts b/packages/types/src/interfaces/mmr/types.ts index f7ba211d25..f1fad89f57 100644 --- a/packages/types/src/interfaces/mmr/types.ts +++ b/packages/types/src/interfaces/mmr/types.ts @@ -2,9 +2,18 @@ /* eslint-disable */ import type { Bytes, Enum, Struct, Vec, u64 } from '@polkadot/types-codec'; +import type { ITuple } from '@polkadot/types-codec/types'; import type { BlockHash } from '@polkadot/types/interfaces/chain'; import type { Hash } from '@polkadot/types/interfaces/runtime'; +/** @name MmrAncestryProof */ +export interface MmrAncestryProof extends Struct { + readonly prevPeaks: Vec; + readonly prevLeafCount: MmrNodeIndex; + readonly leafCount: MmrNodeIndex; + readonly items: Vec>; +} + /** @name MmrBatchProof */ export interface MmrBatchProof extends Struct { readonly leafIndices: Vec;