cosmwasm: Add query methods to Cw3CosmWasmClient
This commit is contained in:
parent
09c5968437
commit
bb8f2d856f
@ -18,6 +18,43 @@ export enum Vote {
|
||||
Veto = "veto",
|
||||
}
|
||||
|
||||
export interface ThresholdResult {
|
||||
readonly absolute_count: {
|
||||
readonly weight_needed: number;
|
||||
readonly total_weight: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ProposalResult {
|
||||
readonly id: number;
|
||||
readonly title: string;
|
||||
readonly description: string;
|
||||
readonly msgs: ReadonlyArray<Record<string, unknown>>;
|
||||
readonly expires: Expiration;
|
||||
readonly status: string;
|
||||
}
|
||||
|
||||
export interface ProposalsResult {
|
||||
readonly proposals: readonly ProposalResult[];
|
||||
}
|
||||
|
||||
export interface VoteResult {
|
||||
readonly vote: Vote;
|
||||
}
|
||||
|
||||
export interface VotesResult {
|
||||
readonly votes: ReadonlyArray<{ readonly vote: Vote; readonly voter: string; readonly weight: number }>;
|
||||
}
|
||||
|
||||
export interface VoterResult {
|
||||
readonly addr: string;
|
||||
readonly weight: number;
|
||||
}
|
||||
|
||||
export interface VotersResult {
|
||||
readonly voters: readonly VoterResult[];
|
||||
}
|
||||
|
||||
export class Cw3CosmWasmClient extends SigningCosmWasmClient {
|
||||
private readonly cw3ContractAddress: string;
|
||||
|
||||
@ -34,6 +71,68 @@ export class Cw3CosmWasmClient extends SigningCosmWasmClient {
|
||||
this.cw3ContractAddress = cw3ContractAddress;
|
||||
}
|
||||
|
||||
public getThreshold(): Promise<ThresholdResult> {
|
||||
return this.queryContractSmart(this.cw3ContractAddress, { threshold: {} });
|
||||
}
|
||||
|
||||
public getProposal(proposalId: number): Promise<ProposalResult> {
|
||||
return this.queryContractSmart(this.cw3ContractAddress, { proposal: { proposal_id: proposalId } });
|
||||
}
|
||||
|
||||
public listProposals(startAfter?: number, limit?: number): Promise<ProposalsResult> {
|
||||
return this.queryContractSmart(this.cw3ContractAddress, {
|
||||
list_proposals: {
|
||||
start_after: startAfter,
|
||||
limit: limit,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public reverseProposals(startBefore?: number, limit?: number): Promise<ProposalsResult> {
|
||||
return this.queryContractSmart(this.cw3ContractAddress, {
|
||||
reverse_proposals: {
|
||||
start_before: startBefore,
|
||||
limit: limit,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public getVote(proposalId: number, voter: string): Promise<VoteResult> {
|
||||
return this.queryContractSmart(this.cw3ContractAddress, {
|
||||
vote: {
|
||||
proposal_id: proposalId,
|
||||
voter: voter,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public listVotes(proposalId: number, startAfter?: string, limit?: number): Promise<VotesResult> {
|
||||
return this.queryContractSmart(this.cw3ContractAddress, {
|
||||
list_votes: {
|
||||
proposal_id: proposalId,
|
||||
start_after: startAfter,
|
||||
limit: limit,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public getVoter(address: string): Promise<VoterResult> {
|
||||
return this.queryContractSmart(this.cw3ContractAddress, {
|
||||
voter: {
|
||||
address: address,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public listVoters(startAfter?: string, limit?: number): Promise<VotersResult> {
|
||||
return this.queryContractSmart(this.cw3ContractAddress, {
|
||||
list_voters: {
|
||||
start_after: startAfter,
|
||||
limit: limit,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public createMultisigProposal(
|
||||
title: string,
|
||||
description: string,
|
||||
|
||||
42
packages/cosmwasm/types/cw3cosmwasmclient.d.ts
vendored
42
packages/cosmwasm/types/cw3cosmwasmclient.d.ts
vendored
@ -13,6 +13,40 @@ export declare enum Vote {
|
||||
Abstain = "abstain",
|
||||
Veto = "veto",
|
||||
}
|
||||
export interface ThresholdResult {
|
||||
readonly absolute_count: {
|
||||
readonly weight_needed: number;
|
||||
readonly total_weight: number;
|
||||
};
|
||||
}
|
||||
export interface ProposalResult {
|
||||
readonly id: number;
|
||||
readonly title: string;
|
||||
readonly description: string;
|
||||
readonly msgs: ReadonlyArray<Record<string, unknown>>;
|
||||
readonly expires: Expiration;
|
||||
readonly status: string;
|
||||
}
|
||||
export interface ProposalsResult {
|
||||
readonly proposals: readonly ProposalResult[];
|
||||
}
|
||||
export interface VoteResult {
|
||||
readonly vote: Vote;
|
||||
}
|
||||
export interface VotesResult {
|
||||
readonly votes: ReadonlyArray<{
|
||||
readonly vote: Vote;
|
||||
readonly voter: string;
|
||||
readonly weight: number;
|
||||
}>;
|
||||
}
|
||||
export interface VoterResult {
|
||||
readonly addr: string;
|
||||
readonly weight: number;
|
||||
}
|
||||
export interface VotersResult {
|
||||
readonly voters: readonly VoterResult[];
|
||||
}
|
||||
export declare class Cw3CosmWasmClient extends SigningCosmWasmClient {
|
||||
private readonly cw3ContractAddress;
|
||||
constructor(
|
||||
@ -24,6 +58,14 @@ export declare class Cw3CosmWasmClient extends SigningCosmWasmClient {
|
||||
gasLimits?: Partial<GasLimits<CosmWasmFeeTable>>,
|
||||
broadcastMode?: BroadcastMode,
|
||||
);
|
||||
getThreshold(): Promise<ThresholdResult>;
|
||||
getProposal(proposalId: number): Promise<ProposalResult>;
|
||||
listProposals(startAfter?: number, limit?: number): Promise<ProposalsResult>;
|
||||
reverseProposals(startBefore?: number, limit?: number): Promise<ProposalsResult>;
|
||||
getVote(proposalId: number, voter: string): Promise<VoteResult>;
|
||||
listVotes(proposalId: number, startAfter?: string, limit?: number): Promise<VotesResult>;
|
||||
getVoter(address: string): Promise<VoterResult>;
|
||||
listVoters(startAfter?: string, limit?: number): Promise<VotersResult>;
|
||||
createMultisigProposal(
|
||||
title: string,
|
||||
description: string,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user