Documentation ¶
Index ¶
- func CalculateGas(queryFunc func(string, common.HexBytes) ([]byte, error), cdc *amino.Codec, ...) (estimate, adjusted uint64, err error)
- func CompleteAndBroadcastTxCli(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) error
- func CompleteAndBroadcastTxREST(w http.ResponseWriter, r *http.Request, cliCtx context.CLIContext, ...)
- func EnrichCtxWithGas(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, name string, ...) (authtxb.TxBuilder, error)
- func GetTxEncoder(cdc *codec.Codec) (encoder sdk.TxEncoder)
- func ParseFloat64OrReturnBadRequest(w http.ResponseWriter, s string, defaultIfEmpty float64) (n float64, ok bool)
- func ParseInt64OrReturnBadRequest(w http.ResponseWriter, s string) (n int64, ok bool)
- func ParseUint64OrReturnBadRequest(w http.ResponseWriter, s string) (n uint64, ok bool)
- func PostProcessResponse(w http.ResponseWriter, cdc *codec.Codec, response interface{}, indent bool)
- func PrintUnsignedStdTx(w io.Writer, txBldr authtxb.TxBuilder, cliCtx context.CLIContext, ...) (err error)
- func ReadRESTReq(w http.ResponseWriter, r *http.Request, cdc *codec.Codec, req interface{}) error
- func SignStdTx(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, name string, ...) (auth.StdTx, error)
- func SignStdTxWithSignerAddress(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, addr sdk.AccAddress, ...) (signedStdTx auth.StdTx, err error)
- func WriteErrorResponse(w http.ResponseWriter, status int, err string)
- func WriteGenerateStdTxResponse(w http.ResponseWriter, cdc *codec.Codec, txBldr authtxb.TxBuilder, ...)
- func WriteSimulationResponse(w http.ResponseWriter, gas uint64)
- type BaseReq
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateGas ¶ added in v0.25.0
func CalculateGas(queryFunc func(string, common.HexBytes) ([]byte, error), cdc *amino.Codec, txBytes []byte, adjustment float64) (estimate, adjusted uint64, err error)
CalculateGas simulates the execution of a transaction and returns both the estimate obtained by the query and the adjusted amount.
func CompleteAndBroadcastTxCli ¶ added in v0.25.0
func CompleteAndBroadcastTxCli(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) error
CompleteAndBroadcastTxCli implements a utility function that facilitates sending a series of messages in a signed transaction given a TxBuilder and a QueryContext. It ensures that the account exists, has a proper number and sequence set. In addition, it builds and signs a transaction with the supplied messages. Finally, it broadcasts the signed transaction to a node.
NOTE: Also see CompleteAndBroadcastTxREST.
func CompleteAndBroadcastTxREST ¶ added in v0.25.0
func CompleteAndBroadcastTxREST( w http.ResponseWriter, r *http.Request, cliCtx context.CLIContext, baseReq BaseReq, msgs []sdk.Msg, cdc *codec.Codec, )
CompleteAndBroadcastTxREST implements a utility function that facilitates sending a series of messages in a signed transaction given a TxBuilder and a QueryContext. It ensures that the account exists, has a proper number and sequence set. In addition, it builds and signs a transaction with the supplied messages. Finally, it broadcasts the signed transaction to a node.
NOTE: Also see CompleteAndBroadcastTxCli. NOTE: Also see x/stake/client/rest/tx.go delegationsRequestHandlerFn.
func EnrichCtxWithGas ¶ added in v0.25.0
func EnrichCtxWithGas(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, name string, msgs []sdk.Msg) (authtxb.TxBuilder, error)
EnrichCtxWithGas calculates the gas estimate that would be consumed by the transaction and set the transaction's respective value accordingly.
func GetTxEncoder ¶ added in v0.28.1
GetTxEncoder return tx encoder from global sdk configuration if ones is defined. Otherwise returns encoder with default logic.
func ParseFloat64OrReturnBadRequest ¶ added in v0.25.0
func ParseFloat64OrReturnBadRequest(w http.ResponseWriter, s string, defaultIfEmpty float64) (n float64, ok bool)
ParseFloat64OrReturnBadRequest converts s to a float64 value. It returns a default value, defaultIfEmpty, if the string is empty.
func ParseInt64OrReturnBadRequest ¶ added in v0.25.0
func ParseInt64OrReturnBadRequest(w http.ResponseWriter, s string) (n int64, ok bool)
ParseInt64OrReturnBadRequest converts s to a int64 value.
func ParseUint64OrReturnBadRequest ¶ added in v0.26.0
func ParseUint64OrReturnBadRequest(w http.ResponseWriter, s string) (n uint64, ok bool)
ParseUint64OrReturnBadRequest converts s to a uint64 value.
func PostProcessResponse ¶ added in v0.25.0
func PostProcessResponse(w http.ResponseWriter, cdc *codec.Codec, response interface{}, indent bool)
PostProcessResponse performs post process for rest response
func PrintUnsignedStdTx ¶ added in v0.25.0
func PrintUnsignedStdTx(w io.Writer, txBldr authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg, offline bool) (err error)
PrintUnsignedStdTx builds an unsigned StdTx and prints it to os.Stdout. Don't perform online validation or lookups if offline is true.
func ReadRESTReq ¶ added in v0.25.0
ReadRESTReq is a simple convenience wrapper that reads the body and unmarshals to the req interface.
Usage: type SomeReq struct { BaseReq `json:"base_req"` CustomField string `json:"custom_field"` } req := new(SomeReq) err := ReadRESTReq(w, r, cdc, req)
func SignStdTx ¶ added in v0.25.0
func SignStdTx(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, name string, stdTx auth.StdTx, appendSig bool, offline bool) (auth.StdTx, error)
SignStdTx appends a signature to a StdTx and returns a copy of a it. If appendSig is false, it replaces the signatures already attached with the new signature. Don't perform online validation or lookups if offline is true.
func SignStdTxWithSignerAddress ¶ added in v0.30.0
func SignStdTxWithSignerAddress(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, addr sdk.AccAddress, name string, stdTx auth.StdTx, offline bool) (signedStdTx auth.StdTx, err error)
SignStdTxWithSignerAddress attaches a signature to a StdTx and returns a copy of a it. Don't perform online validation or lookups if offline is true, else populate account and sequence numbers from a foreign account.
func WriteErrorResponse ¶ added in v0.25.0
func WriteErrorResponse(w http.ResponseWriter, status int, err string)
WriteErrorResponse prepares and writes a HTTP error given a status code and an error message.
func WriteGenerateStdTxResponse ¶ added in v0.25.0
func WriteGenerateStdTxResponse(w http.ResponseWriter, cdc *codec.Codec, txBldr authtxb.TxBuilder, msgs []sdk.Msg)
WriteGenerateStdTxResponse writes response for the generate_only mode.
func WriteSimulationResponse ¶ added in v0.25.0
func WriteSimulationResponse(w http.ResponseWriter, gas uint64)
WriteSimulationResponse prepares and writes an HTTP response for transactions simulations.
Types ¶
type BaseReq ¶ added in v0.25.0
type BaseReq struct { Name string `json:"name"` Password string `json:"password"` Memo string `json:"memo"` ChainID string `json:"chain_id"` AccountNumber uint64 `json:"account_number"` Sequence uint64 `json:"sequence"` Fees sdk.Coins `json:"fees"` GasPrices sdk.DecCoins `json:"gas_prices"` Gas string `json:"gas"` GasAdjustment string `json:"gas_adjustment"` GenerateOnly bool `json:"generate_only"` Simulate bool `json:"simulate"` }
BaseReq defines a structure that can be embedded in other request structures that all share common "base" fields.
func NewBaseReq ¶ added in v0.30.0
func NewBaseReq( name, password, memo, chainID string, gas, gasAdjustment string, accNumber, seq uint64, fees sdk.Coins, gasPrices sdk.DecCoins, genOnly, simulate bool, ) BaseReq
NewBaseReq creates a new basic request instance and sanitizes its values
func (BaseReq) Sanitize ¶ added in v0.25.0
Sanitize performs basic sanitization on a BaseReq object.
func (BaseReq) ValidateBasic ¶ added in v0.25.0
func (br BaseReq) ValidateBasic(w http.ResponseWriter) bool
ValidateBasic performs basic validation of a BaseReq. If custom validation logic is needed, the implementing request handler should perform those checks manually.