@substrate/api-sidecar
Version:
REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.
81 lines (80 loc) • 3.86 kB
TypeScript
import { Option, Vec } from '@polkadot/types';
import { AccountId32, BlockHash } from '@polkadot/types/interfaces';
import type { PalletStakingRewardDestination } from '@polkadot/types/lookup';
import { IAccountStakingInfo, IEraStatus } from 'src/types/responses';
import { AbstractService } from '../AbstractService';
export declare class AccountsStakingInfoService extends AbstractService {
/**
* Fetch staking information for a _Stash_ account at a given block for asset hub.
*
* @param hash `BlockHash` to make call at (Only works for the head of the chain for now)
* @param includeClaimedRewards `boolean` to include claimed rewards (Only works for the head of the chain for now)
* @param stash address of the _Stash_ account to get the staking info of
*/
fetchAccountStakingInfoAssetHub(hash: BlockHash, includeClaimedRewards: boolean, stash: string): Promise<{
at: {
hash: `0x${string}`;
height: string;
};
controller: AccountId32;
rewardDestination: Option<PalletStakingRewardDestination>;
numSlashingSpans: number;
nominations: import("@polkadot/types/lookup").PalletStakingNominations | null;
staking: {
stash: AccountId32;
total: import("@polkadot/types").Compact<import("@polkadot/types").U128>;
active: import("@polkadot/types").Compact<import("@polkadot/types").U128>;
unlocking: Vec<import("@polkadot/types/lookup").PalletStakingUnlockChunk>;
claimedRewards: IEraStatus<"undefined" | "claimed" | "unclaimed" | "partially claimed">[];
};
} | {
at: {
hash: `0x${string}`;
height: string;
};
controller: AccountId32;
rewardDestination: Option<PalletStakingRewardDestination>;
numSlashingSpans: number;
nominations: import("@polkadot/types/lookup").PalletStakingNominations | null;
staking: {
stash: AccountId32;
total: import("@polkadot/types").Compact<import("@polkadot/types").U128>;
active: import("@polkadot/types").Compact<import("@polkadot/types").U128>;
unlocking: Vec<import("@polkadot/types/lookup").PalletStakingUnlockChunk>;
claimedRewards?: undefined;
};
}>;
private fetchErasStatusForValidatorAssetHub;
/**
* Fetch staking information for a _Stash_ account at a given block.
*
* @param hash `BlockHash` to make call at
* @param stash address of the _Stash_ account to get the staking info of
*/
fetchAccountStakingInfo(hash: BlockHash, includeClaimedRewards: boolean, stash: string): Promise<IAccountStakingInfo>;
private fetchStakingData;
private fetchErasStatusForValidator;
private fetchErasStatusForNominator;
/**
* This function returns the era and its reward status information for a given stash account.
*/
private fetchErasFromOldCalls;
private ErasStatusNominatorForValPartiallyClaimed;
/**
* This function calculates the era from which we should start checking
* for claimed rewards.
*/
private fetchErasStart;
/**
* This function verifies if the information from old calls has already been checked/used. If not,
* it proceeds to use it and populate the `claimedRewards` array with the eras that have been claimed.
* Note that data from old calls may also be empty (no results), in which case the `claimedRewards` array
* will only be populated with data from the new `query.staking?.claimedRewards` call
* (later in the main function's code).
*
* Returns a boolean flag `oldCallChecked` that indicates if the old calls have already been checked/used or not.
*
*/
private isOldCallsChecked;
private fetchClaimedInfoFromOldCalls;
}