github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/x/gov/client/rest/rest.go (about)

     1  package rest
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"github.com/gorilla/mux"
     7  
     8  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/client/context"
     9  	sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types"
    10  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/rest"
    11  )
    12  
    13  // REST Variable names
    14  // nolint
    15  const (
    16  	RestParamsType     = "type"
    17  	RestProposalID     = "proposal-id"
    18  	RestDepositor      = "depositor"
    19  	RestVoter          = "voter"
    20  	RestProposalStatus = "status"
    21  	RestNumLimit       = "limit"
    22  )
    23  
    24  // ProposalRESTHandler defines a REST handler implemented in another module. The
    25  // sub-route is mounted on the governance REST handler.
    26  type ProposalRESTHandler struct {
    27  	SubRoute string
    28  	Handler  func(http.ResponseWriter, *http.Request)
    29  }
    30  
    31  // RegisterRoutes - Central function to define routes that get registered by the main application
    32  func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, phs []ProposalRESTHandler) {
    33  	registerQueryRoutes(cliCtx, r)
    34  	registerTxRoutes(cliCtx, r, phs)
    35  }
    36  
    37  // PostProposalReq defines the properties of a proposal request's body.
    38  type PostProposalReq struct {
    39  	BaseReq        rest.BaseReq   `json:"base_req" yaml:"base_req"`
    40  	Title          string         `json:"title" yaml:"title"`                     // Title of the proposal
    41  	Description    string         `json:"description" yaml:"description"`         // Description of the proposal
    42  	ProposalType   string         `json:"proposal_type" yaml:"proposal_type"`     // Type of proposal. Initial set {PlainTextProposal }
    43  	Proposer       sdk.AccAddress `json:"proposer" yaml:"proposer"`               // Address of the proposer
    44  	InitialDeposit sdk.Coins      `json:"initial_deposit" yaml:"initial_deposit"` // Coins to add to the proposal's deposit
    45  }
    46  
    47  // DepositReq defines the properties of a deposit request's body.
    48  type DepositReq struct {
    49  	BaseReq   rest.BaseReq   `json:"base_req" yaml:"base_req"`
    50  	Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` // Address of the depositor
    51  	Amount    sdk.Coins      `json:"amount" yaml:"amount"`       // Coins to add to the proposal's deposit
    52  }
    53  
    54  // VoteReq defines the properties of a vote request's body.
    55  type VoteReq struct {
    56  	BaseReq rest.BaseReq   `json:"base_req" yaml:"base_req"`
    57  	Voter   sdk.AccAddress `json:"voter" yaml:"voter"`   // address of the voter
    58  	Option  string         `json:"option" yaml:"option"` // option from OptionSet chosen by the voter
    59  }