@substrate/api-sidecar
Version:
REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.
60 lines (59 loc) • 3.22 kB
TypeScript
import { AccountsVestingInfoService } from '../../services';
import AbstractController from '../AbstractController';
/**
* GET vesting information for an address.
*
* Paths:
* - `address`: Address to query.
*
* Query params:
* - (Optional)`at`: Block at which to retrieve runtime version information at. Block
* identifier, as the block height or block hash. Defaults to most recent block.
* - (Optional)`includeClaimable`: When set to 'true', calculates and includes vested
* amounts for each vesting schedule plus the claimable amount. This may require a
* relay chain connection for Asset Hub post-migration queries. Defaults to 'false'.
* - (Optional)`useRcBlock`: When set to 'true', uses the relay chain block specified in the
* 'at' parameter to determine corresponding Asset Hub block(s). Only supported for
* Asset Hub endpoints.
*
* Returns:
* - When using `useRcBlock` parameter: An array of response objects, one for each Asset Hub block found
* in the specified relay chain block. Returns empty array `[]` if no Asset Hub blocks found.
* - When using `at` parameter or no query params: A single response object.
*
* Response object structure:
* - `at`: Block number and hash at which the call was made.
* - `vesting`: Array of vesting schedules for an account.
* - `locked`: Number of tokens locked at start.
* - `perBlock`: Number of tokens that gets unlocked every block after `startingBlock`.
* - `startingBlock`: Starting block for unlocking(vesting).
* - `vested`: (Only when `includeClaimable=true`) Amount that has vested based on time elapsed.
* - `vestedBalance`: (Only when `includeClaimable=true`) Total vested across all schedules.
* - `vestingTotal`: (Only when `includeClaimable=true`) Total locked across all schedules.
* - `vestedClaimable`: (Only when `includeClaimable=true`) Actual amount that can be claimed now.
* - `blockNumberForCalculation`: (Only when `includeClaimable=true`) The block number used for calculations.
* - `blockNumberSource`: (Only when `includeClaimable=true`) Which chain's block number was used ('relay' or 'self').
* - `rcBlockHash`: The relay chain block hash. Only present when `useRcBlock` parameter is used.
* - `rcBlockNumber`: The relay chain block number. Only present when `useRcBlock` parameter is used.
* - `ahTimestamp`: The Asset Hub block timestamp. Only present when `useRcBlock` parameter is used.
*
* Note: When `includeClaimable=true` for Asset Hub post-migration queries, a relay chain
* connection is required since vesting schedules use relay chain block numbers.
*
* Substrate Reference:
* - Vesting Pallet: https://crates.parity.io/pallet_vesting/index.html
* - `VestingInfo`: https://crates.parity.io/pallet_vesting/struct.VestingInfo.html
*/
export default class AccountsVestingInfoController extends AbstractController<AccountsVestingInfoService> {
static controllerName: string;
static requiredPallets: string[][];
constructor(api: string);
protected initRoutes(): void;
/**
* Get vesting information for an account.
*
* @param req Express Request
* @param res Express Response
*/
private getAccountVestingInfo;
}