diff --git a/packages/types/src/interfaceRegistry.ts b/packages/types/src/interfaceRegistry.ts index bcced822a3..35f9068c99 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 { 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 { CompactAssignments, CompactScore, 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 { AccountInfo, DigestOf, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Key, Phase, RefCount } from '@polkadot/types/interfaces/system'; import { OpenTip, OpenTipFinder, OpenTipTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury'; import { Multiplier } from '@polkadot/types/interfaces/txpayment'; @@ -727,6 +727,9 @@ export interface InterfaceRegistry { CompactAssignments: CompactAssignments; 'Option': Option; 'Vec': Vec; + CompactScore: CompactScore; + 'Option': Option; + 'Vec': Vec; ElectionCompute: ElectionCompute; 'Option': Option; 'Vec': Vec; diff --git a/packages/types/src/interfaces/staking/CompactAssignments.spec.ts b/packages/types/src/interfaces/staking/CompactAssignments.spec.ts new file mode 100644 index 0000000000..c49d3ce2d3 --- /dev/null +++ b/packages/types/src/interfaces/staking/CompactAssignments.spec.ts @@ -0,0 +1,32 @@ +// Copyright 2017-2020 @polkadot/types authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import { TypeRegistry, createType, createTypeUnsafe } from '../../create'; + +describe('CompactAssignments', (): void => { + const registry = new TypeRegistry(); + const votes2 = [['5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', [['5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y', 123456]], '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty']]; + const test = createType(registry, 'CompactAssignments', { + votes1: [['5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', [], '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty']], + votes2 + }); + + it('has a valid vote1 ([Type; ] equivalency)', (): void => { + expect(test.votes1.toHex()).toEqual( + createTypeUnsafe(registry, 'Vec<(AccountId, AccountId)>', [[ + ['5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty'] + ]]).toHex() + ); + }); + + it('hash valid vot2 (actual tuple values)', (): void => { + expect(test.votes2.toHex()).toEqual( + createTypeUnsafe(registry, 'Vec<(AccountId, [(AccountId, u128); 1], AccountId)>', [votes2]).toHex() + ); + }); + + it('has a proper decoded toHuman() available', (): void => { + expect(test.votes2.toHuman()).toEqual([['5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', [['5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y', '123,456']], '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty']]); + }); +}); diff --git a/packages/types/src/interfaces/staking/definitions.ts b/packages/types/src/interfaces/staking/definitions.ts index c7ba20661e..f2560d1d53 100644 --- a/packages/types/src/interfaces/staking/definitions.ts +++ b/packages/types/src/interfaces/staking/definitions.ts @@ -5,23 +5,24 @@ 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)>', + votes1: 'Vec<(AccountId, [CompactScore; 0], AccountId)>', + votes2: 'Vec<(AccountId, [CompactScore; 1], AccountId)>', + votes3: 'Vec<(AccountId, [CompactScore; 2], AccountId)>', + votes4: 'Vec<(AccountId, [CompactScore; 3], AccountId)>', + votes5: 'Vec<(AccountId, [CompactScore; 4], AccountId)>', + votes6: 'Vec<(AccountId, [CompactScore; 5], AccountId)>', + votes7: 'Vec<(AccountId, [CompactScore; 6], AccountId)>', + votes8: 'Vec<(AccountId, [CompactScore; 7], AccountId)>', + votes9: 'Vec<(AccountId, [CompactScore; 8], AccountId)>', + votes10: 'Vec<(AccountId, [CompactScore; 9], AccountId)>', + votes11: 'Vec<(AccountId, [CompactScore; 10], AccountId)>', + votes12: 'Vec<(AccountId, [CompactScore; 11], AccountId)>', + votes13: 'Vec<(AccountId, [CompactScore; 12], AccountId)>', + votes14: 'Vec<(AccountId, [CompactScore; 13], AccountId)>', + votes15: 'Vec<(AccountId, [CompactScore; 14], AccountId)>', + votes16: 'Vec<(AccountId, [CompactScore; 15], AccountId)>' }, + CompactScore: '(AccountId, u128)', ElectionCompute: { _enum: ['OnChain', 'Signed', 'Authority'] }, diff --git a/packages/types/src/interfaces/staking/types.ts b/packages/types/src/interfaces/staking/types.ts index cbe3b77ad9..7977b9878d 100644 --- a/packages/types/src/interfaces/staking/types.ts +++ b/packages/types/src/interfaces/staking/types.ts @@ -8,24 +8,27 @@ import { AccountId, Balance, BlockNumber, Moment, Perbill } from '@polkadot/type /** @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]>>; + readonly votes1: Vec, AccountId]>>; + 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 CompactScore */ +export interface CompactScore extends ITuple<[AccountId, u128]> {} + /** @name ElectionCompute */ export interface ElectionCompute extends Enum { readonly isOnChain: boolean;