From e04e5577eda861895692fd1b108be32c98401d85 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 20 Feb 2020 16:27:48 +0100 Subject: [PATCH] Types for offchain phragmen (#1908) --- .../extrinsic/signedExtensions/substrate.ts | 4 ++ packages/types/src/interfaceRegistry.ts | 24 ++++++++- .../src/interfaces/staking/definitions.ts | 36 +++++++++++++ .../types/src/interfaces/staking/types.ts | 53 ++++++++++++++++++- packages/types/src/known/overrides.ts | 3 ++ 5 files changed, 118 insertions(+), 2 deletions(-) diff --git a/packages/types/src/extrinsic/signedExtensions/substrate.ts b/packages/types/src/extrinsic/signedExtensions/substrate.ts index 78dd430b33..dc498d32cd 100644 --- a/packages/types/src/extrinsic/signedExtensions/substrate.ts +++ b/packages/types/src/extrinsic/signedExtensions/substrate.ts @@ -44,5 +44,9 @@ export default { CheckWeight: { extra: {}, types: {} + }, + LockStakingStatus: { + extra: {}, + types: {} } } as ExtDef; diff --git a/packages/types/src/interfaceRegistry.ts b/packages/types/src/interfaceRegistry.ts index 7c790cc1a0..b2a4486aa7 100644 --- a/packages/types/src/interfaceRegistry.ts +++ b/packages/types/src/interfaceRegistry.ts @@ -24,7 +24,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, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society'; -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 { CompactAssignments, ElectionCompute, ElectionResult, ElectionStatus, EraIndex, EraPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, PhragmenScore, Points, RewardDestination, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, 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'; @@ -721,6 +721,18 @@ export interface InterfaceRegistry { VouchingStatus: VouchingStatus; 'Option': Option; 'Vec': Vec; + CompactAssignments: CompactAssignments; + 'Option': Option; + 'Vec': Vec; + ElectionCompute: ElectionCompute; + 'Option': Option; + 'Vec': Vec; + ElectionResult: ElectionResult; + 'Option': Option; + 'Vec': Vec; + ElectionStatus: ElectionStatus; + 'Option': Option; + 'Vec': Vec; EraIndex: EraIndex; 'Compact': Compact; 'Option': Option; @@ -740,12 +752,18 @@ export interface InterfaceRegistry { IndividualExposure: IndividualExposure; 'Option': Option; 'Vec': Vec; + KeyType: KeyType; + 'Option': Option; + 'Vec': Vec; MomentOf: MomentOf; 'Option': Option; 'Vec': Vec; Nominations: Nominations; 'Option': Option; 'Vec': Vec; + PhragmenScore: PhragmenScore; + 'Option': Option; + 'Vec': Vec; Points: Points; 'Compact': Compact; 'Option': Option; @@ -781,6 +799,10 @@ export interface InterfaceRegistry { UnlockChunk: UnlockChunk; 'Option': Option; 'Vec': Vec; + ValidatorIndex: ValidatorIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; ValidatorPrefs: ValidatorPrefs; 'Option': Option; 'Vec': Vec; diff --git a/packages/types/src/interfaces/staking/definitions.ts b/packages/types/src/interfaces/staking/definitions.ts index 531ab5bd84..c7ba20661e 100644 --- a/packages/types/src/interfaces/staking/definitions.ts +++ b/packages/types/src/interfaces/staking/definitions.ts @@ -4,6 +4,39 @@ export default { types: { + CompactAssignments: { + votes1: 'Vec<(AccountId, AccountId)>', + votes2: 'Vec<(AccountId, (AccountId, u128), AccountId)>', + votes3: 'Vec<(AccountId, [(AccountId, u128); 2], AccountId)>', + votes4: 'Vec<(AccountId, [(AccountId, u128); 3], AccountId)>', + votes5: 'Vec<(AccountId, [(AccountId, u128); 4], AccountId)>', + votes6: 'Vec<(AccountId, [(AccountId, u128); 5], AccountId)>', + votes7: 'Vec<(AccountId, [(AccountId, u128); 6], AccountId)>', + votes8: 'Vec<(AccountId, [(AccountId, u128); 7], AccountId)>', + votes9: 'Vec<(AccountId, [(AccountId, u128); 8], AccountId)>', + votes10: 'Vec<(AccountId, [(AccountId, u128); 9], AccountId)>', + votes11: 'Vec<(AccountId, [(AccountId, u128); 10], AccountId)>', + votes12: 'Vec<(AccountId, [(AccountId, u128); 11], AccountId)>', + votes13: 'Vec<(AccountId, [(AccountId, u128); 12], AccountId)>', + votes14: 'Vec<(AccountId, [(AccountId, u128); 13], AccountId)>', + votes15: 'Vec<(AccountId, [(AccountId, u128); 14], AccountId)>', + votes16: 'Vec<(AccountId, [(AccountId, u128); 15], AccountId)>', + }, + ElectionCompute: { + _enum: ['OnChain', 'Signed', 'Authority'] + }, + ElectionResult: { + compute: 'ElectionCompute', + slotStake: 'Balance', + electedStashes: 'Vec', + exposures: 'Vec<(AccountId, Exposure)>' + }, + ElectionStatus: { + _enum: { + Close: 'Null', + Open: 'BlockNumber' + } + }, EraIndex: 'u32', EraPoints: { total: 'Points', @@ -30,12 +63,14 @@ export default { who: 'AccountId', value: 'Compact' }, + KeyType: 'AccountId', MomentOf: 'Moment', Nominations: { targets: 'Vec', submittedIn: 'EraIndex', suppressed: 'bool' }, + PhragmenScore: '[u128; 3]', Points: 'u32', RewardDestination: { _enum: [ @@ -83,6 +118,7 @@ export default { value: 'Compact', era: 'Compact' }, + ValidatorIndex: 'u16', ValidatorPrefs: { commission: 'Compact' }, diff --git a/packages/types/src/interfaces/staking/types.ts b/packages/types/src/interfaces/staking/types.ts index 55af1bcebf..cbe3b77ad9 100644 --- a/packages/types/src/interfaces/staking/types.ts +++ b/packages/types/src/interfaces/staking/types.ts @@ -3,9 +3,51 @@ import { ITuple } from '@polkadot/types/types'; import { Compact, Enum, Struct, Vec } from '@polkadot/types/codec'; -import { bool, u32 } from '@polkadot/types/primitive'; +import { bool, u128, u16, u32 } from '@polkadot/types/primitive'; import { AccountId, Balance, BlockNumber, Moment, Perbill } from '@polkadot/types/interfaces/runtime'; +/** @name CompactAssignments */ +export interface CompactAssignments extends Struct { + readonly votes1: Vec>; + readonly votes2: Vec, AccountId]>>; + readonly votes3: Vec>, AccountId]>>; + readonly votes4: Vec>, AccountId]>>; + readonly votes5: Vec>, AccountId]>>; + readonly votes6: Vec>, AccountId]>>; + readonly votes7: Vec>, AccountId]>>; + readonly votes8: Vec>, AccountId]>>; + readonly votes9: Vec>, AccountId]>>; + readonly votes10: Vec>, AccountId]>>; + readonly votes11: Vec>, AccountId]>>; + readonly votes12: Vec>, AccountId]>>; + readonly votes13: Vec>, AccountId]>>; + readonly votes14: Vec>, AccountId]>>; + readonly votes15: Vec>, AccountId]>>; + readonly votes16: Vec>, AccountId]>>; +} + +/** @name ElectionCompute */ +export interface ElectionCompute extends Enum { + readonly isOnChain: boolean; + readonly isSigned: boolean; + readonly isAuthority: boolean; +} + +/** @name ElectionResult */ +export interface ElectionResult extends Struct { + readonly compute: ElectionCompute; + readonly slotStake: Balance; + readonly electedStashes: Vec; + readonly exposures: Vec>; +} + +/** @name ElectionStatus */ +export interface ElectionStatus extends Enum { + readonly isClose: boolean; + readonly isOpen: boolean; + readonly asOpen: BlockNumber; +} + /** @name EraIndex */ export interface EraIndex extends u32 {} @@ -42,6 +84,9 @@ export interface IndividualExposure extends Struct { readonly value: Compact; } +/** @name KeyType */ +export interface KeyType extends AccountId {} + /** @name MomentOf */ export interface MomentOf extends Moment {} @@ -52,6 +97,9 @@ export interface Nominations extends Struct { readonly suppressed: bool; } +/** @name PhragmenScore */ +export interface PhragmenScore extends Vec {} + /** @name Points */ export interface Points extends u32 {} @@ -119,6 +167,9 @@ export interface UnlockChunk extends Struct { readonly era: Compact; } +/** @name ValidatorIndex */ +export interface ValidatorIndex extends u16 {} + /** @name ValidatorPrefs */ export interface ValidatorPrefs extends Struct { readonly commission: Compact; diff --git a/packages/types/src/known/overrides.ts b/packages/types/src/known/overrides.ts index f78bb1745e..b369050f18 100644 --- a/packages/types/src/known/overrides.ts +++ b/packages/types/src/known/overrides.ts @@ -19,6 +19,9 @@ const TYPES_MODULES: Record = { Judgement: 'SocietyJudgement', Vote: 'SocietyVote' }, + staking: { + Compact: 'CompactAssignments' + }, treasury: { Proposal: 'TreasuryProposal' }