github.com/Finschia/finschia-sdk@v0.48.1/types/tx_msg.go (about)

     1  package types
     2  
     3  import (
     4  	"github.com/gogo/protobuf/proto"
     5  
     6  	cryptotypes "github.com/Finschia/finschia-sdk/crypto/types"
     7  )
     8  
     9  type (
    10  	// Msg defines the interface a transaction message must fulfill.
    11  	Msg interface {
    12  		proto.Message
    13  
    14  		// ValidateBasic does a simple validation check that
    15  		// doesn't require access to any other information.
    16  		ValidateBasic() error
    17  
    18  		// Signers returns the addrs of signers that must sign.
    19  		// CONTRACT: All signatures must be present to be valid.
    20  		// CONTRACT: Returns addrs in some deterministic order.
    21  		GetSigners() []AccAddress
    22  	}
    23  
    24  	// Fee defines an interface for an application application-defined concrete
    25  	// transaction type to be able to set and return the transaction fee.
    26  	Fee interface {
    27  		GetGas() uint64
    28  		GetAmount() Coins
    29  	}
    30  
    31  	// Signature defines an interface for an application application-defined
    32  	// concrete transaction type to be able to set and return transaction signatures.
    33  	Signature interface {
    34  		GetPubKey() cryptotypes.PubKey
    35  		GetSignature() []byte
    36  	}
    37  
    38  	// Tx defines the interface a transaction must fulfill.
    39  	Tx interface {
    40  		// Gets the all the transaction's messages.
    41  		GetMsgs() []Msg
    42  
    43  		// ValidateBasic does a simple and lightweight validation check that doesn't
    44  		// require access to any other information.
    45  		ValidateBasic() error
    46  	}
    47  
    48  	// FeeTx defines the interface to be implemented by Tx to use the FeeDecorators
    49  	FeeTx interface {
    50  		Tx
    51  		GetGas() uint64
    52  		GetFee() Coins
    53  		FeePayer() AccAddress
    54  		FeeGranter() AccAddress
    55  	}
    56  
    57  	// Tx must have GetMemo() method to use ValidateMemoDecorator
    58  	TxWithMemo interface {
    59  		Tx
    60  		GetMemo() string
    61  	}
    62  
    63  	// TxWithTimeoutHeight extends the Tx interface by allowing a transaction to
    64  	// set a height timeout.
    65  	TxWithTimeoutHeight interface {
    66  		Tx
    67  
    68  		GetTimeoutHeight() uint64
    69  	}
    70  )
    71  
    72  // TxDecoder unmarshals transaction bytes
    73  type TxDecoder func(txBytes []byte) (Tx, error)
    74  
    75  // TxEncoder marshals transaction to bytes
    76  type TxEncoder func(tx Tx) ([]byte, error)
    77  
    78  // MsgTypeURL returns the TypeURL of a `sdk.Msg`.
    79  func MsgTypeURL(msg Msg) string {
    80  	return "/" + proto.MessageName(msg)
    81  }