From ed62d164ea47f8822966ec8bc0ba884c73478453 Mon Sep 17 00:00:00 2001 From: Valentin Fernandez <33705477+valentinfernandez1@users.noreply.github.com> Date: Thu, 27 Feb 2025 10:56:34 -0300 Subject: [PATCH] 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 --- packages/api-derive/README.md | 25 ++++++++ packages/api-derive/src/accounts/accountId.ts | 10 ++- packages/api-derive/src/accounts/flags.ts | 14 +++- .../api-derive/src/accounts/idAndIndex.ts | 6 +- packages/api-derive/src/accounts/idToIndex.ts | 6 +- packages/api-derive/src/accounts/identity.ts | 35 +++++++++- packages/api-derive/src/accounts/indexToId.ts | 12 ++-- packages/api-derive/src/accounts/indexes.ts | 4 +- packages/api-derive/src/accounts/info.ts | 10 +++ packages/api-derive/src/alliance/index.ts | 64 ++++++++++++++++++- packages/api-derive/src/bagsList/get.ts | 5 ++ .../api-derive/src/bagsList/getExpanded.ts | 10 +++ packages/api-derive/src/bagsList/listNodes.ts | 5 ++ packages/api-derive/src/balances/account.ts | 6 +- packages/api-derive/src/balances/all.ts | 13 ++-- packages/api-derive/src/balances/index.ts | 15 +++++ .../api-derive/src/balances/votingBalances.ts | 11 ++++ packages/api-derive/src/bounties/bounties.ts | 9 +++ packages/api-derive/src/chain/bestNumber.ts | 4 +- .../src/chain/bestNumberFinalized.ts | 2 - .../api-derive/src/chain/bestNumberLag.ts | 4 +- packages/api-derive/src/chain/getBlock.ts | 4 +- .../api-derive/src/chain/getBlockByNumber.ts | 11 ++++ packages/api-derive/src/chain/getHeader.ts | 2 - .../src/chain/subscribeFinalizedBlocks.ts | 8 ++- .../src/chain/subscribeFinalizedHeads.ts | 10 ++- .../src/chain/subscribeNewBlocks.ts | 6 ++ .../api-derive/src/chain/subscribeNewHeads.ts | 6 +- packages/api-derive/src/contracts/fees.ts | 2 - packages/api-derive/src/council/index.ts | 64 ++++++++++++++++++- packages/api-derive/src/council/votes.ts | 8 +++ packages/api-derive/src/council/votesOf.ts | 12 ++++ packages/api-derive/src/crowdloan/childKey.ts | 11 ++++ .../api-derive/src/crowdloan/contributions.ts | 10 +++ .../src/crowdloan/ownContributions.ts | 11 ++++ .../api-derive/src/democracy/dispatchQueue.ts | 9 +++ packages/api-derive/src/democracy/locks.ts | 10 +++ .../api-derive/src/democracy/nextExternal.ts | 9 +++ .../api-derive/src/democracy/preimages.ts | 18 ++++++ .../api-derive/src/democracy/proposals.ts | 9 +++ .../api-derive/src/democracy/referendumIds.ts | 8 +++ .../api-derive/src/democracy/referendums.ts | 8 +++ .../src/democracy/referendumsActive.ts | 9 +++ .../src/democracy/referendumsFinished.ts | 9 +++ .../src/democracy/referendumsInfo.ts | 13 ++++ .../src/democracy/sqrtElectorate.ts | 9 +++ packages/api-derive/src/elections/info.ts | 5 +- .../src/imOnline/receivedHeartbeats.ts | 9 ++- packages/api-derive/src/membership/index.ts | 64 ++++++++++++++++++- packages/api-derive/src/parachains/info.ts | 15 +++++ .../api-derive/src/parachains/overview.ts | 12 ++++ packages/api-derive/src/session/indexes.ts | 12 ++++ packages/api-derive/src/session/info.ts | 9 ++- packages/api-derive/src/session/progress.ts | 39 ++++++++++- packages/api-derive/src/society/candidates.ts | 8 ++- packages/api-derive/src/society/info.ts | 8 ++- packages/api-derive/src/society/member.ts | 9 ++- packages/api-derive/src/society/members.ts | 8 ++- packages/api-derive/src/staking/account.ts | 20 +++++- .../api-derive/src/staking/currentPoints.ts | 8 ++- .../api-derive/src/staking/electedInfo.ts | 20 ++++++ .../api-derive/src/staking/erasExposure.ts | 19 ++++++ .../api-derive/src/staking/erasHistoric.ts | 4 ++ packages/api-derive/src/staking/erasPoints.ts | 13 ++++ packages/api-derive/src/staking/erasPrefs.ts | 21 ++++++ .../api-derive/src/staking/erasRewards.ts | 9 +++ .../api-derive/src/staking/erasSlashes.ts | 19 ++++++ packages/api-derive/src/staking/keys.ts | 30 +++++++++ packages/api-derive/src/staking/overview.ts | 15 ++++- .../api-derive/src/staking/ownExposure.ts | 29 +++++++++ packages/api-derive/src/staking/ownSlashes.ts | 29 +++++++++ packages/api-derive/src/staking/query.ts | 25 +++++++- .../api-derive/src/staking/stakerExposure.ts | 26 ++++++++ .../api-derive/src/staking/stakerPoints.ts | 17 +++++ .../api-derive/src/staking/stakerPrefs.ts | 19 ++++++ .../api-derive/src/staking/stakerRewards.ts | 39 +++++++++++ .../api-derive/src/staking/stakerSlashes.ts | 17 +++++ packages/api-derive/src/staking/stashes.ts | 11 +++- packages/api-derive/src/staking/validators.ts | 27 +++++++- .../api-derive/src/staking/waitingInfo.ts | 13 ++++ .../src/technicalCommittee/index.ts | 64 ++++++++++++++++++- packages/api-derive/src/treasury/proposals.ts | 8 ++- packages/api-derive/src/tx/events.ts | 13 ++++ packages/api-derive/src/tx/signingInfo.ts | 14 ++++ packages/typegen/src/metadataMd.ts | 2 +- 85 files changed, 1195 insertions(+), 80 deletions(-) diff --git a/packages/api-derive/README.md b/packages/api-derive/README.md index 6373fa5017..d8551298a7 100644 --- a/packages/api-derive/README.md +++ b/packages/api-derive/README.md @@ -3,3 +3,28 @@ Collection of high-level utility functions built on top of the @polkadot/api library. Designed to simplify the process of querying complex on-chain data by combining multiple RPC calls, storage queries, and runtime logic into a single, callable function. Instead of manually fetching and processing blockchain data, developers can use `api.derive` methods to retrieve information. + +## Available Derive Namespaces + +The derive functions are categorized into namespaces based on different common Substrate modules. Accesible by calling `api.derive.NAMESPACE` (e.g. `api.derive.balances`). The available modules are as follows: + +- [accounts](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/accounts) +- [alliance](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/alliance) +- [bagsList](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/bagsList) +- [balances](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/balances) +- [bounties](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/bounties) +- [chain](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/chain) +- [contracts](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/contracts) +- [council](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/council) +- [crowdloan](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/crowdloan) +- [democracy](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/democracy) +- [elections](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/elections) +- [imOnline](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/imOnline) +- [membership](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/membership) +- [parachains](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/parachains) +- [session](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/session) +- [society](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/society) +- [staking](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/staking) +- [technicalCommittee](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/technicalCommittee) +- [treasury](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/treasury) +- [tx](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/tx) diff --git a/packages/api-derive/src/accounts/accountId.ts b/packages/api-derive/src/accounts/accountId.ts index 1db63b99d0..171ddd9fe5 100644 --- a/packages/api-derive/src/accounts/accountId.ts +++ b/packages/api-derive/src/accounts/accountId.ts @@ -15,7 +15,15 @@ import { memo } from '../util/index.js'; /** * @name accountId * @param {(Address | AccountId | AccountIndex | string | null)} address An accounts address in various formats. - * @description An [[AccountId]] + * @description Resolves an address (in different formats) to its corresponding `AccountId`. + * @example + * ```javascript + * const ALICE = "F7Hs"; + * + * api.derive.accounts.accountId(ALICE, (accountId) => { + * console.log(`Resolved AccountId: ${accountId}`); + * }); + * ``` */ export function accountId (instanceId: string, api: DeriveApi): (address?: Address | AccountId | AccountIndex | string | null) => Observable { return memo(instanceId, (address?: Address | AccountId | AccountIndex | string | null): Observable => { diff --git a/packages/api-derive/src/accounts/flags.ts b/packages/api-derive/src/accounts/flags.ts index f916c954b4..8187487581 100644 --- a/packages/api-derive/src/accounts/flags.ts +++ b/packages/api-derive/src/accounts/flags.ts @@ -68,8 +68,18 @@ export function _flags (instanceId: string, api: DeriveApi): () => Observable { + * console.log( + * `Account Flags:`, + * Object.keys(flags).map((flag) => `${flag}: ${flags[flag]}`) + * ); + * }); */ export function flags (instanceId: string, api: DeriveApi): (address?: AccountId | Address | string | null) => Observable { return memo(instanceId, (address?: AccountId | Address | string | null): Observable => diff --git a/packages/api-derive/src/accounts/idAndIndex.ts b/packages/api-derive/src/accounts/idAndIndex.ts index be5de45e1b..37a13278ca 100644 --- a/packages/api-derive/src/accounts/idAndIndex.ts +++ b/packages/api-derive/src/accounts/idAndIndex.ts @@ -14,11 +14,9 @@ import { memo } from '../util/index.js'; /** * @name idAndIndex - * @param {(Address | AccountId | AccountIndex | Uint8Array | string | null)} address - An accounts address in various formats. - * @description An array containing the [[AccountId]] and [[AccountIndex]] as optional values. + * @param {(Address | AccountId | AccountIndex | Uint8Array | string | null)} address An accounts address in various formats. + * @description An array containing the [[AccountId]] and [[AccountIndex]] as optional values. * @example - *
- * * ```javascript * api.derive.accounts.idAndIndex('F7Hs', ([id, ix]) => { * console.log(`AccountId #${id} with corresponding AccountIndex ${ix}`); diff --git a/packages/api-derive/src/accounts/idToIndex.ts b/packages/api-derive/src/accounts/idToIndex.ts index f4cd06adbb..f8de77e804 100644 --- a/packages/api-derive/src/accounts/idToIndex.ts +++ b/packages/api-derive/src/accounts/idToIndex.ts @@ -11,11 +11,9 @@ import { memo } from '../util/index.js'; /** * @name idToIndex - * @param {( AccountId | string )} accountId - An accounts Id in different formats. - * @returns Returns the corresponding AccountIndex. + * @description Retrieves the corresponding AccountIndex. + * @param {( AccountId | string )} accountId An accounts Id in different formats. * @example - *
- * * ```javascript * const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'; * api.derive.accounts.idToIndex(ALICE, (accountIndex) => { diff --git a/packages/api-derive/src/accounts/identity.ts b/packages/api-derive/src/accounts/identity.ts index f77bf36eda..8634957d1e 100644 --- a/packages/api-derive/src/accounts/identity.ts +++ b/packages/api-derive/src/accounts/identity.ts @@ -125,7 +125,19 @@ export function _identity (instanceId: string, api: DeriveApi): (accountId?: Acc /** * @name identity - * @description Returns identity info for an account + * @description Retrieves the on chain identity information for a given account. + * @param {(AccountId | Uint8Array | string)} accoutId The account identifier to query the identity for. + * @example + * ```javascript + * const ALICE = "13xAUH"; + * + * api.derive.accounts.identity(ALICE, (identity) => { + * console.log( + * "Account Identity:", + * Object.keys(identity).map((key) => `${key}: ${identity[key]}`) + * ); + * }); + * ``` */ export function identity (instanceId: string, api: DeriveApi): (accountId?: AccountId | Uint8Array | string) => Observable { return memo(instanceId, (accountId?: AccountId | Uint8Array | string): Observable => @@ -165,11 +177,32 @@ function getSubIdentities (identity: DeriveAccountRegistration, api: DeriveApi, ); } +/** + * @name hasIdentity + * @description Checks if a specific account has an identity registered on chain. + * @param {(AccountId | Uint8Array | string)} accoutId The account identifier to query. + * @example + * ```javascript + * const ALICE = "13AU"; + * console.log(await api.derive.accounts.hasIdentity(ALICE)); + * ``` + */ export const hasIdentity = /*#__PURE__*/ firstMemo( (api: DeriveApi, accountId: AccountId | Uint8Array | string) => api.derive.accounts.hasIdentityMulti([accountId]) ); +/** + * @name hasIdentityMulti + * @description Checks whether multiple accounts have on chain identities registered. + * @param {(AccountId | Uint8Array | string)[]} accountIds Array of account identifiers to query. + * @example + * ```javascript + * const ALICE = "13AU"; + * const BOB = "16WW"; + * console.log(await api.derive.accounts.hasIdentityMulti([ALICE, BOB])); + * ``` + */ export function hasIdentityMulti (instanceId: string, api: DeriveApi): (accountIds: (AccountId | Uint8Array | string)[]) => Observable { return memo(instanceId, (accountIds: (AccountId | Uint8Array | string)[]): Observable => api.query.identity?.identityOf diff --git a/packages/api-derive/src/accounts/indexToId.ts b/packages/api-derive/src/accounts/indexToId.ts index d87af0c0cd..7c27823c61 100644 --- a/packages/api-derive/src/accounts/indexToId.ts +++ b/packages/api-derive/src/accounts/indexToId.ts @@ -11,15 +11,13 @@ import { memo } from '../util/index.js'; /** * @name indexToId - * @param {( AccountIndex | string )} accountIndex - An accounts index in different formats. - * @returns Returns the corresponding AccountId. + * @description Resolves an AccountIndex (short address) to the full AccountId. + * @param {( AccountIndex | string )} accountIndex An accounts index in different formats. * @example - *
- * * ```javascript - * api.derive.accounts.indexToId('F7Hs', (accountId) => { - * console.log(`The AccountId of F7Hs is ${accountId}`); - * }); + * const ALICE = "13AU"; + * const id = await api.derive.accounts.indexToId(ALICE); + * console.log(id); * ``` */ export function indexToId (instanceId: string, api: DeriveApi): (accountIndex: AccountIndex | string) => Observable { diff --git a/packages/api-derive/src/accounts/indexes.ts b/packages/api-derive/src/accounts/indexes.ts index e8c437040b..a2abf5b15e 100644 --- a/packages/api-derive/src/accounts/indexes.ts +++ b/packages/api-derive/src/accounts/indexes.ts @@ -29,10 +29,8 @@ function queryAccounts (api: DeriveApi): Observable { * @returns Returns all the indexes on the system. * @description This is an unwieldly query since it loops through * all of the enumsets and returns all of the values found. This could be up to 32k depending - * on the number of active accounts in the system + * on the number of active accounts in the system. * @example - *
- * * ```javascript * api.derive.accounts.indexes((indexes) => { * console.log('All existing AccountIndexes', indexes); diff --git a/packages/api-derive/src/accounts/info.ts b/packages/api-derive/src/accounts/info.ts index 21212a10c0..1469891626 100644 --- a/packages/api-derive/src/accounts/info.ts +++ b/packages/api-derive/src/accounts/info.ts @@ -30,6 +30,16 @@ function retrieveNick (api: DeriveApi, accountId?: AccountId): Observable `${key}: ${info[key]}`) + * ); + * ``` */ export function info (instanceId: string, api: DeriveApi): (address?: AccountIndex | AccountId | Address | Uint8Array | string | null) => Observable { return memo(instanceId, (address?: AccountIndex | AccountId | Address | Uint8Array | string | null): Observable => diff --git a/packages/api-derive/src/alliance/index.ts b/packages/api-derive/src/alliance/index.ts index 08ca01763a..273a1ab2cf 100644 --- a/packages/api-derive/src/alliance/index.ts +++ b/packages/api-derive/src/alliance/index.ts @@ -3,12 +3,74 @@ import { hasProposals as collectiveHasProposals, members as collectiveMembers, prime as collectivePrime, proposal as collectiveProposal, proposalCount as collectiveProposalCount, proposalHashes as collectiveProposalHashes, proposals as collectiveProposals } from '../collective/index.js'; +/** + * @name members + * @description Retrieves the list of members in the "allianceMotion" collective. + * @example + * ```javascript + * const members = await api.derive.alliance.members(); + * console.log(`Members: ${JSON.stringify(members)}); + * ``` + */ export const members = /*#__PURE__*/ collectiveMembers('allianceMotion'); +/** + * @name hasProposals + * @description Checks if there are any active proposals in the "allianceMotion" collective. + * @example + * ```javascript + * const exists = await api.derive.alliance.hasProposals(); + * console.log(exists); + * ``` + */ export const hasProposals = /*#__PURE__*/ collectiveHasProposals('allianceMotion'); +/** + * @name proposal + * @description Retrieves details of a specific proposal in the "allianceMotion" collective by its hash. + * @example + * ```javascript + * const proposalDetails = await api.derive.alliance.proposal(PROPOSAL_HASH); + * console.log(proposalDetails); + * ``` + */ export const proposal = /*#__PURE__*/ collectiveProposal('allianceMotion'); +/** + * @name proposalCount + * @description Retrieves the total number of proposals in the "allianceMotion" collective. + * @example + * ```javascript + * const count = await api.derive.alliance.proposalCount(); + * console.log(`Amount of proposals: ${count}`); + * ``` + */ export const proposalCount = /*#__PURE__*/ collectiveProposalCount('allianceMotion'); +/** + * @name proposalHashes + * @description Retrieves an array of hashes for all active proposals in the "allianceMotion" collective. + * @example + * ```javascript + * const hashes = await api.derive.alliance.proposalHashes(); + * console.log(`Proposals ${JSON.stringify(hashes)}`); + * ``` + */ export const proposalHashes = /*#__PURE__*/ collectiveProposalHashes('allianceMotion'); +/** + * @name proposals + * @description Retrieves a list of all active proposals in the "allianceMotion" collective. + * @example + * ```javascript + * const proposals = await api.derive.alliance.proposals(); + * console.log(proposals); + * ``` + */ export const proposals = /*#__PURE__*/ collectiveProposals('allianceMotion'); - +/** + * @name prime + * @description Retrieves the prime member of the "allianceMotion" collective, if one exists. + * @example + * ```javascript + * const primeMember = await api.derive.alliance.prime(); + * console.log(primeMember); + * ``` + */ export const prime = /*#__PURE__*/ collectivePrime('allianceMotion'); diff --git a/packages/api-derive/src/bagsList/get.ts b/packages/api-derive/src/bagsList/get.ts index 9835bed9b2..dbe2927004 100644 --- a/packages/api-derive/src/bagsList/get.ts +++ b/packages/api-derive/src/bagsList/get.ts @@ -65,6 +65,11 @@ export function all (instanceId: string, api: DeriveApi): () => Observable Observable { return memo(instanceId, (id: BN | number): Observable => api.derive.bagsList._getIds([bnToBn(id)]).pipe( diff --git a/packages/api-derive/src/bagsList/getExpanded.ts b/packages/api-derive/src/bagsList/getExpanded.ts index 9c6b8a5f86..e2d93d1098 100644 --- a/packages/api-derive/src/bagsList/getExpanded.ts +++ b/packages/api-derive/src/bagsList/getExpanded.ts @@ -12,6 +12,11 @@ import { objectSpread } from '@polkadot/util'; import { memo } from '../util/index.js'; +/** + * @name expand + * @description Expands a given bag by retrieving all its nodes (accounts contained within the bag). + * @param {Bag} bag The bag to be expanded. + */ export function expand (instanceId: string, api: DeriveApi): (bag: Bag) => Observable { return memo(instanceId, (bag: Bag): Observable => api.derive.bagsList.listNodes(bag.bag).pipe( @@ -20,6 +25,11 @@ export function expand (instanceId: string, api: DeriveApi): (bag: Bag) => Obser ); } +/** + * @name getExpanded + * @description Retrieves and expands a specific bag from the BagsList pallet. + * @param {BN | number} id The id of the bag to expand. + */ export function getExpanded (instanceId: string, api: DeriveApi): (id: BN | number) => Observable { return memo(instanceId, (id: BN | number): Observable => api.derive.bagsList.get(id).pipe( diff --git a/packages/api-derive/src/bagsList/listNodes.ts b/packages/api-derive/src/bagsList/listNodes.ts index 34f3889f96..35e8ce8516 100644 --- a/packages/api-derive/src/bagsList/listNodes.ts +++ b/packages/api-derive/src/bagsList/listNodes.ts @@ -36,6 +36,11 @@ function traverseLinks (api: DeriveApi, head: AccountId32 | string): Observable< ); } +/** + * @name listNodes + * @param {(PalletBagsListListBag | null)} bag A reference to a specific bag in the BagsList pallet. + * @description Retrieves the list of nodes (accounts) contained in a specific bag within the BagsList pallet. + */ export function listNodes (instanceId: string, api: DeriveApi): (bag: PalletBagsListListBag | null) => Observable { return memo(instanceId, (bag: PalletBagsListListBag | null): Observable => bag && bag.head.isSome diff --git a/packages/api-derive/src/balances/account.ts b/packages/api-derive/src/balances/account.ts index 7654db4be0..86957667d1 100644 --- a/packages/api-derive/src/balances/account.ts +++ b/packages/api-derive/src/balances/account.ts @@ -167,11 +167,9 @@ function querySystemAccount (api: DeriveApi, accountId: AccountId): Observable - * * ```javascript * const ALICE = 'F7Hs'; * diff --git a/packages/api-derive/src/balances/all.ts b/packages/api-derive/src/balances/all.ts index c50d4ba212..9e576aa86c 100644 --- a/packages/api-derive/src/balances/all.ts +++ b/packages/api-derive/src/balances/all.ts @@ -210,16 +210,17 @@ function queryCurrent (api: DeriveApi, accountId: AccountId | string, balanceIns /** * @name all - * @param {( AccountIndex | AccountId | Address | string )} address - An accounts Id in different formats. - * @returns An object containing the results of various balance queries + * @description Retrieves the complete balance information for an account, including free balance, locked balance, reserved balance, and more. + * @param {( AccountId | string )} address An accountsId in different formats. * @example - *
- * * ```javascript * const ALICE = 'F7Hs'; * - * api.derive.balances.all(ALICE, ({ accountId, lockedBalance }) => { - * console.log(`The account ${accountId} has a locked balance ${lockedBalance} units.`); + * api.derive.balances.account(ALICE, (accountInfo) => { + * console.log( + * `${accountInfo.accountId} info:`, + * Object.keys(accountInfo).map((key) => `${key}: ${accountInfo[key]}`) + * ); * }); * ``` */ diff --git a/packages/api-derive/src/balances/index.ts b/packages/api-derive/src/balances/index.ts index cd5ee508ba..37b7cc7f6c 100644 --- a/packages/api-derive/src/balances/index.ts +++ b/packages/api-derive/src/balances/index.ts @@ -6,6 +6,21 @@ import { all } from './all.js'; export * from './account.js'; export * from './votingBalances.js'; +/** + * @name votingBalance + * @param {( AccountId | string )} address An accounts Id in different formats. + * @returns An object containing the results of various balance queries + * @example + *
+ * + * ```javascript + * const ALICE = 'F7Hs'; + * + * api.derive.balances.votingBalance(ALICE, ({ accountId, lockedBalance }) => { + * console.log(`The account ${accountId} has a locked balance ${lockedBalance} units.`); + * }); + * ``` + */ const votingBalance = all; export { all, votingBalance }; diff --git a/packages/api-derive/src/balances/votingBalances.ts b/packages/api-derive/src/balances/votingBalances.ts index 97bc0f4e59..ac9519dc74 100644 --- a/packages/api-derive/src/balances/votingBalances.ts +++ b/packages/api-derive/src/balances/votingBalances.ts @@ -9,6 +9,17 @@ import { combineLatest, of } from 'rxjs'; import { memo } from '../util/index.js'; +/** + * @name votingBalances + * @description Retrieves the balance information for multiple accounts, typically used in governance-related contexts to check voting power. + * @param {(AccountId | AccountIndex | Address | string)[]} addresses An array of account identifiers. + * @example + * ```javascript + * const addresses = ["5D4b...Zf1", "5HGj...yrV"]; + * const balances = await api.derive.balances.votingBalances(addresses); + * console.log("Voting Balances:", balances); + * ``` + */ export function votingBalances (instanceId: string, api: DeriveApi): (addresses?: (AccountId | AccountIndex | Address | string)[]) => Observable { return memo(instanceId, (addresses?: (AccountId | AccountIndex | Address | string)[]): Observable => !addresses?.length diff --git a/packages/api-derive/src/bounties/bounties.ts b/packages/api-derive/src/bounties/bounties.ts index 4920625cbb..8d5590d091 100644 --- a/packages/api-derive/src/bounties/bounties.ts +++ b/packages/api-derive/src/bounties/bounties.ts @@ -33,6 +33,15 @@ function parseResult ([maybeBounties, maybeDescriptions, ids, bountyProposals]: return bounties; } +/** + * @name bounties + * @descrive Retrieves all active bounties, their descriptions, and associated proposals. + * @example + * ```javascript + * const bounties = await api.derive.bounties(); + * console.log("Active bounties:", bounties); + * ``` + */ export function bounties (instanceId: string, api: DeriveApi): () => Observable { const bountyBase = api.query.bounties || api.query.treasury; diff --git a/packages/api-derive/src/chain/bestNumber.ts b/packages/api-derive/src/chain/bestNumber.ts index 7e536c3d0d..b1b75e7fc0 100644 --- a/packages/api-derive/src/chain/bestNumber.ts +++ b/packages/api-derive/src/chain/bestNumber.ts @@ -7,10 +7,8 @@ import { createBlockNumberDerive } from './util.js'; /** * @name bestNumber - * @returns The latest block number. + * @descrive Retrieves the latest block number. * @example - *
- * * ```javascript * api.derive.chain.bestNumber((blockNumber) => { * console.log(`the current best block is #${blockNumber}`); diff --git a/packages/api-derive/src/chain/bestNumberFinalized.ts b/packages/api-derive/src/chain/bestNumberFinalized.ts index 0c524e6fc3..77ea50b864 100644 --- a/packages/api-derive/src/chain/bestNumberFinalized.ts +++ b/packages/api-derive/src/chain/bestNumberFinalized.ts @@ -10,8 +10,6 @@ import { createBlockNumberDerive } from './util.js'; * @returns A BlockNumber * @description Get the latest finalized block number. * @example - *
- * * ```javascript * api.derive.chain.bestNumberFinalized((blockNumber) => { * console.log(`the current finalized block is #${blockNumber}`); diff --git a/packages/api-derive/src/chain/bestNumberLag.ts b/packages/api-derive/src/chain/bestNumberLag.ts index 8e3ee0f7e1..b40084a556 100644 --- a/packages/api-derive/src/chain/bestNumberLag.ts +++ b/packages/api-derive/src/chain/bestNumberLag.ts @@ -13,9 +13,7 @@ import { memo } from '../util/index.js'; * @name bestNumberLag * @returns A number of blocks * @description Calculates the lag between finalized head and best head - * @example - *
- * + * @examplew * ```javascript * api.derive.chain.bestNumberLag((lag) => { * console.log(`finalized is ${lag} blocks behind head`); diff --git a/packages/api-derive/src/chain/getBlock.ts b/packages/api-derive/src/chain/getBlock.ts index a09132b570..a220575de7 100644 --- a/packages/api-derive/src/chain/getBlock.ts +++ b/packages/api-derive/src/chain/getBlock.ts @@ -13,11 +13,9 @@ import { getAuthorDetails } from './util.js'; /** * @name getBlock - * @param {( Uint8Array | string )} hash - A block hash as U8 array or string. + * @param {( Uint8Array | string )} hash A block hash as U8 array or string. * @description Get a specific block (e.g. rpc.chain.getBlock) and extend it with the author * @example - *
- * * ```javascript * const { author, block } = await api.derive.chain.getBlock('0x123...456'); * diff --git a/packages/api-derive/src/chain/getBlockByNumber.ts b/packages/api-derive/src/chain/getBlockByNumber.ts index 0c2ea481e5..41fd8efdb2 100644 --- a/packages/api-derive/src/chain/getBlockByNumber.ts +++ b/packages/api-derive/src/chain/getBlockByNumber.ts @@ -10,6 +10,17 @@ import { switchMap } from 'rxjs'; import { memo } from '../util/index.js'; +/** + * @name getBlockByNumber + * @param {( BN | bigint | Uint8Array | number | string )} blockNumber + * @description Get a specific block (e.g. rpc.chain.getBlock) and extend it with the author by block number + * @example + * ```javascript + * const { author, block } = await api.derive.chain.getBlockByNumber(123); + * + * console.log(`block #${block.header.number} was authored by ${author}`); + * ``` + */ export function getBlockByNumber (instanceId: string, api: DeriveApi): (blockNumber: AnyNumber) => Observable { return memo(instanceId, (blockNumber: AnyNumber): Observable => api.rpc.chain.getBlockHash(blockNumber).pipe( diff --git a/packages/api-derive/src/chain/getHeader.ts b/packages/api-derive/src/chain/getHeader.ts index 34ce0a6081..715a0c82a9 100644 --- a/packages/api-derive/src/chain/getHeader.ts +++ b/packages/api-derive/src/chain/getHeader.ts @@ -17,8 +17,6 @@ import { getAuthorDetails } from './util.js'; * @returns An array containing the block header and the block author * @description Get a specific block header and extend it with the author * @example - *
- * * ```javascript * const { author, number } = await api.derive.chain.getHeader('0x123...456'); * diff --git a/packages/api-derive/src/chain/subscribeFinalizedBlocks.ts b/packages/api-derive/src/chain/subscribeFinalizedBlocks.ts index 7727e1b72f..41b554ea03 100644 --- a/packages/api-derive/src/chain/subscribeFinalizedBlocks.ts +++ b/packages/api-derive/src/chain/subscribeFinalizedBlocks.ts @@ -11,7 +11,13 @@ import { memo } from '../util/index.js'; /** * @name subscribeFinalizedBlocks - * @returns The finalized block & events for that block + * @description Retrieves the finalized block & events for that block + * @example + * ```javascript + * const unsub = await api.derive.chain.subscribeFinalizedBlocks((finalizedBlock) => { + * console.log(`# Finalized block ${finalizedBlock.block.hash}`); + * }); + * ``` */ export function subscribeFinalizedBlocks (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => diff --git a/packages/api-derive/src/chain/subscribeFinalizedHeads.ts b/packages/api-derive/src/chain/subscribeFinalizedHeads.ts index 26a538b12f..19d93125db 100644 --- a/packages/api-derive/src/chain/subscribeFinalizedHeads.ts +++ b/packages/api-derive/src/chain/subscribeFinalizedHeads.ts @@ -29,8 +29,14 @@ export function _getHeaderRange (instanceId: string, api: DeriveApi): (startHash * @description An observable of the finalized block headers. Unlike the base * chain.subscribeFinalizedHeads this does not skip any headers. Since finalization * may skip specific blocks (finalization happens in terms of chains), this version - * of the derive tracks missing headers (since last retrieved) and provides them - * to the caller + * of the derive tracks missing headers (since last retrieved) and provides them + * to the caller. + * @example + * ```javascript + * const unsub = await api.derive.chain.subscribeFinalizedHeads((finalizedHead) => { + * console.log(`${finalizedHead.hash}`); + * }); + * ``` */ export function subscribeFinalizedHeads (instanceId: string, api: DeriveApi): () => Observable
{ return memo(instanceId, (): Observable
=> { diff --git a/packages/api-derive/src/chain/subscribeNewBlocks.ts b/packages/api-derive/src/chain/subscribeNewBlocks.ts index 30a3a08f9a..0994965d1f 100644 --- a/packages/api-derive/src/chain/subscribeNewBlocks.ts +++ b/packages/api-derive/src/chain/subscribeNewBlocks.ts @@ -12,6 +12,12 @@ import { memo } from '../util/index.js'; /** * @name subscribeNewBlocks * @returns The latest block & events for that block + * @example + * ```javascript + * const unsub = await api.derive.chain.subscribeNewBlocks((newBlock) => { + * console.log(`Block Hash: ${newBlock.hash}`); + * }); + * ``` */ export function subscribeNewBlocks (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => diff --git a/packages/api-derive/src/chain/subscribeNewHeads.ts b/packages/api-derive/src/chain/subscribeNewHeads.ts index daae28664f..36061e0dfa 100644 --- a/packages/api-derive/src/chain/subscribeNewHeads.ts +++ b/packages/api-derive/src/chain/subscribeNewHeads.ts @@ -13,11 +13,9 @@ import { getAuthorDetails } from './util.js'; /** * @name subscribeNewHeads - * @returns A header with the current header (including extracted author) - * @description An observable of the current block header and it's author + * @returns A header with the current header (including extracted author). + * @description An observable of the current block header and it's author. * @example - *
- * * ```javascript * api.derive.chain.subscribeNewHeads((header) => { * console.log(`block #${header.number} was authored by ${header.author}`); diff --git a/packages/api-derive/src/contracts/fees.ts b/packages/api-derive/src/contracts/fees.ts index f287c0f80f..f03e7671df 100644 --- a/packages/api-derive/src/contracts/fees.ts +++ b/packages/api-derive/src/contracts/fees.ts @@ -35,8 +35,6 @@ function queryConstants (api: DeriveApi): Observable { * @returns An object containing the combined results of the queries for * all relevant contract fees as declared in the substrate chain spec. * @example - *
- * * ```javascript * api.derive.contracts.fees(([creationFee, transferFee]) => { * console.log(`The fee for creating a new contract on this chain is ${creationFee} units. The fee required to call this contract is ${transferFee} units.`); diff --git a/packages/api-derive/src/council/index.ts b/packages/api-derive/src/council/index.ts index 9c2fafa90e..33c63603b1 100644 --- a/packages/api-derive/src/council/index.ts +++ b/packages/api-derive/src/council/index.ts @@ -6,12 +6,74 @@ import { hasProposals as collectiveHasProposals, members as collectiveMembers, p export * from './votes.js'; export * from './votesOf.js'; +/** + * @name members + * @description Retrieves the list of members in the "council" collective. + * @example + * ```javascript + * const members = await api.derive.council.members(); + * console.log(`Members: ${JSON.stringify(members)}); + * ``` + */ export const members = /*#__PURE__*/ collectiveMembers('council'); +/** + * @name hasProposals + * @description Checks if there are any active proposals in the "council" collective. + * @example + * ```javascript + * const exists = await api.derive.council.hasProposals(); + * console.log(exists); + * ``` + */ export const hasProposals = /*#__PURE__*/ collectiveHasProposals('council'); +/** + * @name proposal + * @description Retrieves details of a specific proposal in the "councilMotion" collective by its hash. + * @example + * ```javascript + * const proposalDetails = await api.derive.council.proposal(PROPOSAL_HASH); + * console.log(proposalDetails); + * ``` + */ export const proposal = /*#__PURE__*/ collectiveProposal('council'); +/** + * @name proposalCount + * @description Retrieves the total number of proposals in the "council" collective. + * @example + * ```javascript + * const count = await api.derive.council.proposalCount(); + * console.log(`Amount of proposals: ${count}`); + * ``` + */ export const proposalCount = /*#__PURE__*/ collectiveProposalCount('council'); +/** + * @name proposalHashes + * @description Retrieves an array of hashes for all active proposals in the "council" collective. + * @example + * ```javascript + * const hashes = await api.derive.council.proposalHashes(); + * console.log(`Proposals ${JSON.stringify(hashes)}`); + * ``` + */ export const proposalHashes = /*#__PURE__*/ collectiveProposalHashes('council'); +/** + * @name proposals + * @description Retrieves a list of all active proposals in the "council" collective. + * @example + * ```javascript + * const proposals = await api.derive.council.proposals(); + * console.log(proposals); + * ``` + */ export const proposals = /*#__PURE__*/ collectiveProposals('council'); - +/** + * @name prime + * @description Retrieves the prime member of the "council" collective, if one exists. + * @example + * ```javascript + * const primeMember = await api.derive.council.prime(); + * console.log(primeMember); + * ``` + */ export const prime = /*#__PURE__*/ collectivePrime('council'); diff --git a/packages/api-derive/src/council/votes.ts b/packages/api-derive/src/council/votes.ts index 588fd94641..3a192e0835 100644 --- a/packages/api-derive/src/council/votes.ts +++ b/packages/api-derive/src/council/votes.ts @@ -76,6 +76,14 @@ function retrieveCurrent (elections: DeriveApi['query']['elections']): Observabl ); } +/** + * @name votes + * @description Retrieves the council election votes for all participants. + * @example + * ```javascript + * const votes = await api.derive.council.votes(); + * ``` + */ export function votes (instanceId: string, api: DeriveApi): () => Observable { const elections = api.query.elections || api.query['phragmenElection'] || api.query['electionsPhragmen']; diff --git a/packages/api-derive/src/council/votesOf.ts b/packages/api-derive/src/council/votesOf.ts index b7636c548a..9b819a0491 100644 --- a/packages/api-derive/src/council/votesOf.ts +++ b/packages/api-derive/src/council/votesOf.ts @@ -9,6 +9,18 @@ import { map } from 'rxjs'; import { memo } from '../util/index.js'; +/** + * @name votesOf + * @description Retrieves the council votes associated with a given account. + * @returns The stake and the list of candidates the account has voted for. + * @param {string | Uint8Array | AccountId} accountId The accountId to retrieve votes for. + * @example + * ```javascript + * const accountId = "5Gw3s7qQ9Z..."; // Replace with a valid account ID + * const votes = await api.derive.council.votesOf(accountId); + * console.log("Account votes:", votes); + * ``` + */ export function votesOf (instanceId: string, api: DeriveApi): (accountId: string | Uint8Array | AccountId) => Observable { return memo(instanceId, (accountId: string | Uint8Array | AccountId): Observable => api.derive.council.votes().pipe( diff --git a/packages/api-derive/src/crowdloan/childKey.ts b/packages/api-derive/src/crowdloan/childKey.ts index c70ab17ae6..e3cdf2a027 100644 --- a/packages/api-derive/src/crowdloan/childKey.ts +++ b/packages/api-derive/src/crowdloan/childKey.ts @@ -33,6 +33,17 @@ function createChildKey (info: AllInfo): string { ); } +/** + * @name childKey + * @description Retrieves the child storage key for a given parachain’s crowdloan contributions. + * This key is used to access contribution data stored in a separate child trie of the blockchain’s state. + * @param {string | number | BN} paraId The parachain ID for which contributions are being queried. + * @example + * ```javascript + * const childKey = await api.derive.crowdloan.childKey(3369); + * console.log("Child Key:", childKey); + * ``` + */ export function childKey (instanceId: string, api: DeriveApi): (paraId: string | number | BN) => Observable { return memo(instanceId, (paraId: string | number | BN): Observable => api.query['crowdloan']['funds']>(paraId).pipe( diff --git a/packages/api-derive/src/crowdloan/contributions.ts b/packages/api-derive/src/crowdloan/contributions.ts index 2f163f095d..43b64786b0 100644 --- a/packages/api-derive/src/crowdloan/contributions.ts +++ b/packages/api-derive/src/crowdloan/contributions.ts @@ -119,6 +119,16 @@ function _contributions (api: DeriveApi, paraId: string | number | BN, childKey: ); } +/** + * @name contributions + * @description Retrieves all contributions for a given parachain crowdloan. + * @param {string | number | BN} paraId The parachain ID for which contributions are being queried. + * @example + * ```javascript + * const contributions = await api.derive.crowdloan.contributions(3369); + * console.log("Contributions:", contributions); + * ``` + */ export function contributions (instanceId: string, api: DeriveApi): (paraId: string | number | BN) => Observable { return memo(instanceId, (paraId: string | number | BN): Observable => api.derive.crowdloan.childKey(paraId).pipe( diff --git a/packages/api-derive/src/crowdloan/ownContributions.ts b/packages/api-derive/src/crowdloan/ownContributions.ts index e97e47aa71..b4f55b6b7a 100644 --- a/packages/api-derive/src/crowdloan/ownContributions.ts +++ b/packages/api-derive/src/crowdloan/ownContributions.ts @@ -57,6 +57,17 @@ function _contributions (api: DeriveApi, paraId: string | number | BN, childKey: ); } +/** + * @name ownContributions + * @description Retrieves the contribution amounts made by specific accounts (`keys`) to a given parachain crowdloan (`paraId`). + * @param {string | number | BN} paraId The parachain ID for which contributions are being queried. + * @param {string[]} keys An array of account addresses whose contributions are to be fetched. + * @example + * ```javascript + * const contributions = await api.derive.crowdloan.ownContributions(2000, ['5Ff...PqV', '5Gg...XyZ']); + * console.log("Own Contributions:", contributions); + * ``` + */ export function ownContributions (instanceId: string, api: DeriveApi): (paraId: string | number | BN, keys: string[]) => Observable { return memo(instanceId, (paraId: string | number | BN, keys: string[]): Observable => api.derive.crowdloan.childKey(paraId).pipe( diff --git a/packages/api-derive/src/democracy/dispatchQueue.ts b/packages/api-derive/src/democracy/dispatchQueue.ts index c30623ee25..293543f6df 100644 --- a/packages/api-derive/src/democracy/dispatchQueue.ts +++ b/packages/api-derive/src/democracy/dispatchQueue.ts @@ -138,6 +138,15 @@ function queryScheduler (api: DeriveApi): Observable { ); } +/** + * @name dispatchQueue + * @description Retrieves the list of scheduled or pending dispatches in the governance system. + * @example + * ```javascript + * const queue = await api.derive.democracy.dispatchQueue(); + * console.log("Dispatch Queue:", queue); + * ``` + */ export function dispatchQueue (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => isFunction(api.query.scheduler?.agenda) diff --git a/packages/api-derive/src/democracy/locks.ts b/packages/api-derive/src/democracy/locks.ts index a5466e0a68..0468b02799 100644 --- a/packages/api-derive/src/democracy/locks.ts +++ b/packages/api-derive/src/democracy/locks.ts @@ -87,6 +87,16 @@ function directLocks (api: DeriveApi, { votes }: VotingDirect): Observable Observable { return memo(instanceId, (accountId: string | AccountId): Observable => api.query.democracy.votingOf diff --git a/packages/api-derive/src/democracy/nextExternal.ts b/packages/api-derive/src/democracy/nextExternal.ts index ee49d2e05c..7f203a0dd6 100644 --- a/packages/api-derive/src/democracy/nextExternal.ts +++ b/packages/api-derive/src/democracy/nextExternal.ts @@ -29,6 +29,15 @@ function withImage (api: DeriveApi, nextOpt: Option Observable { return memo(instanceId, (): Observable => api.query.democracy?.nextExternal diff --git a/packages/api-derive/src/democracy/preimages.ts b/packages/api-derive/src/democracy/preimages.ts index 49dc596ac0..6dc7687372 100644 --- a/packages/api-derive/src/democracy/preimages.ts +++ b/packages/api-derive/src/democracy/preimages.ts @@ -135,6 +135,15 @@ function getImages (api: DeriveApi, bounded: (FrameSupportPreimagesBounded | Uin ); } +/** + * @name preimages + * @description Retrieves the full details (preimages) of governance proposals using their on-chain hashes. + * @param { (Hash | Uint8Array | string | FrameSupportPreimagesBounded)[] } hashes An array of hashes representing governance proposals. + * @example + * ```javascript + * const preimages = await api.derive.democracy.preimages([HASH1, HASH2]); + * ``` + */ export function preimages (instanceId: string, api: DeriveApi): (hashes: (Hash | Uint8Array | string | FrameSupportPreimagesBounded)[]) => Observable<(DeriveProposalImage | undefined)[]> { return memo(instanceId, (hashes: (Hash | Uint8Array | string | FrameSupportPreimagesBounded)[]): Observable<(DeriveProposalImage | undefined)[]> => hashes.length @@ -147,6 +156,15 @@ export function preimages (instanceId: string, api: DeriveApi): (hashes: (Hash | ); } +/** + * @name preimage + * @description Retrieves the full details (preimage) of a governance proposal using its on-chain hash. + * @param { Hash | Uint8Array | string | FrameSupportPreimagesBounded } hash Hash that represents governance proposals. + * * @example + * ```javascript + * const preimage = await api.derive.democracy.preimage(HASH); + * ``` + */ export const preimage = /*#__PURE__*/ firstMemo( (api: DeriveApi, hash: Hash | Uint8Array | string | FrameSupportPreimagesBounded) => api.derive.democracy.preimages([hash]) diff --git a/packages/api-derive/src/democracy/proposals.ts b/packages/api-derive/src/democracy/proposals.ts index 08a5c9f0a8..1d7b62e1d4 100644 --- a/packages/api-derive/src/democracy/proposals.ts +++ b/packages/api-derive/src/democracy/proposals.ts @@ -48,6 +48,15 @@ function parse ([proposals, images, optDepositors]: Result): DeriveProposal[] { }); } +/** + * @name proposals + * @description Retrieves the list of active public proposals in the democracy module, along with their associated preimage data and deposit information. + * @example + * ```javascript + * const proposals = await api.derive.democracy.proposals(); + * console.log("proposals:", proposals); + * ``` + */ export function proposals (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => isFunction(api.query.democracy?.publicProps) diff --git a/packages/api-derive/src/democracy/referendumIds.ts b/packages/api-derive/src/democracy/referendumIds.ts index 580cac2548..a283975d7f 100644 --- a/packages/api-derive/src/democracy/referendumIds.ts +++ b/packages/api-derive/src/democracy/referendumIds.ts @@ -10,6 +10,14 @@ import { map, of } from 'rxjs'; import { memo } from '../util/index.js'; +/** + * @name referendumIds + * @description Retrieves an array of active referendum IDs. + * @example + * ```javascript + * const referendums = await api.derive.democracy.referendumIds(); + * ``` + */ export function referendumIds (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => api.query.democracy?.lowestUnbaked diff --git a/packages/api-derive/src/democracy/referendums.ts b/packages/api-derive/src/democracy/referendums.ts index eb91af03af..7d44047898 100644 --- a/packages/api-derive/src/democracy/referendums.ts +++ b/packages/api-derive/src/democracy/referendums.ts @@ -10,6 +10,14 @@ import { objectSpread } from '@polkadot/util'; import { memo } from '../util/index.js'; +/** + * @name referendums + * @description Retrieves information about all active referendums, including their details and associated votes. + * @example + * ```javascript + * const referendums = await api.derive.democracy.referendums(); + * ``` + */ export function referendums (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => api.derive.democracy.referendumsActive().pipe( diff --git a/packages/api-derive/src/democracy/referendumsActive.ts b/packages/api-derive/src/democracy/referendumsActive.ts index c2f2128caf..95bd9eee2f 100644 --- a/packages/api-derive/src/democracy/referendumsActive.ts +++ b/packages/api-derive/src/democracy/referendumsActive.ts @@ -8,6 +8,15 @@ import { of, switchMap } from 'rxjs'; import { memo } from '../util/index.js'; +/** + * @name referendumsActive + * @description Retrieves information about active referendums. + * @example + * ```javascript + * const referendums = await api.derive.democracy.referendumsActive(); + * console.log("Active Referendums:", referendums); + * ``` + */ export function referendumsActive (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => api.derive.democracy.referendumIds().pipe( diff --git a/packages/api-derive/src/democracy/referendumsFinished.ts b/packages/api-derive/src/democracy/referendumsFinished.ts index 484b519b1e..3e7e5e298b 100644 --- a/packages/api-derive/src/democracy/referendumsFinished.ts +++ b/packages/api-derive/src/democracy/referendumsFinished.ts @@ -11,6 +11,15 @@ import { memo } from '../util/index.js'; type ReferendumInfoFinished = PalletDemocracyReferendumInfo['asFinished']; +/** + * @name referendumsFinished + * @description Retrieves information about finished referendums. + * @example + * ```javascript + * const referendums = await api.derive.democracy.referendumsFinished(); + * console.log("Finished Referendums:", referendums); + * ``` + */ export function referendumsFinished (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => api.derive.democracy.referendumIds().pipe( diff --git a/packages/api-derive/src/democracy/referendumsInfo.ts b/packages/api-derive/src/democracy/referendumsInfo.ts index f7d474497c..f83e481b03 100644 --- a/packages/api-derive/src/democracy/referendumsInfo.ts +++ b/packages/api-derive/src/democracy/referendumsInfo.ts @@ -148,6 +148,19 @@ export function _referendumInfo (instanceId: string, api: DeriveApi): (index: BN }); } +/** + * @name referendumsInfo + * @description Retrieves information about multiple referendums by their IDs. + * @param {BN[]} ids An array of referendum IDs to query. + * @example + * ```javascript + * import { BN } from "@polkadot/util"; + * + * const referendumIds = [new BN(1)]; + * const referendums = await api.derive.democracy.referendumsInfo(referendumIds); + * console.log("Referendums Info:", referendums); + * ``` + */ export function referendumsInfo (instanceId: string, api: DeriveApi): (ids: BN[]) => Observable { return memo(instanceId, (ids: BN[]): Observable => ids.length diff --git a/packages/api-derive/src/democracy/sqrtElectorate.ts b/packages/api-derive/src/democracy/sqrtElectorate.ts index 89ef167600..369019a0a6 100644 --- a/packages/api-derive/src/democracy/sqrtElectorate.ts +++ b/packages/api-derive/src/democracy/sqrtElectorate.ts @@ -11,6 +11,15 @@ import { bnSqrt } from '@polkadot/util'; import { memo } from '../util/index.js'; +/** + * @name sqrtElectorate + * @description Computes the square root of the total token issuance in the network. + * @example + * ```javascript + * let sqrtElectorate = await api.derive.democracy.sqrtElectorate(); + * console.log("Square root of token issuance:", sqrtElectorate); + * ``` + */ export function sqrtElectorate (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => api.query.balances.totalIssuance().pipe( diff --git a/packages/api-derive/src/elections/info.ts b/packages/api-derive/src/elections/info.ts index 38a368e8ff..13be1023c5 100644 --- a/packages/api-derive/src/elections/info.ts +++ b/packages/api-derive/src/elections/info.ts @@ -94,11 +94,8 @@ function queryCouncil (api: DeriveApi, council: string): Observable<[AccountId32 /** * @name info - * @returns An object containing the combined results of the storage queries for - * all relevant election module properties. + * @description An object containing the combined results of the storage queries for all relevant election module properties. * @example - *
- * * ```javascript * api.derive.elections.info(({ members, candidates }) => { * console.log(`There are currently ${members.length} council members and ${candidates.length} prospective council candidates.`); diff --git a/packages/api-derive/src/imOnline/receivedHeartbeats.ts b/packages/api-derive/src/imOnline/receivedHeartbeats.ts index eae71291c7..abc48faf91 100644 --- a/packages/api-derive/src/imOnline/receivedHeartbeats.ts +++ b/packages/api-derive/src/imOnline/receivedHeartbeats.ts @@ -35,7 +35,14 @@ function mapResult ([result, validators, heartbeats, numBlocks]: Result): Derive } /** - * @description Return a boolean array indicating whether the passed accounts had received heartbeats in the current session + * @name receivedHeartbeats + * @description Return a boolean array indicating whether the passed accounts had received heartbeats in the current session. + * @example + * ```javascript + * let unsub = await api.derive.imOnline.receivedHeartbeats((heartbeat) => { + * console.log(heartbeat); + * }); + * ``` */ export function receivedHeartbeats (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => diff --git a/packages/api-derive/src/membership/index.ts b/packages/api-derive/src/membership/index.ts index 162a095b34..56df32aae4 100644 --- a/packages/api-derive/src/membership/index.ts +++ b/packages/api-derive/src/membership/index.ts @@ -3,12 +3,74 @@ import { hasProposals as collectiveHasProposals, members as collectiveMembers, prime as collectivePrime, proposal as collectiveProposal, proposalCount as collectiveProposalCount, proposalHashes as collectiveProposalHashes, proposals as collectiveProposals } from '../collective/index.js'; +/** + * @name members + * @description Retrieves the list of members in the "membership" collective. + * @example + * ```javascript + * const members = await api.derive.membership.members(); + * console.log(`Members: ${JSON.stringify(members)}); + * ``` + */ export const members = /*#__PURE__*/ collectiveMembers('membership'); +/** + * @name hasProposals + * @description Checks if there are any active proposals in the "membership" collective. + * @example + * ```javascript + * const exists = await api.derive.membership.hasProposals(); + * console.log(exists); + * ``` + */ export const hasProposals = /*#__PURE__*/ collectiveHasProposals('membership'); +/** + * @name proposal + * @description Retrieves details of a specific proposal in the "membership" collective by its hash. + * @example + * ```javascript + * const proposalDetails = await api.derive.membership.proposal(PROPOSAL_HASH); + * console.log(proposalDetails); + * ``` + */ export const proposal = /*#__PURE__*/ collectiveProposal('membership'); +/** + * @name proposalCount + * @description Retrieves the total number of proposals in the "membership" collective. + * @example + * ```javascript + * const count = await api.derive.membership.proposalCount(); + * console.log(`Amount of proposals: ${count}`); + * ``` + */ export const proposalCount = /*#__PURE__*/ collectiveProposalCount('membership'); +/** + * @name proposalHashes + * @description Retrieves an array of hashes for all active proposals in the "membership" collective. + * @example + * ```javascript + * const hashes = await api.derive.membership.proposalHashes(); + * console.log(`Proposals ${JSON.stringify(hashes)}`); + * ``` + */ export const proposalHashes = /*#__PURE__*/ collectiveProposalHashes('membership'); +/** + * @name proposals + * @description Retrieves a list of all active proposals in the "membership" collective. + * @example + * ```javascript + * const proposals = await api.derive.membership.proposals(); + * console.log(proposals); + * ``` + */ export const proposals = /*#__PURE__*/ collectiveProposals('membership'); - +/** + * @name prime + * @description Retrieves the prime member of the "membership" collective, if one exists. + * @example + * ```javascript + * const primeMember = await api.derive.membership.prime(); + * console.log(primeMember); + * ``` + */ export const prime = /*#__PURE__*/ collectivePrime('membership'); diff --git a/packages/api-derive/src/parachains/info.ts b/packages/api-derive/src/parachains/info.ts index 98cea07a43..89baa238a3 100644 --- a/packages/api-derive/src/parachains/info.ts +++ b/packages/api-derive/src/parachains/info.ts @@ -73,6 +73,21 @@ function parse (id: ParaId, [active, retryQueue, selectedThreads, didUpdate, inf }; } +/** + * @name info + * @param {ParaId | number} id A unique numeric (non-negative integer) identifier for a parachain. + * @description Retrieves detailed information about a specific parachain. + * @example + * ```javascript + * await api.derive.parachains.info(1000, (info) => { + * if (info) { + * console.log(`Parachain ${info.id.toString()} is active: ${info.active}`); + * } else { + * console.log("Parachain information not available."); + * } + * }); + * ``` +*/ export function info (instanceId: string, api: DeriveApi): (id: ParaId | number) => Observable { return memo(instanceId, (id: ParaId | number): Observable => api.query['registrar'] && api.query['parachains'] diff --git a/packages/api-derive/src/parachains/overview.ts b/packages/api-derive/src/parachains/overview.ts index c8a15322cf..31008dedae 100644 --- a/packages/api-derive/src/parachains/overview.ts +++ b/packages/api-derive/src/parachains/overview.ts @@ -31,6 +31,18 @@ function parse ([ids, didUpdate, relayDispatchQueueSizes, infos, pendingSwaps]: })); } +/** + * @name overview + * @description Retrieves an overview of all registered parachains. + * @example + * ```javascript + * await api.derive.parachains.overview((overview) => { + * parachains.forEach(parachain => { + * console.log(`Parachain ${parachain.id.toString()} is registered.`); + * }); + * }); + * ``` + */ export function overview (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => api.query['registrar']?.['parachains'] && api.query['parachains'] diff --git a/packages/api-derive/src/session/indexes.ts b/packages/api-derive/src/session/indexes.ts index d11cfa2a5f..6aff51fe8a 100644 --- a/packages/api-derive/src/session/indexes.ts +++ b/packages/api-derive/src/session/indexes.ts @@ -67,6 +67,18 @@ function empty (api: DeriveApi): Observable { ])); } +/** + * @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 { return memo(instanceId, (): Observable => api.query.session diff --git a/packages/api-derive/src/session/info.ts b/packages/api-derive/src/session/info.ts index 5693a6e622..616c857d05 100644 --- a/packages/api-derive/src/session/info.ts +++ b/packages/api-derive/src/session/info.ts @@ -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 { return memo(instanceId, (): Observable => diff --git a/packages/api-derive/src/session/progress.ts b/packages/api-derive/src/session/progress.ts index 40cb290aac..60280b9893 100644 --- a/packages/api-derive/src/session/progress.ts +++ b/packages/api-derive/src/session/progress.ts @@ -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 { return memo(instanceId, (): Observable => @@ -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'); diff --git a/packages/api-derive/src/society/candidates.ts b/packages/api-derive/src/society/candidates.ts index 064a2f87ca..d6fe1eafa8 100644 --- a/packages/api-derive/src/society/candidates.ts +++ b/packages/api-derive/src/society/candidates.ts @@ -54,7 +54,13 @@ function getCurr (api: DeriveApi) { } /** - * @description Get the candidate info for a society + * @name candidate + * @description Retrieves the list of candidates for the society module. + * @example + * ```javascript + * const societyCandidates = await api.derive.society.candidates(); + * console.log(societyCandidates); + * ``` */ export function candidates (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => diff --git a/packages/api-derive/src/society/info.ts b/packages/api-derive/src/society/info.ts index 429c666dca..1995715b50 100644 --- a/packages/api-derive/src/society/info.ts +++ b/packages/api-derive/src/society/info.ts @@ -14,7 +14,13 @@ import { memo } from '../util/index.js'; type Result = [Vec, Option | undefined, Option, Option, u32 | undefined, BalanceOf] /** - * @description Get the overall info for a society + * @name info + * @description Get the overall info for a society. + * @example + * ```javascript + * const societyInfo = await api.derive.society.candidates(); + * console.log(societyInfo); + * ``` */ export function info (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => diff --git a/packages/api-derive/src/society/member.ts b/packages/api-derive/src/society/member.ts index 98f8a7f178..337be7a108 100644 --- a/packages/api-derive/src/society/member.ts +++ b/packages/api-derive/src/society/member.ts @@ -10,7 +10,14 @@ import { map } from 'rxjs'; import { memo } from '../util/index.js'; /** - * @description Get the member info for a society + * @name member + * @description Get the member info for a society. + * @param { AccountId } accountId + * @example + * ```javascript + * const member = await api.derive.society.member(ALICE); + * console.log(member); + * ``` */ export function member (instanceId: string, api: DeriveApi): (accountId: AccountId) => Observable { return memo(instanceId, (accountId: AccountId): Observable => diff --git a/packages/api-derive/src/society/members.ts b/packages/api-derive/src/society/members.ts index 3137c470ea..13ab0ccacd 100644 --- a/packages/api-derive/src/society/members.ts +++ b/packages/api-derive/src/society/members.ts @@ -82,7 +82,13 @@ export function _members (instanceId: string, api: DeriveApi): (accountIds: Acco } /** - * @description Get the member info for a society + * @name members + * @description Get the society members. + * @example + * ```javascript + * const members = await api.derive.society.members(); + * console.log(members); + * ``` */ export function members (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => diff --git a/packages/api-derive/src/staking/account.ts b/packages/api-derive/src/staking/account.ts index b26b89a52c..502b891ec8 100644 --- a/packages/api-derive/src/staking/account.ts +++ b/packages/api-derive/src/staking/account.ts @@ -68,6 +68,13 @@ function parseResult (api: DeriveApi, sessionInfo: DeriveSessionInfo, keys: Deri * @param {(Uint8Array | string)[]} accountIds List of account stashes * @param {StakingQueryFlags} opts optional filtering flag * @description From a list of stashes, fill in all the relevant staking details + * @example + * ```javascript + * const accounts = await api.derive.staking.accounts([ + * "149B17nn7zVL4SkLSNmANupEkGexUBAxVrdk4bbWFZYibkFc", + * ]); + * console.log("First account staking info:", accounts[0]); + * ``` */ export function accounts (instanceId: string, api: DeriveApi): (accountIds: (Uint8Array | string)[], opts?: StakingQueryFlags) => Observable { return memo(instanceId, (accountIds: (Uint8Array | string)[], opts: StakingQueryFlags = QUERY_OPTS): Observable => @@ -88,9 +95,16 @@ export function accounts (instanceId: string, api: DeriveApi): (accountIds: (Uin /** * @name account - * @param {(Uint8Array | string)} accountId AccountId of the stash - * @param {StakingQueryFlags} opts optional filtering flag - * @description From a stash, retrieve the controllerId and fill in all the relevant staking details + * @param {(Uint8Array | string)} accountId AccountId of the stash. + * @param {StakingQueryFlags} opts (Optional) filtering flag. + * @description From a stash, retrieve the controllerId and fill in all the relevant staking details. + * @example + * ```javascript + * const accountStakingData = await api.derive.staking.account( + * "149B17nn7zVL4SkLSNmANupEkGexUBAxVrdk4bbWFZYibkFc" + * ); + * console.log(accountStakingData); + * ``` */ export const account = /*#__PURE__*/ firstMemo( (api: DeriveApi, accountId: Uint8Array | string, opts?: StakingQueryFlags) => diff --git a/packages/api-derive/src/staking/currentPoints.ts b/packages/api-derive/src/staking/currentPoints.ts index ef3b58b860..9ff81ccbf1 100644 --- a/packages/api-derive/src/staking/currentPoints.ts +++ b/packages/api-derive/src/staking/currentPoints.ts @@ -10,7 +10,13 @@ import { switchMap } from 'rxjs'; import { memo } from '../util/index.js'; /** - * @description Retrieve the staking overview, including elected and points earned + * @name currentPoints + * @description Retrieve the staking overview, including elected and points earned. + * @example + * ```javascript + * const currentPoints = await api.derive.staking.currentPoints(); + * console.log(currentPoints.toHuman()); + * ``` */ export function currentPoints (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => diff --git a/packages/api-derive/src/staking/electedInfo.ts b/packages/api-derive/src/staking/electedInfo.ts index e48d24747d..f727621202 100644 --- a/packages/api-derive/src/staking/electedInfo.ts +++ b/packages/api-derive/src/staking/electedInfo.ts @@ -17,6 +17,26 @@ function combineAccounts (nextElected: AccountId[], validators: AccountId[]): Ac return arrayFlatten([nextElected, validators.filter((v) => !nextElected.find((n) => n.eq(v)))]); } +/** + * @name electedInfo + * @param {StakingQueryFlags} flags? (Optional) Query flags to filter the staking data. + * @param {number} page? (Optional) The page index for paginated results. + * @description Retrieves detailed staking information about the next elected validators and their associated staking data. + * @example + * ```javascript + * const { nextElected, validators, info } = + * await api.derive.staking.electedInfo(); + * console.log( + * "Next Elected Validators:", + * nextElected.map((acc) => acc.toString()) + * ); + * console.log( + * "Current Validators:", + * validators.map((acc) => acc.toString()) + * ); + * console.log("Validator Staking Info:", info); + * ``` + */ export function electedInfo (instanceId: string, api: DeriveApi): (flags?: StakingQueryFlags, page?: number) => Observable { return memo(instanceId, (flags: StakingQueryFlags = DEFAULT_FLAGS, page = 0): Observable => api.derive.staking.validators().pipe( diff --git a/packages/api-derive/src/staking/erasExposure.ts b/packages/api-derive/src/staking/erasExposure.ts index b95c4f7179..f915d92d79 100644 --- a/packages/api-derive/src/staking/erasExposure.ts +++ b/packages/api-derive/src/staking/erasExposure.ts @@ -81,6 +81,25 @@ export function _eraExposure (instanceId: string, api: DeriveApi): (era: EraInde }); } +/** + * @name eraExposure + * @description Retrieves the staking exposure (nominators and total stake) for a specific era. + * @param {EraIndex} eras The staking era to query. + * @example + * ```javascript + * const era = api.createType("EraIndex", 1000); + * const exposure = await api.derive.staking.eraExposure(era); + * ``` + */ export const eraExposure = /*#__PURE__*/ singleEra('_eraExposure'); export const _erasExposure = /*#__PURE__*/ combineEras('_eraExposure'); +/** + * @name erasExposure + * @description Retrieves staking exposure details for multiple past eras. + * @param {boolean} withActive? (Optional) Whether to include the active era in the result. + * @example + * ```javascript + * const exposure = await api.derive.staking.erasExposure(true); + * ``` + */ export const erasExposure = /*#__PURE__*/ erasHistoricApply('_erasExposure'); diff --git a/packages/api-derive/src/staking/erasHistoric.ts b/packages/api-derive/src/staking/erasHistoric.ts index 0dd2037df6..77dd26b7d3 100644 --- a/packages/api-derive/src/staking/erasHistoric.ts +++ b/packages/api-derive/src/staking/erasHistoric.ts @@ -13,6 +13,10 @@ import { BN_ONE, BN_ZERO } from '@polkadot/util'; import { memo } from '../util/index.js'; +/** + * @name erasHistoric + * @param {boolean} withActive? (Optional) Whether to include the active era in the result. + */ export function erasHistoric (instanceId: string, api: DeriveApi): (withActive?: boolean) => Observable { return memo(instanceId, (withActive?: boolean): Observable => combineLatest([ diff --git a/packages/api-derive/src/staking/erasPoints.ts b/packages/api-derive/src/staking/erasPoints.ts index a15abead50..25c840bcc9 100644 --- a/packages/api-derive/src/staking/erasPoints.ts +++ b/packages/api-derive/src/staking/erasPoints.ts @@ -51,4 +51,17 @@ export function _erasPoints (instanceId: string, api: DeriveApi): (eras: EraInde }); } +/** + * @name erasPoints + * @description Retrieves historical era points with its validators. + * @param {boolean} withActive? (Optional) Whether to include the active era in the result. + * @example + * ```javascript + * const points = await api.derive.staking.erasPoints(true); + * console.log( + * "Validator points:", + * points.map(({ era, eraPoints }) => `Era: ${era}, points ${eraPoints}`) + * ); + * ``` + */ export const erasPoints = /*#__PURE__*/ erasHistoricApply('_erasPoints'); diff --git a/packages/api-derive/src/staking/erasPrefs.ts b/packages/api-derive/src/staking/erasPrefs.ts index 5b2942c479..2a9bb859c0 100644 --- a/packages/api-derive/src/staking/erasPrefs.ts +++ b/packages/api-derive/src/staking/erasPrefs.ts @@ -37,6 +37,27 @@ export function _eraPrefs (instanceId: string, api: DeriveApi): (era: EraIndex, }); } +/** + * @name eraPrefs + * @description Retrieves the validators commission preferences for a given staking era. + * @param {EraIndex} era The staking era to query. + * @example + * ```javascript + * const era = api.createType("EraIndex", 1000); + * const prefs = await api.derive.staking.eraPrefs(era); + * console.log(JSON.stringify(prefs)); + * ``` + */ export const eraPrefs = /*#__PURE__*/ singleEra('_eraPrefs'); export const _erasPrefs = /*#__PURE__*/ combineEras('_eraPrefs'); + +/** + * @name erasPrefs + * @description Retrieves validators commission preferences for multiple past staking eras + * @param {boolean} withActive? (Optional) Whether to include the active era in the result. + * @example + * ```javascript + * const prefs = await api.derive.staking.erasPrefs(true); + * ``` + */ export const erasPrefs = /*#__PURE__*/ erasHistoricApply('_erasPrefs'); diff --git a/packages/api-derive/src/staking/erasRewards.ts b/packages/api-derive/src/staking/erasRewards.ts index 905d211e20..a661d7ba44 100644 --- a/packages/api-derive/src/staking/erasRewards.ts +++ b/packages/api-derive/src/staking/erasRewards.ts @@ -40,4 +40,13 @@ export function _erasRewards (instanceId: string, api: DeriveApi): (eras: EraInd }); } +/** + * @name erasRewards + * @description Retrieves rewards for historical eras. + * @param {boolean} withActive? (Optional) Whether to include the active era in the result. + * @example + * ```javascript + * const rewards = await api.derive.staking.erasRewards(true); + * ``` + */ export const erasRewards = /*#__PURE__*/ erasHistoricApply('_erasRewards'); diff --git a/packages/api-derive/src/staking/erasSlashes.ts b/packages/api-derive/src/staking/erasSlashes.ts index 46a35c5bd1..6279a8d43d 100644 --- a/packages/api-derive/src/staking/erasSlashes.ts +++ b/packages/api-derive/src/staking/erasSlashes.ts @@ -45,6 +45,25 @@ export function _eraSlashes (instanceId: string, api: DeriveApi): (era: EraIndex }); } +/** + * @name eraSlashes + * @description Retrieves the slashes for a specific staking era. + * @param {EraIndex} eras The staking era to query. + * @example + * ```javascript + * const era = api.createType("EraIndex", 1000); + * const slashes = await api.derive.staking.eraSlashes(era); + * ``` + */ export const eraSlashes = /*#__PURE__*/ singleEra('_eraSlashes'); export const _erasSlashes = /*#__PURE__*/ combineEras('_eraSlashes'); +/** + * @name erasSlashes + * @description Retrieves slashes for historical eras. + * @param {boolean} withActive? (Optional) Whether to include the active era in the result. + * @example + * ```javascript + * const slashes = await api.derive.staking.erasSlashes(true); + * ``` + */ export const erasSlashes = /*#__PURE__*/ erasHistoricApply('_erasSlashes'); diff --git a/packages/api-derive/src/staking/keys.ts b/packages/api-derive/src/staking/keys.ts index 419c45a3c4..8f047699e1 100644 --- a/packages/api-derive/src/staking/keys.ts +++ b/packages/api-derive/src/staking/keys.ts @@ -26,11 +26,41 @@ function extractsIds (stashId: Uint8Array | string, queuedKeys: [AccountId, Kitc }; } +/** + * @name keys + * @param { Uint8Array | string } stashId The stash account ID whose session keys are to be retrieved. + * @description Retrieves the session keys associated with a given stash account. + * @example + * ```javascript + * const keys = await api.derive.staking.keys( + * ALICE + * ); + * console.log( + * "Session keys:", + * keys.sessionIds.map((key) => `Key: ${key}`) + * ); + * ``` + */ export const keys = /*#__PURE__*/ firstMemo( (api: DeriveApi, stashId: Uint8Array | string) => api.derive.staking.keysMulti([stashId]) ); +/** + * @name keysMulti + * @description Retrieves session keys for multiple stash accounts. + * @param { (Uint8Array | string)[] } stashIds Array of stash account IDs. + * @example + * ```javascript + * const keysMulti = await api.derive.staking.keysMulti([ ALICE, BOB ]); + * keysMulti.forEach((keys) => { + * console.log( + * "Session keys:", + * keys.sessionIds.map((key) => `Key: ${key}`) + * ); + * }); + * ``` + */ export function keysMulti (instanceId: string, api: DeriveApi): (stashIds: (Uint8Array | string)[]) => Observable { return memo(instanceId, (stashIds: (Uint8Array | string)[]): Observable => stashIds.length diff --git a/packages/api-derive/src/staking/overview.ts b/packages/api-derive/src/staking/overview.ts index ca638ed787..10783e52e8 100644 --- a/packages/api-derive/src/staking/overview.ts +++ b/packages/api-derive/src/staking/overview.ts @@ -11,7 +11,20 @@ import { objectSpread } from '@polkadot/util'; import { memo } from '../util/index.js'; /** - * @description Retrieve the staking overview, including elected and points earned + * @name overview + * @description Retrieve the staking overview, including elected validators and points earned. + * @example + * ```javascript + * const { + * activeEra, + * activeEraStart, + * currentEra, + * currentIndex, + * nextElected, + * validatorCount, + * validators, + * } = await api.derive.staking.overview(); + * ``` */ export function overview (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => diff --git a/packages/api-derive/src/staking/ownExposure.ts b/packages/api-derive/src/staking/ownExposure.ts index 6335f4844f..61fabe8a21 100644 --- a/packages/api-derive/src/staking/ownExposure.ts +++ b/packages/api-derive/src/staking/ownExposure.ts @@ -46,9 +46,38 @@ export function _ownExposures (instanceId: string, api: DeriveApi): (accountId: ); } +/** + * @name ownExposure + * @description Retrieves the staking exposure of a validator for a specific era, including their own stake. + * @param { Uint8Array | string } accountId The validator stash account. + * @param {EraIndex} era The staking era to query. + * @param { u32 | AnyNumber } page? (Optional) The pagination index. + * @example + * ```javascript + * const era = api.createType("EraIndex", 1000); + * const exposure = await api.derive.staking.ownExposure( + * "11VR4pF6c7kfBhfmuwwjWY3FodeYBKWx7ix2rsRCU2q6hqJ", + * era + * ); + * console.log(JSON.stringify(exposure)); + * ``` + */ export const ownExposure = /*#__PURE__*/ firstMemo( (api: DeriveApi, accountId: Uint8Array | string, era: EraIndex, page?: u32 | AnyNumber) => api.derive.staking._ownExposures(accountId, [era], true, page || 0) ); +/** + * @name ownExposures + * @description Retrieves staking exposures for a validator across multiple historical eras. + * @param { Uint8Array | string } accountId The validator stash account. + * @param { boolean } withActive Whether to include the active era. + * @example + * ```javascript + * const exposures = await api.derive.staking.ownExposures( + * ALICE, + * true + * ); + * ``` + */ export const ownExposures = /*#__PURE__*/ erasHistoricApplyAccount('_ownExposures'); diff --git a/packages/api-derive/src/staking/ownSlashes.ts b/packages/api-derive/src/staking/ownSlashes.ts index ffea663a46..2d2dec8149 100644 --- a/packages/api-derive/src/staking/ownSlashes.ts +++ b/packages/api-derive/src/staking/ownSlashes.ts @@ -31,9 +31,38 @@ export function _ownSlashes (instanceId: string, api: DeriveApi): (accountId: Ui ); } +/** + * @name ownSlash + * @description Retrieves the slashes applied to a specific account in a given era. + * @param { Uint8Array | string } accountId The validator stash account. + * @param {EraIndex} era The staking era to query. + * @example + * ```javascript + * const era = api.createType("EraIndex", 1000); + * const slashedAmount = await api.derive.staking.ownSlash( + * ALICE, + * era + * ); + * console.log(`Era: ${slashedAmount.era}, total ${slashedAmount.total}`); + * ``` + */ export const ownSlash = /*#__PURE__*/ firstMemo( (api: DeriveApi, accountId: Uint8Array | string, era: EraIndex) => api.derive.staking._ownSlashes(accountId, [era], true) ); +/** + * @name ownSlashes + * @description Retrieves the slashes for a specific account across all historic eras. + * @param { Uint8Array | string } accountId The validator stash account. + * @param { boolean } withActive Whether to include the active era. + * @example + * ```javascript + * const slashes = await api.derive.staking.ownSlashes( + * ALICE, + * true + * ); + * console.log(slashes); + * ``` + */ export const ownSlashes = /*#__PURE__*/ erasHistoricApplyAccount('_ownSlashes'); diff --git a/packages/api-derive/src/staking/query.ts b/packages/api-derive/src/staking/query.ts index 987fe4063c..e97fb06820 100644 --- a/packages/api-derive/src/staking/query.ts +++ b/packages/api-derive/src/staking/query.ts @@ -184,15 +184,36 @@ function getBatch (api: DeriveApi, activeEra: EraIndex, stashIds: AccountId[], f ); } -// /** - * @description From a stash, retrieve the controllerId and all relevant details + * @name query + * @param { Uint8Array | string } accountId The stash account to query. + * @param { StakingQueryFlags } flags Flags to customize the query. + * @param { u32 } page (Optional) pagination parameter. + * @description Retrieves staking details for a given stash account. + * @example + * ```javascript + * const stakingInfo = await api.derive.staking.query( + * ALICE, + * {} + * ); + * ``` */ export const query = /*#__PURE__*/ firstMemo( (api: DeriveApi, accountId: Uint8Array | string, flags: StakingQueryFlags, page?: u32) => api.derive.staking.queryMulti([accountId], flags, page) ); +/** + * @name queryMulti + * @param { (Uint8Array | string)[] } accountIds List of stash accounts to query. + * @param { StakingQueryFlags } flags Flags to customize the query. + * @param { u32 } page (Optional) pagination parameter. + * @description Retrieves staking details for multiple stash accounts. + * @example + * ```javascript + * const stakingInfos = await api.derive.staking.queryMulti([stashId1, stashId2], {}); + * ``` + */ export function queryMulti (instanceId: string, api: DeriveApi): (accountIds: (Uint8Array | string)[], flags: StakingQueryFlags, page?: u32 | AnyNumber) => Observable { return memo(instanceId, (accountIds: (Uint8Array | string)[], flags: StakingQueryFlags, page?: u32 | AnyNumber): Observable => api.derive.session.indexes().pipe( diff --git a/packages/api-derive/src/staking/stakerExposure.ts b/packages/api-derive/src/staking/stakerExposure.ts index 06bc243c3e..5e404cb8eb 100644 --- a/packages/api-derive/src/staking/stakerExposure.ts +++ b/packages/api-derive/src/staking/stakerExposure.ts @@ -38,6 +38,19 @@ export function _stakerExposures (instanceId: string, api: DeriveApi): (accountI }); } +/** + * @name stakerExposures + * @param { (Uint8Array | string)[] } accountIds List of validator stash accounts. + * @param { boolean } withActive Whether to include the active era. + * @description Retrieves staking exposure for multiple accounts across historical eras. + * @example + * ```javascript + * const exposure = await api.derive.staking.stakerExposures( + * [ALICE, BOB], + * true + * ); + * ``` +*/ export function stakerExposures (instanceId: string, api: DeriveApi): (accountIds: (Uint8Array | string)[], withActive?: boolean) => Observable { return memo(instanceId, (accountIds: (Uint8Array | string)[], withActive = false): Observable => api.derive.staking.erasHistoric(withActive).pipe( @@ -46,6 +59,19 @@ export function stakerExposures (instanceId: string, api: DeriveApi): (accountId ); } +/** + * @name stakerExposure + * @param { Uint8Array | string } accountId The validator stash account. + * @param { boolean } withActive Whether to include the active era. + * @description Retrieves staking exposure for a single account across historical eras. Exposure refers to the total stake associated with a validator. + * @example + * ```javascript + * const exposure = await api.derive.staking.stakerExposure( + * ALICE, + * true + * ); + * ``` +*/ export const stakerExposure = /*#__PURE__*/ firstMemo( (api: DeriveApi, accountId: Uint8Array | string, withActive?: boolean) => api.derive.staking.stakerExposures([accountId], withActive) diff --git a/packages/api-derive/src/staking/stakerPoints.ts b/packages/api-derive/src/staking/stakerPoints.ts index 85c341888d..52c91cfde2 100644 --- a/packages/api-derive/src/staking/stakerPoints.ts +++ b/packages/api-derive/src/staking/stakerPoints.ts @@ -26,4 +26,21 @@ export function _stakerPoints (instanceId: string, api: DeriveApi): (accountId: }); } +/** + * @name stakerPoints + * @param { Uint8Array | string } accountId The stakers AccountId. + * @param { boolean } withActive Whether to include the active era. + * @description Retrieves the era reward points earned by a given staker across all eras. + * @example + * ```javascript + * const points = await api.derive.staking.stakerPoints( + * ALICE, //Alice accountId + * false + * ); + * console.log( + * 'Validator Era Points:', + * points.map(({ era, points }) => `Era ${era}: ${points.toString()} points`) + * ); + * ``` +*/ export const stakerPoints = /*#__PURE__*/ erasHistoricApplyAccount('_stakerPoints'); diff --git a/packages/api-derive/src/staking/stakerPrefs.ts b/packages/api-derive/src/staking/stakerPrefs.ts index 0fd9518a0d..8afdbfa84d 100644 --- a/packages/api-derive/src/staking/stakerPrefs.ts +++ b/packages/api-derive/src/staking/stakerPrefs.ts @@ -23,4 +23,23 @@ export function _stakerPrefs (instanceId: string, api: DeriveApi): (accountId: U ); } +/** + * @name stakerPrefs + * @param { Uint8Array | string } accountId The stakers AccountId. + * @param { boolean } withActive Whether to include the active era. + * @description Retrieves the validator preferences for a given staker across historical eras. + * @example + * ```javascript + * const prefs = await api.derive.staking.stakerPrefs( + * ALICE, //Alice accountId + * false + * ); + * console.log( + * 'Validator Preferences:', + * prefs.map( + * ({ era, validatorPrefs }) => `Era ${era}: Commission ${validatorPrefs.commission.toString()}` + * ) + * ); + * ``` +*/ export const stakerPrefs = /*#__PURE__*/ erasHistoricApplyAccount('_stakerPrefs'); diff --git a/packages/api-derive/src/staking/stakerRewards.ts b/packages/api-derive/src/staking/stakerRewards.ts index f0ee043614..6a02487c96 100644 --- a/packages/api-derive/src/staking/stakerRewards.ts +++ b/packages/api-derive/src/staking/stakerRewards.ts @@ -235,6 +235,19 @@ export function _stakerRewards (instanceId: string, api: DeriveApi): (accountIds ); } +/** + * @name stakerRewards + * @description Staking rewards history for a given staker. + * @param { Uint8Array | string } accountId The stakers AccountId. + * @param { boolean } withActive Whether to include the active era. + * @example + * ```javascript + * const rewards = await api.derive.staking.stakerRewards( + * ALICE, //Alice accountId + * false + * ); + * ``` + */ export const stakerRewards = /*#__PURE__*/ firstMemo( (api: DeriveApi, accountId: Uint8Array | string, withActive?: boolean) => api.derive.staking.erasHistoric(withActive).pipe( @@ -242,6 +255,19 @@ export const stakerRewards = /*#__PURE__*/ firstMemo( ) ); +/** + * @name stakerRewardsMultiEras + * @description Staking rewards for multiple stakers over specific eras. + * @param { Uint8Array | string } accountIds List of stakers identified by their AccountId. + * @param { EraIndex[] } eras Eras for which to retrieve the data. + * @example + * ```javascript + * const rewards = await api.derive.staking.stakerRewardsMultiEras( + * [ALICE, BOB, CHARLIER], //accountIds + * [100,101] //eras + * ); + * ``` + */ export function stakerRewardsMultiEras (instanceId: string, api: DeriveApi): (accountIds: (Uint8Array | string)[], eras: EraIndex[]) => Observable { return memo(instanceId, (accountIds: (Uint8Array | string)[], eras: EraIndex[]): Observable => accountIds.length && eras.length @@ -250,6 +276,19 @@ export function stakerRewardsMultiEras (instanceId: string, api: DeriveApi): (ac ); } +/** + * @name stakerRewardsMulti + * @description Staking rewards for multiple stakers. + * @param { Uint8Array | string } accountIds List of stakers identified by their AccountId. + * @param { boolean } withActive Whether to include the active era. + * @example + * ```javascript + * const rewards = await api.derive.staking.stakerRewardsMulti( + * [ALICE, BOB, CHARLIER], //accountIds + * true + * ); + * ``` + */ export function stakerRewardsMulti (instanceId: string, api: DeriveApi): (accountIds: (Uint8Array | string)[], withActive?: boolean) => Observable { return memo(instanceId, (accountIds: (Uint8Array | string)[], withActive = false): Observable => api.derive.staking.erasHistoric(withActive).pipe( diff --git a/packages/api-derive/src/staking/stakerSlashes.ts b/packages/api-derive/src/staking/stakerSlashes.ts index 536e289349..383ed9563a 100644 --- a/packages/api-derive/src/staking/stakerSlashes.ts +++ b/packages/api-derive/src/staking/stakerSlashes.ts @@ -25,4 +25,21 @@ export function _stakerSlashes (instanceId: string, api: DeriveApi): (accountId: }); } +/** + * @name stakerSlashes + * @param { Uint8Array | string } accountId The stakers AccountId. + * @param { boolean } withActive Whether to include the active era. + * @description Retrieve the historical slashes (penalties) for a given staker. + * @example + * ```javascript + * const stakerSlashes = await api.derive.staking.stakerSlashes( + * ALICE, //Alice accountId + * true + * ); + * console.log( + * 'Staker Slashes:', + * stakerSlashes.map(({ era, total }) => `Era ${era}: Slashed ${total.toString()}`) + * ); + * ``` + */ export const stakerSlashes = /*#__PURE__*/ erasHistoricApplyAccount('_stakerSlashes'); diff --git a/packages/api-derive/src/staking/stashes.ts b/packages/api-derive/src/staking/stashes.ts index d1c4bc6377..4436cc2c89 100644 --- a/packages/api-derive/src/staking/stashes.ts +++ b/packages/api-derive/src/staking/stashes.ts @@ -34,7 +34,16 @@ function onBondedEvent (api: DeriveApi): Observable { } /** - * @description Retrieve the list of all validator stashes + * @name stashes + * @description Retrieve the list of all validator stashes. + * @example + * ```javascript + * const stashes = await api.derive.staking.stashes(); + * console.log( + * "Validator Stashes:", + * stashes.map((s) => s.toString()) + * ); + * ``` */ export function stashes (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => diff --git a/packages/api-derive/src/staking/validators.ts b/packages/api-derive/src/staking/validators.ts index 729c869b46..12f8fb8cc1 100644 --- a/packages/api-derive/src/staking/validators.ts +++ b/packages/api-derive/src/staking/validators.ts @@ -9,6 +9,18 @@ import { combineLatest, map, of, switchMap } from 'rxjs'; import { memo } from '../util/index.js'; +/** + * @name nextElected + * @description Retrieves the list of accounts that are set to be the next elected validators in the staking system. It provides a preview of who will be validators in the next staking era. + * @example + * ```javascript + * const nextElected = await api.derive.staking.nextElected(); + * console.log( + * "Next Elected Validators:", + * nextElected.map((acc) => acc.toString()) + * ); + * ``` + */ export function nextElected (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => // Compatibility for future generation changes in staking. @@ -33,7 +45,20 @@ export function nextElected (instanceId: string, api: DeriveApi): () => Observab } /** - * @description Retrieve latest list of validators + * @name validators + * @description Retrieve latest list of validators. + * @example + * ```javascript + * const { validators, nextElected } = await api.derive.staking.validators(); + * console.log( + * "Current Validators:", + * validators.map((v) => v.toString()) + * ); + * console.log( + * "Next Elected Validators:", + * nextElected.map((v) => v.toString()) + * ); + * ``` */ export function validators (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => diff --git a/packages/api-derive/src/staking/waitingInfo.ts b/packages/api-derive/src/staking/waitingInfo.ts index 264a489719..33583c0268 100644 --- a/packages/api-derive/src/staking/waitingInfo.ts +++ b/packages/api-derive/src/staking/waitingInfo.ts @@ -10,6 +10,19 @@ import { memo } from '../util/index.js'; const DEFAULT_FLAGS = { withController: true, withPrefs: true }; +/** + * @name waitingInfo + * @param {StakingQueryFlags} flags? (Optional) Query flags to filter the staking data. + * @description Staking candidates who are waiting to become validators. + * @example + * ```javascript + * const { waiting, info } = await api.derive.staking.waitingInfo(); + * console.log( + * "Waiting Candidates:", + * waiting.map((acc) => acc.toString()) + * ); + * ``` + */ export function waitingInfo (instanceId: string, api: DeriveApi): (flags?: StakingQueryFlags) => Observable { return memo(instanceId, (flags: StakingQueryFlags = DEFAULT_FLAGS): Observable => combineLatest([ diff --git a/packages/api-derive/src/technicalCommittee/index.ts b/packages/api-derive/src/technicalCommittee/index.ts index aa4414d80f..78c7d3b0ff 100644 --- a/packages/api-derive/src/technicalCommittee/index.ts +++ b/packages/api-derive/src/technicalCommittee/index.ts @@ -3,12 +3,74 @@ import { hasProposals as collectiveHasProposals, members as collectiveMembers, prime as collectivePrime, proposal as collectiveProposal, proposalCount as collectiveProposalCount, proposalHashes as collectiveProposalHashes, proposals as collectiveProposals } from '../collective/index.js'; +/** + * @name members + * @description Retrieves the list of members in the "technicalCommittee" collective. + * @example + * ```javascript + * const members = await api.derive.technicalCommittee.members(); + * console.log(`Members: ${JSON.stringify(members)}); + * ``` + */ export const members = /*#__PURE__*/ collectiveMembers('technicalCommittee'); +/** + * @name hasProposals + * @description Checks if there are any active proposals in the "technicalCommittee" collective. + * @example + * ```javascript + * const exists = await api.derive.technicalCommittee.hasProposals(); + * console.log(exists); + * ``` + */ export const hasProposals = /*#__PURE__*/ collectiveHasProposals('technicalCommittee'); +/** + * @name proposal + * @description Retrieves details of a specific proposal in the "technicalCommitteeMotion" collective by its hash. + * @example + * ```javascript + * const proposalDetails = await api.derive.technicalCommittee.proposal(PROPOSAL_HASH); + * console.log(proposalDetails); + * ``` + */ export const proposal = /*#__PURE__*/ collectiveProposal('technicalCommittee'); +/** + * @name proposalCount + * @description Retrieves the total number of proposals in the "technicalCommittee" collective. + * @example + * ```javascript + * const count = await api.derive.technicalCommittee.proposalCount(); + * console.log(`Amount of proposals: ${count}`); + * ``` + */ export const proposalCount = /*#__PURE__*/ collectiveProposalCount('technicalCommittee'); +/** + * @name proposalHashes + * @description Retrieves an array of hashes for all active proposals in the "technicalCommittee" collective. + * @example + * ```javascript + * const hashes = await api.derive.technicalCommittee.proposalHashes(); + * console.log(`Proposals ${JSON.stringify(hashes)}`); + * ``` + */ export const proposalHashes = /*#__PURE__*/ collectiveProposalHashes('technicalCommittee'); +/** + * @name proposals + * @description Retrieves a list of all active proposals in the "technicalCommittee" collective. + * @example + * ```javascript + * const proposals = await api.derive.technicalCommittee.proposals(); + * console.log(proposals); + * ``` + */ export const proposals = /*#__PURE__*/ collectiveProposals('technicalCommittee'); - +/** + * @name prime + * @description Retrieves the prime member of the "technicalCommittee" collective, if one exists. + * @example + * ```javascript + * const primeMember = await api.derive.technicalCommittee.prime(); + * console.log(primeMember); + * ``` + */ export const prime = /*#__PURE__*/ collectivePrime('technicalCommittee'); diff --git a/packages/api-derive/src/treasury/proposals.ts b/packages/api-derive/src/treasury/proposals.ts index 275e703a77..736a09ca41 100644 --- a/packages/api-derive/src/treasury/proposals.ts +++ b/packages/api-derive/src/treasury/proposals.ts @@ -81,7 +81,13 @@ function retrieveProposals (api: DeriveApi, proposalCount: ProposalIndex, approv } /** - * @description Retrieve all active and approved treasury proposals, along with their info + * @name proposals + * @description Retrieve all active and approved treasury proposals, along with their info. + * @example + * ```javascript + * const treasuryProposals = await api.derive.treasury.proposals(); + * console.log(treasuryProposals); + * ``` */ export function proposals (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => diff --git a/packages/api-derive/src/tx/events.ts b/packages/api-derive/src/tx/events.ts index d412b5add1..84379d53bd 100644 --- a/packages/api-derive/src/tx/events.ts +++ b/packages/api-derive/src/tx/events.ts @@ -14,6 +14,19 @@ interface Result { events: EventRecord[]; } +/** + * @name events + * @param {Hash} at Block hash to query at. + * @description Retrieves the block information alongside its events at a given block hash + * @example + * ```javascript + * const blockHash = api.registry.createType( + * "Hash", + * "0xf1dc2efe8265be67deea5e91b05a98a7f9f81f66854e92825cf36f541beb7af6" + * ); + * const { events, block } = await api.derive.tx.events(blockHash); + * ``` + */ export function events (instanceId: string, api: DeriveApi): (at: Hash) => Observable { return memo(instanceId, (blockHash: Hash) => combineLatest([ diff --git a/packages/api-derive/src/tx/signingInfo.ts b/packages/api-derive/src/tx/signingInfo.ts index d1fdc64797..4fc028b39e 100644 --- a/packages/api-derive/src/tx/signingInfo.ts +++ b/packages/api-derive/src/tx/signingInfo.ts @@ -83,6 +83,20 @@ function babeOrAuraPeriod (api: DeriveApi): BN | undefined { return period && period.isZero && !period.isZero() ? period : undefined; } +/** + * @name signingInfo + * @description Retrieves signing-related information for an account, including the nonce, block header, and mortal length. + * @param {string} address The account address for which signing information is needed. + * @param { BN | bigint | Uint8Array | number | string } nonce? (Optional) The nonce to use. If `undefined`, the latest nonce is retrieved. + * @param { IExtrinsicEra | number } era? (Optional) The transaction era. + * @example + * ```javascript + * const info = await api.derive.tx.signingInfo( + * "14mM9FRDDtwSYicjNxSvMfQkap8o4m9zHq7hNW4JpbSL4PPU" + * ); + * console.log(info); + * ``` + */ export function signingInfo (_instanceId: string, api: DeriveApi): (address: string, nonce?: AnyNumber | Codec, era?: IExtrinsicEra | number) => Observable { // no memo, we want to do this fresh on each run return (address: string, nonce?: AnyNumber | Codec, era?: IExtrinsicEra | number): Observable => diff --git a/packages/typegen/src/metadataMd.ts b/packages/typegen/src/metadataMd.ts index 209a8bd758..a70973897e 100644 --- a/packages/typegen/src/metadataMd.ts +++ b/packages/typegen/src/metadataMd.ts @@ -693,7 +693,7 @@ function renderDerives (metadata: Record) { md += '\n- **params**:\n'; params.forEach( (param) => - (md += ` - ${param.name} \`${param.type}\`: ${param.description}`) + (md += ` - ${param.name} \`${param.type}\`: ${param.description}\n`) ); }