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:
Stefanie Doll
2019-06-12 19:43:40 +02:00
committed by Jaco Greeff
parent e6aacffd76
commit 6771f9948b
5 changed files with 85 additions and 0 deletions
+13
View File
@@ -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 {
}
+13
View File
@@ -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 {
}
+53
View File
@@ -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;
}
}
+3
View File
@@ -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';