From 7ed1857589d2a733a2f2ccb5d9780b207ac3d1c8 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Wed, 22 Jan 2020 10:33:05 +0100 Subject: [PATCH] Update SlashingSpans (#1738) * Update SlashingSpans * Digest 0toX -> ToX --- packages/api/src/base/typeInjector.ts | 14 ++++++++-- packages/types/src/interfaceRegistry.ts | 25 +++++++++-------- .../types/src/interfaces/babe/definitions.ts | 10 +++---- packages/types/src/interfaces/babe/types.ts | 28 +++++++++---------- .../src/interfaces/staking/definitions.ts | 6 ++++ .../types/src/interfaces/staking/types.ts | 12 ++++++++ 6 files changed, 62 insertions(+), 33 deletions(-) diff --git a/packages/api/src/base/typeInjector.ts b/packages/api/src/base/typeInjector.ts index d0d40e52a6..daec735d64 100644 --- a/packages/api/src/base/typeInjector.ts +++ b/packages/api/src/base/typeInjector.ts @@ -28,14 +28,22 @@ const TYPES_POLKADOT_VERSIONED: VersionedType[] = [ const TYPES_KUSAMA_VERSIONED: VersionedType[] = [ { - minmax: [1019, 1031], // CC3, from launch + minmax: [1019, 1031], types: { DispatchError: 'DispatchErrorTo198', - Keys: 'SessionKeys5' + Keys: 'SessionKeys5', + SlashingSpans: 'SlashingSpansTo204' } }, { - minmax: [1032, undefined], // CC3, with DispatchError + minmax: [1032, 1042], + types: { + Keys: 'SessionKeys5', + SlashingSpans: 'SlashingSpansTo204' + } + }, + { + minmax: [1043, undefined], types: { Keys: 'SessionKeys5' } diff --git a/packages/types/src/interfaceRegistry.ts b/packages/types/src/interfaceRegistry.ts index fd37814305..13451dd3b2 100644 --- a/packages/types/src/interfaceRegistry.ts +++ b/packages/types/src/interfaceRegistry.ts @@ -6,7 +6,7 @@ import { Bytes, Data, Fixed64, H160, H256, H512, IdentityFields, Null, StorageDa import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, DispatchClass, DispatchInfo, DispatchInfoTo190, EcdsaSignature, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV1, ExtrinsicPayloadV2, ExtrinsicPayloadV3, ExtrinsicPayloadV4, ExtrinsicUnknown, ExtrinsicV1, ExtrinsicV2, ExtrinsicV3, ExtrinsicV4, Hash, Header, ImmortalEra, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, Moment, MortalEra, MultiSignature, Origin, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Seal, SealV0, Signature, SignedBlock, SignerPayload, Sr25519Signature, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime'; import { InclusionHeight, Uncle, UncleEntryItem } from '@polkadot/types/interfaces/authorship'; import { RawAuraPreDigest } from '@polkadot/types/interfaces/aura'; -import { BabeAuthorityWeight, BabeBlockWeight, BabeWeight, MaybeVrf, RawBabePreDigest, RawBabePreDigest0to159, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimary0to159, RawBabePreDigestSecondary, RawBabePreDigestSecondary0to159, SlotNumber, VrfData, VrfProof } from '@polkadot/types/interfaces/babe'; +import { BabeAuthorityWeight, BabeBlockWeight, BabeWeight, MaybeVrf, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondary, RawBabePreDigestSecondaryTo159, RawBabePreDigestTo159, SlotNumber, VrfData, VrfProof } from '@polkadot/types/interfaces/babe'; import { BalanceLock, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances'; import { MemberCount, ProposalIndex, Votes } from '@polkadot/types/interfaces/collective'; import { AuthorityId } from '@polkadot/types/interfaces/consensus'; @@ -22,7 +22,7 @@ import { Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } import { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery'; import { FullIdentification, IdentificationTuple, Keys, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6 } from '@polkadot/types/interfaces/session'; import { Bid, BidKind, BidKindVouch, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society'; -import { EraIndex, EraPoints, EraRewards, Exposure, Forcing, IndividualExposure, MomentOf, Nominations, Points, RewardDestination, SlashJournalEntry, SlashingSpans, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking'; +import { EraIndex, EraPoints, EraRewards, Exposure, Forcing, IndividualExposure, MomentOf, Nominations, Points, RewardDestination, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking'; import { DigestOf, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Key, Phase } from '@polkadot/types/interfaces/system'; import { OpenTip, OpenTipFinder, OpenTipTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury'; import { Multiplier } from '@polkadot/types/interfaces/txpayment'; @@ -358,15 +358,15 @@ export interface InterfaceRegistry { RawBabePreDigestSecondary: RawBabePreDigestSecondary; 'Option': Option; 'Vec': Vec; - RawBabePreDigest0to159: RawBabePreDigest0to159; - 'Option': Option; - 'Vec': Vec; - RawBabePreDigestPrimary0to159: RawBabePreDigestPrimary0to159; - 'Option': Option; - 'Vec': Vec; - RawBabePreDigestSecondary0to159: RawBabePreDigestSecondary0to159; - 'Option': Option; - 'Vec': Vec; + RawBabePreDigestTo159: RawBabePreDigestTo159; + 'Option': Option; + 'Vec': Vec; + RawBabePreDigestPrimaryTo159: RawBabePreDigestPrimaryTo159; + 'Option': Option; + 'Vec': Vec; + RawBabePreDigestSecondaryTo159: RawBabePreDigestSecondaryTo159; + 'Option': Option; + 'Vec': Vec; RawBabePreDigestCompat: RawBabePreDigestCompat; 'Option': Option; 'Vec': Vec; @@ -701,6 +701,9 @@ export interface InterfaceRegistry { SlashJournalEntry: SlashJournalEntry; 'Option': Option; 'Vec': Vec; + SlashingSpansTo204: SlashingSpansTo204; + 'Option': Option; + 'Vec': Vec; SlashingSpans: SlashingSpans; 'Option': Option; 'Vec': Vec; diff --git a/packages/types/src/interfaces/babe/definitions.ts b/packages/types/src/interfaces/babe/definitions.ts index 552fe5e6ee..ecce00ab27 100644 --- a/packages/types/src/interfaces/babe/definitions.ts +++ b/packages/types/src/interfaces/babe/definitions.ts @@ -26,20 +26,20 @@ export default { authorityIndex: 'u32', // AuthorityIndex (also in aura) slotNumber: 'SlotNumber' }, - RawBabePreDigest0to159: { + RawBabePreDigestTo159: { _enum: { - Primary: 'RawBabePreDigestPrimary0to159', - Secondary: 'RawBabePreDigestSecondary0to159' + Primary: 'RawBabePreDigestPrimaryTo159', + Secondary: 'RawBabePreDigestSecondaryTo159' } }, - RawBabePreDigestPrimary0to159: { + RawBabePreDigestPrimaryTo159: { authorityIndex: 'u32', slotNumber: 'SlotNumber', weight: 'BabeBlockWeight', vrfOutput: 'VrfData', vrfProof: 'VrfProof' }, - RawBabePreDigestSecondary0to159: { + RawBabePreDigestSecondaryTo159: { authorityIndex: 'u32', slotNumber: 'SlotNumber', weight: 'BabeBlockWeight' diff --git a/packages/types/src/interfaces/babe/types.ts b/packages/types/src/interfaces/babe/types.ts index a43fd3474a..fe33f977ac 100644 --- a/packages/types/src/interfaces/babe/types.ts +++ b/packages/types/src/interfaces/babe/types.ts @@ -31,18 +31,6 @@ export interface RawBabePreDigest extends Enum { readonly asSecondary: RawBabePreDigestSecondary; } -/** Enum */ -export interface RawBabePreDigest0to159 extends Enum { - /** 0:: Primary(RawBabePreDigestPrimary0to159) */ - readonly isPrimary: boolean; - /** RawBabePreDigestPrimary0to159 */ - readonly asPrimary: RawBabePreDigestPrimary0to159; - /** 1:: Secondary(RawBabePreDigestSecondary0to159) */ - readonly isSecondary: boolean; - /** RawBabePreDigestSecondary0to159 */ - readonly asSecondary: RawBabePreDigestSecondary0to159; -} - /** Enum */ export interface RawBabePreDigestCompat extends Enum { /** 0:: Zero(u32) */ @@ -72,7 +60,7 @@ export interface RawBabePreDigestPrimary extends Struct { } /** Struct */ -export interface RawBabePreDigestPrimary0to159 extends Struct { +export interface RawBabePreDigestPrimaryTo159 extends Struct { /** u32 */ readonly authorityIndex: u32; /** SlotNumber */ @@ -94,7 +82,7 @@ export interface RawBabePreDigestSecondary extends Struct { } /** Struct */ -export interface RawBabePreDigestSecondary0to159 extends Struct { +export interface RawBabePreDigestSecondaryTo159 extends Struct { /** u32 */ readonly authorityIndex: u32; /** SlotNumber */ @@ -103,6 +91,18 @@ export interface RawBabePreDigestSecondary0to159 extends Struct { readonly weight: BabeBlockWeight; } +/** Enum */ +export interface RawBabePreDigestTo159 extends Enum { + /** 0:: Primary(RawBabePreDigestPrimaryTo159) */ + readonly isPrimary: boolean; + /** RawBabePreDigestPrimaryTo159 */ + readonly asPrimary: RawBabePreDigestPrimaryTo159; + /** 1:: Secondary(RawBabePreDigestSecondaryTo159) */ + readonly isSecondary: boolean; + /** RawBabePreDigestSecondaryTo159 */ + readonly asSecondary: RawBabePreDigestSecondaryTo159; +} + /** u64 */ export interface SlotNumber extends u64 {} diff --git a/packages/types/src/interfaces/staking/definitions.ts b/packages/types/src/interfaces/staking/definitions.ts index 1a80abd415..531ab5bd84 100644 --- a/packages/types/src/interfaces/staking/definitions.ts +++ b/packages/types/src/interfaces/staking/definitions.ts @@ -49,9 +49,15 @@ export default { amount: 'Balance', ownSlash: 'Balance' }, + SlashingSpansTo204: { + spanIndex: 'SpanIndex', + lastStart: 'EraIndex', + prior: 'Vec' + }, SlashingSpans: { spanIndex: 'SpanIndex', lastStart: 'EraIndex', + lastNonzeroSlash: 'EraIndex', prior: 'Vec' }, SpanIndex: 'u32', diff --git a/packages/types/src/interfaces/staking/types.ts b/packages/types/src/interfaces/staking/types.ts index 72215bb02e..6955e32743 100644 --- a/packages/types/src/interfaces/staking/types.ts +++ b/packages/types/src/interfaces/staking/types.ts @@ -83,6 +83,18 @@ export interface RewardDestination extends Enum { /** Struct */ export interface SlashingSpans extends Struct { + /** SpanIndex */ + readonly spanIndex: SpanIndex; + /** EraIndex */ + readonly lastStart: EraIndex; + /** EraIndex */ + readonly lastNonzeroSlash: EraIndex; + /** Vec */ + readonly prior: Vec; +} + +/** Struct */ +export interface SlashingSpansTo204 extends Struct { /** SpanIndex */ readonly spanIndex: SpanIndex; /** EraIndex */