mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-25 13:54:05 -06:00
195 lines
6.6 KiB
TypeScript
195 lines
6.6 KiB
TypeScript
import { VotingGovernor } from "@3rdweb/contracts";
|
|
import { TransactionReceipt } from "@ethersproject/providers";
|
|
import { BigNumber } from "ethers";
|
|
import { Currency, CurrencyValue, ModuleType } from "../common";
|
|
import { Module } from "../core/module";
|
|
import { MetadataURIOrObject } from "../core/types";
|
|
import { VoteType } from "../enums";
|
|
import { Proposal, ProposalExecutable } from "../types/vote";
|
|
export interface VoteSettings {
|
|
votingDelay: string;
|
|
votingPeriod: string;
|
|
votingTokenAddress: string;
|
|
votingTokenMetadata: Currency;
|
|
votingQuorumFraction: string;
|
|
proposalTokenThreshold: string;
|
|
}
|
|
/**
|
|
* Create a decentralized organization for token holders to vote on proposals.
|
|
*
|
|
* @example
|
|
*
|
|
* ```javascript
|
|
* import { ThirdwebSDK } from "@3rdweb/sdk";
|
|
*
|
|
* // You can switch out this provider with any wallet or provider setup you like.
|
|
* const provider = ethers.Wallet.createRandom();
|
|
* const sdk = new ThirdwebSDK(provider);
|
|
* const module = sdk.getVoteModule("{{module_address}}");
|
|
* ```
|
|
*
|
|
* @public
|
|
*/
|
|
export declare class VoteModule extends Module<VotingGovernor> {
|
|
static moduleType: ModuleType;
|
|
/**
|
|
* @internal
|
|
*/
|
|
protected connectContract(): VotingGovernor;
|
|
/**
|
|
* @internal
|
|
*/
|
|
protected getModuleType(): ModuleType;
|
|
settings(): Promise<VoteSettings>;
|
|
/**
|
|
* Get a proposal by id.
|
|
*
|
|
* @param proposalId - The proposal id to get.
|
|
* @returns - The proposal.
|
|
*/
|
|
get(proposalId: string): Promise<Proposal>;
|
|
/**
|
|
* Get All Proposals
|
|
*
|
|
* @remarks Get all the proposals in this module.
|
|
*
|
|
* @example
|
|
* ```javascript
|
|
* const proposals = await module.getAll();
|
|
* console.log(proposals);
|
|
* ```
|
|
*
|
|
* @returns - All the proposals in the contract.
|
|
*/
|
|
getAll(): Promise<Proposal[]>;
|
|
/**
|
|
* Create Proposal
|
|
*
|
|
* @remarks Create a new proposal for token holders to vote on.
|
|
*
|
|
* @example
|
|
* ```javascript
|
|
* // The description of the proposal you want to pass
|
|
* const description = "This is a great proposal - vote for it!"
|
|
* // You can (optionally) pass in contract calls that will executed when the proposal is executed.
|
|
* const executions = [
|
|
* {
|
|
* // The contract you want to make a call to
|
|
* toAddress: "0x...",
|
|
* // The amount of the native currency to send in this transaction
|
|
* nativeTokenValue: 0,
|
|
* // Transaction data that will be executed when the proposal is executed
|
|
* // This is an example transfer transaction with a token module (which you would need to setup in code)
|
|
* transactionData: tokenModule.contract.interface.encodeFunctionData(
|
|
* "transfer", [
|
|
* fromAddress,
|
|
* amount,
|
|
* ]
|
|
* ),
|
|
* }
|
|
* ]
|
|
*
|
|
* const proposal = await module.propose(description, executions);
|
|
* ```
|
|
*
|
|
* @param description - The description of the proposal.
|
|
* @param executions - A set of executable transactions that will be run if the proposal is passed and executed.
|
|
* @returns - The id of the created proposal.
|
|
*/
|
|
propose(description: string, executions?: ProposalExecutable[]): Promise<BigNumber>;
|
|
/**
|
|
* Vote
|
|
*
|
|
* @remarks Vote on an active proposal
|
|
*
|
|
* @example
|
|
* ```javascript
|
|
* // The proposal ID of the proposal you want to vote on
|
|
* const proposalId = "0";
|
|
* // The vote type you want to cast, can be VoteType.Against, VoteType.For, or VoteType.Abstain
|
|
* const voteType = VoteType.For;
|
|
* // The (optional) reason for the vote
|
|
* const reason = "I like this proposal!";
|
|
*
|
|
* await module.vote(proposalId, voteType, reason);
|
|
* ```
|
|
* @param proposalId - The proposal to cast a vote on.
|
|
* @param voteType - The position the voter is taking on their vote.
|
|
* @param reason - (optional) The reason for the vote.
|
|
*/
|
|
vote(proposalId: string, voteType: VoteType, reason?: string): Promise<void>;
|
|
/**
|
|
* Check If Wallet Voted
|
|
*
|
|
* @remarks Check if a specified wallet has voted a specific proposal
|
|
*
|
|
* @example
|
|
* ```javascript
|
|
* // The proposal ID of the proposal you want to check
|
|
* const proposalId = "0";
|
|
* // The address of the wallet you want to check to see if they voted
|
|
* const address = "{{wallet_address}}";
|
|
*
|
|
* await module.hasVoted(proposalId, address);
|
|
* ```
|
|
*
|
|
* @param proposalId - The unique identifier of a proposal .
|
|
* @param account - (optional) wallet account address. Defaults to connected signer.
|
|
* @returns - True if the account has already voted on the proposal.
|
|
*/
|
|
hasVoted(proposalId: string, account?: string): Promise<boolean>;
|
|
/**
|
|
* Execute Proposal
|
|
*
|
|
* @remarks Execute the related transactions for a proposal if the proposal succeeded.
|
|
*
|
|
* @example
|
|
* ```javascript
|
|
* // The proposal ID ofthe proposal you want to execute
|
|
* const proposalId = "0"
|
|
* await module.execute(proposalId);
|
|
* ```
|
|
*
|
|
* @param proposalId - The proposal id to execute.
|
|
*/
|
|
execute(proposalId: string): Promise<void>;
|
|
/**
|
|
* Can Execute
|
|
*
|
|
* @remarks Check if a proposal can be executed (if the proposal has succeeded).
|
|
*
|
|
* @example
|
|
* ```javascript
|
|
* // The proposal ID of the proposal you want to check
|
|
* const proposalId = "0";
|
|
* const canExecute = await module.canExecute(proposalId);
|
|
* console.log(canExecute);
|
|
* ```
|
|
*
|
|
* @param proposalId - The proposal ID to check.
|
|
* @returns - True if the proposal can be executed, false otherwise.
|
|
*/
|
|
canExecute(proposalId: string): Promise<boolean>;
|
|
/**
|
|
* Check the balance of the project wallet in the native token of the chain
|
|
*
|
|
* @returns - The balance of the project in the native token of the chain
|
|
*/
|
|
balance(): Promise<CurrencyValue>;
|
|
/**
|
|
* Check the balance of the project wallet in a particular
|
|
* ERC20 token contract
|
|
*
|
|
* @returns - The balance of the project in the native token of the chain
|
|
*/
|
|
balanceOfToken(tokenAddress: string): Promise<CurrencyValue>;
|
|
setModuleMetadata(metadata: MetadataURIOrObject): Promise<TransactionReceipt>;
|
|
/**
|
|
* Find a proposal by its id.
|
|
*
|
|
* @internal
|
|
* @param proposalId - Proposal to check for
|
|
*/
|
|
private ensureExists;
|
|
}
|