diff --git a/CHANGELOG.md b/CHANGELOG.md index 730b5a4f36..b37e1b9b64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# 1.12.0-beta.x + +- Fix `CompactAssignments` types (Thanks to https://github.com/arjanz) +- Cleanup generation for c-like enums (Thanks to https://github.com/monitz87) +- All to subscribe to all storage keys, alignment with Substrate (Thanks to https://github.com/xlc) +- Cater for vote delegations in democracy derives +- Cleanup account derive flags where to allow for optional council modules +- Allow generic types in ApiPromise.combineLatest +- Update to latest substrate metadata + # 1.11.2 Apr 22, 2020 - Small patch to add missing Polkadot master types (will be in next Kusama update) diff --git a/packages/types/src/augment/registry.ts b/packages/types/src/augment/registry.ts index c2bc437846..dcf716f71a 100644 --- a/packages/types/src/augment/registry.ts +++ b/packages/types/src/augment/registry.ts @@ -35,7 +35,7 @@ import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, Balanc import { SchedulePeriod, SchedulePriority, Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler'; import { FullIdentification, IdentificationTuple, Keys, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6 } from '@polkadot/types/interfaces/session'; import { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society'; -import { ActiveEraInfo, CompactAssignments, CompactScore, ElectionCompute, ElectionResult, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, PhragmenScore, Points, ReleasesStaking, RewardDestination, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking'; +import { ActiveEraInfo, CompactAssignments, CompactScore, ElectionCompute, ElectionResult, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, OffchainAccuracy, PerU16, PhragmenScore, Points, ReleasesStaking, RewardDestination, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking'; import { ApiId, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from '@polkadot/types/interfaces/state'; import { AccountInfo, ChainProperties, ChainType, DigestOf, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Health, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, Phase, RefCount } from '@polkadot/types/interfaces/system'; import { OpenTip, OpenTipFinder, OpenTipTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury'; @@ -836,6 +836,17 @@ declare module '@polkadot/types/types/registry' { Nominations: Nominations; 'Option': Option; 'Vec': Vec; + NominatorIndex: NominatorIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + OffchainAccuracy: OffchainAccuracy; + 'Option': Option; + 'Vec': Vec; + PerU16: PerU16; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; PhragmenScore: PhragmenScore; 'Option': Option; 'Vec': Vec; diff --git a/packages/types/src/interfaces/staking/CompactAssignments.spec.ts b/packages/types/src/interfaces/staking/CompactAssignments.spec.ts index a2526065e8..d308fdc7d5 100644 --- a/packages/types/src/interfaces/staking/CompactAssignments.spec.ts +++ b/packages/types/src/interfaces/staking/CompactAssignments.spec.ts @@ -6,27 +6,27 @@ import { TypeRegistry, createTypeUnsafe } from '../../create'; describe('CompactAssignments', (): void => { const registry = new TypeRegistry(); - const votes2 = [['5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', [['5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y', 123456]], '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty']]; + const votes2 = [[1, [[2, 12345]], 3]]; const test = registry.createType('CompactAssignments', { - votes1: [['5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', [], '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty']], + votes1: [[1, [], 3]], votes2 }); it('has a valid vote1 ([Type; ] equivalency)', (): void => { expect(test.votes1.toHex()).toEqual( - createTypeUnsafe(registry, 'Vec<(AccountId, AccountId)>', [[ - ['5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty'] + createTypeUnsafe(registry, 'Vec<(u16, u32)>', [[ + [1, 3] ]]).toHex() ); }); it('hash valid vot2 (actual tuple values)', (): void => { expect(test.votes2.toHex()).toEqual( - createTypeUnsafe(registry, 'Vec<(AccountId, [(AccountId, u128); 1], AccountId)>', [votes2]).toHex() + createTypeUnsafe(registry, 'Vec<(u16, [(u16, u16); 1], u32)>', [votes2]).toHex() ); }); it('has a proper decoded toHuman() available', (): void => { - expect(test.votes2.toHuman()).toEqual([['5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', [['5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y', '123,456']], '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty']]); + expect(test.votes2.toHuman()).toEqual([['1', [['2', '12,345']], '3']]); }); }); diff --git a/packages/types/src/interfaces/staking/definitions.ts b/packages/types/src/interfaces/staking/definitions.ts index d8f49adba4..7d70de20f4 100644 --- a/packages/types/src/interfaces/staking/definitions.ts +++ b/packages/types/src/interfaces/staking/definitions.ts @@ -24,24 +24,24 @@ export default { start: 'Option' }, CompactAssignments: { - 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)>' + votes1: 'Vec<(ValidatorIndex, [CompactScore; 0], NominatorIndex)>', + votes2: 'Vec<(ValidatorIndex, [CompactScore; 1], NominatorIndex)>', + votes3: 'Vec<(ValidatorIndex, [CompactScore; 2], NominatorIndex)>', + votes4: 'Vec<(ValidatorIndex, [CompactScore; 3], NominatorIndex)>', + votes5: 'Vec<(ValidatorIndex, [CompactScore; 4], NominatorIndex)>', + votes6: 'Vec<(ValidatorIndex, [CompactScore; 5], NominatorIndex)>', + votes7: 'Vec<(ValidatorIndex, [CompactScore; 6], NominatorIndex)>', + votes8: 'Vec<(ValidatorIndex, [CompactScore; 7], NominatorIndex)>', + votes9: 'Vec<(ValidatorIndex, [CompactScore; 8], NominatorIndex)>', + votes10: 'Vec<(ValidatorIndex, [CompactScore; 9], NominatorIndex)>', + votes11: 'Vec<(ValidatorIndex, [CompactScore; 10], NominatorIndex)>', + votes12: 'Vec<(ValidatorIndex, [CompactScore; 11], NominatorIndex)>', + votes13: 'Vec<(ValidatorIndex, [CompactScore; 12], NominatorIndex)>', + votes14: 'Vec<(ValidatorIndex, [CompactScore; 13], NominatorIndex)>', + votes15: 'Vec<(ValidatorIndex, [CompactScore; 14], NominatorIndex)>', + votes16: 'Vec<(ValidatorIndex, [CompactScore; 15], NominatorIndex)>' }, - CompactScore: '(AccountId, u128)', + CompactScore: '(u16, OffchainAccuracy)', ElectionCompute: { _enum: ['OnChain', 'Signed', 'Authority'] }, @@ -90,6 +90,9 @@ export default { submittedIn: 'EraIndex', suppressed: 'bool' }, + NominatorIndex: 'u32', + OffchainAccuracy: 'PerU16', + PerU16: 'u16', PhragmenScore: '[u128; 3]', Points: 'u32', ReleasesStaking: { diff --git a/packages/types/src/interfaces/staking/types.ts b/packages/types/src/interfaces/staking/types.ts index 7dd279ded6..93bfabf9ca 100644 --- a/packages/types/src/interfaces/staking/types.ts +++ b/packages/types/src/interfaces/staking/types.ts @@ -14,26 +14,26 @@ export interface ActiveEraInfo extends Struct { /** @name CompactAssignments */ export interface CompactAssignments extends Struct { - 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]>>; + readonly votes1: Vec, NominatorIndex]>>; + readonly votes2: Vec, NominatorIndex]>>; + readonly votes3: Vec, NominatorIndex]>>; + readonly votes4: Vec, NominatorIndex]>>; + readonly votes5: Vec, NominatorIndex]>>; + readonly votes6: Vec, NominatorIndex]>>; + readonly votes7: Vec, NominatorIndex]>>; + readonly votes8: Vec, NominatorIndex]>>; + readonly votes9: Vec, NominatorIndex]>>; + readonly votes10: Vec, NominatorIndex]>>; + readonly votes11: Vec, NominatorIndex]>>; + readonly votes12: Vec, NominatorIndex]>>; + readonly votes13: Vec, NominatorIndex]>>; + readonly votes14: Vec, NominatorIndex]>>; + readonly votes15: Vec, NominatorIndex]>>; + readonly votes16: Vec, NominatorIndex]>>; } /** @name CompactScore */ -export interface CompactScore extends ITuple<[AccountId, u128]> {} +export interface CompactScore extends ITuple<[u16, OffchainAccuracy]> {} /** @name ElectionCompute */ export interface ElectionCompute extends Enum { @@ -112,6 +112,15 @@ export interface Nominations extends Struct { readonly suppressed: bool; } +/** @name NominatorIndex */ +export interface NominatorIndex extends u32 {} + +/** @name OffchainAccuracy */ +export interface OffchainAccuracy extends PerU16 {} + +/** @name PerU16 */ +export interface PerU16 extends u16 {} + /** @name PhragmenScore */ export interface PhragmenScore extends Vec {}