gov

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 14 Imported by: 0

README

Gov module

Usage

(Tx) Submit proposal
submitProposalMsg := types.SubmitProposalMsg{
    Title: "Test proposal",
    Description: "Proposal description",
    Type: "text",
    Deposit: "1000",
}
txbytes, err := xplac.SubmitProposal(submitProposalMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Deposit
govDepositMsg := types.GovDepositMsg {
    ProposalID: "1",
    Deposit: "1000axpla",
}

txbytes, err := xplac.GovDeposit(govDepositMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Vote
voteMsg := types.VoteMsg{
    ProposalID: "1",
    Option: "yes",
}

txbytes, err := xplac.Vote(voteMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Weighted vote
weightedVoteMsg := types.WeightedVoteMsg{
    ProposalID: "1",
    Yes: "0.6",
    No: "0.3",
    Abstain: "0.05",
    NoWithVeto: "0.05",
}

txbytes, err := xplac.WeightedVote(weightedVoteMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Query) proposal
queryProposalMsg := types.QueryProposalMsg{
    ProposalID: "1",
}

res, err := xplac.QueryProposal(queryProposalMsg).Query()
(Query) proposals
// Query all proposals
queryProposalsMsg := types.QueryProposalsMsg{}

// Set options
queryProposalsMsg := types.QueryProposalsMsg{
    Status: "DepositPeriod",
    Voter: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",
    Depositor: "xpla19yq7kjcgse7x672faptju0lxmy4cvdlcpmxnyn",
}    

res, err := xplac.QueryProposals(queryProposalsMsg).Query()
(Query) deposit
// Query details of a deposit
queryDepositMsg := types.QueryDepositMsg{
    Depositor: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",
    ProposalID: "1",
}

// Query depostis on a proposal
queryDepositMsg := types.QueryDepositMsg{
    ProposalID: "1",
}

res, err := xplac.QueryDeposit(queryDepositMsg).Query()
(Query) Tally
tallyMsg := types.TallyMsg{
    ProposalID: "1",
}

res, err := xplac.Tally(tallyMsg).Query()
(Query) gov params
// Query all parameters of the gov process
res, err := xplac.GovParams().Query()

// Query the parameters (voting|tallying|deposit) of the governance process
govParamsMsg := types.GovParamsMsg{
    ParamType: "tallying",
}
res, err := xplac.GovParams(govParamsMsg).Query()
(Query) proposer
proposerMsg := types.ProposerMsg {
    ProposalID: "1",
}

res, err := xplac.Proposer(proposerMsg).Query()
(Query) Votes
// query details of a single vote
queryVoteMsg := types.QueryVoteMsg{
    ProposalID: "1",
    VoterAddr: "xpla1mss8agu59x3qte67lfn80x6w65thq4283dvn7l",
}

// Query votes on a proposal
queryVoteMsg := types.QueryVoteMsg{
    ProposalID: "1",
}

res, err := xplac.QueryVote(queryVoteMsg).Query()

Documentation

Index

Constants

View Source
const (
	GovModule                       = "gov"
	GovSubmitProposalMsgType        = "submit-proposal"
	GovDepositMsgType               = "gov-deposit"
	GovVoteMsgType                  = "vote"
	GovWeightedVoteMsgType          = "weighted-vote"
	GovQueryProposalMsgType         = "query-proposal"
	GovQueryProposalsMsgType        = "query-proposals"
	GovQueryDepositParamsMsgType    = "query-deposit-params"
	GovQueryDepositRequestMsgType   = "query-deposit-request"
	GovQueryDepositsParamsMsgType   = "query-deposits-params"
	GovQueryDepositsRequestMsgType  = "query-deposits-request"
	GovTallyMsgType                 = "gov-tally"
	GovQueryGovParamsMsgType        = "gov-params"
	GovQueryGovParamVotingMsgType   = "gov-param-voting"
	GovQueryGovParamTallyingMsgType = "gov-param-tallying"
	GovQueryGovParamDepositMsgType  = "gov-param-deposit"
	GovQueryProposerMsgType         = "query-proposer"
	GovQueryVoteMsgType             = "query-vote"
	GovQueryVotesNotPassedMsgType   = "query-votes-notpassed"
	GovQueryVotesPassedMsgType      = "query-votes-passed"
)

Variables

This section is empty.

Functions

func MakeGovDepositMsg

func MakeGovDepositMsg(govDepositMsg types.GovDepositMsg, from sdk.AccAddress) (govtypes.MsgDeposit, error)

(Tx) make msg - deposit

func MakeGovParamsMsg

func MakeGovParamsMsg(govParamsMsg types.GovParamsMsg) (govtypes.QueryParamsRequest, error)

(Query) make msg - gov params

func MakeGovTallyMsg

func MakeGovTallyMsg(tallyMsg types.TallyMsg, httpMutex *sync.Mutex, grpcConn grpc.ClientConn, ctx context.Context, lcdUrl string, queryType int) (interface{}, error)

(Query) make msg - tally

func MakeQueryDepositMsg

func MakeQueryDepositMsg(queryDepositMsg types.QueryDepositMsg, httpMutex *sync.Mutex, grpcConn grpc.ClientConn, ctx context.Context, lcdUrl string, queryType int) (interface{}, string, error)

(Query) make msg - query deposit

func MakeQueryDepositsMsg

func MakeQueryDepositsMsg(queryDepositMsg types.QueryDepositMsg, httpMutex *sync.Mutex, grpcConn grpc.ClientConn, ctx context.Context, lcdUrl string, queryType int) (interface{}, string, error)

(Query) make msg - query deposits

func MakeQueryProposalMsg

func MakeQueryProposalMsg(queryProposalMsg types.QueryProposalMsg) (govtypes.QueryProposalRequest, error)

(Query) make msg - proposal

func MakeQueryProposalsMsg

func MakeQueryProposalsMsg(queryProposalsMsg types.QueryProposalsMsg) (govtypes.QueryProposalsRequest, error)

(Query) make msg - proposals

func MakeQueryVoteMsg

func MakeQueryVoteMsg(queryVoteMsg types.QueryVoteMsg, httpMutex *sync.Mutex, grpcConn grpc.ClientConn, ctx context.Context, lcdUrl string, queryType int) (govtypes.QueryVoteRequest, error)

(Query) make msg - query vote

func MakeQueryVotesMsg

func MakeQueryVotesMsg(queryVoteMsg types.QueryVoteMsg, httpMutex *sync.Mutex, grpcConn grpc.ClientConn, ctx context.Context, lcdUrl string, queryType int) (interface{}, string, error)

(Query) make msg - query votes

func MakeSubmitProposalMsg

func MakeSubmitProposalMsg(submitProposalMsg types.SubmitProposalMsg, proposer sdk.AccAddress) (govtypes.MsgSubmitProposal, error)

(Tx) make msg - submit proposal

func MakeVoteMsg

func MakeVoteMsg(voteMsg types.VoteMsg, from sdk.AccAddress) (govtypes.MsgVote, error)

(Tx) make msg - vote

func MakeWeightedVoteMsg

func MakeWeightedVoteMsg(weightedVoteMsg types.WeightedVoteMsg, from sdk.AccAddress) (govtypes.MsgVoteWeighted, error)

(Tx) make msg - weighted vote

func NewCoreModule added in v0.1.2

func NewCoreModule() core.CoreModule

func QueryGov

func QueryGov(i core.QueryClient) (string, error)

Query client for gov module.

Types

type GovExternal added in v0.1.2

type GovExternal struct {
	Xplac provider.XplaClient
}

func NewGovExternal added in v0.1.2

func NewGovExternal(xplac provider.XplaClient) (e GovExternal)

func (GovExternal) GovDeposit added in v0.1.2

func (e GovExternal) GovDeposit(govDepositMsg types.GovDepositMsg) provider.XplaClient

Deposit tokens for an active proposal.

func (GovExternal) GovParams added in v0.1.2

func (e GovExternal) GovParams(govParamsMsg ...types.GovParamsMsg) provider.XplaClient

Query parameters of the governance process or the parameters (voting|tallying|deposit) of the governance process.

func (GovExternal) Proposer added in v0.1.2

func (e GovExternal) Proposer(proposerMsg types.ProposerMsg) provider.XplaClient

Query the proposer of a governance proposal.

func (GovExternal) QueryDeposit added in v0.1.2

func (e GovExternal) QueryDeposit(queryDepositMsg types.QueryDepositMsg) provider.XplaClient

Query details of a deposit or deposits on a proposal.

func (GovExternal) QueryProposal added in v0.1.2

func (e GovExternal) QueryProposal(queryProposal types.QueryProposalMsg) provider.XplaClient

Query details of a singla proposal.

func (GovExternal) QueryProposals added in v0.1.2

func (e GovExternal) QueryProposals(queryProposals types.QueryProposalsMsg) provider.XplaClient

Query proposals with optional filters.

func (GovExternal) QueryVote added in v0.1.2

func (e GovExternal) QueryVote(queryVoteMsg types.QueryVoteMsg) provider.XplaClient

Query details of a single vote or votes on a proposal.

func (GovExternal) SubmitProposal added in v0.1.2

func (e GovExternal) SubmitProposal(submitProposalMsg types.SubmitProposalMsg) provider.XplaClient

Submit a proposal along with an initial deposit.

func (GovExternal) Tally added in v0.1.2

func (e GovExternal) Tally(tallyMsg types.TallyMsg) provider.XplaClient

Query the tally of a proposal vote.

func (GovExternal) Vote added in v0.1.2

func (e GovExternal) Vote(voteMsg types.VoteMsg) provider.XplaClient

Vote for an active proposal, options: yes/no/no_with_veto/abstain.

func (GovExternal) WeightedVote added in v0.1.2

func (e GovExternal) WeightedVote(weightedVoteMsg types.WeightedVoteMsg) provider.XplaClient

Vote for an active proposal, options: yes/no/no_with_veto/abstain.

Jump to

Keyboard shortcuts

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