mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
stargate: Rearrange distribution query extension
This commit is contained in:
parent
8ab0d86cba
commit
664affd493
@ -51,7 +51,7 @@ describe("DistributionExtension", () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.unverified.communityPool();
|
||||
const response = await client.distribution.communityPool();
|
||||
expect(response.pool).toBeDefined();
|
||||
expect(response.pool).not.toBeNull();
|
||||
|
||||
@ -65,7 +65,7 @@ describe("DistributionExtension", () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.unverified.delegationRewards(
|
||||
const response = await client.distribution.delegationRewards(
|
||||
faucet.address0,
|
||||
validator.validatorAddress,
|
||||
);
|
||||
@ -81,7 +81,7 @@ describe("DistributionExtension", () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.unverified.delegationTotalRewards(faucet.address0);
|
||||
const response = await client.distribution.delegationTotalRewards(faucet.address0);
|
||||
expect(response.rewards).toBeDefined();
|
||||
expect(response.rewards).not.toBeNull();
|
||||
|
||||
@ -94,7 +94,7 @@ describe("DistributionExtension", () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.unverified.delegatorValidators(faucet.address0);
|
||||
const response = await client.distribution.delegatorValidators(faucet.address0);
|
||||
expect(response.validators).toBeDefined();
|
||||
expect(response.validators).not.toBeNull();
|
||||
|
||||
@ -107,7 +107,7 @@ describe("DistributionExtension", () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.unverified.delegatorWithdrawAddress(faucet.address0);
|
||||
const response = await client.distribution.delegatorWithdrawAddress(faucet.address0);
|
||||
expect(response.withdrawAddress).toBeDefined();
|
||||
expect(response.withdrawAddress).not.toBeNull();
|
||||
|
||||
@ -120,7 +120,7 @@ describe("DistributionExtension", () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.unverified.params();
|
||||
const response = await client.distribution.params();
|
||||
expect(response.params).toBeDefined();
|
||||
expect(response.params).not.toBeNull();
|
||||
|
||||
@ -133,7 +133,7 @@ describe("DistributionExtension", () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.unverified.validatorCommission(validator.validatorAddress);
|
||||
const response = await client.distribution.validatorCommission(validator.validatorAddress);
|
||||
expect(response.commission).toBeDefined();
|
||||
expect(response.commission).not.toBeNull();
|
||||
|
||||
@ -146,9 +146,7 @@ describe("DistributionExtension", () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.unverified.validatorOutstandingRewards(
|
||||
validator.validatorAddress,
|
||||
);
|
||||
const response = await client.distribution.validatorOutstandingRewards(validator.validatorAddress);
|
||||
expect(response.rewards).toBeDefined();
|
||||
expect(response.rewards).not.toBeNull();
|
||||
|
||||
@ -161,11 +159,7 @@ describe("DistributionExtension", () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.unverified.validatorSlashes(
|
||||
validator.validatorAddress,
|
||||
1,
|
||||
5,
|
||||
);
|
||||
const response = await client.distribution.validatorSlashes(validator.validatorAddress, 1, 5);
|
||||
expect(response.slashes).toBeDefined();
|
||||
expect(response.slashes).not.toBeNull();
|
||||
|
||||
|
@ -18,27 +18,25 @@ import { createPagination, createProtobufRpcClient } from "./utils";
|
||||
|
||||
export interface DistributionExtension {
|
||||
readonly distribution: {
|
||||
unverified: {
|
||||
communityPool: () => Promise<QueryCommunityPoolResponse>;
|
||||
delegationRewards: (
|
||||
delegatorAddress: string,
|
||||
validatorAddress: string,
|
||||
) => Promise<QueryDelegationRewardsResponse>;
|
||||
delegationTotalRewards: (delegatorAddress: string) => Promise<QueryDelegationTotalRewardsResponse>;
|
||||
delegatorValidators: (delegatorAddress: string) => Promise<QueryDelegatorValidatorsResponse>;
|
||||
delegatorWithdrawAddress: (delegatorAddress: string) => Promise<QueryDelegatorWithdrawAddressResponse>;
|
||||
params: () => Promise<QueryParamsResponse>;
|
||||
validatorCommission: (validatorAddress: string) => Promise<QueryValidatorCommissionResponse>;
|
||||
validatorOutstandingRewards: (
|
||||
validatorAddress: string,
|
||||
) => Promise<QueryValidatorOutstandingRewardsResponse>;
|
||||
validatorSlashes: (
|
||||
validatorAddress: string,
|
||||
startingHeight: number,
|
||||
endingHeight: number,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<QueryValidatorSlashesResponse>;
|
||||
};
|
||||
communityPool: () => Promise<QueryCommunityPoolResponse>;
|
||||
delegationRewards: (
|
||||
delegatorAddress: string,
|
||||
validatorAddress: string,
|
||||
) => Promise<QueryDelegationRewardsResponse>;
|
||||
delegationTotalRewards: (delegatorAddress: string) => Promise<QueryDelegationTotalRewardsResponse>;
|
||||
delegatorValidators: (delegatorAddress: string) => Promise<QueryDelegatorValidatorsResponse>;
|
||||
delegatorWithdrawAddress: (delegatorAddress: string) => Promise<QueryDelegatorWithdrawAddressResponse>;
|
||||
params: () => Promise<QueryParamsResponse>;
|
||||
validatorCommission: (validatorAddress: string) => Promise<QueryValidatorCommissionResponse>;
|
||||
validatorOutstandingRewards: (
|
||||
validatorAddress: string,
|
||||
) => Promise<QueryValidatorOutstandingRewardsResponse>;
|
||||
validatorSlashes: (
|
||||
validatorAddress: string,
|
||||
startingHeight: number,
|
||||
endingHeight: number,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<QueryValidatorSlashesResponse>;
|
||||
};
|
||||
}
|
||||
|
||||
@ -50,66 +48,64 @@ export function setupDistributionExtension(base: QueryClient): DistributionExten
|
||||
|
||||
return {
|
||||
distribution: {
|
||||
unverified: {
|
||||
communityPool: async () => {
|
||||
const response = await queryService.CommunityPool({});
|
||||
return response;
|
||||
},
|
||||
delegationRewards: async (delegatorAddress: string, validatorAddress: string) => {
|
||||
const response = await queryService.DelegationRewards({
|
||||
delegatorAddress: delegatorAddress,
|
||||
validatorAddress: validatorAddress,
|
||||
});
|
||||
return response;
|
||||
},
|
||||
delegationTotalRewards: async (delegatorAddress: string) => {
|
||||
const response = await queryService.DelegationTotalRewards({
|
||||
delegatorAddress: delegatorAddress,
|
||||
});
|
||||
return response;
|
||||
},
|
||||
delegatorValidators: async (delegatorAddress: string) => {
|
||||
const response = await queryService.DelegatorValidators({
|
||||
delegatorAddress: delegatorAddress,
|
||||
});
|
||||
return response;
|
||||
},
|
||||
delegatorWithdrawAddress: async (delegatorAddress: string) => {
|
||||
const response = await queryService.DelegatorWithdrawAddress({
|
||||
delegatorAddress: delegatorAddress,
|
||||
});
|
||||
return response;
|
||||
},
|
||||
params: async () => {
|
||||
const response = await queryService.Params({});
|
||||
return response;
|
||||
},
|
||||
validatorCommission: async (validatorAddress: string) => {
|
||||
const response = await queryService.ValidatorCommission({
|
||||
validatorAddress: validatorAddress,
|
||||
});
|
||||
return response;
|
||||
},
|
||||
validatorOutstandingRewards: async (validatorAddress: string) => {
|
||||
const response = await queryService.ValidatorOutstandingRewards({
|
||||
validatorAddress: validatorAddress,
|
||||
});
|
||||
return response;
|
||||
},
|
||||
validatorSlashes: async (
|
||||
validatorAddress: string,
|
||||
startingHeight: number,
|
||||
endingHeight: number,
|
||||
paginationKey?: Uint8Array,
|
||||
) => {
|
||||
const response = await queryService.ValidatorSlashes({
|
||||
validatorAddress: validatorAddress,
|
||||
startingHeight: Long.fromNumber(startingHeight, true),
|
||||
endingHeight: Long.fromNumber(endingHeight, true),
|
||||
pagination: createPagination(paginationKey),
|
||||
});
|
||||
return response;
|
||||
},
|
||||
communityPool: async () => {
|
||||
const response = await queryService.CommunityPool({});
|
||||
return response;
|
||||
},
|
||||
delegationRewards: async (delegatorAddress: string, validatorAddress: string) => {
|
||||
const response = await queryService.DelegationRewards({
|
||||
delegatorAddress: delegatorAddress,
|
||||
validatorAddress: validatorAddress,
|
||||
});
|
||||
return response;
|
||||
},
|
||||
delegationTotalRewards: async (delegatorAddress: string) => {
|
||||
const response = await queryService.DelegationTotalRewards({
|
||||
delegatorAddress: delegatorAddress,
|
||||
});
|
||||
return response;
|
||||
},
|
||||
delegatorValidators: async (delegatorAddress: string) => {
|
||||
const response = await queryService.DelegatorValidators({
|
||||
delegatorAddress: delegatorAddress,
|
||||
});
|
||||
return response;
|
||||
},
|
||||
delegatorWithdrawAddress: async (delegatorAddress: string) => {
|
||||
const response = await queryService.DelegatorWithdrawAddress({
|
||||
delegatorAddress: delegatorAddress,
|
||||
});
|
||||
return response;
|
||||
},
|
||||
params: async () => {
|
||||
const response = await queryService.Params({});
|
||||
return response;
|
||||
},
|
||||
validatorCommission: async (validatorAddress: string) => {
|
||||
const response = await queryService.ValidatorCommission({
|
||||
validatorAddress: validatorAddress,
|
||||
});
|
||||
return response;
|
||||
},
|
||||
validatorOutstandingRewards: async (validatorAddress: string) => {
|
||||
const response = await queryService.ValidatorOutstandingRewards({
|
||||
validatorAddress: validatorAddress,
|
||||
});
|
||||
return response;
|
||||
},
|
||||
validatorSlashes: async (
|
||||
validatorAddress: string,
|
||||
startingHeight: number,
|
||||
endingHeight: number,
|
||||
paginationKey?: Uint8Array,
|
||||
) => {
|
||||
const response = await queryService.ValidatorSlashes({
|
||||
validatorAddress: validatorAddress,
|
||||
startingHeight: Long.fromNumber(startingHeight, true),
|
||||
endingHeight: Long.fromNumber(endingHeight, true),
|
||||
pagination: createPagination(paginationKey),
|
||||
});
|
||||
return response;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user