UNPKG

@q-dev/q-js-sdk

Version:

Typescript Library to interact with Q System Contracts

234 lines (233 loc) 6.88 kB
export interface ValidatorStats { lastBlockValidated: number; lastBlockValidatedTime: Date; lastAvailability: number; } export interface GetBlockOptions { 'filter[to]'?: number; 'filter[from]'?: number; sort?: string; 'page[cursor]'?: number; 'page[limit]'?: number; 'filter[signer]'?: string; 'filter[inturnsigner]'?: string; 'filter[anysigner]'?: string; 'filter[outofturn]'?: boolean; } export interface BlockInfo { id: string; type: string; attributes: { hash: string; parent_hash: string; miner: string; mainaccount: string; timestamp: number; inturn_signer: string; difficulty: number; }; } export interface GetMetricOptions { 'filter[cycles]'?: number; 'filter[signer]'?: string; 'filter[mainaccount]'?: string; 'page[cursor]'?: string; 'page[limit]'?: number; sort?: string; } export interface GetOnchainRootNodeMetricOptions { 'filter[rootAddress]'?: string; 'page[cursor]'?: number; 'page[limit]'?: number; sort?: string; } export interface GetRootNodeMetricOptions { cycles?: number; rootAddress?: string; blocksDelay?: number; sort?: 'asc' | 'desc'; } export interface RootNodeAggregatedOptions { rootAddress?: string; startBlock?: number; sort?: 'asc' | 'desc'; } export interface RootNodeAggregatedParams { 'filter[rootAddress]'?: string; 'filter[startBlock]'?: number; 'page[limit]': number; sort: 'asc' | 'desc'; } export interface VotingItemResponse { ProposalId: number; VotingType: string; VotingStatus: number; VotingStartTime: number; CurrentQuorum: string; RequiredQuorum: string; VotingEndTime: number; VetoEndTime: number; VotingSubType?: number; Candidate?: string; ReplaceDest?: string; } export interface VotingsResponse { data: VotingItemResponse[]; links: { self: string; prev?: string; next?: string; }; } export interface VotingOptions { filterType?: string; filterStatus?: string; sort?: 'voting_end_time' | '-voting_end_time'; pageCursor?: string; pageLimit?: number; } export interface ValidatorMetric { address: string; dueBlocks: number; inTurnBlocks: number; outOfTurnBlocks: number; inTurnAvailability: number; totalAvailability: number; } export interface OnchainRootNodeMetric { id: string; type: string; attributes: { rootAddress: string; startBlock: number; endBlock: number; startTime: number; endTime: number; }; } interface FirstObservedApproval { block: number; dueCycles: number | null; } interface LastObservedApproval { block: number; offlineCycles: number; } export interface RootNodeMetricApproval { mainAccount: string; firstObservedApproval: FirstObservedApproval; lastObservedApproval: LastObservedApproval; observedApprovals: { alias: string; firstObservedApproval: FirstObservedApproval; lastObservedApproval: LastObservedApproval; }[]; } export interface RootNodeMetric { firstTransitionBlock: number; lastTransitionBlock: number; byAddress: RootNodeMetricApproval[]; } export interface RootNodeQTHVotingsAggregated { total: { all: number; constitutionVoting?: number; epdrMembershipVoting?: number; epqfiMembershipVoting?: number; eprsMembershipVoting?: number; generalUpdateVoting?: number; rootNodesMembershipVoting?: number; rootNodesSlashingVoting?: number; }; byAddress: { accountAddress: string; counts: { all: number; constitutionVoting?: number; epdrMembershipVoting?: number; epqfiMembershipVoting?: number; eprsMembershipVoting?: number; generalUpdateVoting?: number; rootNodesMembershipVoting?: number; rootNodesSlashingVoting?: number; }; }[]; } export interface RootNodeVotingsAggregated { total: { all: number; addressVoting?: number; emergencyUpdateVoting?: number; upgradeVoting?: number; validatorsSlashingVoting?: number; }; byAddress: { accountAddress: string; counts: { all: number; addressVoting?: number; emergencyUpdateVoting?: number; upgradeVoting?: number; validatorsSlashingVoting?: number; }; }[]; } export interface RootNodeProposalsAggregated { total: { all: number; emergencyUpdateVoting?: number; rootNodesSlashingVoting?: number; validatorsSlashingVoting?: number; }; byAddress: { accountAddress: string; counts: { all: number; emergencyUpdateVoting?: number; rootNodesSlashingVoting?: number; validatorsSlashingVoting?: number; }; }[]; } export declare type L0ListItemStatus = 'active' | 'proposed'; export interface L0AddressEntry { signer: string; mainAccount: string; } export interface L0RootListItem { status: L0ListItemStatus; timestamp: string; signers: L0AddressEntry[] | null; roots: L0AddressEntry[]; activeRootPercentage?: number; } export interface L0ExclusionListItem { status: L0ListItemStatus; timestamp: string; signers: L0AddressEntry[] | null; exclusions: L0AddressEntry[]; activeRootPercentage?: number; } export declare class Indexer { protected baseURL: string; private _axios; constructor(baseURL: string); getValidatorStats(signers?: string[], options?: GetBlockOptions): Promise<ValidatorStats[]>; getInactiveValidators(signers: string[]): Promise<number>; getValidatorMetrics(cycles: number): Promise<ValidatorMetric[]>; private getBlocks; private getMetrics; getOnchainRootNodeMetrics(options: GetOnchainRootNodeMetricOptions): Promise<OnchainRootNodeMetric[]>; getVotings(options: VotingOptions): Promise<VotingsResponse>; getVotingsByCursor(cursor: string): Promise<VotingsResponse>; getL0RootList(status: L0ListItemStatus): Promise<L0RootListItem>; getL0ExclusionList(status: L0ListItemStatus): Promise<L0ExclusionListItem>; getRootNodeMetrics(options: GetRootNodeMetricOptions): Promise<RootNodeMetric>; getRNQTHVotingsAggregated(options?: RootNodeAggregatedOptions): Promise<RootNodeQTHVotingsAggregated>; getRNVotingsAggregated(options?: RootNodeAggregatedOptions): Promise<RootNodeVotingsAggregated>; getRNProposalsAggregated(options?: RootNodeAggregatedOptions): Promise<RootNodeProposalsAggregated>; private countValidatorStats; private countValidatorMetric; private buildRootNodeAggregatedParams; } export {};