stargate: Add BondStatusString type to staking query extension

This commit is contained in:
willclarktech 2021-01-27 14:27:50 +00:00
parent 1754019fb6
commit a7b4ed87f7
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7
2 changed files with 9 additions and 3 deletions

View File

@ -20,8 +20,12 @@ type IQueryValidatorDelegationsResponse = cosmos.staking.v1beta1.IQueryValidator
type IQueryValidatorsResponse = cosmos.staking.v1beta1.IQueryValidatorsResponse;
type IQueryValidatorUnbondingDelegationsResponse = cosmos.staking.v1beta1.IQueryValidatorUnbondingDelegationsResponse;
// This needs to be exported otherwise TS wont let you export BondStatusString
export const { BondStatus } = cosmos.staking.v1beta1;
const { Query } = cosmos.staking.v1beta1;
export type BondStatusString = Exclude<keyof typeof BondStatus, "BOND_STATUS_UNSPECIFIED">;
export interface StakingExtension {
readonly staking: {
readonly unverified: {
@ -60,7 +64,7 @@ export interface StakingExtension {
validatorAddress: string,
paginationKey?: Uint8Array,
) => Promise<IQueryValidatorDelegationsResponse>;
validators: (status: string, paginationKey?: Uint8Array) => Promise<IQueryValidatorsResponse>;
validators: (status: BondStatusString, paginationKey?: Uint8Array) => Promise<IQueryValidatorsResponse>;
validatorUnbondingDelegations: (
validatorAddress: string,
paginationKey?: Uint8Array,
@ -165,7 +169,7 @@ export function setupStakingExtension(base: QueryClient): StakingExtension {
});
return toObject(response);
},
validators: async (status: string, paginationKey?: Uint8Array) => {
validators: async (status: BondStatusString, paginationKey?: Uint8Array) => {
const response = await queryService.validators({
status: status,
pagination: paginationKey ? { key: paginationKey } : undefined,

View File

@ -14,6 +14,8 @@ declare type IQueryValidatorResponse = cosmos.staking.v1beta1.IQueryValidatorRes
declare type IQueryValidatorDelegationsResponse = cosmos.staking.v1beta1.IQueryValidatorDelegationsResponse;
declare type IQueryValidatorsResponse = cosmos.staking.v1beta1.IQueryValidatorsResponse;
declare type IQueryValidatorUnbondingDelegationsResponse = cosmos.staking.v1beta1.IQueryValidatorUnbondingDelegationsResponse;
export declare const BondStatus: typeof cosmos.staking.v1beta1.BondStatus;
export declare type BondStatusString = Exclude<keyof typeof BondStatus, "BOND_STATUS_UNSPECIFIED">;
export interface StakingExtension {
readonly staking: {
readonly unverified: {
@ -52,7 +54,7 @@ export interface StakingExtension {
validatorAddress: string,
paginationKey?: Uint8Array,
) => Promise<IQueryValidatorDelegationsResponse>;
validators: (status: string, paginationKey?: Uint8Array) => Promise<IQueryValidatorsResponse>;
validators: (status: BondStatusString, paginationKey?: Uint8Array) => Promise<IQueryValidatorsResponse>;
validatorUnbondingDelegations: (
validatorAddress: string,
paginationKey?: Uint8Array,