Additional derives for new staking points & rewards (#1994)

* Additional derives for new staking points & rewards

* Fix method name

* StakingLedger update

* Expand derives

* Cleanups

* Cleanup Compact decode

* Cleanup derives

* Update CHANGELOG

* Split types
This commit is contained in:
Jaco Greeff
2020-03-05 15:37:34 +01:00
committed by GitHub
parent 62ef032594
commit aaf1273794
19 changed files with 405 additions and 122 deletions
+1 -4
View File
@@ -29,7 +29,7 @@ import { ApiId, BlockHash, ChainProperties, ExtrinsicOrHash, ExtrinsicStatus, He
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, DispatchClass, DispatchInfo, DispatchInfoTo190, Fixed64, H160, H256, H512, Hash, Header, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, Moment, Origin, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Seal, SealV0, SignedBlock, StorageData, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
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, RewardDestination, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerNew, StakingLedgerTo223, 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, PhragmenScore, Points, RewardDestination, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking';
import { AccountInfo, DigestOf, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Key, Phase, RefCount } from '@polkadot/types/interfaces/system';
import { OpenTip, OpenTipFinder, OpenTipTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
import { Multiplier } from '@polkadot/types/interfaces/txpayment';
@@ -773,9 +773,6 @@ declare module '@polkadot/types/types/registry' {
StakingLedgerTo223: StakingLedgerTo223;
'Option<StakingLedgerTo223>': Option<StakingLedgerTo223>;
'Vec<StakingLedgerTo223>': Vec<StakingLedgerTo223>;
StakingLedgerNew: StakingLedgerNew;
'Option<StakingLedgerNew>': Option<StakingLedgerNew>;
'Vec<StakingLedgerNew>': Vec<StakingLedgerNew>;
StakingLedger: StakingLedger;
'Option<StakingLedger>': Option<StakingLedger>;
'Vec<StakingLedger>': Vec<StakingLedger>;
+1 -1
View File
@@ -103,7 +103,7 @@ export default abstract class AbstractInt extends BN implements Codec {
/**
* @description Returns the number of bits in the value
*/
public bitLength (): UIntBitLength {
public bitLength (): number {
return this.#bitLength;
}
+3 -3
View File
@@ -13,7 +13,7 @@ import { UIntBitLength } from './AbstractInt';
import Base from './Base';
export interface CompactEncodable extends Codec {
bitLength (): UIntBitLength;
bitLength (): number;
toBn (): BN;
toNumber (): number;
}
@@ -64,7 +64,7 @@ export default class Compact<T extends CompactEncodable> extends Base<T> impleme
return new Type(registry, value);
}
const [, _value] = Compact.decodeU8a(value, new Type(registry, 0).bitLength());
const [, _value] = Compact.decodeU8a(value, new Type(registry, 0).bitLength() as UIntBitLength);
return new Type(registry, _value);
}
@@ -72,7 +72,7 @@ export default class Compact<T extends CompactEncodable> extends Base<T> impleme
/**
* @description Returns the number of bits in the value
*/
public bitLength (): UIntBitLength {
public bitLength (): number {
return this.raw.bitLength();
}
@@ -122,14 +122,13 @@ export default {
unlocking: 'Vec<UnlockChunk>'
},
// TODO Enable as default when new staking payouts go live
StakingLedgerNew: {
StakingLedger: {
stash: 'AccountId',
total: 'Compact<Balance>',
active: 'Compact<Balance>',
unlocking: 'Vec<UnlockChunk>',
nextReward: 'EraIndex'
lastReward: 'Option<EraIndex>'
},
StakingLedger: 'StakingLedgerTo223',
UnappliedSlashOther: '(AccountId, Balance)',
UnappliedSlash: {
validator: 'AccountId',
@@ -160,15 +160,12 @@ export interface SpanRecord extends Struct {
}
/** @name StakingLedger */
export interface StakingLedger extends StakingLedgerTo223 {}
/** @name StakingLedgerNew */
export interface StakingLedgerNew extends Struct {
export interface StakingLedger extends Struct {
readonly stash: AccountId;
readonly total: Compact<Balance>;
readonly active: Compact<Balance>;
readonly unlocking: Vec<UnlockChunk>;
readonly nextReward: EraIndex;
readonly lastReward: Option<EraIndex>;
}
/** @name StakingLedgerTo223 */
+1 -2
View File
@@ -94,8 +94,7 @@ const TYPES_KUSAMA_VERSIONED: OverrideVersionedType[] = [
types: {
// Indices optional, not in transaction
Address: 'AccountId',
Keys: 'SessionKeys5',
StakingLedger: 'StakingLedgerTo223'
Keys: 'SessionKeys5'
}
}
];