Documentation
¶
Index ¶
- Constants
- func BuildQueryParamsRequest(args []interface{}) (*govv1.QueryParamsRequest, error)
- func LoadABI() (abi.ABI, error)
- func NewMsgVote(args []interface{}) (*govv1.MsgVote, common.Address, error)
- func ParseDepositArgs(args []interface{}) (*govv1.QueryDepositRequest, error)
- func ParseDepositsArgs(method *abi.Method, args []interface{}) (*govv1.QueryDepositsRequest, error)
- func ParseProposalArgs(args []interface{}) (*govv1.QueryProposalRequest, error)
- func ParseProposalsArgs(method *abi.Method, args []interface{}) (*govv1.QueryProposalsRequest, error)
- func ParseTallyResultArgs(args []interface{}) (*govv1.QueryTallyResultRequest, error)
- func ParseVoteArgs(args []interface{}) (*govv1.QueryVoteRequest, error)
- func ParseVotesArgs(method *abi.Method, args []interface{}) (*govv1.QueryVotesRequest, error)
- type DepositData
- type DepositInput
- type DepositOutput
- type DepositsInput
- type DepositsOutput
- type EventVote
- type EventVoteWeighted
- type ParamsOutput
- type Precompile
- func (p Precompile) EmitVoteEvent(ctx sdk.Context, stateDB vm.StateDB, voterAddress common.Address, ...) error
- func (p Precompile) EmitVoteWeightedEvent(ctx sdk.Context, stateDB vm.StateDB, voterAddress common.Address, ...) error
- func (p *Precompile) GetDeposit(ctx sdk.Context, method *abi.Method, _ *vm.Contract, args []interface{}) ([]byte, error)
- func (p *Precompile) GetDeposits(ctx sdk.Context, method *abi.Method, _ *vm.Contract, args []interface{}) ([]byte, error)
- func (p *Precompile) GetParams(ctx sdk.Context, method *abi.Method, _ *vm.Contract, args []interface{}) ([]byte, error)
- func (p *Precompile) GetProposal(ctx sdk.Context, method *abi.Method, _ *vm.Contract, args []interface{}) ([]byte, error)
- func (p *Precompile) GetProposals(ctx sdk.Context, method *abi.Method, _ *vm.Contract, args []interface{}) ([]byte, error)
- func (p *Precompile) GetTallyResult(ctx sdk.Context, method *abi.Method, _ *vm.Contract, args []interface{}) ([]byte, error)
- func (p *Precompile) GetVote(ctx sdk.Context, method *abi.Method, _ *vm.Contract, args []interface{}) ([]byte, error)
- func (p *Precompile) GetVotes(ctx sdk.Context, method *abi.Method, _ *vm.Contract, args []interface{}) ([]byte, error)
- func (Precompile) IsTransaction(method *abi.Method) bool
- func (p Precompile) Logger(ctx sdk.Context) log.Logger
- func (p Precompile) RequiredGas(input []byte) uint64
- func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz []byte, err error)
- func (p Precompile) Vote(ctx sdk.Context, origin common.Address, contract *vm.Contract, ...) ([]byte, error)
- func (p Precompile) VoteWeighted(ctx sdk.Context, origin common.Address, contract *vm.Contract, ...) ([]byte, error)
- type ProposalData
- type ProposalOutput
- type ProposalsInput
- type ProposalsOutput
- type TallyResultData
- type TallyResultOutput
- type VoteOutput
- type VotesInput
- type VotesOutput
- type WeightedVote
- type WeightedVoteOption
- type WeightedVoteOptions
Constants ¶
const ( // ErrDifferentOrigin is raised when the origin address is not the same as the voter address. ErrDifferentOrigin = "tx origin address %s does not match the voter address %s" // 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 " // ErrInvalidDepositor invalid depositor. ErrInvalidDepositor = "invalid depositor %s " )
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" )
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" )
const ( // 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 ¶
This section is empty.
Functions ¶
func BuildQueryParamsRequest ¶
func BuildQueryParamsRequest(args []interface{}) (*govv1.QueryParamsRequest, error)
BuildQueryParamsRequest returns the structure for the governance parameters query.
func NewMsgVote ¶
NewMsgVote creates a new MsgVote instance.
func ParseDepositArgs ¶
func ParseDepositArgs(args []interface{}) (*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{}) (*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{}) (*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 ¶
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
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
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
// contains filtered or unexported fields
}
Precompile defines the precompiled contract for gov.
func NewPrecompile ¶
func NewPrecompile( govKeeper govkeeper.Keeper, authzKeeper authzkeeper.Keeper, ) (*Precompile, error)
NewPrecompile creates a new gov Precompile instance as a PrecompiledContract interface.
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) 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) Logger ¶
func (p Precompile) Logger(ctx sdk.Context) log.Logger
Logger returns a precompile-specific logger.
func (Precompile) RequiredGas ¶
func (p Precompile) RequiredGas(input []byte) uint64
RequiredGas calculates the precompiled contract's base gas rate.
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
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 ¶
func (po *ProposalsOutput) FromResponse(res *govv1.QueryProposalsResponse) *ProposalsOutput
type TallyResultData ¶
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 ¶
func (tro *TallyResultOutput) FromResponse(res *govv1.QueryTallyResultResponse) *TallyResultOutput
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
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
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 ¶
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{}) (*govv1.MsgVoteWeighted, common.Address, WeightedVoteOptions, error)
NewMsgVoteWeighted creates a new MsgVoteWeighted instance.