New democracy types (#2078)

* New democracy types

* ReferendumInfo

* Adjust democracy derives

* Spring cleaning

* Remove ReferendumInfoExtended
This commit is contained in:
Jaco Greeff
2020-03-22 11:05:57 +01:00
committed by GitHub
parent 7a1bdb18a8
commit 7a7d6e9b8a
9 changed files with 254 additions and 89 deletions
+40 -1
View File
@@ -12,7 +12,7 @@ import { EthereumAddress } from '@polkadot/types/interfaces/claims';
import { MemberCount, ProposalIndex, Votes, VotesTo230 } from '@polkadot/types/interfaces/collective';
import { AuthorityId } from '@polkadot/types/interfaces/consensus';
import { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultSuccess, ContractInfo, ContractStorageKey, Gas, PrefabWasmModule, PrefabWasmModuleReserved, Schedule, ScheduleTo212, SeedOf, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
import { Conviction, PropIndex, Proposal, ProxyState, ReferendumIndex, ReferendumInfo } from '@polkadot/types/interfaces/democracy';
import { AccountVote, AccountVoteSplit, AccountVoteStandard, Conviction, Delegations, PriorLock, PropIndex, Proposal, ProxyState, ReferendumIndex, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, ReferendumStatus, Tally, Voting, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces/democracy';
import { ApprovalFlag, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from '@polkadot/types/interfaces/elections';
import { CreatedBlock, ImportedAux } from '@polkadot/types/interfaces/engine';
import { Account, Log } from '@polkadot/types/interfaces/evm';
@@ -410,9 +410,24 @@ declare module '@polkadot/types/types/registry' {
TrieId: TrieId;
'Option<TrieId>': Option<TrieId>;
'Vec<TrieId>': Vec<TrieId>;
AccountVote: AccountVote;
'Option<AccountVote>': Option<AccountVote>;
'Vec<AccountVote>': Vec<AccountVote>;
AccountVoteSplit: AccountVoteSplit;
'Option<AccountVoteSplit>': Option<AccountVoteSplit>;
'Vec<AccountVoteSplit>': Vec<AccountVoteSplit>;
AccountVoteStandard: AccountVoteStandard;
'Option<AccountVoteStandard>': Option<AccountVoteStandard>;
'Vec<AccountVoteStandard>': Vec<AccountVoteStandard>;
Conviction: Conviction;
'Option<Conviction>': Option<Conviction>;
'Vec<Conviction>': Vec<Conviction>;
Delegations: Delegations;
'Option<Delegations>': Option<Delegations>;
'Vec<Delegations>': Vec<Delegations>;
PriorLock: PriorLock;
'Option<PriorLock>': Option<PriorLock>;
'Vec<PriorLock>': Vec<PriorLock>;
PropIndex: PropIndex;
'Compact<PropIndex>': Compact<PropIndex>;
'Option<PropIndex>': Option<PropIndex>;
@@ -427,9 +442,33 @@ declare module '@polkadot/types/types/registry' {
'Compact<ReferendumIndex>': Compact<ReferendumIndex>;
'Option<ReferendumIndex>': Option<ReferendumIndex>;
'Vec<ReferendumIndex>': Vec<ReferendumIndex>;
ReferendumInfoTo239: ReferendumInfoTo239;
'Option<ReferendumInfoTo239>': Option<ReferendumInfoTo239>;
'Vec<ReferendumInfoTo239>': Vec<ReferendumInfoTo239>;
ReferendumInfo: ReferendumInfo;
'Option<ReferendumInfo>': Option<ReferendumInfo>;
'Vec<ReferendumInfo>': Vec<ReferendumInfo>;
ReferendumInfoFinished: ReferendumInfoFinished;
'Option<ReferendumInfoFinished>': Option<ReferendumInfoFinished>;
'Vec<ReferendumInfoFinished>': Vec<ReferendumInfoFinished>;
ReferendumStatus: ReferendumStatus;
'Option<ReferendumStatus>': Option<ReferendumStatus>;
'Vec<ReferendumStatus>': Vec<ReferendumStatus>;
Tally: Tally;
'Option<Tally>': Option<Tally>;
'Vec<Tally>': Vec<Tally>;
Voting: Voting;
'Option<Voting>': Option<Voting>;
'Vec<Voting>': Vec<Voting>;
VotingDirect: VotingDirect;
'Option<VotingDirect>': Option<VotingDirect>;
'Vec<VotingDirect>': Vec<VotingDirect>;
VotingDirectVote: VotingDirectVote;
'Option<VotingDirectVote>': Option<VotingDirectVote>;
'Vec<VotingDirectVote>': Vec<VotingDirectVote>;
VotingDelegating: VotingDelegating;
'Option<VotingDelegating>': Option<VotingDelegating>;
'Vec<VotingDelegating>': Vec<VotingDelegating>;
ApprovalFlag: ApprovalFlag;
'Compact<ApprovalFlag>': Compact<ApprovalFlag>;
'Option<ApprovalFlag>': Option<ApprovalFlag>;
@@ -26,9 +26,28 @@ export { AllConvictions };
export default {
rpc: {},
types: {
AccountVote: {
_enum: {
Standard: 'AccountVoteStandard',
Split: 'AccountVoteSplit'
}
},
AccountVoteSplit: {
aye: 'Balance',
nay: 'Balance'
},
AccountVoteStandard: {
vote: 'Vote',
balance: 'Balance'
},
Conviction: {
_enum: AllConvictions
},
Delegations: {
votes: 'Balance',
capital: 'Balance'
},
PriorLock: '(BlockNumber, Balance)',
PropIndex: 'u32',
Proposal: 'Call',
ProxyState: {
@@ -36,11 +55,52 @@ export default {
Active: 'AccountId'
},
ReferendumIndex: 'u32',
ReferendumInfo: {
ReferendumInfoTo239: {
end: 'BlockNumber',
proposalHash: 'Hash',
threshold: 'VoteThreshold',
delay: 'BlockNumber'
},
ReferendumInfo: {
_enum: {
Ongoing: 'ReferendumStatus',
Finished: 'ReferendumInfoFinished'
}
},
ReferendumInfoFinished: {
approved: 'bool',
end: 'BlockNumber'
},
ReferendumStatus: {
end: 'BlockNumber',
proposalHash: 'Hash',
threshold: 'VoteThreshold',
delay: 'BlockNumber',
tally: 'Tally'
},
Tally: {
ayes: 'Balance',
nays: 'Balance',
turnout: 'Balance'
},
Voting: {
_enum: {
Direct: 'VotingDirect',
Delegating: 'VotingDelegating'
}
},
VotingDirect: {
votes: 'Vec<VotingDirectVote>',
delegations: 'Delegations',
prior: 'PriorLock'
},
VotingDirectVote: '(ReferendumIndex, AccountVote)',
VotingDelegating: {
balance: 'Balance',
target: 'AccountId',
conviction: 'Conviction',
delegations: 'Delegations',
prior: 'PriorLock'
}
}
} as Definitions;
@@ -1,10 +1,31 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import { Enum, Struct } from '@polkadot/types/codec';
import { u32 } from '@polkadot/types/primitive';
import { VoteThreshold } from '@polkadot/types/interfaces/elections';
import { AccountId, BlockNumber, Call, Hash } from '@polkadot/types/interfaces/runtime';
import { ITuple } from '@polkadot/types/types';
import { Enum, Struct, Vec } from '@polkadot/types/codec';
import { bool, u32 } from '@polkadot/types/primitive';
import { Vote, VoteThreshold } from '@polkadot/types/interfaces/elections';
import { AccountId, Balance, BlockNumber, Call, Hash } from '@polkadot/types/interfaces/runtime';
/** @name AccountVote */
export interface AccountVote extends Enum {
readonly isStandard: boolean;
readonly asStandard: AccountVoteStandard;
readonly isSplit: boolean;
readonly asSplit: AccountVoteSplit;
}
/** @name AccountVoteSplit */
export interface AccountVoteSplit extends Struct {
readonly aye: Balance;
readonly nay: Balance;
}
/** @name AccountVoteStandard */
export interface AccountVoteStandard extends Struct {
readonly vote: Vote;
readonly balance: Balance;
}
/** @name Conviction */
export interface Conviction extends Enum {
@@ -17,6 +38,15 @@ export interface Conviction extends Enum {
readonly isLocked6X: boolean;
}
/** @name Delegations */
export interface Delegations extends Struct {
readonly votes: Balance;
readonly capital: Balance;
}
/** @name PriorLock */
export interface PriorLock extends ITuple<[BlockNumber, Balance]> {}
/** @name PropIndex */
export interface PropIndex extends u32 {}
@@ -33,11 +63,68 @@ export interface ProxyState extends Struct {
export interface ReferendumIndex extends u32 {}
/** @name ReferendumInfo */
export interface ReferendumInfo extends Struct {
export interface ReferendumInfo extends Enum {
readonly isOngoing: boolean;
readonly asOngoing: ReferendumStatus;
readonly isFinished: boolean;
readonly asFinished: ReferendumInfoFinished;
}
/** @name ReferendumInfoFinished */
export interface ReferendumInfoFinished extends Struct {
readonly approved: bool;
readonly end: BlockNumber;
}
/** @name ReferendumInfoTo239 */
export interface ReferendumInfoTo239 extends Struct {
readonly end: BlockNumber;
readonly proposalHash: Hash;
readonly threshold: VoteThreshold;
readonly delay: BlockNumber;
}
/** @name ReferendumStatus */
export interface ReferendumStatus extends Struct {
readonly end: BlockNumber;
readonly proposalHash: Hash;
readonly threshold: VoteThreshold;
readonly delay: BlockNumber;
readonly tally: Tally;
}
/** @name Tally */
export interface Tally extends Struct {
readonly ayes: Balance;
readonly nays: Balance;
readonly turnout: Balance;
}
/** @name Voting */
export interface Voting extends Enum {
readonly isDirect: boolean;
readonly asDirect: VotingDirect;
readonly isDelegating: boolean;
readonly asDelegating: VotingDelegating;
}
/** @name VotingDelegating */
export interface VotingDelegating extends Struct {
readonly balance: Balance;
readonly target: AccountId;
readonly conviction: Conviction;
readonly delegations: Delegations;
readonly prior: PriorLock;
}
/** @name VotingDirect */
export interface VotingDirect extends Struct {
readonly votes: Vec<VotingDirectVote>;
readonly delegations: Delegations;
readonly prior: PriorLock;
}
/** @name VotingDirectVote */
export interface VotingDirectVote extends ITuple<[ReferendumIndex, AccountVote]> {}
export type PHANTOM_DEMOCRACY = 'democracy';
+21 -2
View File
@@ -53,9 +53,17 @@ const TYPES_POLKADOT_VERSIONED: OverrideVersionedType[] = [
}
},
{
minmax: [1004, undefined],
minmax: [1004, 1004],
types: {
// Indices optional, not in transaction
Address: 'AccountId',
Keys: 'SessionKeys5',
ReferendumInfo: 'ReferendumInfoTo239'
}
},
{
minmax: [1005, undefined],
types: {
Address: 'AccountId',
Keys: 'SessionKeys5'
}
@@ -71,6 +79,7 @@ const TYPES_KUSAMA_VERSIONED: OverrideVersionedType[] = [
BalanceLock: 'BalanceLockTo212',
DispatchError: 'DispatchErrorTo198',
Keys: 'SessionKeys5',
ReferendumInfo: 'ReferendumInfoTo239',
SlashingSpans: 'SlashingSpansTo204',
StakingLedger: 'StakingLedgerTo223',
Votes: 'VotesTo230'
@@ -82,6 +91,7 @@ const TYPES_KUSAMA_VERSIONED: OverrideVersionedType[] = [
Address: 'GenericAddress',
BalanceLock: 'BalanceLockTo212',
Keys: 'SessionKeys5',
ReferendumInfo: 'ReferendumInfoTo239',
SlashingSpans: 'SlashingSpansTo204',
StakingLedger: 'StakingLedgerTo223',
Votes: 'VotesTo230'
@@ -94,15 +104,24 @@ const TYPES_KUSAMA_VERSIONED: OverrideVersionedType[] = [
Address: 'GenericAddress',
BalanceLock: 'BalanceLockTo212',
Keys: 'SessionKeys5',
ReferendumInfo: 'ReferendumInfoTo239',
StakingLedger: 'StakingLedgerTo223',
Votes: 'VotesTo230'
}
},
{
// actual at 1050 (1046-1049 is dev)
minmax: [1046, undefined],
minmax: [1046, 1054],
types: {
// Indices optional, not in transaction
Address: 'AccountId',
Keys: 'SessionKeys5',
ReferendumInfo: 'ReferendumInfoTo239'
}
},
{
minmax: [1055, undefined],
types: {
Address: 'AccountId',
Keys: 'SessionKeys5'
}