Update for latest substrate Metadata (#761)

This commit is contained in:
Jaco Greeff
2019-03-07 12:06:39 +01:00
committed by GitHub
parent f911abf380
commit 7f8a7f4286
12 changed files with 592 additions and 151 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ There primitive types are available: [[Bool]], [[Bytes]], [[Data]], [[H160]], [[
## Substrate types
These types implement specific types that are found as part of the Substrate base: [[AccountId]], [[AccountIndex]], [[Address]], [[Amount]], [[AssetOf]], [[AttestedCandidate]], [[AuthorityId]], [[Balance]], [[BalanceOf]], [[Block]], [[BlockNumber]], [[CodeHash]], [[Digest]], [[Event]], [[EventRecord]], [[Extrinsic]], [[ExtrinsicEra]], [[ExtrinsicSignature]], [[Gas]], [[Hash]], [[Header]], [[InherentOfflineReport]], [[Justification]], [[KeyValue]], [[MisbehaviorReport]], [[NewAccountOutcome]], [[Nonce]], [[Origin]], [[ParaId]], [[Perbill]], [[Permill]], [[PrefabWasmModule]], [[PropIndex]], [[Proposal]], [[ProposalIndex]], [[ReferendumIndex]], [[ReferendumInfo]], [[Schedule]], [[SeedOf]], [[SessionKey]], [[Signature]], [[SignaturePayload]], [[StoredPendingChange]], [[ValidatorPrefs]], [[VestingSchedule]], [[Vote]], [[VoteIndex]], [[VoteThreshold]]
These types implement specific types that are found as part of the Substrate base: [[AccountId]], [[AccountIndex]], [[Address]], [[Amount]], [[AssetOf]], [[AttestedCandidate]], [[AuthorityId]], [[Balance]], [[BalanceLock]], [[BalanceOf]], [[Block]], [[BlockNumber]], [[CodeHash]], [[Digest]], [[Event]], [[EventRecord]], [[Exposure]], [[Extrinsic]], [[ExtrinsicEra]], [[ExtrinsicSignature]], [[Gas]], [[Hash]], [[Header]], [[IndividualExposure]], [[InherentOfflineReport]], [[Justification]], [[KeyValue]], [[LockIdentifier]], [[MisbehaviorReport]], [[NewAccountOutcome]], [[Nonce]], [[Origin]], [[ParaId]], [[Perbill]], [[Permill]], [[PrefabWasmModule]], [[PropIndex]], [[Proposal]], [[ProposalIndex]], [[ReferendumIndex]], [[ReferendumInfo]], [[RewardDestination]], [[Schedule]], [[SeedOf]], [[SessionKey]], [[Signature]], [[SignaturePayload]], [[StakingLedger]], [[StoredPendingChange]], [[UnlockChunk]], [[ValidatorPrefs]], [[VestingSchedule]], [[Vote]], [[VoteIndex]], [[VoteThreshold]], [[WithdrawReasons]]
## Codec types
@@ -451,6 +451,20 @@
" `system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets",
" collapsed to zero if it ever becomes less than `ExistentialDeposit`."
]
},
{
"name": "Locks",
"modifier": "Default",
"type": {
"MapType": {
"key": "AccountId",
"value": "Vec<BalanceLock>"
}
},
"fallback": "0x00",
"docs": [
" Any liquidity locks on some account balances."
]
}
],
"calls": [
@@ -762,11 +776,109 @@
"PlainType": "Vec<AccountId>"
},
"fallback": "0x00",
"docs": []
},
{
"name": "Invulnerables",
"modifier": "Default",
"type": {
"PlainType": "Vec<AccountId>"
},
"fallback": "0x00",
"docs": [
" Any validators that may never be slashed or forcible kicked. It's a Vec since they're easy to initialise",
" Any validators that may never be slashed or forcibly kicked. It's a Vec since they're easy to initialise",
" and the performance hit is minimal (we expect no more than four invulnerables) and restricted to testnets."
]
},
{
"name": "Bonded",
"modifier": "Optional",
"type": {
"MapType": {
"key": "AccountId",
"value": "AccountId"
}
},
"fallback": "0x00",
"docs": [
" Map from all locked \"stash\" accounts to the controller account."
]
},
{
"name": "Ledger",
"modifier": "Optional",
"type": {
"MapType": {
"key": "AccountId",
"value": "StakingLedger"
}
},
"fallback": "0x00",
"docs": [
" Map from all (unlocked) \"controller\" accounts to the info regarding the staking."
]
},
{
"name": "Payee",
"modifier": "Default",
"type": {
"MapType": {
"key": "AccountId",
"value": "RewardDestination"
}
},
"fallback": "0x00",
"docs": [
" Where the reward payment should be made."
]
},
{
"name": "Validators",
"modifier": "Default",
"type": {
"MapType": {
"key": "AccountId",
"value": "ValidatorPrefs"
}
},
"fallback": "0x0c00",
"docs": [
" The set of keys are all controllers that want to validate.",
" ",
" The values are the preferences that a validator has."
]
},
{
"name": "Nominators",
"modifier": "Default",
"type": {
"MapType": {
"key": "AccountId",
"value": "Vec<AccountId>"
}
},
"fallback": "0x00",
"docs": [
" The set of keys are all controllers that want to nominate.",
" ",
" The value are the nominations."
]
},
{
"name": "Stakers",
"modifier": "Default",
"type": {
"MapType": {
"key": "AccountId",
"value": "Exposure"
}
},
"fallback": "0x000000",
"docs": [
" Nominators for a particular account that is in action right now. You can't iterate through validators here,",
" but you can find them in the `sessions` module."
]
},
{
"name": "CurrentEra",
"modifier": "Default",
@@ -778,73 +890,6 @@
" The current era index."
]
},
{
"name": "ValidatorPreferences",
"modifier": "Default",
"type": {
"MapType": {
"key": "AccountId",
"value": "ValidatorPrefs"
}
},
"fallback": "0x0c00",
"docs": [
" Preferences that a validator has."
]
},
{
"name": "Intentions",
"modifier": "Default",
"type": {
"PlainType": "Vec<AccountId>"
},
"fallback": "0x00",
"docs": [
" All the accounts with a desire to stake."
]
},
{
"name": "Nominating",
"modifier": "Optional",
"type": {
"MapType": {
"key": "AccountId",
"value": "AccountId"
}
},
"fallback": "0x00",
"docs": [
" All nominator -> nominee relationships."
]
},
{
"name": "NominatorsFor",
"modifier": "Default",
"type": {
"MapType": {
"key": "AccountId",
"value": "Vec<AccountId>"
}
},
"fallback": "0x00",
"docs": [
" Nominators for a particular account."
]
},
{
"name": "CurrentNominatorsFor",
"modifier": "Default",
"type": {
"MapType": {
"key": "AccountId",
"value": "Vec<AccountId>"
}
},
"fallback": "0x00",
"docs": [
" Nominators for a particular account that is in action right now."
]
},
{
"name": "CurrentSessionReward",
"modifier": "Default",
@@ -867,6 +912,18 @@
" Slash, per validator that is taken for the first time they are found to be offline."
]
},
{
"name": "CurrentEraReward",
"modifier": "Default",
"type": {
"PlainType": "BalanceOf"
},
"fallback": "0x00000000000000000000000000000000",
"docs": [
" The accumulated reward for the current era. Reset to zero at the beginning of the era and",
" increased for every successfully finished session."
]
},
{
"name": "NextSessionsPerEra",
"modifier": "Optional",
@@ -890,28 +947,16 @@
]
},
{
"name": "StakeRange",
"name": "SlotStake",
"modifier": "Default",
"type": {
"PlainType": "(BalanceOf,BalanceOf)"
"PlainType": "BalanceOf"
},
"fallback": "0x0000000000000000000000000000000000000000000000000000000000000000",
"fallback": "0x00000000000000000000000000000000",
"docs": [
" The highest and lowest staked validator slashable balances."
]
},
{
"name": "Bondage",
"modifier": "Default",
"type": {
"MapType": {
"key": "AccountId",
"value": "BlockNumber"
}
},
"fallback": "0x0000000000000000",
"docs": [
" The block at which the `who`'s funds become entirely liquid."
" The amount of balance actively at stake for each validator slot, currently.",
"",
" This is used to derive rewards and punishments."
]
},
{
@@ -953,67 +998,135 @@
],
"calls": [
{
"name": "stake",
"name": "bond",
"args": [
{
"name": "controller",
"type": "Address"
},
{
"name": "value",
"type": "Compact<BalanceOf>"
},
{
"name": "payee",
"type": "RewardDestination"
}
],
"docs": [
" Take the origin account as a stash and lock up `value` of its balance. `controller` will be the",
" account that controls it."
]
},
{
"name": "bond_extra",
"args": [
{
"name": "max_additional",
"type": "BalanceOf"
}
],
"docs": [
" Add some extra amount that have appeared in the stash `free_balance` into the balance up for",
" staking.",
" ",
" Use this if there are additional funds in your stash account that you wish to bond.",
" ",
" NOTE: This call must be made by the controller, not the stash."
]
},
{
"name": "unbond",
"args": [
{
"name": "value",
"type": "Compact<BalanceOf>"
}
],
"docs": [
" Schedule a portion of the stash to be unlocked ready for transfer out after the bond",
" period ends. If this leaves an amount actively bonded less than ",
" T::Currency::existential_deposit(), then it is increased to the full amount.",
" ",
" Once the unlock period is done, you can call `withdraw_unbonded` to actually move",
" the funds out of management ready for transfer. ",
" ",
" NOTE: This call must be made by the controller, not the stash.",
" ",
" See also `withdraw_unbonded`."
]
},
{
"name": "withdraw_unbonded",
"args": [],
"docs": [
" Declare the desire to stake for the transactor.",
"",
" Effects will be felt at the beginning of the next era."
" Remove any unlocked chunks from the `unlocking` queue from our management.",
" ",
" This essentially frees up that balance to be used by the stash account to do",
" whatever it wants.",
" ",
" NOTE: This call must be made by the controller, not the stash.",
" ",
" See also `unbond`."
]
},
{
"name": "unstake",
"name": "validate",
"args": [
{
"name": "intentions_index",
"type": "Compact<u32>"
}
],
"docs": [
" Retract the desire to stake for the transactor.",
"",
" Effects will be felt at the beginning of the next era."
]
},
{
"name": "nominate",
"args": [
{
"name": "target",
"type": "Address"
}
],
"docs": []
},
{
"name": "unnominate",
"args": [
{
"name": "target_index",
"type": "Compact<u32>"
}
],
"docs": [
" Will panic if called when source isn't currently nominating target.",
" Updates Nominating, NominatorsFor and NominationBalance."
]
},
{
"name": "register_preferences",
"args": [
{
"name": "intentions_index",
"type": "Compact<u32>"
},
{
"name": "prefs",
"type": "ValidatorPrefs"
}
],
"docs": [
" Set the given account's preference for slashing behaviour should they be a validator.",
" Declare the desire to validate for the origin controller.",
"",
" An error (no-op) if `Self::intentions()[intentions_index] != origin`."
" Effects will be felt at the beginning of the next era.",
" ",
" NOTE: This call must be made by the controller, not the stash."
]
},
{
"name": "nominate",
"args": [
{
"name": "targets",
"type": "Vec<Address>"
}
],
"docs": [
" Declare the desire to nominate `targets` for the origin controller.",
"",
" Effects will be felt at the beginning of the next era.",
" ",
" NOTE: This call must be made by the controller, not the stash."
]
},
{
"name": "chill",
"args": [],
"docs": [
" Declare no desire to either validate or nominate.",
"",
" Effects will be felt at the beginning of the next era.",
" ",
" NOTE: This call must be made by the controller, not the stash."
]
},
{
"name": "set_payee",
"args": [
{
"name": "payee",
"type": "RewardDestination"
}
],
"docs": [
" (Re-)set the payment target for a controller.",
"",
" Effects will be felt at the beginning of the next era.",
" ",
" NOTE: This call must be made by the controller, not the stash."
]
},
{
@@ -1268,20 +1381,6 @@
" Queue of successful referenda to be dispatched."
]
},
{
"name": "Bondage",
"modifier": "Default",
"type": {
"MapType": {
"key": "AccountId",
"value": "BlockNumber"
}
},
"fallback": "0x0000000000000000",
"docs": [
" The block at which the `who`'s funds become liquid."
]
},
{
"name": "VotersFor",
"modifier": "Default",
@@ -2215,6 +2314,27 @@
}
]
},
{
"name": "finality_tracker",
"prefix": "",
"storage": null,
"calls": [
{
"name": "final_hint",
"args": [
{
"name": "hint",
"type": "Compact<BlockNumber>"
}
],
"docs": [
" Hint that the author of this block thinks the best finalized",
" block is the given number."
]
}
],
"events": null
},
{
"name": "grandpa",
"prefix": "GrandpaFinality",
@@ -2227,6 +2347,15 @@
},
"fallback": "0x00",
"docs": []
},
{
"name": "NextForced",
"modifier": "Optional",
"type": {
"PlainType": "BlockNumber"
},
"fallback": "0x00",
"docs": []
}
],
"calls": [
File diff suppressed because one or more lines are too long
+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 BlockNumber from './BlockNumber';
import LockIdentifier from './LockIdentifier';
import WithdrawReasons from './WithdrawReasons';
/**
* @name BalanceLock
* @description
* The Substrate BalanceLock for staking
*/
export default class BalanceLock extends Struct {
constructor (value?: any) {
super({
id: LockIdentifier,
amount: Balance,
until: BlockNumber,
reasons: WithdrawReasons
}, value);
}
/**
* @description The amount
*/
get amount (): Balance {
return this.get('amount') as Balance;
}
/**
* @description The lock id
*/
get id (): LockIdentifier {
return this.get('id') as LockIdentifier;
}
/**
* @description The reasons
*/
get reasons (): WithdrawReasons {
return this.get('reasons') as WithdrawReasons;
}
/**
* @description Until when this is available
*/
get until (): BlockNumber {
return this.get('until') as BlockNumber;
}
}
+45
View File
@@ -0,0 +1,45 @@
// 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 Compact from '../codec/Compact';
import Struct from '../codec/Struct';
import Vector from '../codec/Vector';
import Balance from './Balance';
import IndividualExposure from './IndividualExposure';
/**
* @name Exposure
* @description
* A snapshot of the stake backing a single validator in the system
*/
export default class Exposure extends Struct {
constructor (value?: any) {
super({
total: Compact.with(Balance),
own: Compact.with(Balance),
others: Vector.with(IndividualExposure)
}, value);
}
/**
* @description The validator's own stash that is exposed
*/
get own (): Balance {
return (this.get('own') as Compact).toBn() as Balance;
}
/**
* @description The total balance backing this validator
*/
get total (): Balance {
return (this.get('total') as Compact).toBn() as Balance;
}
/**
* @description The portions of nominators stashes that are exposed
*/
get others (): Vector<IndividualExposure> {
return this.get('others') as Vector<IndividualExposure>;
}
}
@@ -0,0 +1,36 @@
// 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 Compact from '../codec/Compact';
import Struct from '../codec/Struct';
import AccountId from './AccountId';
import Balance from './Balance';
/**
* @name IndividualExposure
* @description
* The Substrate IndividualExposure for staking
*/
export default class IndividualExposure extends Struct {
constructor (value?: any) {
super({
who: AccountId,
value: Compact.with(Balance)
}, value);
}
/**
* @description The value
*/
get value (): Balance {
return (this.get('value') as Compact).toBn() as Balance;
}
/**
* @description The AccountId
*/
get who (): AccountId {
return this.get('who') as AccountId;
}
}
+16
View File
@@ -0,0 +1,16 @@
// 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 U8aFixed from '../codec/U8aFixed';
/**
* @name LockIdentifier
* @description
* The Substrate LockIdentifier for staking
*/
export default class LockIdentifier extends U8aFixed {
constructor (value?: any) {
super(value, 64); // [u8; 8]
}
}
@@ -0,0 +1,23 @@
// 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 Enum from '../codec/Enum';
/**
* @name RewardDestination
* @description
* A destination account for payment
*/
export default class RewardDestination extends Enum {
constructor (value?: any) {
super([
// Pay into the stash account, increasing the amount at stake accordingly.
'Staked',
// Pay into the stash account, not increasing the amount at stake.
'Stash',
// Pay into the controller account.
'Controller'
], value);
}
}
+55
View File
@@ -0,0 +1,55 @@
// 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 Compact from '../codec/Compact';
import Struct from '../codec/Struct';
import Vector from '../codec/Vector';
import AccountId from './AccountId';
import Balance from './Balance';
import BlockNumber from './BlockNumber';
import UnlockChunk from './UnlockChunk';
/**
* @name StakingLedger
* @description
* The ledger of a (bonded) stash
*/
export default class StakingLedger extends Struct {
constructor (value?: any) {
super({
stash: AccountId,
total: Compact.with(Balance),
active: Compact.with(Balance),
unlocking: Vector.with(UnlockChunk)
}, value);
}
/**
* @description The total amount of the stash's balance that will be at stake in any forthcoming rounds
*/
get active (): Balance {
return (this.get('active') as Compact).toBn() as BlockNumber;
}
/**
* @description The stash account whose balance is actually locked and at stake
*/
get stash (): AccountId {
return this.get('stash') as AccountId;
}
/**
* @description The total amount of the stash's balance that we are currently accounting for. It's just `active` plus all the `unlocking` balances
*/
get total (): Balance {
return (this.get('total') as Compact).toBn() as Balance;
}
/**
* @description Any balance that is becoming free, which may eventually be transferred out of the stash (assuming it doesn't get slashed first)
*/
get unlocking (): Vector<UnlockChunk> {
return this.get('unlocking') as Vector<UnlockChunk>;
}
}
+36
View File
@@ -0,0 +1,36 @@
// 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 Compact from '../codec/Compact';
import Struct from '../codec/Struct';
import Balance from './Balance';
import BlockNumber from './BlockNumber';
/**
* @name UnlockChunk
* @description
* Just a Balance/BlockNumber tuple to encode when a chunk of funds will be unlocked
*/
export default class UnlockChunk extends Struct {
constructor (value?: any) {
super({
value: Compact.with(Balance),
era: Compact.with(BlockNumber)
}, value);
}
/**
* @description Era number at which point it'll be unlocked
*/
get era (): BlockNumber {
return (this.get('era') as Compact).toBn() as BlockNumber;
}
/**
* @description Amount of funds to be unlocked
*/
get value (): Balance {
return (this.get('value') as Compact).toBn() as Balance;
}
}
@@ -0,0 +1,41 @@
// 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 Set from '../codec/Set';
/**
* @name WithdrawReasons
* @description
* The Substrate WithdrawReasons for staking
*/
export default class WithdrawReasons extends Set {
constructor (value: any = ['header', 'body', 'justification']) {
super({
TransactionPayment: 0b00000001,
Transfer: 0b00000010,
Reserve: 0b00000100
}, value);
}
/**
* @description In order to reserve some funds for a later return or repatriation
*/
get isReserve (): boolean {
return this.values.includes('Reserve');
}
/**
* @description In order to pay for (system) transaction costs
*/
get isTransactionPayment (): boolean {
return this.values.includes('TransactionPayment');
}
/**
* @description In order to transfer ownership
*/
get isTransfer (): boolean {
return this.values.includes('Transfer');
}
}
+8 -1
View File
@@ -16,6 +16,7 @@ export { default as AssetOf } from './AssetOf';
export { default as AttestedCandidate } from './AttestedCandidate';
export { default as AuthorityId } from './AuthorityId';
export { default as Balance, BalanceOf } from './Balance';
export { default as BalanceLock } from './BalanceLock';
// NOTE Bft items are only used in internal structures
// export * from './Bft;
export { default as Block } from './Block';
@@ -24,6 +25,7 @@ export { default as CodeHash } from './CodeHash';
export { default as Digest, DigestItem } from './Digest';
export { default as Event } from './Event';
export { default as EventRecord } from './EventRecord';
export { default as Exposure } from './Exposure';
export { default as Extrinsic } from './Extrinsic';
export { default as ExtrinsicEra } from './ExtrinsicEra';
export { default as ExtrinsicSignature } from './ExtrinsicSignature';
@@ -32,8 +34,10 @@ export { default as ExtrinsicSignature } from './ExtrinsicSignature';
export { default as Gas } from './Gas';
export { default as Hash } from './Hash';
export { default as Header, HeaderExtended } from './Header';
export { default as IndividualExposure } from './IndividualExposure';
export { default as InherentOfflineReport } from './InherentOfflineReport';
export { default as KeyValue } from './KeyValue';
export { default as LockIdentifier } from './LockIdentifier';
export { default as LockPeriods } from './LockPeriods';
export { default as MisbehaviorReport } from './MisbehaviorReport';
export { default as NewAccountOutcome } from './NewAccountOutcome';
@@ -51,14 +55,17 @@ export { default as Proposal } from './Proposal';
export { default as ProposalIndex } from './ProposalIndex';
export { default as ReferendumIndex } from './ReferendumIndex';
export { default as ReferendumInfo } from './ReferendumInfo';
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 Signature, Ed25519Signature, Sr25519Signature } from './Signature';
export { default as StakingLedger } from './StakingLedger';
export { default as StoredPendingChange } from './StoredPendingChange';
export { default as UnlockChunk } from './UnlockChunk';
export { default as ValidatorPrefs } from './ValidatorPrefs';
export { default as VestingSchedule } from './VestingSchedule';
export { default as Vote } from './Vote';
export { default as VoteThreshold } from './VoteThreshold';
export { default as VoteIndex } from './VoteIndex';
export { default as WithdrawReasons } from './WithdrawReasons';