diff --git a/packages/api-augment/src/kusama/runtime.ts b/packages/api-augment/src/kusama/runtime.ts index 9514d45999..edf2c82158 100644 --- a/packages/api-augment/src/kusama/runtime.ts +++ b/packages/api-augment/src/kusama/runtime.ts @@ -2,12 +2,14 @@ /* eslint-disable */ import type { ApiTypes } from '@polkadot/api-base/types'; -import type { Bytes, u32 } from '@polkadot/types-codec'; -import type { AnyNumber } from '@polkadot/types-codec/types'; +import type { Bytes, Option, Vec, u32 } from '@polkadot/types-codec'; +import type { AnyNumber, ITuple } from '@polkadot/types-codec/types'; +import type { BabeGenesisConfiguration, Epoch, OpaqueKeyOwnershipProof } from '@polkadot/types/interfaces/babe'; +import type { AuthorityId } from '@polkadot/types/interfaces/consensus'; import type { AuthorityList, SetId } from '@polkadot/types/interfaces/grandpa'; import type { OpaqueMetadata } from '@polkadot/types/interfaces/metadata'; import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment'; -import type { AccountId, Index } from '@polkadot/types/interfaces/runtime'; +import type { AccountId, Index, KeyTypeId, Slot } from '@polkadot/types/interfaces/runtime'; import type { Observable } from '@polkadot/types/types'; declare module '@polkadot/api-base/types/calls' { @@ -22,6 +24,32 @@ declare module '@polkadot/api-base/types/calls' { **/ [key: string]: DecoratedCallBase; }; + babeApi: { + /** + * Return the genesis configuration for BABE. The configuration is only read on genesis. + **/ + configuration: AugmentedCall Observable>; + /** + * Returns information regarding the current epoch. + **/ + currentEpoch: AugmentedCall Observable>; + /** + * Returns the slot that started the current epoch. + **/ + currentEpochStart: AugmentedCall Observable>; + /** + * Generates a proof of key ownership for the given authority in the current epoch. + **/ + generateKeyOwnershipProof: AugmentedCall Observable>>; + /** + * Returns information regarding the next epoch (which was already previously announced). + **/ + nextEpoch: AugmentedCall Observable>; + /** + * Generic call + **/ + [key: string]: DecoratedCallBase; + }; grandpaApi: { /** * Get current GRANDPA authority set id. @@ -46,6 +74,20 @@ declare module '@polkadot/api-base/types/calls' { **/ [key: string]: DecoratedCallBase; }; + sessionKeys: { + /** + * Decode the given public session keys. + **/ + decodeSessionKeys: AugmentedCall Observable>>>>; + /** + * Generate a set of session keys with optionally using the given seed. + **/ + generateSessionKeys: AugmentedCall | null | object | string | Uint8Array) => Observable>; + /** + * Generic call + **/ + [key: string]: DecoratedCallBase; + }; transactionPaymentApi: { /** * The transaction fee details diff --git a/packages/api-augment/src/polkadot/runtime.ts b/packages/api-augment/src/polkadot/runtime.ts index 9514d45999..edf2c82158 100644 --- a/packages/api-augment/src/polkadot/runtime.ts +++ b/packages/api-augment/src/polkadot/runtime.ts @@ -2,12 +2,14 @@ /* eslint-disable */ import type { ApiTypes } from '@polkadot/api-base/types'; -import type { Bytes, u32 } from '@polkadot/types-codec'; -import type { AnyNumber } from '@polkadot/types-codec/types'; +import type { Bytes, Option, Vec, u32 } from '@polkadot/types-codec'; +import type { AnyNumber, ITuple } from '@polkadot/types-codec/types'; +import type { BabeGenesisConfiguration, Epoch, OpaqueKeyOwnershipProof } from '@polkadot/types/interfaces/babe'; +import type { AuthorityId } from '@polkadot/types/interfaces/consensus'; import type { AuthorityList, SetId } from '@polkadot/types/interfaces/grandpa'; import type { OpaqueMetadata } from '@polkadot/types/interfaces/metadata'; import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment'; -import type { AccountId, Index } from '@polkadot/types/interfaces/runtime'; +import type { AccountId, Index, KeyTypeId, Slot } from '@polkadot/types/interfaces/runtime'; import type { Observable } from '@polkadot/types/types'; declare module '@polkadot/api-base/types/calls' { @@ -22,6 +24,32 @@ declare module '@polkadot/api-base/types/calls' { **/ [key: string]: DecoratedCallBase; }; + babeApi: { + /** + * Return the genesis configuration for BABE. The configuration is only read on genesis. + **/ + configuration: AugmentedCall Observable>; + /** + * Returns information regarding the current epoch. + **/ + currentEpoch: AugmentedCall Observable>; + /** + * Returns the slot that started the current epoch. + **/ + currentEpochStart: AugmentedCall Observable>; + /** + * Generates a proof of key ownership for the given authority in the current epoch. + **/ + generateKeyOwnershipProof: AugmentedCall Observable>>; + /** + * Returns information regarding the next epoch (which was already previously announced). + **/ + nextEpoch: AugmentedCall Observable>; + /** + * Generic call + **/ + [key: string]: DecoratedCallBase; + }; grandpaApi: { /** * Get current GRANDPA authority set id. @@ -46,6 +74,20 @@ declare module '@polkadot/api-base/types/calls' { **/ [key: string]: DecoratedCallBase; }; + sessionKeys: { + /** + * Decode the given public session keys. + **/ + decodeSessionKeys: AugmentedCall Observable>>>>; + /** + * Generate a set of session keys with optionally using the given seed. + **/ + generateSessionKeys: AugmentedCall | null | object | string | Uint8Array) => Observable>; + /** + * Generic call + **/ + [key: string]: DecoratedCallBase; + }; transactionPaymentApi: { /** * The transaction fee details diff --git a/packages/api-augment/src/substrate/runtime.ts b/packages/api-augment/src/substrate/runtime.ts index 3465f5fe90..4fedc4dbc8 100644 --- a/packages/api-augment/src/substrate/runtime.ts +++ b/packages/api-augment/src/substrate/runtime.ts @@ -2,13 +2,15 @@ /* eslint-disable */ import type { ApiTypes } from '@polkadot/api-base/types'; -import type { Bytes, Option, u32, u64 } from '@polkadot/types-codec'; -import type { AnyNumber } from '@polkadot/types-codec/types'; +import type { Bytes, Option, Vec, u32, u64 } from '@polkadot/types-codec'; +import type { AnyNumber, ITuple } from '@polkadot/types-codec/types'; +import type { BabeGenesisConfiguration, Epoch, OpaqueKeyOwnershipProof } from '@polkadot/types/interfaces/babe'; +import type { AuthorityId } from '@polkadot/types/interfaces/consensus'; import type { CodeUploadResult, ContractExecResult, ContractInstantiateResult } from '@polkadot/types/interfaces/contracts'; import type { AuthorityList, SetId } from '@polkadot/types/interfaces/grandpa'; import type { OpaqueMetadata } from '@polkadot/types/interfaces/metadata'; import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment'; -import type { AccountId, Balance, Index } from '@polkadot/types/interfaces/runtime'; +import type { AccountId, Balance, Index, KeyTypeId, Slot } from '@polkadot/types/interfaces/runtime'; import type { Observable } from '@polkadot/types/types'; declare module '@polkadot/api-base/types/calls' { @@ -23,6 +25,32 @@ declare module '@polkadot/api-base/types/calls' { **/ [key: string]: DecoratedCallBase; }; + babeApi: { + /** + * Return the genesis configuration for BABE. The configuration is only read on genesis. + **/ + configuration: AugmentedCall Observable>; + /** + * Returns information regarding the current epoch. + **/ + currentEpoch: AugmentedCall Observable>; + /** + * Returns the slot that started the current epoch. + **/ + currentEpochStart: AugmentedCall Observable>; + /** + * Generates a proof of key ownership for the given authority in the current epoch. + **/ + generateKeyOwnershipProof: AugmentedCall Observable>>; + /** + * Returns information regarding the next epoch (which was already previously announced). + **/ + nextEpoch: AugmentedCall Observable>; + /** + * Generic call + **/ + [key: string]: DecoratedCallBase; + }; contractsApi: { /** * Perform a call from a specified account to a given contract. @@ -69,6 +97,20 @@ declare module '@polkadot/api-base/types/calls' { **/ [key: string]: DecoratedCallBase; }; + sessionKeys: { + /** + * Decode the given public session keys. + **/ + decodeSessionKeys: AugmentedCall Observable>>>>; + /** + * Generate a set of session keys with optionally using the given seed. + **/ + generateSessionKeys: AugmentedCall | null | object | string | Uint8Array) => Observable>; + /** + * Generic call + **/ + [key: string]: DecoratedCallBase; + }; transactionPaymentApi: { /** * The transaction fee details diff --git a/packages/types-augment/src/registry/interfaces.ts b/packages/types-augment/src/registry/interfaces.ts index 409a78d21d..21adba5fd9 100644 --- a/packages/types-augment/src/registry/interfaces.ts +++ b/packages/types-augment/src/registry/interfaces.ts @@ -8,7 +8,7 @@ import type { BlockAttestations, IncludedBlocks, MoreAttestations } from '@polka import type { RawAuraPreDigest } from '@polkadot/types/interfaces/aura'; import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author'; import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship'; -import type { AllowedSlots, BabeAuthorityWeight, BabeBlockWeight, BabeEpochConfiguration, BabeEquivocationProof, BabeWeight, EpochAuthorship, MaybeRandomness, MaybeVrf, NextConfigDescriptor, NextConfigDescriptorV1, Randomness, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondaryPlain, RawBabePreDigestSecondaryTo159, RawBabePreDigestSecondaryVRF, RawBabePreDigestTo159, SlotNumber, VrfData, VrfOutput, VrfProof } from '@polkadot/types/interfaces/babe'; +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'; import type { BeefyAuthoritySet, BeefyCommitment, BeefyId, BeefyNextAuthoritySet, BeefyPayload, BeefyPayloadId, BeefySignedCommitment, MmrRootHash, ValidatorSetId } from '@polkadot/types/interfaces/beefy'; import type { BridgeMessageId, BridgedBlockHash, BridgedBlockNumber, BridgedHeader, CallOrigin, ChainId, DeliveredMessages, DispatchFeePayment, InboundLaneData, InboundRelayer, InitializationData, LaneId, MessageData, MessageKey, MessageNonce, MessagesDeliveryProofOf, MessagesProofOf, OperatingMode, OutboundLaneData, OutboundMessageFee, OutboundPayload, Parameter, RelayerId, UnrewardedRelayer, UnrewardedRelayersState } from '@polkadot/types/interfaces/bridges'; @@ -45,7 +45,7 @@ import type { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/ty import type { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/purchase'; import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery'; import type { RpcMethods } from '@polkadot/types/interfaces/rpc'; -import type { AccountId, AccountId20, AccountId32, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, BlockNumberFor, BlockNumberOf, Call, CallHash, CallHashOf, ChangesTrieConfiguration, ChangesTrieSignal, CodecHash, Consensus, ConsensusEngineId, CrateVersion, Digest, DigestItem, EncodedJustification, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H32, H512, H64, Hash, Header, HeaderPartial, I32F32, Index, IndicesLookupSource, Justification, Justifications, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, MultiSigner, OpaqueCall, Origin, OriginCaller, PalletId, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, SignedBlockWithJustification, SignedBlockWithJustifications, Slot, StorageData, StorageProof, TransactionInfo, TransactionPriority, TransactionStorageProof, U32F32, ValidatorId, ValidatorIdOf, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime'; +import type { AccountId, AccountId20, AccountId32, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, BlockNumberFor, BlockNumberOf, Call, CallHash, CallHashOf, ChangesTrieConfiguration, ChangesTrieSignal, CodecHash, Consensus, ConsensusEngineId, CrateVersion, Digest, DigestItem, EncodedJustification, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H32, H512, H64, Hash, Header, HeaderPartial, I32F32, Index, IndicesLookupSource, Justification, Justifications, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, MultiSigner, OpaqueCall, Origin, OriginCaller, PalletId, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, SignedBlockWithJustification, SignedBlockWithJustifications, Slot, SlotDuration, StorageData, StorageProof, TransactionInfo, TransactionPriority, TransactionStorageProof, U32F32, ValidatorId, ValidatorIdOf, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime'; import type { Si0Field, Si0LookupTypeId, Si0Path, Si0Type, Si0TypeDef, Si0TypeDefArray, Si0TypeDefBitSequence, Si0TypeDefCompact, Si0TypeDefComposite, Si0TypeDefPhantom, Si0TypeDefPrimitive, Si0TypeDefSequence, Si0TypeDefTuple, Si0TypeDefVariant, Si0TypeParameter, Si0Variant, Si1Field, Si1LookupTypeId, Si1Path, Si1Type, Si1TypeDef, Si1TypeDefArray, Si1TypeDefBitSequence, Si1TypeDefCompact, Si1TypeDefComposite, Si1TypeDefPrimitive, Si1TypeDefSequence, Si1TypeDefTuple, Si1TypeDefVariant, Si1TypeParameter, Si1Variant, SiField, SiLookupTypeId, SiPath, SiType, SiTypeDef, SiTypeDefArray, SiTypeDefBitSequence, SiTypeDefCompact, SiTypeDefComposite, SiTypeDefPrimitive, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiTypeParameter, SiVariant } from '@polkadot/types/interfaces/scaleInfo'; import type { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, ScheduledTo254, TaskAddress } from '@polkadot/types/interfaces/scheduler'; import type { BeefyKey, FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys10, SessionKeys10B, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, SessionKeys6B, SessionKeys7, SessionKeys7B, SessionKeys8, SessionKeys8B, SessionKeys9, SessionKeys9B, ValidatorCount } from '@polkadot/types/interfaces/session'; @@ -129,6 +129,8 @@ declare module '@polkadot/types/types/registry' { BabeBlockWeight: BabeBlockWeight; BabeEpochConfiguration: BabeEpochConfiguration; BabeEquivocationProof: BabeEquivocationProof; + BabeGenesisConfiguration: BabeGenesisConfiguration; + BabeGenesisConfigurationV1: BabeGenesisConfigurationV1; BabeWeight: BabeWeight; BackedCandidate: BackedCandidate; Balance: Balance; @@ -338,6 +340,7 @@ declare module '@polkadot/types/types/registry' { ElectionStatus: ElectionStatus; EncodedFinalityProofs: EncodedFinalityProofs; EncodedJustification: EncodedJustification; + Epoch: Epoch; EpochAuthorship: EpochAuthorship; Era: Era; EraIndex: EraIndex; @@ -658,6 +661,7 @@ declare module '@polkadot/types/types/registry' { OffenceDetails: OffenceDetails; Offender: Offender; OpaqueCall: OpaqueCall; + OpaqueKeyOwnershipProof: OpaqueKeyOwnershipProof; OpaqueMetadata: OpaqueMetadata; OpaqueMultiaddr: OpaqueMultiaddr; OpaqueNetworkState: OpaqueNetworkState; @@ -926,6 +930,7 @@ declare module '@polkadot/types/types/registry' { SlashingSpansTo204: SlashingSpansTo204; SlashJournalEntry: SlashJournalEntry; Slot: Slot; + SlotDuration: SlotDuration; SlotNumber: SlotNumber; SlotRange: SlotRange; SlotRange10: SlotRange10; diff --git a/packages/types/src/interfaces/aura/definitions.ts b/packages/types/src/interfaces/aura/definitions.ts index 8dfb87ed9c..f4ad52ccbe 100644 --- a/packages/types/src/interfaces/aura/definitions.ts +++ b/packages/types/src/interfaces/aura/definitions.ts @@ -6,8 +6,11 @@ import type { Definitions } from '../../types'; +import { runtime } from './runtime'; + export default { rpc: {}, + runtime, types: { RawAuraPreDigest: { slotNumber: 'u64' diff --git a/packages/types/src/interfaces/aura/runtime.ts b/packages/types/src/interfaces/aura/runtime.ts new file mode 100644 index 0000000000..7ab833f242 --- /dev/null +++ b/packages/types/src/interfaces/aura/runtime.ts @@ -0,0 +1,23 @@ +// Copyright 2017-2022 @polkadot/types authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { DefinitionsCall } from '../../types'; + +export const runtime: DefinitionsCall = { + AuraApi: [ + { + methods: { + authorities: { + description: 'Return the current set of authorities.', + params: [], + type: 'Vec' + }, + slot_duration: { + description: 'Returns the slot duration for Aura.', + params: [], + type: 'SlotDuration' + } + } + } + ] +}; diff --git a/packages/types/src/interfaces/babe/definitions.ts b/packages/types/src/interfaces/babe/definitions.ts index ba174f95ee..f0e5f7cff8 100644 --- a/packages/types/src/interfaces/babe/definitions.ts +++ b/packages/types/src/interfaces/babe/definitions.ts @@ -7,9 +7,11 @@ import type { Definitions } from '../../types'; import { rpc } from './rpc'; +import { runtime } from './runtime'; export default { rpc, + runtime, types: { AllowedSlots: { _enum: ['PrimarySlots', 'PrimaryAndSecondaryPlainSlots', 'PrimaryAndSecondaryVRFSlots'] @@ -26,9 +28,33 @@ export default { firstHeader: 'Header', secondHeader: 'Header' }, + BabeGenesisConfiguration: { + slotDuration: 'u64', + epochLength: 'u64', + c: '(u64, u64)', + genesisAuthorities: 'Vec<(AuthorityId, BabeAuthorityWeight)>', + randomness: 'Randomness', + allowedSlots: 'AllowedSlots' + }, + BabeGenesisConfigurationV1: { + slotDuration: 'u64', + epochLength: 'u64', + c: '(u64, u64)', + genesisAuthorities: 'Vec<(AuthorityId, BabeAuthorityWeight)>', + randomness: 'Randomness', + secondarySlots: 'bool' + }, BabeWeight: 'u64', MaybeRandomness: 'Option', MaybeVrf: 'Option', + Epoch: { + epochIndex: 'u64', + startSlot: 'Slot', + duration: 'u64', + authorities: 'Vec<(AuthorityId, BabeAuthorityWeight)>', + randomness: 'Hash', // [u8; VRF_OUTPUT_LENGTH], + config: 'BabeEpochConfiguration' + }, EpochAuthorship: { primary: 'Vec', secondary: 'Vec', @@ -44,7 +70,8 @@ export default { c: '(u64, u64)', allowedSlots: 'AllowedSlots' }, - Randomness: 'Hash', + OpaqueKeyOwnershipProof: 'Bytes', + Randomness: 'Hash', // [u8; RANDOMNESS_LENGTH], RawBabePreDigest: { _enum: { Phantom: 'Null', // index starts at 1... empty slot at 0 diff --git a/packages/types/src/interfaces/babe/runtime.ts b/packages/types/src/interfaces/babe/runtime.ts new file mode 100644 index 0000000000..b51cb7b536 --- /dev/null +++ b/packages/types/src/interfaces/babe/runtime.ts @@ -0,0 +1,64 @@ +// Copyright 2017-2022 @polkadot/types authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { DefinitionCall, DefinitionsCall } from '../../types'; + +import { objectSpread } from '@polkadot/util'; + +const V1_V2_SHARED: Record = { + current_epoch: { + description: 'Returns information regarding the current epoch.', + params: [], + type: 'Epoch' + }, + current_epoch_start: { + description: 'Returns the slot that started the current epoch.', + params: [], + type: 'Slot' + }, + generate_key_ownership_proof: { + description: 'Generates a proof of key ownership for the given authority in the current epoch.', + params: [ + { + name: 'slot', + type: 'Slot' + }, + { + name: 'authorityId', + type: 'AuthorityId' + } + ], + type: 'Option' + }, + next_epoch: { + description: 'Returns information regarding the next epoch (which was already previously announced).', + params: [], + type: 'Epoch' + } + // TDODO Add submit_report_equivocation_unsigned_extrinsic +}; + +export const runtime: DefinitionsCall = { + BabeApi: [ + { + methods: objectSpread({ + configuration: { + description: 'Return the genesis configuration for BABE. The configuration is only read on genesis.', + params: [], + type: 'BabeGenesisConfiguration' + } + }, V1_V2_SHARED), + version: 2 + }, + { + methods: objectSpread({ + configuration: { + description: 'Return the configuration for BABE. Version 1.', + params: [], + type: 'BabeGenesisConfigurationV1' + } + }, V1_V2_SHARED), + version: 1 + } + ] +}; diff --git a/packages/types/src/interfaces/babe/types.ts b/packages/types/src/interfaces/babe/types.ts index e7e6ab09bb..b13604d819 100644 --- a/packages/types/src/interfaces/babe/types.ts +++ b/packages/types/src/interfaces/babe/types.ts @@ -1,10 +1,10 @@ // Auto-generated via `yarn polkadot-types-from-defs`, do not edit /* eslint-disable */ -import type { Enum, Option, Struct, U8aFixed, Vec, u32, u64 } from '@polkadot/types-codec'; +import type { Bytes, Enum, Option, Struct, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types-codec'; import type { ITuple } from '@polkadot/types-codec/types'; import type { AuthorityId } from '@polkadot/types/interfaces/consensus'; -import type { Hash, Header } from '@polkadot/types/interfaces/runtime'; +import type { Hash, Header, Slot } from '@polkadot/types/interfaces/runtime'; /** @name AllowedSlots */ export interface AllowedSlots extends Enum { @@ -34,9 +34,39 @@ export interface BabeEquivocationProof extends Struct { readonly secondHeader: Header; } +/** @name BabeGenesisConfiguration */ +export interface BabeGenesisConfiguration extends Struct { + readonly slotDuration: u64; + readonly epochLength: u64; + readonly c: ITuple<[u64, u64]>; + readonly genesisAuthorities: Vec>; + readonly randomness: Randomness; + readonly allowedSlots: AllowedSlots; +} + +/** @name BabeGenesisConfigurationV1 */ +export interface BabeGenesisConfigurationV1 extends Struct { + readonly slotDuration: u64; + readonly epochLength: u64; + readonly c: ITuple<[u64, u64]>; + readonly genesisAuthorities: Vec>; + readonly randomness: Randomness; + readonly secondarySlots: bool; +} + /** @name BabeWeight */ export interface BabeWeight extends u64 {} +/** @name Epoch */ +export interface Epoch extends Struct { + readonly epochIndex: u64; + readonly startSlot: Slot; + readonly duration: u64; + readonly authorities: Vec>; + readonly randomness: Hash; + readonly config: BabeEpochConfiguration; +} + /** @name EpochAuthorship */ export interface EpochAuthorship extends Struct { readonly primary: Vec; @@ -64,6 +94,9 @@ export interface NextConfigDescriptorV1 extends Struct { readonly allowedSlots: AllowedSlots; } +/** @name OpaqueKeyOwnershipProof */ +export interface OpaqueKeyOwnershipProof extends Bytes {} + /** @name Randomness */ export interface Randomness extends Hash {} diff --git a/packages/types/src/interfaces/runtime/definitions.ts b/packages/types/src/interfaces/runtime/definitions.ts index 66018d4bdb..614d43eaaa 100644 --- a/packages/types/src/interfaces/runtime/definitions.ts +++ b/packages/types/src/interfaces/runtime/definitions.ts @@ -178,6 +178,7 @@ export default { justifications: 'Option' }, Slot: 'u64', + SlotDuration: 'u64', StorageData: 'Bytes', StorageProof: { trieNodes: 'Vec' diff --git a/packages/types/src/interfaces/runtime/types.ts b/packages/types/src/interfaces/runtime/types.ts index 92000a75f9..167aadab5f 100644 --- a/packages/types/src/interfaces/runtime/types.ts +++ b/packages/types/src/interfaces/runtime/types.ts @@ -333,6 +333,9 @@ export interface SignedBlockWithJustifications extends Struct { /** @name Slot */ export interface Slot extends u64 {} +/** @name SlotDuration */ +export interface SlotDuration extends u64 {} + /** @name StorageData */ export interface StorageData extends Bytes {} diff --git a/packages/types/src/interfaces/session/definitions.ts b/packages/types/src/interfaces/session/definitions.ts index f85f3fdcb0..48f6f2b86b 100644 --- a/packages/types/src/interfaces/session/definitions.ts +++ b/packages/types/src/interfaces/session/definitions.ts @@ -8,6 +8,8 @@ import type { Definitions } from '../../types'; import { objectSpread } from '@polkadot/util'; +import { runtime } from './runtime'; + // The runtime definition of SessionKeys are passed as a Trait to session // Defined in `node/runtime/src/lib.rs` as follow // impl_opaque_keys! { @@ -39,12 +41,13 @@ const keyTypes = { export default { rpc: {}, + runtime, types: objectSpread({}, keyTypes, { FullIdentification: 'Exposure', IdentificationTuple: '(ValidatorId, FullIdentification)', MembershipProof: { session: 'SessionIndex', - trieNodes: 'Vec>', + trieNodes: 'Vec', validatorCount: 'ValidatorCount' }, SessionIndex: 'u32', diff --git a/packages/types/src/interfaces/session/runtime.ts b/packages/types/src/interfaces/session/runtime.ts new file mode 100644 index 0000000000..0e84820b1a --- /dev/null +++ b/packages/types/src/interfaces/session/runtime.ts @@ -0,0 +1,33 @@ +// Copyright 2017-2022 @polkadot/types authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { DefinitionsCall } from '../../types'; + +export const runtime: DefinitionsCall = { + SessionKeys: [ + { + methods: { + decode_session_keys: { + description: 'Decode the given public session keys.', + params: [ + { + name: 'encoded', + type: 'Bytes' + } + ], + type: 'Option>' + }, + generate_session_keys: { + description: 'Generate a set of session keys with optionally using the given seed.', + params: [ + { + name: 'seed', + type: 'Option' + } + ], + type: 'Bytes' + } + } + } + ] +};