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:
Valentin Fernandez
2025-02-27 10:56:34 -03:00
committed by GitHub
parent 3d45da3195
commit ed62d164ea
85 changed files with 1195 additions and 80 deletions
@@ -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
+8 -1
View File
@@ -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> =>
+38 -1
View File
@@ -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');