Merge pull request #630 from cosmos/629-stargate-distribution-staking

Add support for staking/distribution queries
This commit is contained in:
Will Clark 2021-01-26 16:30:30 +01:00 committed by GitHub
commit 692bdc3e01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 12586 additions and 3 deletions

View File

@ -31,6 +31,10 @@ yarn pbjs \
"$COSMOS_PROTO_DIR/base/v1beta1/coin.proto" \
"$COSMOS_PROTO_DIR/crypto/multisig/v1beta1/multisig.proto" \
"$COSMOS_PROTO_DIR/crypto/secp256k1/keys.proto" \
"$COSMOS_PROTO_DIR/distribution/v1beta1/distribution.proto" \
"$COSMOS_PROTO_DIR/distribution/v1beta1/query.proto" \
"$COSMOS_PROTO_DIR/distribution/v1beta1/tx.proto" \
"$COSMOS_PROTO_DIR/staking/v1beta1/query.proto" \
"$COSMOS_PROTO_DIR/staking/v1beta1/staking.proto" \
"$COSMOS_PROTO_DIR/staking/v1beta1/tx.proto" \
"$COSMOS_PROTO_DIR/tx/signing/v1beta1/signing.proto" \

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,11 +4,15 @@ export { parseRawLog } from "./logs";
export {
AuthExtension,
BankExtension,
DistributionExtension,
IbcExtension,
QueryClient,
setupAuthExtension,
setupBankExtension,
setupDistributionExtension,
setupIbcExtension,
setupStakingExtension,
StakingExtension,
} from "./queries";
export {
Account,

View File

@ -0,0 +1,65 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { coin, coins } from "@cosmjs/launchpad";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { adaptor34, Client as TendermintClient } from "@cosmjs/tendermint-rpc";
import { assertDefinedAndNotNull, sleep } from "@cosmjs/utils";
import { cosmos } from "../codec";
import { SigningStargateClient } from "../signingstargateclient";
import { assertIsBroadcastTxSuccess } from "../stargateclient";
import { faucet, pendingWithoutSimapp, simapp, simappEnabled, validator } from "../testutils.spec";
import { DistributionExtension, setupDistributionExtension } from "./distribution";
import { QueryClient } from "./queryclient";
type IMsgDelegate = cosmos.staking.v1beta1.IMsgDelegate;
async function makeClientWithDistribution(
rpcUrl: string,
): Promise<[QueryClient & DistributionExtension, TendermintClient]> {
const tmClient = await TendermintClient.connect(rpcUrl, adaptor34);
return [QueryClient.withExtensions(tmClient, setupDistributionExtension), tmClient];
}
describe("DistributionExtension", () => {
const defaultFee = {
amount: coins(25000, "ucosm"),
gas: "1500000", // 1.5 million
};
beforeAll(async () => {
if (simappEnabled()) {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic);
const client = await SigningStargateClient.connectWithSigner(simapp.tendermintUrl, wallet);
const msg: IMsgDelegate = {
delegatorAddress: faucet.address0,
validatorAddress: validator.validatorAddress,
amount: coin(25000, "ustake"),
};
const msgAny = {
typeUrl: "/cosmos.staking.v1beta1.MsgDelegate",
value: msg,
};
const memo = "Test delegation for Stargate";
const result = await client.signAndBroadcast(faucet.address0, [msgAny], defaultFee, memo);
assertIsBroadcastTxSuccess(result);
await sleep(75); // wait until transactions are indexed
}
});
describe("unverified", () => {
describe("communityPool", () => {
it("works", async () => {
pendingWithoutSimapp();
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
const response = await client.distribution.unverified.communityPool();
assertDefinedAndNotNull(response.pool);
expect(response.pool.length).toBeGreaterThanOrEqual(1);
tmClient.disconnect();
});
});
});
});

View File

@ -0,0 +1,122 @@
/* eslint-disable @typescript-eslint/naming-convention */
import Long from "long";
import { cosmos } from "../codec";
import { QueryClient } from "./queryclient";
import { toObject } from "./utils";
type IQueryCommunityPoolResponse = cosmos.distribution.v1beta1.IQueryCommunityPoolResponse;
type IQueryDelegationRewardsResponse = cosmos.distribution.v1beta1.IQueryDelegationRewardsResponse;
type IQueryDelegationTotalRewardsResponse = cosmos.distribution.v1beta1.IQueryDelegationTotalRewardsResponse;
type IQueryDelegatorValidatorsResponse = cosmos.distribution.v1beta1.IQueryDelegatorValidatorsResponse;
type IQueryDelegatorWithdrawAddressResponse = cosmos.distribution.v1beta1.IQueryDelegatorWithdrawAddressResponse;
type IQueryParamsResponse = cosmos.distribution.v1beta1.IQueryParamsResponse;
type IQueryValidatorCommissionResponse = cosmos.distribution.v1beta1.IQueryValidatorCommissionResponse;
type IQueryValidatorOutstandingRewardsResponse = cosmos.distribution.v1beta1.IQueryValidatorOutstandingRewardsResponse;
type IQueryValidatorSlashesResponse = cosmos.distribution.v1beta1.IQueryValidatorSlashesResponse;
const { Query } = cosmos.distribution.v1beta1;
export interface DistributionExtension {
readonly distribution: {
unverified: {
communityPool: () => Promise<IQueryCommunityPoolResponse>;
delegationRewards: (
delegatorAddress: string,
validatorAddress: string,
) => Promise<IQueryDelegationRewardsResponse>;
delegationTotalRewards: (delegatorAddress: string) => Promise<IQueryDelegationTotalRewardsResponse>;
delegatorValidators: (delegatorAddress: string) => Promise<IQueryDelegatorValidatorsResponse>;
delegatorWithdrawAddress: (delegatorAddress: string) => Promise<IQueryDelegatorWithdrawAddressResponse>;
params: () => Promise<IQueryParamsResponse>;
validatorCommission: (validatorAddress: string) => Promise<IQueryValidatorCommissionResponse>;
validatorOutstandingRewards: (
validatorAddress: string,
) => Promise<IQueryValidatorOutstandingRewardsResponse>;
validatorSlashes: (
validatorAddress: string,
startingHeight: number,
endingHeight: number,
paginationKey?: Uint8Array,
) => Promise<IQueryValidatorSlashesResponse>;
};
};
}
export function setupDistributionExtension(base: QueryClient): DistributionExtension {
// Use this service to get easy typed access to query methods
// This cannot be used to for proof verification
const queryService = Query.create((method: any, requestData, callback) => {
// Parts of the path are unavailable, so we hardcode them here. See https://github.com/protobufjs/protobuf.js/issues/1229
const path = `/cosmos.distribution.v1beta1.Query/${method.name}`;
base
.queryUnverified(path, requestData)
.then((response) => callback(null, response))
.catch((error) => callback(error));
});
return {
distribution: {
unverified: {
communityPool: async () => {
const response = await queryService.communityPool({});
return toObject(response);
},
delegationRewards: async (delegatorAddress: string, validatorAddress: string) => {
const response = await queryService.delegationRewards({
delegatorAddress: delegatorAddress,
validatorAddress: validatorAddress,
});
return toObject(response);
},
delegationTotalRewards: async (delegatorAddress: string) => {
const response = await queryService.delegationTotalRewards({
delegatorAddress: delegatorAddress,
});
return toObject(response);
},
delegatorValidators: async (delegatorAddress: string) => {
const response = await queryService.delegatorValidators({
delegatorAddress: delegatorAddress,
});
return toObject(response);
},
delegatorWithdrawAddress: async (delegatorAddress: string) => {
const response = await queryService.delegatorWithdrawAddress({
delegatorAddress: delegatorAddress,
});
return toObject(response);
},
params: async () => {
const response = await queryService.params({});
return toObject(response);
},
validatorCommission: async (validatorAddress: string) => {
const response = await queryService.validatorCommission({
validatorAddress: validatorAddress,
});
return toObject(response);
},
validatorOutstandingRewards: async (validatorAddress: string) => {
const response = await queryService.validatorOutstandingRewards({
validatorAddress: validatorAddress,
});
return toObject(response);
},
validatorSlashes: async (
validatorAddress: string,
startingHeight: number,
endingHeight: number,
paginationKey?: Uint8Array,
) => {
const response = await queryService.validatorSlashes({
validatorAddress: validatorAddress,
startingHeight: Long.fromNumber(startingHeight),
endingHeight: Long.fromNumber(endingHeight),
pagination: paginationKey ? { key: paginationKey } : undefined,
});
return toObject(response);
},
},
},
};
}

View File

@ -6,4 +6,6 @@ export { QueryClient } from "./queryclient";
export { AuthExtension, setupAuthExtension } from "./auth";
export { BankExtension, setupBankExtension } from "./bank";
export { DistributionExtension, setupDistributionExtension } from "./distribution";
export { IbcExtension, setupIbcExtension } from "./ibc";
export { setupStakingExtension, StakingExtension } from "./staking";

View File

@ -0,0 +1,102 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { coin, coins } from "@cosmjs/launchpad";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { adaptor34, Client as TendermintClient } from "@cosmjs/tendermint-rpc";
import { assertDefinedAndNotNull, sleep } from "@cosmjs/utils";
import { cosmos } from "../codec";
import { SigningStargateClient } from "../signingstargateclient";
import { assertIsBroadcastTxSuccess } from "../stargateclient";
import {
faucet,
nonNegativeIntegerMatcher,
pendingWithoutSimapp,
simapp,
simappEnabled,
validator,
} from "../testutils.spec";
import { QueryClient } from "./queryclient";
import { setupStakingExtension, StakingExtension } from "./staking";
type IMsgDelegate = cosmos.staking.v1beta1.IMsgDelegate;
type IMsgUndelegate = cosmos.staking.v1beta1.IMsgUndelegate;
async function makeClientWithStaking(
rpcUrl: string,
): Promise<[QueryClient & StakingExtension, TendermintClient]> {
const tmClient = await TendermintClient.connect(rpcUrl, adaptor34);
return [QueryClient.withExtensions(tmClient, setupStakingExtension), tmClient];
}
describe("StakingExtension", () => {
const defaultFee = {
amount: coins(25000, "ucosm"),
gas: "1500000", // 1.5 million
};
beforeAll(async () => {
if (simappEnabled()) {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic);
const client = await SigningStargateClient.connectWithSigner(simapp.tendermintUrl, wallet);
{
const msg: IMsgDelegate = {
delegatorAddress: faucet.address0,
validatorAddress: validator.validatorAddress,
amount: coin(25000, "ustake"),
};
const msgAny = {
typeUrl: "/cosmos.staking.v1beta1.MsgDelegate",
value: msg,
};
const memo = "Test delegation for Stargate";
const result = await client.signAndBroadcast(faucet.address0, [msgAny], defaultFee, memo);
assertIsBroadcastTxSuccess(result);
}
{
const msg: IMsgUndelegate = {
delegatorAddress: faucet.address0,
validatorAddress: validator.validatorAddress,
amount: coin(100, "ustake"),
};
const msgAny = {
typeUrl: "/cosmos.staking.v1beta1.MsgUndelegate",
value: msg,
};
const memo = "Test undelegation for Stargate";
const result = await client.signAndBroadcast(faucet.address0, [msgAny], defaultFee, memo);
assertIsBroadcastTxSuccess(result);
}
await sleep(75); // wait until transactions are indexed
}
});
describe("unverified", () => {
describe("delegation", () => {
it("works", async () => {
pendingWithoutSimapp();
const [client, tmClient] = await makeClientWithStaking(simapp.tendermintUrl);
const response = await client.staking.unverified.delegation(
faucet.address0,
validator.validatorAddress,
);
assertDefinedAndNotNull(response.delegationResponse);
assertDefinedAndNotNull(response.delegationResponse.delegation);
assertDefinedAndNotNull(response.delegationResponse.balance);
expect({ ...response.delegationResponse.delegation }).toEqual({
delegatorAddress: faucet.address0,
validatorAddress: validator.validatorAddress,
shares: jasmine.stringMatching(nonNegativeIntegerMatcher),
});
expect({ ...response.delegationResponse.balance }).toEqual({
denom: "ustake",
amount: jasmine.stringMatching(nonNegativeIntegerMatcher),
});
tmClient.disconnect();
});
});
});
});

View File

@ -0,0 +1,185 @@
/* eslint-disable @typescript-eslint/naming-convention */
import Long from "long";
import { cosmos } from "../codec";
import { QueryClient } from "./queryclient";
import { toObject } from "./utils";
type IQueryDelegationResponse = cosmos.staking.v1beta1.IQueryDelegationResponse;
type IQueryDelegatorDelegationsResponse = cosmos.staking.v1beta1.IQueryDelegatorDelegationsResponse;
type IQueryDelegatorUnbondingDelegationsResponse = cosmos.staking.v1beta1.IQueryDelegatorUnbondingDelegationsResponse;
type IQueryDelegatorValidatorResponse = cosmos.staking.v1beta1.IQueryDelegatorValidatorResponse;
type IQueryDelegatorValidatorsResponse = cosmos.staking.v1beta1.IQueryDelegatorValidatorsResponse;
type IQueryHistoricalInfoResponse = cosmos.staking.v1beta1.IQueryHistoricalInfoResponse;
type IQueryParamsResponse = cosmos.staking.v1beta1.IQueryParamsResponse;
type IQueryPoolResponse = cosmos.staking.v1beta1.IQueryPoolResponse;
type IQueryRedelegationsResponse = cosmos.staking.v1beta1.IQueryRedelegationsResponse;
type IQueryUnbondingDelegationResponse = cosmos.staking.v1beta1.IQueryUnbondingDelegationResponse;
type IQueryValidatorResponse = cosmos.staking.v1beta1.IQueryValidatorResponse;
type IQueryValidatorDelegationsResponse = cosmos.staking.v1beta1.IQueryValidatorDelegationsResponse;
type IQueryValidatorsResponse = cosmos.staking.v1beta1.IQueryValidatorsResponse;
type IQueryValidatorUnbondingDelegationsResponse = cosmos.staking.v1beta1.IQueryValidatorUnbondingDelegationsResponse;
const { Query } = cosmos.staking.v1beta1;
export interface StakingExtension {
readonly staking: {
readonly unverified: {
delegation: (delegatorAddress: string, validatorAddress: string) => Promise<IQueryDelegationResponse>;
delegatorDelegations: (
delegatorAddress: string,
paginationKey?: Uint8Array,
) => Promise<IQueryDelegatorDelegationsResponse>;
delegatorUnbondingDelegations: (
delegatorAddress: string,
paginationKey?: Uint8Array,
) => Promise<IQueryDelegatorUnbondingDelegationsResponse>;
delegatorValidator: (
delegatorAddress: string,
validatorAddress: string,
) => Promise<IQueryDelegatorValidatorResponse>;
delegatorValidators: (
delegatorAddress: string,
paginationKey?: Uint8Array,
) => Promise<IQueryDelegatorValidatorsResponse>;
historicalInfo: (height: number) => Promise<IQueryHistoricalInfoResponse>;
params: () => Promise<IQueryParamsResponse>;
pool: () => Promise<IQueryPoolResponse>;
redelegations: (
delegatorAddress: string,
sourceValidatorAddress: string,
destinationValidatorAddress: string,
paginationKey?: Uint8Array,
) => Promise<IQueryRedelegationsResponse>;
unbondingDelegation: (
delegatorAddress: string,
validatorAddress: string,
) => Promise<IQueryUnbondingDelegationResponse>;
validator: (validatorAddress: string) => Promise<IQueryValidatorResponse>;
validatorDelegations: (
validatorAddress: string,
paginationKey?: Uint8Array,
) => Promise<IQueryValidatorDelegationsResponse>;
validators: (status: string, paginationKey?: Uint8Array) => Promise<IQueryValidatorsResponse>;
validatorUnbondingDelegations: (
validatorAddress: string,
paginationKey?: Uint8Array,
) => Promise<IQueryValidatorUnbondingDelegationsResponse>;
};
};
}
export function setupStakingExtension(base: QueryClient): StakingExtension {
// Use this service to get easy typed access to query methods
// This cannot be used to for proof verification
const queryService = Query.create((method: any, requestData, callback) => {
// Parts of the path are unavailable, so we hardcode them here. See https://github.com/protobufjs/protobuf.js/issues/1229
const path = `/cosmos.staking.v1beta1.Query/${method.name}`;
base
.queryUnverified(path, requestData)
.then((response) => callback(null, response))
.catch((error) => callback(error));
});
return {
staking: {
unverified: {
delegation: async (delegatorAddress: string, validatorAddress: string) => {
const response = await queryService.delegation({
delegatorAddr: delegatorAddress,
validatorAddr: validatorAddress,
});
return toObject(response);
},
delegatorDelegations: async (delegatorAddress: string, paginationKey?: Uint8Array) => {
const response = await queryService.delegatorDelegations({
delegatorAddr: delegatorAddress,
pagination: paginationKey ? { key: paginationKey } : undefined,
});
return toObject(response);
},
delegatorUnbondingDelegations: async (delegatorAddress: string, paginationKey?: Uint8Array) => {
const response = await queryService.delegatorUnbondingDelegations({
delegatorAddr: delegatorAddress,
pagination: paginationKey ? { key: paginationKey } : undefined,
});
return toObject(response);
},
delegatorValidator: async (delegatorAddress: string, validatorAddress: string) => {
const response = queryService.delegatorValidator({
delegatorAddr: delegatorAddress,
validatorAddr: validatorAddress,
});
return toObject(response);
},
delegatorValidators: async (delegatorAddress: string, paginationKey?: Uint8Array) => {
const response = queryService.delegatorValidators({
delegatorAddr: delegatorAddress,
pagination: paginationKey ? { key: paginationKey } : undefined,
});
return toObject(response);
},
historicalInfo: async (height: number) => {
const response = queryService.historicalInfo({
height: Long.fromNumber(height),
});
return toObject(response);
},
params: async () => {
const response = queryService.params({});
return toObject(response);
},
pool: async () => {
const response = queryService.pool({});
return toObject(response);
},
redelegations: async (
delegatorAddress: string,
sourceValidatorAddress: string,
destinationValidatorAddress: string,
paginationKey?: Uint8Array,
) => {
const response = queryService.redelegations({
delegatorAddr: delegatorAddress,
srcValidatorAddr: sourceValidatorAddress,
dstValidatorAddr: destinationValidatorAddress,
pagination: paginationKey ? { key: paginationKey } : undefined,
});
return toObject(response);
},
unbondingDelegation: async (delegatorAddress: string, validatorAddress: string) => {
const response = queryService.unbondingDelegation({
delegatorAddr: delegatorAddress,
validatorAddr: validatorAddress,
});
return toObject(response);
},
validator: async (validatorAddress: string) => {
const response = queryService.validator({ validatorAddr: validatorAddress });
return toObject(response);
},
validatorDelegations: async (validatorAddress: string, paginationKey?: Uint8Array) => {
const response = queryService.validatorDelegations({
validatorAddr: validatorAddress,
pagination: paginationKey ? { key: paginationKey } : undefined,
});
return toObject(response);
},
validators: async (status: string, paginationKey?: Uint8Array) => {
const response = queryService.validators({
status: status,
pagination: paginationKey ? { key: paginationKey } : undefined,
});
return toObject(response);
},
validatorUnbondingDelegations: async (validatorAddress: string, paginationKey?: Uint8Array) => {
const response = queryService.validatorUnbondingDelegations({
validatorAddr: validatorAddress,
pagination: paginationKey ? { key: paginationKey } : undefined,
});
return toObject(response);
},
},
},
};
}

View File

@ -28,6 +28,12 @@ import { cosmos } from "./codec";
import { BroadcastTxResponse, StargateClient } from "./stargateclient";
const { MsgMultiSend } = cosmos.bank.v1beta1;
const {
MsgFundCommunityPool,
MsgSetWithdrawAddress,
MsgWithdrawDelegatorReward,
MsgWithdrawValidatorCommission,
} = cosmos.distribution.v1beta1;
const {
MsgBeginRedelegate,
MsgCreateValidator,
@ -48,6 +54,10 @@ function createDefaultRegistry(): Registry {
["/cosmos.staking.v1beta1.MsgDelegate", MsgDelegate],
["/cosmos.staking.v1beta1.MsgEditValidator", MsgEditValidator],
["/cosmos.staking.v1beta1.MsgUndelegate", MsgUndelegate],
["/cosmos.distribution.v1beta1.MsgFundCommunityPool", MsgFundCommunityPool],
["/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", MsgSetWithdrawAddress],
["/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", MsgWithdrawDelegatorReward],
["/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", MsgWithdrawValidatorCommission],
]);
}

View File

@ -22,7 +22,19 @@ import { assert, assertDefinedAndNotNull } from "@cosmjs/utils";
import Long from "long";
import { cosmos } from "./codec";
import { AuthExtension, BankExtension, QueryClient, setupAuthExtension, setupBankExtension } from "./queries";
import {
AuthExtension,
BankExtension,
DistributionExtension,
IbcExtension,
QueryClient,
setupAuthExtension,
setupBankExtension,
setupDistributionExtension,
setupIbcExtension,
setupStakingExtension,
StakingExtension,
} from "./queries";
type IBaseAccount = cosmos.auth.v1beta1.IBaseAccount;
type IMsgData = cosmos.base.abci.v1beta1.IMsgData;
@ -125,7 +137,12 @@ export interface PrivateStargateClient {
export class StargateClient {
private readonly tmClient: TendermintClient;
private readonly queryClient: QueryClient & AuthExtension & BankExtension;
private readonly queryClient: QueryClient &
AuthExtension &
BankExtension &
DistributionExtension &
IbcExtension &
StakingExtension;
private chainId: string | undefined;
public static async connect(endpoint: string): Promise<StargateClient> {
@ -135,7 +152,14 @@ export class StargateClient {
protected constructor(tmClient: TendermintClient) {
this.tmClient = tmClient;
this.queryClient = QueryClient.withExtensions(tmClient, setupAuthExtension, setupBankExtension);
this.queryClient = QueryClient.withExtensions(
tmClient,
setupAuthExtension,
setupBankExtension,
setupDistributionExtension,
setupIbcExtension,
setupStakingExtension,
);
}
public async getChainId(): Promise<string> {

File diff suppressed because it is too large Load Diff

View File

@ -4,11 +4,15 @@ export { parseRawLog } from "./logs";
export {
AuthExtension,
BankExtension,
DistributionExtension,
IbcExtension,
QueryClient,
setupAuthExtension,
setupBankExtension,
setupDistributionExtension,
setupIbcExtension,
setupStakingExtension,
StakingExtension,
} from "./queries";
export {
Account,

View File

@ -0,0 +1,38 @@
import { cosmos } from "../codec";
import { QueryClient } from "./queryclient";
declare type IQueryCommunityPoolResponse = cosmos.distribution.v1beta1.IQueryCommunityPoolResponse;
declare type IQueryDelegationRewardsResponse = cosmos.distribution.v1beta1.IQueryDelegationRewardsResponse;
declare type IQueryDelegationTotalRewardsResponse = cosmos.distribution.v1beta1.IQueryDelegationTotalRewardsResponse;
declare type IQueryDelegatorValidatorsResponse = cosmos.distribution.v1beta1.IQueryDelegatorValidatorsResponse;
declare type IQueryDelegatorWithdrawAddressResponse = cosmos.distribution.v1beta1.IQueryDelegatorWithdrawAddressResponse;
declare type IQueryParamsResponse = cosmos.distribution.v1beta1.IQueryParamsResponse;
declare type IQueryValidatorCommissionResponse = cosmos.distribution.v1beta1.IQueryValidatorCommissionResponse;
declare type IQueryValidatorOutstandingRewardsResponse = cosmos.distribution.v1beta1.IQueryValidatorOutstandingRewardsResponse;
declare type IQueryValidatorSlashesResponse = cosmos.distribution.v1beta1.IQueryValidatorSlashesResponse;
export interface DistributionExtension {
readonly distribution: {
unverified: {
communityPool: () => Promise<IQueryCommunityPoolResponse>;
delegationRewards: (
delegatorAddress: string,
validatorAddress: string,
) => Promise<IQueryDelegationRewardsResponse>;
delegationTotalRewards: (delegatorAddress: string) => Promise<IQueryDelegationTotalRewardsResponse>;
delegatorValidators: (delegatorAddress: string) => Promise<IQueryDelegatorValidatorsResponse>;
delegatorWithdrawAddress: (delegatorAddress: string) => Promise<IQueryDelegatorWithdrawAddressResponse>;
params: () => Promise<IQueryParamsResponse>;
validatorCommission: (validatorAddress: string) => Promise<IQueryValidatorCommissionResponse>;
validatorOutstandingRewards: (
validatorAddress: string,
) => Promise<IQueryValidatorOutstandingRewardsResponse>;
validatorSlashes: (
validatorAddress: string,
startingHeight: number,
endingHeight: number,
paginationKey?: Uint8Array,
) => Promise<IQueryValidatorSlashesResponse>;
};
};
}
export declare function setupDistributionExtension(base: QueryClient): DistributionExtension;
export {};

View File

@ -1,4 +1,6 @@
export { QueryClient } from "./queryclient";
export { AuthExtension, setupAuthExtension } from "./auth";
export { BankExtension, setupBankExtension } from "./bank";
export { DistributionExtension, setupDistributionExtension } from "./distribution";
export { IbcExtension, setupIbcExtension } from "./ibc";
export { setupStakingExtension, StakingExtension } from "./staking";

View File

@ -0,0 +1,64 @@
import { cosmos } from "../codec";
import { QueryClient } from "./queryclient";
declare type IQueryDelegationResponse = cosmos.staking.v1beta1.IQueryDelegationResponse;
declare type IQueryDelegatorDelegationsResponse = cosmos.staking.v1beta1.IQueryDelegatorDelegationsResponse;
declare type IQueryDelegatorUnbondingDelegationsResponse = cosmos.staking.v1beta1.IQueryDelegatorUnbondingDelegationsResponse;
declare type IQueryDelegatorValidatorResponse = cosmos.staking.v1beta1.IQueryDelegatorValidatorResponse;
declare type IQueryDelegatorValidatorsResponse = cosmos.staking.v1beta1.IQueryDelegatorValidatorsResponse;
declare type IQueryHistoricalInfoResponse = cosmos.staking.v1beta1.IQueryHistoricalInfoResponse;
declare type IQueryParamsResponse = cosmos.staking.v1beta1.IQueryParamsResponse;
declare type IQueryPoolResponse = cosmos.staking.v1beta1.IQueryPoolResponse;
declare type IQueryRedelegationsResponse = cosmos.staking.v1beta1.IQueryRedelegationsResponse;
declare type IQueryUnbondingDelegationResponse = cosmos.staking.v1beta1.IQueryUnbondingDelegationResponse;
declare type IQueryValidatorResponse = cosmos.staking.v1beta1.IQueryValidatorResponse;
declare type IQueryValidatorDelegationsResponse = cosmos.staking.v1beta1.IQueryValidatorDelegationsResponse;
declare type IQueryValidatorsResponse = cosmos.staking.v1beta1.IQueryValidatorsResponse;
declare type IQueryValidatorUnbondingDelegationsResponse = cosmos.staking.v1beta1.IQueryValidatorUnbondingDelegationsResponse;
export interface StakingExtension {
readonly staking: {
readonly unverified: {
delegation: (delegatorAddress: string, validatorAddress: string) => Promise<IQueryDelegationResponse>;
delegatorDelegations: (
delegatorAddress: string,
paginationKey?: Uint8Array,
) => Promise<IQueryDelegatorDelegationsResponse>;
delegatorUnbondingDelegations: (
delegatorAddress: string,
paginationKey?: Uint8Array,
) => Promise<IQueryDelegatorUnbondingDelegationsResponse>;
delegatorValidator: (
delegatorAddress: string,
validatorAddress: string,
) => Promise<IQueryDelegatorValidatorResponse>;
delegatorValidators: (
delegatorAddress: string,
paginationKey?: Uint8Array,
) => Promise<IQueryDelegatorValidatorsResponse>;
historicalInfo: (height: number) => Promise<IQueryHistoricalInfoResponse>;
params: () => Promise<IQueryParamsResponse>;
pool: () => Promise<IQueryPoolResponse>;
redelegations: (
delegatorAddress: string,
sourceValidatorAddress: string,
destinationValidatorAddress: string,
paginationKey?: Uint8Array,
) => Promise<IQueryRedelegationsResponse>;
unbondingDelegation: (
delegatorAddress: string,
validatorAddress: string,
) => Promise<IQueryUnbondingDelegationResponse>;
validator: (validatorAddress: string) => Promise<IQueryValidatorResponse>;
validatorDelegations: (
validatorAddress: string,
paginationKey?: Uint8Array,
) => Promise<IQueryValidatorDelegationsResponse>;
validators: (status: string, paginationKey?: Uint8Array) => Promise<IQueryValidatorsResponse>;
validatorUnbondingDelegations: (
validatorAddress: string,
paginationKey?: Uint8Array,
) => Promise<IQueryValidatorUnbondingDelegationsResponse>;
};
};
}
export declare function setupStakingExtension(base: QueryClient): StakingExtension;
export {};