Documentation
¶
Index ¶
- Constants
- Variables
- func BuildQueryConstitutionRequest(args []interface{}) (*govv1.QueryConstitutionRequest, error)
- func BuildQueryParamsRequest(args []interface{}) (*govv1.QueryParamsRequest, error)
- func NewMsgCancelProposal(args []interface{}, addrCdc address.Codec) (*govv1.MsgCancelProposal, common.Address, error)
- func NewMsgDeposit(args []interface{}, addrCdc address.Codec) (*govv1.MsgDeposit, common.Address, error)
- func NewMsgSubmitProposal(args []interface{}, cdc codec.Codec, addrCdc address.Codec) (*govv1.MsgSubmitProposal, common.Address, error)
- func NewMsgVote(args []interface{}, addrCdc address.Codec) (*govv1.MsgVote, common.Address, error)
- func ParseDepositArgs(args []interface{}, addrCdc address.Codec) (*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{}, addrCdc address.Codec) (*govv1.QueryProposalsRequest, error)
- func ParseTallyResultArgs(args []interface{}) (*govv1.QueryTallyResultRequest, error)
- func ParseVoteArgs(args []interface{}, addrCdc address.Codec) (*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) CancelProposal(ctx sdk.Context, contract *vm.Contract, stateDB vm.StateDB, method *abi.Method, ...) ([]byte, error)
- func (p *Precompile) Deposit(ctx sdk.Context, contract *vm.Contract, stateDB vm.StateDB, method *abi.Method, ...) ([]byte, error)
- func (p Precompile) EmitCancelProposalEvent(ctx sdk.Context, stateDB vm.StateDB, proposerAddress common.Address, ...) error
- func (p Precompile) EmitDepositEvent(ctx sdk.Context, stateDB vm.StateDB, depositorAddress common.Address, ...) error
- func (p Precompile) EmitSubmitProposalEvent(ctx sdk.Context, stateDB vm.StateDB, proposerAddress common.Address, ...) error
- 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) Execute(ctx sdk.Context, stateDB vm.StateDB, contract *vm.Contract, readOnly bool) ([]byte, error)
- func (p *Precompile) GetConstitution(ctx sdk.Context, method *abi.Method, _ *vm.Contract, args []interface{}) ([]byte, 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) RequiredGas(input []byte) uint64
- func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)
- func (p *Precompile) SubmitProposal(ctx sdk.Context, contract *vm.Contract, stateDB vm.StateDB, method *abi.Method, ...) ([]byte, error)
- func (p Precompile) Vote(ctx sdk.Context, contract *vm.Contract, stateDB vm.StateDB, method *abi.Method, ...) ([]byte, error)
- func (p Precompile) VoteWeighted(ctx sdk.Context, contract *vm.Contract, stateDB vm.StateDB, method *abi.Method, ...) ([]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 ( // 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 " )
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" )
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" )
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 ¶
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 ¶
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 ¶
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 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) 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) 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.
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 ¶
func (po *ProposalsOutput) FromResponse(res *govv1.QueryProposalsResponse) (*ProposalsOutput, error)
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, 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 ¶
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.