github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/ibc-go/modules/core/common/codec.go (about)

     1  package common
     2  
     3  import (
     4  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec"
     5  	conntypes "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/03-connection/types"
     6  	"github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/04-channel/types"
     7  )
     8  
     9  func MustMarshalChannel(cdc *codec.CodecProxy, c *types.Channel) []byte {
    10  	ret := cdc.GetProtocMarshal().MustMarshalBinaryBare(c)
    11  	return ret
    12  }
    13  
    14  func MarshalChannel(cdc *codec.CodecProxy, c *types.Channel) ([]byte, error) {
    15  	return cdc.GetProtocMarshal().MarshalBinaryBare(c)
    16  }
    17  
    18  func MustUnmarshalChannel(cdc *codec.CodecProxy, data []byte) *types.Channel {
    19  	var ret types.Channel
    20  	cdc.GetProtocMarshal().MustUnmarshalBinaryBare(data, &ret)
    21  	return &ret
    22  }
    23  
    24  func MustUnmarshalConnection(cdc *codec.CodecProxy, data []byte) *conntypes.ConnectionEnd {
    25  	var ret conntypes.ConnectionEnd
    26  	cdc.GetProtocMarshal().MustUnmarshalBinaryBare(data, &ret)
    27  	return &ret
    28  }
    29  func UnmarshalConnection(cdc *codec.CodecProxy, data []byte) (*conntypes.ConnectionEnd, error) {
    30  	var ret conntypes.ConnectionEnd
    31  	err := cdc.GetProtocMarshal().UnmarshalBinaryBare(data, &ret)
    32  	return &ret, err
    33  }
    34  
    35  func MustMarshalConnection(cdc *codec.CodecProxy, c *conntypes.ConnectionEnd) []byte {
    36  	ret := cdc.GetProtocMarshal().MustMarshalBinaryBare(c)
    37  	return ret
    38  }