rest

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadcastTxRequest

func BroadcastTxRequest(clientCtx client.Context) http.HandlerFunc

BroadcastTxRequest implements a tx broadcasting handler that is responsible for broadcasting a valid and signed tx to a full node. The tx can be broadcasted via a sync|async|block mechanism.

func ConvertAndEncodeStdTx

func ConvertAndEncodeStdTx(txConfig client.TxConfig, stdTx StdTx) ([]byte, error)

ConvertAndEncodeStdTx encodes the stdTx as a transaction in the format specified by txConfig

func CopyTx

func CopyTx(tx signing.Tx, builder client.TxBuilder, ignoreSignatureError bool) error

CopyTx copies a Tx to a new TxBuilder, allowing conversion between different transaction formats. If ignoreSignatureError is true, copying will continue tx even if the signature cannot be set in the target builder resulting in an unsigned tx.

func RegisterRoutes

func RegisterRoutes(cliCtx client.Context, r *mux.Router, storeName string)

RegisterRoutes - Central function to define routes that get registered by the main application

func StdSignatureToSignatureV2

func StdSignatureToSignatureV2(cdc *codec.LegacyAmino, sig StdSignature) (signing.SignatureV2, error)

StdSignatureToSignatureV2 converts a StdSignature to a SignatureV2

Types

type BroadcastReq

type BroadcastReq struct {
	Tx   StdTx  `json:"tx" yaml:"tx"`
	Mode string `json:"mode" yaml:"mode"`
}

BroadcastReq defines a tx broadcasting request.

func (BroadcastReq) UnpackInterfaces

func (m BroadcastReq) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error

UnpackInterfaces implements the UnpackInterfacesMessage interface.

type StdFee

type StdFee struct {
	Amount sdk.Coins `json:"amount" yaml:"amount"`
	Gas    uint64    `json:"gas" yaml:"gas"`
}

StdFee includes the amount of coins paid in fees and the maximum gas to be used by the transaction. The ratio yields an effective "gasprice", which must be above some miminum to be accepted into the mempool.

func NewStdFee deprecated

func NewStdFee(gas uint64, amount sdk.Coins) StdFee

Deprecated: NewStdFee returns a new instance of StdFee

func (StdFee) Bytes

func (fee StdFee) Bytes() []byte

Bytes returns the encoded bytes of a StdFee.

func (StdFee) GasPrices

func (fee StdFee) GasPrices() sdk.DecCoins

GasPrices returns the gas prices for a StdFee.

NOTE: The gas prices returned are not the true gas prices that were originally part of the submitted transaction because the fee is computed as fee = ceil(gasWanted * gasPrices).

func (StdFee) GetAmount

func (fee StdFee) GetAmount() sdk.Coins

GetAmount returns the fee's amount.

func (StdFee) GetGas

func (fee StdFee) GetGas() uint64

GetGas returns the fee's (wanted) gas.

type StdSignature

type StdSignature struct {
	cryptotypes.PubKey `json:"pub_key" yaml:"pub_key"` // optional
	Signature          []byte                          `json:"signature" yaml:"signature"`
	Sequence           uint64                          `json:"sequence"`
}

StdSignature represents a sig

func NewStdSignature

func NewStdSignature(pk cryptotypes.PubKey, sig []byte) StdSignature

func (StdSignature) GetPubKey

func (ss StdSignature) GetPubKey() cryptotypes.PubKey

GetPubKey returns the public key of a signature as a cryptotypes.PubKey using the Amino codec.

func (StdSignature) GetSignature

func (ss StdSignature) GetSignature() []byte

GetSignature returns the raw signature bytes.

func (StdSignature) MarshalYAML

func (ss StdSignature) MarshalYAML() (interface{}, error)

MarshalYAML returns the YAML representation of the signature.

func (StdSignature) UnpackInterfaces

func (ss StdSignature) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error

type StdTx

type StdTx struct {
	Msgs          []sdk.Msg      `json:"msg" yaml:"msg"`
	Fee           StdFee         `json:"fee" yaml:"fee"`
	Signatures    []StdSignature `json:"signatures" yaml:"signatures"`
	Memo          string         `json:"memo" yaml:"memo"`
	TimeoutHeight uint64         `json:"timeout_height" yaml:"timeout_height"`
}

StdTx is the legacy transaction format for wrapping a Msg with Fee and Signatures. It only works with Amino, please prefer the new protobuf Tx in types/tx. NOTE: the first signature is the fee payer (Signatures must not be nil).

func NewStdTx

func NewStdTx(msgs []sdk.Msg, fee StdFee, sigs []StdSignature, memo string) StdTx

Deprecated

func (*StdTx) AsAny deprecated

func (tx *StdTx) AsAny() *codectypes.Any

Deprecated: AsAny implements intoAny. It doesn't work for protobuf serialization, so it can't be saved into protobuf configured storage. We are using it only for API compatibility.

func (StdTx) FeeGranter

func (tx StdTx) FeeGranter() sdk.AccAddress

FeeGranter always returns nil for StdTx

func (StdTx) FeePayer

func (tx StdTx) FeePayer() sdk.AccAddress

FeePayer returns the address that is responsible for paying fee StdTx returns the first signer as the fee payer If no signers for tx, return empty address

func (StdTx) GetFee

func (tx StdTx) GetFee() sdk.Coins

GetFee returns the FeeAmount in StdFee

func (StdTx) GetGas

func (tx StdTx) GetGas() uint64

GetGas returns the Gas in StdFee

func (StdTx) GetMemo

func (tx StdTx) GetMemo() string

GetMemo returns the memo

func (StdTx) GetMsgs

func (tx StdTx) GetMsgs() []sdk.Msg

GetMsgs returns the all the transaction's messages.

func (StdTx) GetPubKeys

func (tx StdTx) GetPubKeys() ([]cryptotypes.PubKey, error)

GetPubkeys returns the pubkeys of signers if the pubkey is included in the signature If pubkey is not included in the signature, then nil is in the slice instead

func (StdTx) GetSignatures

func (tx StdTx) GetSignatures() [][]byte

GetSignatures returns the signature of signers who signed the Msg. CONTRACT: Length returned is same as length of pubkeys returned from MsgKeySigners, and the order matches. CONTRACT: If the signature is missing (ie the Msg is invalid), then the corresponding signature is .Empty().

func (StdTx) GetSignaturesV2

func (tx StdTx) GetSignaturesV2() ([]signing.SignatureV2, error)

GetSignaturesV2 implements SigVerifiableTx.GetSignaturesV2

func (StdTx) GetSigners

func (tx StdTx) GetSigners() []sdk.AccAddress

GetSigners returns the addresses that must sign the transaction. Addresses are returned in a deterministic order. They are accumulated from the GetSigners method for each Msg in the order they appear in tx.GetMsgs(). Duplicate addresses will be omitted.

func (StdTx) GetTimeoutHeight

func (tx StdTx) GetTimeoutHeight() uint64

GetTimeoutHeight returns the transaction's timeout height (if set).

func (StdTx) UnpackInterfaces

func (tx StdTx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error

func (StdTx) ValidateBasic

func (tx StdTx) ValidateBasic() error

ValidateBasic does a simple and lightweight validation check that doesn't require access to any other information.

Jump to

Keyboard shortcuts

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