gov

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2025 License: Apache-2.0 Imports: 18 Imported by: 13

README

Gov Precompile

The Gov precompile provides an EVM interface to the Cosmos SDK governance module, enabling smart contracts to interact with on-chain governance proposals, voting, and deposits.

Address

The precompile is available at the fixed address: 0x0000000000000000000000000000000000000805

Interface

Data Structures
enum VoteOption {
    Unspecified,    // 0 - No-op vote option
    Yes,            // 1 - Yes vote
    Abstain,        // 2 - Abstain vote
    No,             // 3 - No vote
    NoWithVeto      // 4 - No with veto vote
}

struct WeightedVoteOption {
    VoteOption option;
    string weight;      // Decimal string representation (e.g., "0.5")
}

struct ProposalData {
    uint64 id;
    string[] messages;  // Proposal messages in JSON format
    uint32 status;
    TallyResultData finalTallyResult;
    uint64 submitTime;
    uint64 depositEndTime;
    Coin[] totalDeposit;
    uint64 votingStartTime;
    uint64 votingEndTime;
    string metadata;
    string title;
    string summary;
    address proposer;
}

struct TallyResultData {
    string yes;
    string abstain;
    string no;
    string noWithVeto;
}
Transaction Methods
// Submit a new governance proposal
function submitProposal(
    address proposer,
    bytes calldata jsonProposal,
    Coin[] calldata deposit
) external returns (uint64 proposalId);

// Cancel an existing proposal
function cancelProposal(
    address proposer,
    uint64 proposalId
) external returns (bool success);

// Add deposit to a proposal
function deposit(
    address depositor,
    uint64 proposalId,
    Coin[] calldata amount
) external returns (bool success);

// Submit a simple vote
function vote(
    address voter,
    uint64 proposalId,
    VoteOption option,
    string memory metadata
) external returns (bool success);

// Submit a weighted vote
function voteWeighted(
    address voter,
    uint64 proposalId,
    WeightedVoteOption[] calldata options,
    string memory metadata
) external returns (bool success);
Query Methods
// Get a specific vote
function getVote(
    uint64 proposalId,
    address voter
) external view returns (WeightedVote memory vote);

// Get all votes for a proposal
function getVotes(
    uint64 proposalId,
    PageRequest calldata pagination
) external view returns (WeightedVote[] memory votes, PageResponse memory pageResponse);

// Get a specific deposit
function getDeposit(
    uint64 proposalId,
    address depositor
) external view returns (DepositData memory deposit);

// Get all deposits for a proposal
function getDeposits(
    uint64 proposalId,
    PageRequest calldata pagination
) external view returns (DepositData[] memory deposits, PageResponse memory pageResponse);

// Get tally results
function getTallyResult(
    uint64 proposalId
) external view returns (TallyResultData memory tallyResult);

// Get proposal details
function getProposal(
    uint64 proposalId
) external view returns (ProposalData memory proposal);

// Get proposals by status/voter/depositor
function getProposals(
    uint32 proposalStatus,
    address voter,
    address depositor,
    PageRequest calldata pagination
) external view returns (ProposalData[] memory proposals, PageResponse memory pageResponse);

// Get governance parameters
function getParams() external view returns (Params memory params);

// Get constitution
function getConstitution() external view returns (string memory constitution);

Gas Costs

Gas costs are calculated dynamically based on the method and the Cosmos SDK operations performed. The precompile uses the standard gas configuration for key-value operations.

Implementation Details

Proposal Submission
  • Proposals are submitted in JSON format following Cosmos SDK proposal message structure
  • The proposer must be the transaction sender
  • Initial deposits can be included with the proposal
  • Returns the newly created proposal ID
Voting Mechanism
  • Simple voting: Single vote option with full voting power
  • Weighted voting: Multiple options with specified weights (must sum to 1.0)
  • Votes are recorded in the Cosmos SDK governance module
  • Metadata can be attached to votes for additional context
Deposit Handling
  • Deposits use the native token balance handler
  • Deposits must meet minimum requirements defined in governance parameters
  • The depositor must be the transaction sender
Query Operations
  • All queries are read-only and don't consume significant gas
  • Pagination is supported for large result sets
  • Proposal filtering by status, voter, or depositor

Events

event SubmitProposal(address indexed proposer, uint64 proposalId);
event CancelProposal(address indexed proposer, uint64 proposalId);
event Deposit(address indexed depositor, uint64 proposalId, Coin[] amount);
event Vote(address indexed voter, uint64 proposalId, uint8 option);
event VoteWeighted(address indexed voter, uint64 proposalId, WeightedVoteOption[] options);

Security Considerations

  1. Sender Verification: All transactions verify that the message sender matches the specified address parameter
  2. Balance Handling: Uses the balance handler for proper native token management
  3. Permission Checks: Inherits all permission checks from the Cosmos SDK governance module

Usage Example

IGov gov = IGov(GOV_PRECOMPILE_ADDRESS);

// Submit a proposal with initial deposit
Coin[] memory initialDeposit = new Coin[](1);
initialDeposit[0] = Coin({denom: "aevmos", amount: 1000000000000000000}); // 1 token

bytes memory proposalJSON = '{"messages":[...],"metadata":"...","title":"...","summary":"..."}';
uint64 proposalId = gov.submitProposal(msg.sender, proposalJSON, initialDeposit);

// Vote on the proposal
gov.vote(msg.sender, proposalId, VoteOption.Yes, "Supporting this proposal");

// Add additional deposit
Coin[] memory additionalDeposit = new Coin[](1);
additionalDeposit[0] = Coin({denom: "aevmos", amount: 500000000000000000}); // 0.5 token
gov.deposit(msg.sender, proposalId, additionalDeposit);

// Query proposal status
ProposalData memory proposal = gov.getProposal(proposalId);

Integration Notes

  • The precompile integrates directly with the Cosmos SDK governance module
  • All governance parameters and rules apply
  • Proposal JSON must be properly formatted according to Cosmos SDK standards
  • Vote weights in weighted voting must be decimal strings that sum to "1.0"

Documentation

Index

Constants

View Source
const (
	// ErrInvalidVoter is raised when the voter address is not valid.
	ErrInvalidVoter = "invalid voter address: %s"
	// ErrInvalidProposalID invalid proposal id.
	ErrInvalidProposalID = "invalid proposal id %d "
	// ErrInvalidPageRequest invalid page request.
	ErrInvalidPageRequest = "invalid page request"
	// ErrInvalidOption invalid option.
	ErrInvalidOption = "invalid option %s "
	// ErrInvalidMetadata invalid metadata.
	ErrInvalidMetadata = "invalid metadata %s "
	// ErrInvalidWeightedVoteOptions invalid weighted vote options.
	ErrInvalidWeightedVoteOptions = "invalid weighted vote options %s "
	// ErrInvalidWeightedVoteOption invalid weighted vote option.
	ErrInvalidWeightedVoteOption = "invalid weighted vote option %s "
	// ErrInvalidWeightedVoteOptionType invalid weighted vote option type.
	ErrInvalidWeightedVoteOptionType = "invalid weighted vote option type %s "
	// ErrInvalidWeightedVoteOptionWeight invalid weighted vote option weight.
	ErrInvalidWeightedVoteOptionWeight = "invalid weighted vote option weight %s "
	// ErrInvalidProposalJSON invalid proposal json.
	ErrInvalidProposalJSON = "invalid proposal json %s "
	// ErrInvalidProposer invalid proposer.
	ErrInvalidProposer = "invalid proposer %s"
	// ErrInvalidDepositor invalid depositor address.
	ErrInvalidDepositor = "invalid depositor address: %s"
	// ErrInvalidDeposits invalid deposits.
	ErrInvalidDeposits = "invalid deposits %s "
)
View Source
const (
	// EventTypeVote defines the event type for the gov VoteMethod transaction.
	EventTypeVote = "Vote"
	// EventTypeVoteWeighted defines the event type for the gov VoteWeightedMethod transaction.
	EventTypeVoteWeighted = "VoteWeighted"
	// EventTypeSubmitProposal defines the event type for the gov SubmitProposalMethod transaction.
	EventTypeSubmitProposal = "SubmitProposal"
	// EventTypeCanclelProposal defines the event type for the gov CancelProposalMethod transaction.
	EventTypeCancelProposal = "CancelProposal"
	// EventTypeDeposit defines the event type for the gov DepositMethod transaction.
	EventTypeDeposit = "Deposit"
)
View Source
const (
	// GetVotesMethod defines the method name for the votes precompile request.
	GetVotesMethod = "getVotes"
	// GetVoteMethod defines the method name for the vote precompile request.
	GetVoteMethod = "getVote"
	// GetDepositMethod defines the method name for the deposit precompile request.
	GetDepositMethod = "getDeposit"
	// GetDepositsMethod defines the method name for the deposits precompile request.
	GetDepositsMethod = "getDeposits"
	// GetTallyResultMethod defines the method name for the tally result precompile request.
	GetTallyResultMethod = "getTallyResult"
	// GetProposalMethod defines the method name for the proposal precompile request.
	GetProposalMethod = "getProposal"
	// GetProposalsMethod defines the method name for the proposals precompile request.
	GetProposalsMethod = "getProposals"
	// GetParamsMethod defines the method name for the get params precompile request.
	GetParamsMethod = "getParams"
	// GetConstitutionMethod defines the method name for the get constitution precompile request.
	GetConstitutionMethod = "getConstitution"
)
View Source
const (
	// SubmitProposalMethod defines the ABI method name for the gov SubmitProposal transaction.
	SubmitProposalMethod = "submitProposal"
	// DepositMethod defines the ABI method name for the gov Deposit transaction.
	DepositMethod = "deposit"
	// DepositProposalMethod defines the ABI method name for the gov DepositProposal transaction.
	CancelProposalMethod = "cancelProposal"
	// VoteMethod defines the ABI method name for the gov Vote transaction.
	VoteMethod = "vote"
	// VoteWeightedMethod defines the ABI method name for the gov VoteWeighted transaction.
	VoteWeightedMethod = "voteWeighted"
)

Variables

View Source
var (
	ABI abi.ABI
)

Functions

func BuildQueryConstitutionRequest added in v0.3.0

func BuildQueryConstitutionRequest(args []interface{}) (*govv1.QueryConstitutionRequest, error)

BuildQueryConstitutionRequest validates the args (none expected).

func BuildQueryParamsRequest

func BuildQueryParamsRequest(args []interface{}) (*govv1.QueryParamsRequest, error)

BuildQueryParamsRequest returns the structure for the governance parameters query.

func NewMsgCancelProposal added in v0.3.0

func NewMsgCancelProposal(args []interface{}, addrCdc address.Codec) (*govv1.MsgCancelProposal, common.Address, error)

NewMsgCancelProposal constructs a MsgCancelProposal. args: [proposerAddress, proposalID]

func NewMsgDeposit added in v0.3.0

func NewMsgDeposit(args []interface{}, addrCdc address.Codec) (*govv1.MsgDeposit, common.Address, error)

NewMsgDeposit constructs a MsgDeposit. args: [depositorAddress, proposalID, []cmn.CoinInput deposit]

func NewMsgSubmitProposal added in v0.3.0

func NewMsgSubmitProposal(args []interface{}, cdc codec.Codec, addrCdc address.Codec) (*govv1.MsgSubmitProposal, common.Address, error)

NewMsgSubmitProposal constructs a MsgSubmitProposal. args: [proposerAddress, jsonBlob, []cmn.CoinInput deposit]

func NewMsgVote

func NewMsgVote(args []interface{}, addrCdc address.Codec) (*govv1.MsgVote, common.Address, error)

NewMsgVote creates a new MsgVote instance.

func ParseDepositArgs

func ParseDepositArgs(args []interface{}, addrCdc address.Codec) (*govv1.QueryDepositRequest, error)

ParseDepositArgs parses the arguments for the Deposit query.

func ParseDepositsArgs

func ParseDepositsArgs(method *abi.Method, args []interface{}) (*govv1.QueryDepositsRequest, error)

ParseDepositsArgs parses the arguments for the Deposits query.

func ParseProposalArgs

func ParseProposalArgs(args []interface{}) (*govv1.QueryProposalRequest, error)

ParseProposalArgs parses the arguments for the Proposal query

func ParseProposalsArgs

func ParseProposalsArgs(method *abi.Method, args []interface{}, addrCdc address.Codec) (*govv1.QueryProposalsRequest, error)

ParseProposalsArgs parses the arguments for the Proposals query

func ParseTallyResultArgs

func ParseTallyResultArgs(args []interface{}) (*govv1.QueryTallyResultRequest, error)

ParseTallyResultArgs parses the arguments for the TallyResult query.

func ParseVoteArgs

func ParseVoteArgs(args []interface{}, addrCdc address.Codec) (*govv1.QueryVoteRequest, error)

ParseVoteArgs parses the arguments for the Votes query.

func ParseVotesArgs

func ParseVotesArgs(method *abi.Method, args []interface{}) (*govv1.QueryVotesRequest, error)

ParseVotesArgs parses the arguments for the Votes query.

Types

type DepositData

type DepositData struct {
	ProposalId uint64         `abi:"proposalId"` //nolint:revive
	Depositor  common.Address `abi:"depositor"`
	Amount     []cmn.Coin     `abi:"amount"`
}

DepositData represents information about a deposit on a proposal

type DepositInput

type DepositInput struct {
	ProposalId uint64 //nolint:revive
	Depositor  common.Address
}

DepositInput defines the input for the Deposit query.

type DepositOutput

type DepositOutput struct {
	Deposit DepositData
}

DepositOutput defines the output for the Deposit query.

func (*DepositOutput) FromResponse

func (do *DepositOutput) FromResponse(res *govv1.QueryDepositResponse) (*DepositOutput, error)

type DepositsInput

type DepositsInput struct {
	ProposalId uint64 //nolint:revive
	Pagination query.PageRequest
}

DepositsInput defines the input for the Deposits query.

type DepositsOutput

type DepositsOutput struct {
	Deposits     []DepositData      `abi:"deposits"`
	PageResponse query.PageResponse `abi:"pageResponse"`
}

DepositsOutput defines the output for the Deposits query.

func (*DepositsOutput) FromResponse

func (do *DepositsOutput) FromResponse(res *govv1.QueryDepositsResponse) (*DepositsOutput, error)

type EventVote

type EventVote struct {
	Voter      common.Address
	ProposalId uint64 //nolint:revive
	Option     uint8
}

EventVote defines the event data for the Vote transaction.

type EventVoteWeighted

type EventVoteWeighted struct {
	Voter      common.Address
	ProposalId uint64 //nolint:revive
	Options    WeightedVoteOptions
}

EventVoteWeighted defines the event data for the VoteWeighted transaction.

type ParamsOutput

type ParamsOutput struct {
	VotingPeriod               int64      `abi:"votingPeriod"`
	MinDeposit                 []cmn.Coin `abi:"minDeposit"`
	MaxDepositPeriod           int64      `abi:"maxDepositPeriod"`
	Quorum                     string     `abi:"quorum"`
	Threshold                  string     `abi:"threshold"`
	VetoThreshold              string     `abi:"vetoThreshold"`
	MinInitialDepositRatio     string     `abi:"minInitialDepositRatio"`
	ProposalCancelRatio        string     `abi:"proposalCancelRatio"`
	ProposalCancelDest         string     `abi:"proposalCancelDest"`
	ExpeditedVotingPeriod      int64      `abi:"expeditedVotingPeriod"`
	ExpeditedThreshold         string     `abi:"expeditedThreshold"`
	ExpeditedMinDeposit        []cmn.Coin `abi:"expeditedMinDeposit"`
	BurnVoteQuorum             bool       `abi:"burnVoteQuorum"`
	BurnProposalDepositPrevote bool       `abi:"burnProposalDepositPrevote"`
	BurnVoteVeto               bool       `abi:"burnVoteVeto"`
	MinDepositRatio            string     `abi:"minDepositRatio"`
}

ParamsOutput contains the output data for the governance parameters query

func (*ParamsOutput) FromResponse

func (o *ParamsOutput) FromResponse(res *govv1.QueryParamsResponse) *ParamsOutput

FromResponse populates the ParamsOutput from a query response

type Precompile

type Precompile struct {
	cmn.Precompile

	abi.ABI
	// contains filtered or unexported fields
}

Precompile defines the precompiled contract for gov.

func NewPrecompile

func NewPrecompile(
	govMsgServer govtypes.MsgServer,
	govQuerier govtypes.QueryServer,
	bankKeeper cmn.BankKeeper,
	codec codec.Codec,
	addrCdc address.Codec,
) *Precompile

NewPrecompile creates a new gov Precompile instance as a PrecompiledContract interface.

func (*Precompile) CancelProposal added in v0.3.0

func (p *Precompile) CancelProposal(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

CancelProposal defines a method to cancel a proposal.

func (*Precompile) Deposit added in v0.3.0

func (p *Precompile) Deposit(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

Deposit defines a method to add a deposit on a specific proposal.

func (Precompile) EmitCancelProposalEvent added in v0.3.0

func (p Precompile) EmitCancelProposalEvent(ctx sdk.Context, stateDB vm.StateDB, proposerAddress common.Address, proposalID uint64) error

EmitCancelProposalEvent creates a new event emitted on a CancelProposal transaction.

func (Precompile) EmitDepositEvent added in v0.3.0

func (p Precompile) EmitDepositEvent(ctx sdk.Context, stateDB vm.StateDB, depositorAddress common.Address, proposalID uint64, amount []sdk.Coin) error

EmitDepositEvent creates a new event emitted on a Deposit transaction.

func (Precompile) EmitSubmitProposalEvent added in v0.3.0

func (p Precompile) EmitSubmitProposalEvent(ctx sdk.Context, stateDB vm.StateDB, proposerAddress common.Address, proposalID uint64) error

EmitSubmitProposalEvent creates a new event emitted on a SubmitProposal transaction.

func (Precompile) EmitVoteEvent

func (p Precompile) EmitVoteEvent(ctx sdk.Context, stateDB vm.StateDB, voterAddress common.Address, proposalID uint64, option int32) error

EmitVoteEvent creates a new event emitted on a Vote transaction.

func (Precompile) EmitVoteWeightedEvent

func (p Precompile) EmitVoteWeightedEvent(ctx sdk.Context, stateDB vm.StateDB, voterAddress common.Address, proposalID uint64, options WeightedVoteOptions) error

EmitVoteWeightedEvent creates a new event emitted on a VoteWeighted transaction.

func (Precompile) Execute added in v0.5.0

func (p Precompile) Execute(ctx sdk.Context, stateDB vm.StateDB, contract *vm.Contract, readOnly bool) ([]byte, error)

func (*Precompile) GetConstitution added in v0.3.0

func (p *Precompile) GetConstitution(
	ctx sdk.Context,
	method *abi.Method,
	_ *vm.Contract,
	args []interface{},
) ([]byte, error)

GetConstitution implements the query logic for getting the constitution

func (*Precompile) GetDeposit

func (p *Precompile) GetDeposit(
	ctx sdk.Context,
	method *abi.Method,
	_ *vm.Contract,
	args []interface{},
) ([]byte, error)

GetDeposit implements the query logic for getting a deposit for a proposal.

func (*Precompile) GetDeposits

func (p *Precompile) GetDeposits(
	ctx sdk.Context,
	method *abi.Method,
	_ *vm.Contract,
	args []interface{},
) ([]byte, error)

GetDeposits implements the query logic for getting all deposits for a proposal.

func (*Precompile) GetParams

func (p *Precompile) GetParams(
	ctx sdk.Context,
	method *abi.Method,
	_ *vm.Contract,
	args []interface{},
) ([]byte, error)

GetParams implements the query logic for getting governance parameters

func (*Precompile) GetProposal

func (p *Precompile) GetProposal(
	ctx sdk.Context,
	method *abi.Method,
	_ *vm.Contract,
	args []interface{},
) ([]byte, error)

GetProposal implements the query logic for getting a proposal

func (*Precompile) GetProposals

func (p *Precompile) GetProposals(
	ctx sdk.Context,
	method *abi.Method,
	_ *vm.Contract,
	args []interface{},
) ([]byte, error)

GetProposals implements the query logic for getting proposals

func (*Precompile) GetTallyResult

func (p *Precompile) GetTallyResult(
	ctx sdk.Context,
	method *abi.Method,
	_ *vm.Contract,
	args []interface{},
) ([]byte, error)

GetTallyResult implements the query logic for getting the tally result of a proposal.

func (*Precompile) GetVote

func (p *Precompile) GetVote(
	ctx sdk.Context,
	method *abi.Method,
	_ *vm.Contract,
	args []interface{},
) ([]byte, error)

GetVote implements the query logic for getting votes for a proposal.

func (*Precompile) GetVotes

func (p *Precompile) GetVotes(
	ctx sdk.Context,
	method *abi.Method,
	_ *vm.Contract,
	args []interface{},
) ([]byte, error)

GetVotes implements the query logic for getting votes for a proposal.

func (Precompile) IsTransaction

func (Precompile) IsTransaction(method *abi.Method) bool

IsTransaction checks if the given method name corresponds to a transaction or query.

func (Precompile) RequiredGas

func (p Precompile) RequiredGas(input []byte) uint64

RequiredGas calculates the precompiled contract's base gas rate.

func (Precompile) Run

func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)

func (*Precompile) SubmitProposal added in v0.3.0

func (p *Precompile) SubmitProposal(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

SubmitProposal defines a method to submit a proposal.

func (Precompile) Vote

func (p Precompile) Vote(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

Vote defines a method to add a vote on a specific proposal.

func (Precompile) VoteWeighted

func (p Precompile) VoteWeighted(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

VoteWeighted defines a method to add a vote on a specific proposal.

type ProposalData

type ProposalData struct {
	Id               uint64          `abi:"id"` //nolint
	Messages         []string        `abi:"messages"`
	Status           uint32          `abi:"status"`
	FinalTallyResult TallyResultData `abi:"finalTallyResult"`
	SubmitTime       uint64          `abi:"submitTime"`
	DepositEndTime   uint64          `abi:"depositEndTime"`
	TotalDeposit     []cmn.Coin      `abi:"totalDeposit"`
	VotingStartTime  uint64          `abi:"votingStartTime"`
	VotingEndTime    uint64          `abi:"votingEndTime"`
	Metadata         string          `abi:"metadata"`
	Title            string          `abi:"title"`
	Summary          string          `abi:"summary"`
	Proposer         common.Address  `abi:"proposer"`
}

ProposalData represents a governance proposal

type ProposalOutput

type ProposalOutput struct {
	Proposal ProposalData
}

ProposalOutput defines the output for the Proposal query

func (*ProposalOutput) FromResponse

func (po *ProposalOutput) FromResponse(res *govv1.QueryProposalResponse) (*ProposalOutput, error)

type ProposalsInput

type ProposalsInput struct {
	ProposalStatus uint32
	Voter          common.Address
	Depositor      common.Address
	Pagination     query.PageRequest
}

ProposalsInput defines the input for the Proposals query

type ProposalsOutput

type ProposalsOutput struct {
	Proposals    []ProposalData
	PageResponse query.PageResponse
}

ProposalsOutput defines the output for the Proposals query

func (*ProposalsOutput) FromResponse

type TallyResultData

type TallyResultData struct {
	Yes        string
	Abstain    string
	No         string
	NoWithVeto string
}

TallyResultData represents the tally result of a proposal

type TallyResultOutput

type TallyResultOutput struct {
	TallyResult TallyResultData
}

TallyResultOutput defines the output for the TallyResult query.

func (*TallyResultOutput) FromResponse

type VoteOutput

type VoteOutput struct {
	Vote WeightedVote
}

VoteOutput is the output response returned by the vote query method.

func (*VoteOutput) FromResponse

func (vo *VoteOutput) FromResponse(res *govv1.QueryVoteResponse) (*VoteOutput, error)

type VotesInput

type VotesInput struct {
	ProposalId uint64 //nolint:revive
	Pagination query.PageRequest
}

VotesInput defines the input for the Votes query.

type VotesOutput

type VotesOutput struct {
	Votes        []WeightedVote
	PageResponse query.PageResponse
}

VotesOutput defines the output for the Votes query.

func (*VotesOutput) FromResponse

func (vo *VotesOutput) FromResponse(res *govv1.QueryVotesResponse) (*VotesOutput, error)

type WeightedVote

type WeightedVote struct {
	ProposalId uint64 //nolint:revive
	Voter      common.Address
	Options    []WeightedVoteOption
	Metadata   string
}

WeightedVote defines a struct of vote for vote split.

type WeightedVoteOption

type WeightedVoteOption struct {
	Option uint8
	Weight string
}

WeightedVoteOption defines a unit of vote for vote split.

type WeightedVoteOptions

type WeightedVoteOptions []WeightedVoteOption

WeightedVoteOptions defines a slice of WeightedVoteOption.

func NewMsgVoteWeighted

func NewMsgVoteWeighted(method *abi.Method, args []interface{}, addrCdc address.Codec) (*govv1.MsgVoteWeighted, common.Address, WeightedVoteOptions, error)

NewMsgVoteWeighted creates a new MsgVoteWeighted instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL