github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/types/service_msg.go (about)

     1  package types
     2  
     3  import (
     4  	"github.com/gogo/protobuf/proto"
     5  )
     6  
     7  // MsgRequest is the interface a transaction message, defined as a proto
     8  // service method, must fulfill.
     9  type MsgRequest interface {
    10  	proto.Message
    11  	// ValidateBasic does a simple validation check that
    12  	// doesn't require access to any other information.
    13  	ValidateBasic() error
    14  	// Signers returns the addrs of signers that must sign.
    15  	// CONTRACT: All signatures must be present to be valid.
    16  	// CONTRACT: Returns addrs in some deterministic order.
    17  	GetSigners() []AccAddress
    18  }
    19  
    20  // ServiceMsg is the struct into which an Any whose typeUrl matches a service
    21  // method format (ex. `/cosmos.gov.Msg/SubmitProposal`) unpacks.
    22  type ServiceMsg struct {
    23  	// MethodName is the fully-qualified service method name.
    24  	MethodName string
    25  	// Request is the request payload.
    26  	Request MsgRequest
    27  }
    28  
    29  var _ Msg = ServiceMsg{}
    30  
    31  func (msg ServiceMsg) ProtoMessage()  {}
    32  func (msg ServiceMsg) Reset()         {}
    33  func (msg ServiceMsg) String() string { return "ServiceMsg" }
    34  
    35  // Route implements Msg.Route method.
    36  func (msg ServiceMsg) Route() string {
    37  	return msg.MethodName
    38  }
    39  
    40  // ValidateBasic implements Msg.ValidateBasic method.
    41  func (msg ServiceMsg) ValidateBasic() error {
    42  	return msg.Request.ValidateBasic()
    43  }
    44  
    45  // GetSignBytes implements Msg.GetSignBytes method.
    46  func (msg ServiceMsg) GetSignBytes() []byte {
    47  	panic("ServiceMsg does not have a GetSignBytes method")
    48  }
    49  
    50  // GetSigners implements Msg.GetSigners method.
    51  func (msg ServiceMsg) GetSigners() []AccAddress {
    52  	return msg.Request.GetSigners()
    53  }
    54  
    55  // Type implements Msg.Type method.
    56  func (msg ServiceMsg) Type() string {
    57  	return msg.MethodName
    58  }