Documentation ¶
Index ¶
- Constants
- func AsyncOnlyArg(r *http.Request) bool
- func CalculateGas(queryFunc func(string, common.HexBytes) ([]byte, error), cdc *amino.Codec, ...) (estimate, adjusted uint64, simulationResult sdk.Result, err error)
- func CommitOnlyArg(r *http.Request) bool
- func ConvertDecToRat(input sdk.Dec) sdk.Rat
- func ExRateFromStakeTokenToMainUnit(cliCtx context.CLIContext) sdk.Rat
- func GetAccountDecoder(cdc *codec.Codec) auth.AccountDecoder
- func HasDryRunArg(r *http.Request) bool
- func InitReqCliCtx(cliCtx context.CLIContext, r *http.Request) context.CLIContext
- 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(txCtx TxContext, cliCtx context.CLIContext, msgs []sdk.Msg, offline bool) (err error)
- func ReadPostBody(w http.ResponseWriter, r *http.Request, cdc *codec.Codec, req interface{}) (err error)
- func SendOrPrintTx(txCtx TxContext, cliCtx context.CLIContext, msgs []sdk.Msg) error
- func SignStdTx(txCtx TxContext, cliCtx context.CLIContext, name string, stdTx auth.StdTx, ...) (auth.StdTx, error)
- func SignStdTxWithSignerAddress(txCtx TxContext, cliCtx context.CLIContext, addr sdk.AccAddress, name string, ...) (signedStdTx auth.StdTx, err error)
- func WriteErrorResponse(w http.ResponseWriter, status int, err string)
- func WriteGenerateStdTxResponse(w http.ResponseWriter, txCtx TxContext, msgs []sdk.Msg)
- func WriteSimulationResponse(w http.ResponseWriter, cliCtx context.CLIContext, gas uint64, ...)
- type BaseTx
- type TxContext
- func (txCtx TxContext) Build(msgs []sdk.Msg) (client.StdSignMsg, error)
- func (txCtx TxContext) BuildAndSign(name, passphrase string, msgs []sdk.Msg) ([]byte, error)
- func (txCtx TxContext) BuildWithPubKey(name string, msgs []sdk.Msg) ([]byte, error)
- func (txCtx TxContext) Sign(name, passphrase string, msg client.StdSignMsg) ([]byte, error)
- func (txCtx TxContext) SignStdTx(name, passphrase string, stdTx auth.StdTx, appendSig bool) (signedStdTx auth.StdTx, err error)
- func (txCtx TxContext) WithAccountNumber(accnum uint64) TxContext
- func (txCtx TxContext) WithChainID(chainID string) TxContext
- func (txCtx TxContext) WithCliCtx(ctx context.CLIContext) TxContext
- func (txCtx TxContext) WithCodec(cdc *codec.Codec) TxContext
- func (txCtx TxContext) WithFee(fee string) TxContext
- func (txCtx TxContext) WithGas(gas uint64) TxContext
- func (txCtx TxContext) WithMemo(memo string) TxContext
- func (txCtx TxContext) WithSequence(sequence uint64) TxContext
Constants ¶
const ( Async = "async" Commit = "commit" )
Variables ¶
This section is empty.
Functions ¶
func AsyncOnlyArg ¶
AsyncOnlyArg returns whether a URL's query "async" parameter
func CalculateGas ¶ added in v0.7.0
func CalculateGas(queryFunc func(string, common.HexBytes) ([]byte, error), cdc *amino.Codec, txBytes []byte, adjustment float64) (estimate, adjusted uint64, simulationResult sdk.Result, err error)
CalculateGas simulates the execution of a transaction and returns both the estimate obtained by the query and the adjusted amount.
func CommitOnlyArg ¶ added in v0.10.0
CommitOnlyArg returns whether a URL's query "commit" parameter
func ExRateFromStakeTokenToMainUnit ¶ added in v0.7.0
func ExRateFromStakeTokenToMainUnit(cliCtx context.CLIContext) sdk.Rat
func GetAccountDecoder ¶ added in v0.9.0
func GetAccountDecoder(cdc *codec.Codec) auth.AccountDecoder
GetAccountDecoder gets the account decoder for auth.DefaultAccount.
func HasDryRunArg ¶ added in v0.7.0
HasDryRunArg returns true if the request's URL query contains the dry run argument and its value is set to "true".
func InitReqCliCtx ¶ added in v0.7.0
func InitReqCliCtx(cliCtx context.CLIContext, r *http.Request) context.CLIContext
InitReqCliCtx
func ParseFloat64OrReturnBadRequest ¶ added in v0.7.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.7.0
func ParseInt64OrReturnBadRequest(w http.ResponseWriter, s string) (n int64, ok bool)
ParseInt64OrReturnBadRequest converts s to a int64 value.
func ParseUint64OrReturnBadRequest ¶ added in v0.7.0
func ParseUint64OrReturnBadRequest(w http.ResponseWriter, s string) (n uint64, ok bool)
ParseUint64OrReturnBadRequest converts s to a uint64 value.
func PostProcessResponse ¶ added in v0.7.0
func PostProcessResponse(w http.ResponseWriter, cdc *codec.Codec, response interface{}, indent bool)
PostProcessResponse performs post process for rest response
func PrintUnsignedStdTx ¶
func PrintUnsignedStdTx(txCtx TxContext, 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 ReadPostBody ¶
func ReadPostBody(w http.ResponseWriter, r *http.Request, cdc *codec.Codec, req interface{}) (err error)
ReadPostBody
func SendOrPrintTx ¶
SendOrPrintTx implements a utility function that facilitates sending a series of messages in a signed transaction given a TxContext 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 SignStdTx ¶ added in v0.7.0
func SignStdTx(txCtx TxContext, 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.15.0
func SignStdTxWithSignerAddress(txCtx TxContext, 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 ¶
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 ¶
func WriteGenerateStdTxResponse(w http.ResponseWriter, txCtx TxContext, msgs []sdk.Msg)
WriteGenerateStdTxResponse writes response for the generate_only mode.
func WriteSimulationResponse ¶ added in v0.7.0
func WriteSimulationResponse(w http.ResponseWriter, cliCtx context.CLIContext, gas uint64, result sdk.Result)
Types ¶
type BaseTx ¶ added in v0.9.0
type BaseTx struct { ChainID string `json:"chain_id"` Gas string `json:"gas"` Fee string `json:"fee"` Memo string `json:"memo"` }
BaseTx defines a structure that can be embedded in other request structures that all share common "base" fields.
func (BaseTx) ValidateBasic ¶ added in v0.9.0
func (br BaseTx) ValidateBasic(w http.ResponseWriter) bool
ValidateBasic performs basic validation of a BaseTx. If custom validation logic is needed, the implementing request handler should perform those checks manually.
type TxContext ¶ added in v0.9.0
type TxContext struct { Codec *codec.Codec AccountNumber uint64 Sequence uint64 Gas uint64 GasAdjustment float64 SimulateGas bool ChainID string Memo string Fee string // contains filtered or unexported fields }
TxContext implements a transaction context created in SDK modules.
func BuildReqTxCtx ¶ added in v0.15.0
func BuildReqTxCtx(cliCtx context.CLIContext, baseTx BaseTx, w http.ResponseWriter) TxContext
BuildReqTxCtx builds a tx context for the request. Make sure baseTx has been validated
func EnrichCtxWithGas ¶ added in v0.7.0
func EnrichCtxWithGas(txCtx TxContext, cliCtx context.CLIContext, name string, msgs []sdk.Msg) (TxContext, sdk.Result, error)
EnrichCtxWithGas calculates the gas estimate that would be consumed by the transaction and set the transaction's respective value accordingly.
func NewTxContextFromCLI ¶ added in v0.9.0
func NewTxContextFromCLI() TxContext
NewTxBuilderFromCLI returns a new initialized TxContext with parameters from the command line using Viper.
func (TxContext) Build ¶ added in v0.9.0
Build builds a single message to be signed from a TxContext given a set of messages. It returns an error if a fee is supplied but cannot be parsed.
func (TxContext) BuildAndSign ¶ added in v0.9.0
BuildAndSign builds a single message to be signed, and signs a transaction with the built message given a name, passphrase, and a set of messages.
func (TxContext) BuildWithPubKey ¶ added in v0.9.0
BuildWithPubKey builds a single message to be signed from a TxContext given a set of messages and attach the public key associated to the given name. It returns an error if a fee is supplied but cannot be parsed or the key cannot be retrieved.
func (TxContext) Sign ¶ added in v0.9.0
Sign signs a transaction given a name, passphrase, and a single message to signed. An error is returned if signing fails.
func (TxContext) SignStdTx ¶ added in v0.9.0
func (txCtx TxContext) SignStdTx(name, passphrase string, stdTx auth.StdTx, appendSig bool) (signedStdTx auth.StdTx, err error)
SignStdTx appends a signature to a StdTx and returns a copy of a it. If append is false, it replaces the signatures already attached with the new signature.
func (TxContext) WithAccountNumber ¶ added in v0.9.0
WithAccountNumber returns a copy of the context with an account number.
func (TxContext) WithChainID ¶ added in v0.9.0
WithChainID returns a copy of the context with an updated chainID.
func (TxContext) WithCliCtx ¶ added in v0.9.0
func (txCtx TxContext) WithCliCtx(ctx context.CLIContext) TxContext
WithCodec returns a copy of the context with an updated codec.
func (TxContext) WithCodec ¶ added in v0.9.0
WithCodec returns a copy of the context with an updated codec.
func (TxContext) WithFee ¶ added in v0.9.0
WithFee returns a copy of the context with an updated fee.
func (TxContext) WithGas ¶ added in v0.9.0
WithGas returns a copy of the context with an updated gas.
func (TxContext) WithMemo ¶ added in v0.9.0
WithMemo returns a copy of the context with an updated memo.
func (TxContext) WithSequence ¶ added in v0.9.0
WithSequence returns a copy of the context with an updated sequence number.