sdk38: Add gov proposals endpoint to lcd

This commit is contained in:
willclarktech 2020-07-14 15:57:32 +02:00
parent 0d6484648a
commit 275ff2fb5e
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7
3 changed files with 53 additions and 2 deletions

View File

@ -51,4 +51,16 @@ describe("GovExtension", () => {
});
});
});
describe("proposals", () => {
it("works", async () => {
pendingWithoutWasmd();
const client = makeGovClient(wasmd.endpoint);
const response = await client.gov.proposals();
expect(response).toEqual({
height: jasmine.stringMatching(nonNegativeIntegerMatcher),
result: [],
});
});
});
});

View File

@ -36,9 +36,28 @@ export type GovParametersByTypeResponse =
| GovParametersTallyingResponse
| GovParametersVotingResponse;
export interface TallyResult {
readonly yes: string;
readonly abstain: string;
readonly no: string;
readonly no_with_veto: string;
}
export interface TextProposal {
readonly proposal_id: number;
readonly title: string;
readonly description: string;
readonly proposal_type: string;
readonly proposal_status: string;
readonly final_tally_result: TallyResult;
readonly submit_time: string;
readonly total_deposit: readonly Coin[];
readonly voting_start_time: string;
}
export interface GovProposalsResponse {
readonly height: string;
readonly result: {};
readonly result: readonly TextProposal[];
}
export interface GovProposalsByIdResponse {
@ -79,6 +98,7 @@ export interface GovVotesByVoterResponse {
export interface GovExtension {
readonly gov: {
readonly parametersByType: (parametersType: GovParametersType) => Promise<GovParametersByTypeResponse>;
readonly proposals: () => Promise<GovProposalsResponse>;
};
}
@ -87,6 +107,7 @@ export function setupGovExtension(base: LcdClient): GovExtension {
gov: {
parametersByType: async (parametersType: GovParametersType) =>
base.get(`/gov/parameters/${parametersType}`),
proposals: async () => base.get("/gov/proposals"),
},
};
}

View File

@ -30,9 +30,26 @@ export declare type GovParametersByTypeResponse =
| GovParametersDepositResponse
| GovParametersTallyingResponse
| GovParametersVotingResponse;
export interface TallyResult {
readonly yes: string;
readonly abstain: string;
readonly no: string;
readonly no_with_veto: string;
}
export interface TextProposal {
readonly proposal_id: number;
readonly title: string;
readonly description: string;
readonly proposal_type: string;
readonly proposal_status: string;
readonly final_tally_result: TallyResult;
readonly submit_time: string;
readonly total_deposit: readonly Coin[];
readonly voting_start_time: string;
}
export interface GovProposalsResponse {
readonly height: string;
readonly result: {};
readonly result: readonly TextProposal[];
}
export interface GovProposalsByIdResponse {
readonly height: string;
@ -65,6 +82,7 @@ export interface GovVotesByVoterResponse {
export interface GovExtension {
readonly gov: {
readonly parametersByType: (parametersType: GovParametersType) => Promise<GovParametersByTypeResponse>;
readonly proposals: () => Promise<GovProposalsResponse>;
};
}
export declare function setupGovExtension(base: LcdClient): GovExtension;