Document available Api Derives (#6106)
* document derives from accounts to democracy * Derive Documentation progress * Derive Documentation progress * tx and staking docs * Staking docs progress * more staking docs * Staking module complete * imonline, elections and progress in democracy * Document missing derives * lint
This commit is contained in:
@@ -67,6 +67,18 @@ function empty (api: DeriveApi): Observable<DeriveSessionIndexes> {
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @name indexes
|
||||
* @description Retrieves session-related index data, adapting to whether
|
||||
* the chain has staking enabled.
|
||||
* @example
|
||||
* ```javascript
|
||||
* api.derive.session.indexes((indexes) => {
|
||||
* console.log(`Current session index: ${indexes.currentIndex}`);
|
||||
* console.log(`Validator count: ${indexes.validatorCount}`);
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function indexes (instanceId: string, api: DeriveApi): () => Observable<DeriveSessionIndexes> {
|
||||
return memo(instanceId, (): Observable<DeriveSessionIndexes> =>
|
||||
api.query.session
|
||||
|
||||
@@ -11,7 +11,14 @@ import { objectSpread } from '@polkadot/util';
|
||||
import { memo } from '../util/index.js';
|
||||
|
||||
/**
|
||||
* @description Retrieves all the session and era query and calculates specific values on it as the length of the session and eras
|
||||
* @name info
|
||||
* @description Retrieves all the session and era query and calculates specific values on it as the length of the session and eras.
|
||||
* @example
|
||||
* ```javascript
|
||||
* api.derive.session.info((info) => {
|
||||
* console.log(`Session info ${JSON.stringify(info)}`);
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function info (instanceId: string, api: DeriveApi): () => Observable<DeriveSessionInfo> {
|
||||
return memo(instanceId, (): Observable<DeriveSessionInfo> =>
|
||||
|
||||
@@ -74,7 +74,14 @@ function queryBabe (api: DeriveApi): Observable<[DeriveSessionInfo, ResultSlotsF
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Retrieves all the session and era query and calculates specific values on it as the length of the session and eras
|
||||
* @name progress
|
||||
* @description Retrieves session information and progress.
|
||||
* @example
|
||||
* ```javascript
|
||||
* api.derive.session.progress((progress) => {
|
||||
* console.log(`Session progress ${JSON.stringify(progress)}`);
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function progress (instanceId: string, api: DeriveApi): () => Observable<DeriveSessionProgress> {
|
||||
return memo(instanceId, (): Observable<DeriveSessionProgress> =>
|
||||
@@ -88,6 +95,36 @@ export function progress (instanceId: string, api: DeriveApi): () => Observable<
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name eraLenght
|
||||
* @description Retrieves the total length of the current era.
|
||||
* @example
|
||||
* ```javascript
|
||||
* api.derive.session.eraLength((length) => {
|
||||
* console.log(`Current era length: ${length} sessions`);
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export const eraLength = /*#__PURE__*/ withProgressField('eraLength');
|
||||
/**
|
||||
* @name eraProgress
|
||||
* @description Retrieves the progress of the current era.
|
||||
* @example
|
||||
* ```javascript
|
||||
* api.derive.session.eraProgress((progress) => {
|
||||
* console.log(`Current era progress: ${progress} sessions`);
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export const eraProgress = /*#__PURE__*/ withProgressField('eraProgress');
|
||||
/**
|
||||
* @name sessionProgress
|
||||
* @description Retrieves the progress of the current session.
|
||||
* @example
|
||||
* ```javascript
|
||||
* api.derive.session.sessionProgress((progress) => {
|
||||
* console.log(`Current session progress: ${progress} slots`);
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export const sessionProgress = /*#__PURE__*/ withProgressField('sessionProgress');
|
||||
|
||||
Reference in New Issue
Block a user