Fix CompactAssignments types (#2219)
* Fix CompactAssignments types * Cleanup mistaken type adjustments
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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<Nominations>': Option<Nominations>;
|
||||
'Vec<Nominations>': Vec<Nominations>;
|
||||
NominatorIndex: NominatorIndex;
|
||||
'Compact<NominatorIndex>': Compact<NominatorIndex>;
|
||||
'Option<NominatorIndex>': Option<NominatorIndex>;
|
||||
'Vec<NominatorIndex>': Vec<NominatorIndex>;
|
||||
OffchainAccuracy: OffchainAccuracy;
|
||||
'Option<OffchainAccuracy>': Option<OffchainAccuracy>;
|
||||
'Vec<OffchainAccuracy>': Vec<OffchainAccuracy>;
|
||||
PerU16: PerU16;
|
||||
'Compact<PerU16>': Compact<PerU16>;
|
||||
'Option<PerU16>': Option<PerU16>;
|
||||
'Vec<PerU16>': Vec<PerU16>;
|
||||
PhragmenScore: PhragmenScore;
|
||||
'Option<PhragmenScore>': Option<PhragmenScore>;
|
||||
'Vec<PhragmenScore>': Vec<PhragmenScore>;
|
||||
|
||||
@@ -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; <number>] 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']]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,24 +24,24 @@ export default {
|
||||
start: 'Option<Moment>'
|
||||
},
|
||||
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: {
|
||||
|
||||
@@ -14,26 +14,26 @@ export interface ActiveEraInfo extends Struct {
|
||||
|
||||
/** @name CompactAssignments */
|
||||
export interface CompactAssignments extends Struct {
|
||||
readonly votes1: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes2: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes3: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes4: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes5: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes6: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes7: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes8: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes9: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes10: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes11: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes12: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes13: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes14: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes15: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes16: Vec<ITuple<[AccountId, Vec<CompactScore>, AccountId]>>;
|
||||
readonly votes1: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, NominatorIndex]>>;
|
||||
readonly votes2: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, NominatorIndex]>>;
|
||||
readonly votes3: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, NominatorIndex]>>;
|
||||
readonly votes4: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, NominatorIndex]>>;
|
||||
readonly votes5: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, NominatorIndex]>>;
|
||||
readonly votes6: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, NominatorIndex]>>;
|
||||
readonly votes7: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, NominatorIndex]>>;
|
||||
readonly votes8: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, NominatorIndex]>>;
|
||||
readonly votes9: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, NominatorIndex]>>;
|
||||
readonly votes10: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, NominatorIndex]>>;
|
||||
readonly votes11: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, NominatorIndex]>>;
|
||||
readonly votes12: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, NominatorIndex]>>;
|
||||
readonly votes13: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, NominatorIndex]>>;
|
||||
readonly votes14: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, NominatorIndex]>>;
|
||||
readonly votes15: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, NominatorIndex]>>;
|
||||
readonly votes16: Vec<ITuple<[ValidatorIndex, Vec<CompactScore>, 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<u128> {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user