Added types for ApprovalFlag, SetIndex, VoterInfo (#996)
* Added types for ApprovalFlag, SetIndex, VoterInfo * Delete VoterInfo * Fixed typo ApprovalIndex => ApprovalFlag * Added VoterInfo * newline & whitespace
This commit is contained in:
committed by
Jaco Greeff
parent
e6aacffd76
commit
6771f9948b
@@ -76,6 +76,7 @@ These custom types implement specific types that are found as part of the Substr
|
||||
| **Types** | |
|
||||
| --- | --- |
|
||||
| [[Amount]] | The Substrate Amount representation as a [[Balance]] |
|
||||
| [[ApprovalFlag]] | Approval flag, implemented as a [[U32]] |
|
||||
| [[AssetOf]] | The Substrate AssetOf representation as a [[Balance]] |
|
||||
| [[AttestedCandidate]] | An attested candidate |
|
||||
| [[AuthorityId]] | Wrapper for a AuthorityId. Same as an normal AccountId |
|
||||
@@ -128,6 +129,7 @@ These custom types implement specific types that are found as part of the Substr
|
||||
| [[Seal]] | Log item indicating a sealing event |
|
||||
| [[SeedOf]] | The Substrate SeedOf representation as a [[Hash]] |
|
||||
| [[SessionKey]] | Wrapper for a SessionKey. Same as an normal [[AuthorityId]], i.e. a wrapper around publicKey |
|
||||
| [[SetIndex]] | Set index, implemented as a [[U32]] |
|
||||
| [[Signature]] | The default signature that is used accross the system |
|
||||
| [[SignaturePayload]] | A signing payload for an [[Extrinsic]]. For the final encoding, it is variable length based on the contents included |
|
||||
| [[SignaturePayloadRaw]] | A version of the [[SignaturePayload]] where it doesn't rely on [[Method]] with metadata, rather it treats the values as a raw byte stream |
|
||||
@@ -140,6 +142,7 @@ These custom types implement specific types that are found as part of the Substr
|
||||
| [[Vote]] | A number of lock periods, plus a vote, one way or the other |
|
||||
| [[Votes]] | Info for keeping track of a council motion being voted on. |
|
||||
| [[VoteIndex]] | Voting index, implemented as a [[U32]] |
|
||||
| [[VoterInfo]] | The activity status of a voter. |
|
||||
| [[VoteThreshold]] | Voting threshold, used inside proposals to set change the voting tally |
|
||||
| [[WithdrawReasons]] | The Substrate WithdrawReasons for staking |
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2017-2019 @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 U32 from '../primitive/U32';
|
||||
|
||||
/**
|
||||
* @name ApprovalFlag
|
||||
* @description
|
||||
* Approval Flag, implemented as a [[U32]]
|
||||
*/
|
||||
export default class ApprovalFlag extends U32 {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2017-2019 @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 U32 from '../primitive/U32';
|
||||
|
||||
/**
|
||||
* @name SetIndex
|
||||
* @description
|
||||
* Set index, implemented as a [[U32]]
|
||||
*/
|
||||
export default class SetIndex extends U32 {
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// Copyright 2017-2019 @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 Struct from '../codec/Struct';
|
||||
import Balance from './Balance';
|
||||
import VoteIndex from './VoteIndex';
|
||||
|
||||
/**
|
||||
* @name VoterInfo
|
||||
* @description
|
||||
* The activity status of a voter.
|
||||
*/
|
||||
|
||||
export default class VoterInfo extends Struct {
|
||||
constructor (value?: any) {
|
||||
super({
|
||||
lastActive: VoteIndex,
|
||||
lastWin: VoteIndex,
|
||||
pot: Balance,
|
||||
stake: Balance
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Last VoteIndex in which this voter assigned (or initialized) approvals.
|
||||
*/
|
||||
get lastActive (): VoteIndex {
|
||||
return this.get('lastActive') as VoteIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Last VoteIndex in which one of this voter's approvals won.
|
||||
* Note that `last_win = N` indicates a last win at index `N-1`, hence `last_win = 0` means no win ever.
|
||||
*/
|
||||
get lastWin (): VoteIndex {
|
||||
return this.get('lastWin') as VoteIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The amount of stored weight as a result of not winning but changing approvals.
|
||||
*/
|
||||
get pot (): Balance {
|
||||
return this.get('pot') as Balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Current staked amount. A lock equal to this value always exists.
|
||||
*/
|
||||
get stake (): Balance {
|
||||
return this.get('stake') as Balance;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
* @summary Type definitions that are used in the system
|
||||
*/
|
||||
export { default as Amount } from './Amount';
|
||||
export { default as ApprovalFlag } from './ApprovalFlag';
|
||||
export { default as AssetOf } from './AssetOf';
|
||||
export { default as AttestedCandidate } from './AttestedCandidate';
|
||||
export { default as AuthorityId } from './AuthorityId';
|
||||
@@ -54,6 +55,7 @@ export { default as RewardDestination } from './RewardDestination';
|
||||
export { default as Schedule } from './Schedule';
|
||||
export { default as SeedOf } from './SeedOf';
|
||||
export { default as SessionKey } from './SessionKey';
|
||||
export { default as SetIndex } from './SetIndex';
|
||||
export { default as Signature, Ed25519Signature, Sr25519Signature } from './Signature';
|
||||
export { default as SignaturePayload, SignaturePayloadRaw } from './SignaturePayload';
|
||||
export { default as StakingLedger } from './StakingLedger';
|
||||
@@ -66,4 +68,5 @@ export { default as Vote } from './Vote';
|
||||
export { default as Votes } from './Votes';
|
||||
export { default as VoteThreshold } from './VoteThreshold';
|
||||
export { default as VoteIndex } from './VoteIndex';
|
||||
export { default as VoterInfo } from './VoterInfo';
|
||||
export { default as WithdrawReasons } from './WithdrawReasons';
|
||||
|
||||
Reference in New Issue
Block a user