-
Notifications
You must be signed in to change notification settings - Fork 36
/
gov-poll.ts
42 lines (37 loc) · 956 Bytes
/
gov-poll.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { LCDClient } from '@terra-money/terra.js';
import { AddressProvider } from '../../address-provider/provider';
interface ExecuteMsg {
contract: string;
msg: string;
}
export type PollStatus = 'in_progress' | 'passed' | 'rejected' | 'executed';
interface Option {
lcd: LCDClient;
poll_id: number;
}
export interface PollResponse {
id: number;
creator: string;
status: PollStatus;
end_height: number;
title: string;
description: string;
link?: string;
deposit_amount: string;
execute_data?: ExecuteMsg;
yes_votes: string;
no_votes: string;
staked_amount?: string;
total_balance_at_end_poll?: string;
}
export const queryGovPoll = ({ lcd, poll_id }: Option) => async (
addressProvider: AddressProvider,
): Promise<PollResponse> => {
const gov = addressProvider.gov();
const response: PollResponse = await lcd.wasm.contractQuery(gov, {
poll: {
poll_id: +poll_id,
},
});
return response;
};