Documentation ¶
Index ¶
- Variables
- func CalculateGas(queryFunc func(string, []byte) ([]byte, int64, error), cdc *codec.Codec, ...) (estimate, adjusted uint64, err error)
- func CompleteAndBroadcastTxCLI(txBldr TxBuilder, cliCtx KuCLIContext, msgs []sdk.Msg) error
- func GenerateOrBroadcastMsgs(cliCtx KuCLIContext, txBldr TxBuilder, msgs []sdk.Msg) error
- func GetSignBytes(ctx sdk.Context, tx *StdTx, accNum, seq uint64) []byte
- func GetTxEncoder(cdc *codec.Codec) (encoder sdk.TxEncoder)
- func NewAccountRetriever(cliCtx KuCLIContext) accountTypes.AccountRetriever
- func PrintUnsignedStdTx(txBldr TxBuilder, cliCtx KuCLIContext, msgs []sdk.Msg) error
- func QueryAccountAuth(cliCtx KuCLIContext, id types.AccountID) (types.AccAddress, error)
- func QueryTx(cliCtx context.CLIContext, hashHexStr string) (sdk.TxResponse, error)
- func QueryTxsByEvents(cliCtx context.CLIContext, events []string, page, limit int) (*sdk.SearchTxsResult, error)
- func RegisterCodec(cdc *codec.Codec)
- func ValidateTxResult(cliCtx context.CLIContext, resTx *ctypes.ResultTx) error
- func WriteGenerateStdTxResponse(w http.ResponseWriter, cliCtx KuCLIContext, br rest.BaseReq, msgs []sdk.Msg)
- type AccountID
- type GasEstimateResponse
- type KuCLIContext
- type Name
- type StdTx
- func ReadStdTxFromFile(cdc *codec.Codec, filename string) (stdTx StdTx, err error)
- func SignStdTx(txBldr TxBuilder, cliCtx KuCLIContext, name string, stdTx StdTx, ...) (StdTx, error)
- func SignStdTxWithSignerAddress(txBldr TxBuilder, cliCtx KuCLIContext, addr sdk.AccAddress, name string, ...) (signedStdTx StdTx, err error)
- type TxBuilder
Constants ¶
This section is empty.
Variables ¶
var ( NewStdTx = types.NewStdTx NewTxBuilder = transaction.NewTxBuilder DefaultTxDecoder = types.DefaultTxDecoder DefaultTxEncoder = types.DefaultTxEncoder NewTxBuilderFromCLI = transaction.NewTxBuilderFromCLI )
var ModuleCdc = codec.New()
ModuleCdc auth module wide codec
Functions ¶
func CalculateGas ¶
func CalculateGas( queryFunc func(string, []byte) ([]byte, int64, error), cdc *codec.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 ¶
func CompleteAndBroadcastTxCLI(txBldr TxBuilder, cliCtx KuCLIContext, 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.
func GenerateOrBroadcastMsgs ¶
func GenerateOrBroadcastMsgs(cliCtx KuCLIContext, txBldr TxBuilder, msgs []sdk.Msg) error
GenerateOrBroadcastMsgs creates a StdTx given a series of messages. If the provided context has generate-only enabled, the tx will only be printed to STDOUT in a fully offline manner. Otherwise, the tx will be signed and broadcasted.
func GetSignBytes ¶
GetSignBytes returns the signBytes of the tx for a given signer
func GetTxEncoder ¶
GetTxEncoder return tx encoder from global sdk configuration if ones is defined. Otherwise returns encoder with default logic.
func NewAccountRetriever ¶
func NewAccountRetriever(cliCtx KuCLIContext) accountTypes.AccountRetriever
NewAccountRetriever initialises a new AccountRetriever instance.
func PrintUnsignedStdTx ¶
func PrintUnsignedStdTx(txBldr TxBuilder, cliCtx KuCLIContext, msgs []sdk.Msg) error
PrintUnsignedStdTx builds an unsigned StdTx and prints it to os.Stdout.
func QueryAccountAuth ¶
func QueryAccountAuth(cliCtx KuCLIContext, id types.AccountID) (types.AccAddress, error)
QueryAccountAuth query account auth by id
func QueryTx ¶
func QueryTx(cliCtx context.CLIContext, hashHexStr string) (sdk.TxResponse, error)
QueryTx queries for a single transaction by a hash string in hex format. An error is returned if the transaction does not exist or cannot be queried.
func QueryTxsByEvents ¶
func QueryTxsByEvents(cliCtx context.CLIContext, events []string, page, limit int) (*sdk.SearchTxsResult, error)
QueryTxsByEvents performs a search for transactions for a given set of events via the Tendermint RPC. An event takes the form of: "{eventAttribute}.{attributeKey} = '{attributeValue}'". Each event is concatenated with an 'AND' operand. It returns a slice of Info object containing txs and metadata. An error is returned if the query fails.
func RegisterCodec ¶
RegisterCodec registers concrete types on the codec
func ValidateTxResult ¶
func ValidateTxResult(cliCtx context.CLIContext, resTx *ctypes.ResultTx) error
ValidateTxResult performs transaction verification.
func WriteGenerateStdTxResponse ¶
func WriteGenerateStdTxResponse(w http.ResponseWriter, cliCtx KuCLIContext, br rest.BaseReq, msgs []sdk.Msg)
WriteGenerateStdTxResponse writes response for the generate only mode.
Types ¶
type GasEstimateResponse ¶
type GasEstimateResponse struct {
GasEstimate uint64 `json:"gas_estimate" yaml:"gas_estimate"`
}
GasEstimateResponse defines a response definition for tx gas estimation.
func (GasEstimateResponse) String ¶
func (gr GasEstimateResponse) String() string
type KuCLIContext ¶
type KuCLIContext struct { context.CLIContext FromAccount AccountID }
KuCLIContext cli context for kuchain, add account info
func NewKuCLICtx ¶
func NewKuCLICtx(ctx context.CLIContext) KuCLIContext
NewKuCLICtx creates a new KuCLIContext
func NewKuCLICtxByBuf ¶
func NewKuCLICtxByBuf(cdc *codec.Codec, inBuf io.Reader) KuCLIContext
NewKuCLICtxByBuf creates a new KuCLIContext with cmd
func (KuCLIContext) GetAccountID ¶
func (k KuCLIContext) GetAccountID() AccountID
GetAccountID get account id
func (KuCLIContext) GetAccountInfo ¶
func (k KuCLIContext) GetAccountInfo() (exported.Account, error)
GetAccountInfo get account info by from account id
func (KuCLIContext) WithAccount ¶
func (k KuCLIContext) WithAccount(name Name) KuCLIContext
WithAccount with account name
func (KuCLIContext) WithFromAccount ¶
func (k KuCLIContext) WithFromAccount(from AccountID) KuCLIContext
WithFromAccount with account from accountID
func (KuCLIContext) WithOutput ¶
func (k KuCLIContext) WithOutput(w io.Writer) KuCLIContext
WithOutput returns a copy of the context with an updated output writer (e.g. stdout).
type StdTx ¶
func ReadStdTxFromFile ¶
Read and decode a StdTx from the given filename. Can pass "-" to read from stdin.
func SignStdTx ¶
func SignStdTx( txBldr TxBuilder, cliCtx KuCLIContext, name string, stdTx StdTx, appendSig bool, offline bool, ) (StdTx, error)
SignStdTx appends a signature to a StdTx and returns a copy of 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 ¶
func SignStdTxWithSignerAddress( txBldr TxBuilder, cliCtx KuCLIContext, addr sdk.AccAddress, name string, stdTx StdTx, offline bool, ) (signedStdTx 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.
type TxBuilder ¶
type TxBuilder = transaction.TxBuilder
func EnrichWithGas ¶
EnrichWithGas calculates the gas estimate that would be consumed by the transaction and set the transaction's respective value accordingly.
func PrepareTxBuilder ¶
func PrepareTxBuilder(txBldr TxBuilder, cliCtx KuCLIContext) (TxBuilder, error)
PrepareTxBuilder populates a TxBuilder in preparation for the build of a Tx.