Aura, Babe & Session runtime definitions (#4992)
This commit is contained in:
@@ -6,8 +6,11 @@
|
||||
|
||||
import type { Definitions } from '../../types';
|
||||
|
||||
import { runtime } from './runtime';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
runtime,
|
||||
types: {
|
||||
RawAuraPreDigest: {
|
||||
slotNumber: 'u64'
|
||||
|
||||
@@ -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<AuthorityId>'
|
||||
},
|
||||
slot_duration: {
|
||||
description: 'Returns the slot duration for Aura.',
|
||||
params: [],
|
||||
type: 'SlotDuration'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -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<Randomness>',
|
||||
MaybeVrf: 'Option<VrfData>',
|
||||
Epoch: {
|
||||
epochIndex: 'u64',
|
||||
startSlot: 'Slot',
|
||||
duration: 'u64',
|
||||
authorities: 'Vec<(AuthorityId, BabeAuthorityWeight)>',
|
||||
randomness: 'Hash', // [u8; VRF_OUTPUT_LENGTH],
|
||||
config: 'BabeEpochConfiguration'
|
||||
},
|
||||
EpochAuthorship: {
|
||||
primary: 'Vec<u64>',
|
||||
secondary: 'Vec<u64>',
|
||||
@@ -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
|
||||
|
||||
@@ -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<string, DefinitionCall> = {
|
||||
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<OpaqueKeyOwnershipProof>'
|
||||
},
|
||||
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
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -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<ITuple<[AuthorityId, BabeAuthorityWeight]>>;
|
||||
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<ITuple<[AuthorityId, BabeAuthorityWeight]>>;
|
||||
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<ITuple<[AuthorityId, BabeAuthorityWeight]>>;
|
||||
readonly randomness: Hash;
|
||||
readonly config: BabeEpochConfiguration;
|
||||
}
|
||||
|
||||
/** @name EpochAuthorship */
|
||||
export interface EpochAuthorship extends Struct {
|
||||
readonly primary: Vec<u64>;
|
||||
@@ -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 {}
|
||||
|
||||
|
||||
@@ -178,6 +178,7 @@ export default {
|
||||
justifications: 'Option<Justifications>'
|
||||
},
|
||||
Slot: 'u64',
|
||||
SlotDuration: 'u64',
|
||||
StorageData: 'Bytes',
|
||||
StorageProof: {
|
||||
trieNodes: 'Vec<Bytes>'
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
|
||||
@@ -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<Vec<u8>>',
|
||||
trieNodes: 'Vec<Bytes>',
|
||||
validatorCount: 'ValidatorCount'
|
||||
},
|
||||
SessionIndex: 'u32',
|
||||
|
||||
@@ -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<Vec<(Bytes, KeyTypeId)>>'
|
||||
},
|
||||
generate_session_keys: {
|
||||
description: 'Generate a set of session keys with optionally using the given seed.',
|
||||
params: [
|
||||
{
|
||||
name: 'seed',
|
||||
type: 'Option<Bytes>'
|
||||
}
|
||||
],
|
||||
type: 'Bytes'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
Reference in New Issue
Block a user