-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.ts
More file actions
27 lines (24 loc) · 892 Bytes
/
test.ts
File metadata and controls
27 lines (24 loc) · 892 Bytes
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
import { ProposalQueryClient, VoteNotFoundError } from "./src/utils/managers/proposal.manager";
const client = new ProposalQueryClient(
"https://cosmos-api.polkachu.com",
true,
"cosmos1m902jrk0pn4yc47zfvauqwvtq0e03nen3juh82",
30000, // 30 seconds timeout
5 // 5 max retries
);
const proposalId = "938";
const granter = "cosmos1qqp5aqz63nqh3lz43k3m3msv2ymxh8dzznwvjd";
try {
const hasVoted = await client.checkIfVotedByGranter(proposalId);
if (hasVoted) {
console.log(`Granter ${granter} has voted on proposal ${proposalId}`);
} else {
console.log(`Granter ${granter} has not voted on proposal ${proposalId}`);
}
} catch (error) {
if (error instanceof VoteNotFoundError) {
console.log(`Granter ${error.granter} has not voted on proposal ${error.proposalId}`);
} else {
console.error(`Error checking vote: ${error}`);
}
}