Documentation ¶
Index ¶
- Variables
- func CollInterfaceValue[T proto.Message](codec BinaryCodec) collcodec.ValueCodec[T]
- func CollValue[T any, PT protoMessage[T]](cdc BinaryCodec) collcodec.ValueCodec[T]
- func CollValueV2[T any, PT protoMessageV2[T]]() collcodec.ValueCodec[PT]
- func MarshalJSONIndent(cdc *LegacyAmino, obj interface{}) ([]byte, error)
- func MarshalYAML(cdc JSONCodec, toPrint proto.Message) ([]byte, error)
- func MustMarshalJSONIndent(cdc *LegacyAmino, obj interface{}) []byte
- func ProtoMarshalJSON(msg proto.Message, resolver jsonpb.AnyResolver) ([]byte, error)
- func RegisterEvidences(cdc *LegacyAmino)
- type AminoCodecdeprecated
- func (ac *AminoCodec) Marshal(o proto.Message) ([]byte, error)
- func (ac *AminoCodec) MarshalInterface(i proto.Message) ([]byte, error)
- func (ac *AminoCodec) MarshalInterfaceJSON(i proto.Message) ([]byte, error)
- func (ac *AminoCodec) MarshalJSON(o proto.Message) ([]byte, error)
- func (ac *AminoCodec) MarshalLengthPrefixed(o proto.Message) ([]byte, error)
- func (ac *AminoCodec) MustMarshal(o proto.Message) []byte
- func (ac *AminoCodec) MustMarshalJSON(o proto.Message) []byte
- func (ac *AminoCodec) MustMarshalLengthPrefixed(o proto.Message) []byte
- func (ac *AminoCodec) MustUnmarshal(bz []byte, ptr proto.Message)
- func (ac *AminoCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message)
- func (ac *AminoCodec) MustUnmarshalLengthPrefixed(bz []byte, ptr proto.Message)
- func (ac *AminoCodec) Unmarshal(bz []byte, ptr proto.Message) error
- func (ac *AminoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error
- func (ac *AminoCodec) UnmarshalInterfaceJSON(bz []byte, ptr interface{}) error
- func (ac *AminoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error
- func (ac *AminoCodec) UnmarshalLengthPrefixed(bz []byte, ptr proto.Message) error
- type AminoMarshaler
- type BinaryCodec
- type Codec
- type GRPCCodecProvider
- type JSONCodec
- type LegacyAmino
- func (cdc *LegacyAmino) Marshal(o interface{}) ([]byte, error)
- func (cdc *LegacyAmino) MarshalJSON(o interface{}) ([]byte, error)
- func (cdc *LegacyAmino) MarshalJSONIndent(o interface{}, prefix, indent string) ([]byte, error)
- func (cdc *LegacyAmino) MarshalLengthPrefixed(o interface{}) ([]byte, error)
- func (cdc *LegacyAmino) MustMarshal(o interface{}) []byte
- func (cdc *LegacyAmino) MustMarshalJSON(o interface{}) []byte
- func (cdc *LegacyAmino) MustMarshalLengthPrefixed(o interface{}) []byte
- func (cdc *LegacyAmino) MustUnmarshal(bz []byte, ptr interface{})
- func (cdc *LegacyAmino) MustUnmarshalJSON(bz []byte, ptr interface{})
- func (cdc *LegacyAmino) MustUnmarshalLengthPrefixed(bz []byte, ptr interface{})
- func (cdc *LegacyAmino) PrintTypes(out io.Writer) error
- func (cdc *LegacyAmino) RegisterConcrete(o interface{}, name string, copts *amino.ConcreteOptions)
- func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *amino.InterfaceOptions)
- func (cdc *LegacyAmino) Seal()
- func (cdc *LegacyAmino) Unmarshal(bz []byte, ptr interface{}) error
- func (cdc *LegacyAmino) UnmarshalJSON(bz []byte, ptr interface{}) error
- func (cdc *LegacyAmino) UnmarshalLengthPrefixed(bz []byte, ptr interface{}) error
- func (*LegacyAmino) UnpackAny(*types.Any, interface{}) error
- type ProtoCodec
- func (pc *ProtoCodec) GRPCCodec() encoding.Codec
- func (pc ProtoCodec) GetMsgAnySigners(msg *types.Any) ([][]byte, proto.Message, error)
- func (pc *ProtoCodec) GetMsgV1Signers(msg gogoproto.Message) ([][]byte, proto.Message, error)
- func (pc *ProtoCodec) GetMsgV2Signers(msg proto.Message) ([][]byte, error)
- func (pc *ProtoCodec) InterfaceRegistry() types.InterfaceRegistry
- func (pc *ProtoCodec) Marshal(o gogoproto.Message) ([]byte, error)
- func (pc *ProtoCodec) MarshalAminoJSON(msg gogoproto.Message) ([]byte, error)
- func (pc *ProtoCodec) MarshalInterface(i gogoproto.Message) ([]byte, error)
- func (pc *ProtoCodec) MarshalInterfaceJSON(x gogoproto.Message) ([]byte, error)
- func (pc *ProtoCodec) MarshalJSON(o gogoproto.Message) ([]byte, error)
- func (pc *ProtoCodec) MarshalLengthPrefixed(o gogoproto.Message) ([]byte, error)
- func (pc *ProtoCodec) MustMarshal(o gogoproto.Message) []byte
- func (pc *ProtoCodec) MustMarshalJSON(o gogoproto.Message) []byte
- func (pc *ProtoCodec) MustMarshalLengthPrefixed(o gogoproto.Message) []byte
- func (pc *ProtoCodec) MustUnmarshal(bz []byte, ptr gogoproto.Message)
- func (pc *ProtoCodec) MustUnmarshalJSON(bz []byte, ptr gogoproto.Message)
- func (pc *ProtoCodec) MustUnmarshalLengthPrefixed(bz []byte, ptr gogoproto.Message)
- func (pc *ProtoCodec) Unmarshal(bz []byte, ptr gogoproto.Message) error
- func (pc *ProtoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error
- func (pc *ProtoCodec) UnmarshalInterfaceJSON(bz []byte, iface interface{}) error
- func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr gogoproto.Message) error
- func (pc *ProtoCodec) UnmarshalLengthPrefixed(bz []byte, ptr gogoproto.Message) error
- func (pc *ProtoCodec) UnpackAny(any *types.Any, iface interface{}) error
- type ProtoCodecMarshaler
- type ProtoMarshalerdeprecated
Constants ¶
This section is empty.
Variables ¶
var BoolValue collcodec.ValueCodec[bool] = boolValue{}
BoolValue implements a ValueCodec that saves the bool value as if it was a prototypes.BoolValue. Required for backwards compatibility of state.
Functions ¶
func CollInterfaceValue ¶ added in v0.50.0
func CollInterfaceValue[T proto.Message](codec BinaryCodec) collcodec.ValueCodec[T]
CollInterfaceValue instantiates a new collections.ValueCodec for a generic interface value. The codec must be able to marshal and unmarshal the interface.
func CollValue ¶ added in v0.50.0
func CollValue[T any, PT protoMessage[T]](cdc BinaryCodec) collcodec.ValueCodec[T]
CollValue inits a collections.ValueCodec for a generic gogo protobuf message.
func CollValueV2 ¶ added in v0.50.0
func CollValueV2[T any, PT protoMessageV2[T]]() collcodec.ValueCodec[PT]
CollValueV2 is used for protobuf values of the newest google.golang.org/protobuf API.
func MarshalJSONIndent ¶
func MarshalJSONIndent(cdc *LegacyAmino, obj interface{}) ([]byte, error)
MarshalJSONIndent provides a utility for indented JSON encoding of an object via an Amino codec. It returns an error if it cannot serialize or indent as JSON.
func MarshalYAML ¶ added in v0.40.0
MarshalYAML marshals toPrint using JSONCodec to leverage specialized MarshalJSON methods (usually related to serialize data with protobuf or amin depending on a configuration). This involves additional roundtrip through JSON.
func MustMarshalJSONIndent ¶
func MustMarshalJSONIndent(cdc *LegacyAmino, obj interface{}) []byte
MustMarshalJSONIndent executes MarshalJSONIndent except it panics upon failure.
func ProtoMarshalJSON ¶
ProtoMarshalJSON provides an auxiliary function to return Proto3 JSON encoded bytes of a message.
func RegisterEvidences ¶
func RegisterEvidences(cdc *LegacyAmino)
RegisterEvidences registers CometBFT evidence types with the provided Amino codec.
Types ¶
type AminoCodec
deprecated
type AminoCodec struct {
*LegacyAmino
}
Deprecated: AminoCodec defines a codec that utilizes Codec for both binary and JSON encoding. Any usage of amino should be done using the LegacyAmino type directly. Usage of amino with the Codec type is not well-supported and may be removed in the future.
func NewAminoCodec
deprecated
func NewAminoCodec(codec *LegacyAmino) *AminoCodec
Deprecated: NewAminoCodec returns a reference to a new AminoCodec. Use NewLegacyAmino instead.
func (*AminoCodec) Marshal ¶ added in v0.43.0
func (ac *AminoCodec) Marshal(o proto.Message) ([]byte, error)
Marshal implements BinaryMarshaler.Marshal method.
func (*AminoCodec) MarshalInterface ¶ added in v0.40.0
func (ac *AminoCodec) MarshalInterface(i proto.Message) ([]byte, error)
MarshalInterface is a convenience function for amino marshaling interfaces. The `i` must be an interface. NOTE: to marshal a concrete type, you should use Marshal instead
func (*AminoCodec) MarshalInterfaceJSON ¶ added in v0.40.0
func (ac *AminoCodec) MarshalInterfaceJSON(i proto.Message) ([]byte, error)
MarshalInterfaceJSON is a convenience function for amino marshaling interfaces. The `i` must be an interface. NOTE: to marshal a concrete type, you should use MarshalJSON instead
func (*AminoCodec) MarshalJSON ¶
func (ac *AminoCodec) MarshalJSON(o proto.Message) ([]byte, error)
MarshalJSON implements JSONCodec.MarshalJSON method, it marshals to JSON using legacy amino codec.
func (*AminoCodec) MarshalLengthPrefixed ¶ added in v0.43.0
func (ac *AminoCodec) MarshalLengthPrefixed(o proto.Message) ([]byte, error)
MarshalLengthPrefixed implements BinaryMarshaler.MarshalLengthPrefixed method.
func (*AminoCodec) MustMarshal ¶ added in v0.43.0
func (ac *AminoCodec) MustMarshal(o proto.Message) []byte
MustMarshal implements BinaryMarshaler.MustMarshal method.
func (*AminoCodec) MustMarshalJSON ¶
func (ac *AminoCodec) MustMarshalJSON(o proto.Message) []byte
MustMarshalJSON implements JSONCodec.MustMarshalJSON method, it executes MarshalJSON except it panics upon failure.
func (*AminoCodec) MustMarshalLengthPrefixed ¶ added in v0.43.0
func (ac *AminoCodec) MustMarshalLengthPrefixed(o proto.Message) []byte
MustMarshalLengthPrefixed implements BinaryMarshaler.MustMarshalLengthPrefixed method.
func (*AminoCodec) MustUnmarshal ¶ added in v0.43.0
func (ac *AminoCodec) MustUnmarshal(bz []byte, ptr proto.Message)
MustUnmarshal implements BinaryMarshaler.MustUnmarshal method.
func (*AminoCodec) MustUnmarshalJSON ¶
func (ac *AminoCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message)
MustUnmarshalJSON implements JSONCodec.MustUnmarshalJSON method, it executes UnmarshalJSON except it panics upon failure.
func (*AminoCodec) MustUnmarshalLengthPrefixed ¶ added in v0.43.0
func (ac *AminoCodec) MustUnmarshalLengthPrefixed(bz []byte, ptr proto.Message)
MustUnmarshalLengthPrefixed implements BinaryMarshaler.MustUnmarshalLengthPrefixed method.
func (*AminoCodec) Unmarshal ¶ added in v0.43.0
func (ac *AminoCodec) Unmarshal(bz []byte, ptr proto.Message) error
Unmarshal implements BinaryMarshaler.Unmarshal method.
func (*AminoCodec) UnmarshalInterface ¶ added in v0.40.0
func (ac *AminoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error
UnmarshalInterface is a convenience function for amino unmarshaling interfaces. `ptr` must be a pointer to an interface. NOTE: to unmarshal a concrete type, you should use Unmarshal instead
Example:
var x MyInterface err := cdc.UnmarshalInterface(bz, &x)
func (*AminoCodec) UnmarshalInterfaceJSON ¶ added in v0.40.0
func (ac *AminoCodec) UnmarshalInterfaceJSON(bz []byte, ptr interface{}) error
UnmarshalInterfaceJSON is a convenience function for amino unmarshaling interfaces. `ptr` must be a pointer to an interface. NOTE: to unmarshal a concrete type, you should use UnmarshalJSON instead
Example:
var x MyInterface err := cdc.UnmarshalInterfaceJSON(bz, &x)
func (*AminoCodec) UnmarshalJSON ¶
func (ac *AminoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error
UnmarshalJSON implements JSONCodec.UnmarshalJSON method, it unmarshals from JSON using legacy amino codec.
func (*AminoCodec) UnmarshalLengthPrefixed ¶ added in v0.43.0
func (ac *AminoCodec) UnmarshalLengthPrefixed(bz []byte, ptr proto.Message) error
UnmarshalLengthPrefixed implements BinaryMarshaler.UnmarshalLengthPrefixed method.
type AminoMarshaler ¶ added in v0.40.0
type AminoMarshaler interface { MarshalAmino() ([]byte, error) UnmarshalAmino([]byte) error MarshalAminoJSON() ([]byte, error) UnmarshalAminoJSON([]byte) error }
AminoMarshaler defines an interface a type must implement to serialize itself for Amino codec.
type BinaryCodec ¶ added in v0.43.0
type BinaryCodec interface { // Marshal returns binary encoding of v. Marshal(o proto.Message) ([]byte, error) // MustMarshal calls Marshal and panics if error is returned. MustMarshal(o proto.Message) []byte // MarshalLengthPrefixed returns binary encoding of v with bytes length prefix. MarshalLengthPrefixed(o proto.Message) ([]byte, error) // MustMarshalLengthPrefixed calls MarshalLengthPrefixed and panics if // error is returned. MustMarshalLengthPrefixed(o proto.Message) []byte // Unmarshal parses the data encoded with Marshal method and stores the result // in the value pointed to by v. Unmarshal(bz []byte, ptr proto.Message) error // MustUnmarshal calls Unmarshal and panics if error is returned. MustUnmarshal(bz []byte, ptr proto.Message) // Unmarshal parses the data encoded with UnmarshalLengthPrefixed method and stores // the result in the value pointed to by v. UnmarshalLengthPrefixed(bz []byte, ptr proto.Message) error // MustUnmarshalLengthPrefixed calls UnmarshalLengthPrefixed and panics if error // is returned. MustUnmarshalLengthPrefixed(bz []byte, ptr proto.Message) // MarshalInterface is a helper method which will wrap `i` into `Any` for correct // binary interface (de)serialization. MarshalInterface(i proto.Message) ([]byte, error) // UnmarshalInterface is a helper method which will parse binary enoded data // into `Any` and unpack any into the `ptr`. It fails if the target interface type // is not registered in codec, or is not compatible with the serialized data UnmarshalInterface(bz []byte, ptr interface{}) error types.AnyUnpacker }
type Codec ¶
type Codec interface { BinaryCodec JSONCodec // InterfaceRegistry returns the interface registry. InterfaceRegistry() types.InterfaceRegistry // GetMsgAnySigners returns the signers of the given message encoded in a protobuf Any // as well as the decoded google.golang.org/protobuf/proto.Message that was used to // extract the signers so that this can be used in other contexts. GetMsgAnySigners(msg *types.Any) ([][]byte, protov2.Message, error) // GetMsgV2Signers returns the signers of the given message. GetMsgV2Signers(msg protov2.Message) ([][]byte, error) // GetMsgV1Signers returns the signers of the given message plus the // decoded google.golang.org/protobuf/proto.Message that was used to extract the // signers so that this can be used in other contexts. GetMsgV1Signers(msg proto.Message) ([][]byte, protov2.Message, error) // contains filtered or unexported methods }
Codec defines a functionality for serializing other objects. Users can defin a custom Protobuf-based serialization. Note, Amino can still be used without any dependency on Protobuf. SDK provides to Codec implementations:
1. AminoCodec: Provides full Amino serialization compatibility. 2. ProtoCodec: Provides full Protobuf serialization compatibility.
type GRPCCodecProvider ¶ added in v0.46.0
GRPCCodecProvider is implemented by the Codec implementations which return a gRPC encoding.Codec. And it is used to decode requests and encode responses passed through gRPC.
type JSONCodec ¶ added in v0.43.0
type JSONCodec interface { // MarshalJSON returns JSON encoding of v. MarshalJSON(o proto.Message) ([]byte, error) // MustMarshalJSON calls MarshalJSON and panics if error is returned. MustMarshalJSON(o proto.Message) []byte // MarshalInterfaceJSON is a helper method which will wrap `i` into `Any` for correct // JSON interface (de)serialization. MarshalInterfaceJSON(i proto.Message) ([]byte, error) // UnmarshalInterfaceJSON is a helper method which will parse JSON enoded data // into `Any` and unpack any into the `ptr`. It fails if the target interface type // is not registered in codec, or is not compatible with the serialized data UnmarshalInterfaceJSON(bz []byte, ptr interface{}) error // UnmarshalJSON parses the data encoded with MarshalJSON method and stores the result // in the value pointed to by v. UnmarshalJSON(bz []byte, ptr proto.Message) error // MustUnmarshalJSON calls Unmarshal and panics if error is returned. MustUnmarshalJSON(bz []byte, ptr proto.Message) }
type LegacyAmino ¶ added in v0.40.0
LegacyAmino defines a wrapper for an Amino codec that properly handles protobuf types with Any's. Deprecated.
func NewLegacyAmino ¶ added in v0.40.0
func NewLegacyAmino() *LegacyAmino
func (*LegacyAmino) Marshal ¶ added in v0.43.0
func (cdc *LegacyAmino) Marshal(o interface{}) ([]byte, error)
func (*LegacyAmino) MarshalJSON ¶ added in v0.40.0
func (cdc *LegacyAmino) MarshalJSON(o interface{}) ([]byte, error)
MarshalJSON implements codec.Codec interface
func (*LegacyAmino) MarshalJSONIndent ¶ added in v0.40.0
func (cdc *LegacyAmino) MarshalJSONIndent(o interface{}, prefix, indent string) ([]byte, error)
func (*LegacyAmino) MarshalLengthPrefixed ¶ added in v0.43.0
func (cdc *LegacyAmino) MarshalLengthPrefixed(o interface{}) ([]byte, error)
func (*LegacyAmino) MustMarshal ¶ added in v0.43.0
func (cdc *LegacyAmino) MustMarshal(o interface{}) []byte
func (*LegacyAmino) MustMarshalJSON ¶ added in v0.40.0
func (cdc *LegacyAmino) MustMarshalJSON(o interface{}) []byte
func (*LegacyAmino) MustMarshalLengthPrefixed ¶ added in v0.43.0
func (cdc *LegacyAmino) MustMarshalLengthPrefixed(o interface{}) []byte
func (*LegacyAmino) MustUnmarshal ¶ added in v0.43.0
func (cdc *LegacyAmino) MustUnmarshal(bz []byte, ptr interface{})
func (*LegacyAmino) MustUnmarshalJSON ¶ added in v0.40.0
func (cdc *LegacyAmino) MustUnmarshalJSON(bz []byte, ptr interface{})
func (*LegacyAmino) MustUnmarshalLengthPrefixed ¶ added in v0.43.0
func (cdc *LegacyAmino) MustUnmarshalLengthPrefixed(bz []byte, ptr interface{})
func (*LegacyAmino) PrintTypes ¶ added in v0.40.0
func (cdc *LegacyAmino) PrintTypes(out io.Writer) error
func (*LegacyAmino) RegisterConcrete ¶ added in v0.40.0
func (cdc *LegacyAmino) RegisterConcrete(o interface{}, name string, copts *amino.ConcreteOptions)
func (*LegacyAmino) RegisterInterface ¶ added in v0.40.0
func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *amino.InterfaceOptions)
func (*LegacyAmino) Seal ¶ added in v0.40.0
func (cdc *LegacyAmino) Seal()
func (*LegacyAmino) Unmarshal ¶ added in v0.43.0
func (cdc *LegacyAmino) Unmarshal(bz []byte, ptr interface{}) error
func (*LegacyAmino) UnmarshalJSON ¶ added in v0.40.0
func (cdc *LegacyAmino) UnmarshalJSON(bz []byte, ptr interface{}) error
UnmarshalJSON implements codec.Codec interface
func (*LegacyAmino) UnmarshalLengthPrefixed ¶ added in v0.43.0
func (cdc *LegacyAmino) UnmarshalLengthPrefixed(bz []byte, ptr interface{}) error
type ProtoCodec ¶
type ProtoCodec struct {
// contains filtered or unexported fields
}
ProtoCodec defines a codec that utilizes Protobuf for both binary and JSON encoding.
func NewProtoCodec ¶
func NewProtoCodec(interfaceRegistry types.InterfaceRegistry) *ProtoCodec
NewProtoCodec returns a reference to a new ProtoCodec
func (*ProtoCodec) GRPCCodec ¶ added in v0.46.0
func (pc *ProtoCodec) GRPCCodec() encoding.Codec
GRPCCodec returns the gRPC Codec for this specific ProtoCodec
func (ProtoCodec) GetMsgAnySigners ¶ added in v0.50.0
func (*ProtoCodec) GetMsgV1Signers ¶ added in v0.50.0
func (*ProtoCodec) GetMsgV2Signers ¶ added in v0.50.0
func (pc *ProtoCodec) GetMsgV2Signers(msg proto.Message) ([][]byte, error)
func (*ProtoCodec) InterfaceRegistry ¶ added in v0.40.0
func (pc *ProtoCodec) InterfaceRegistry() types.InterfaceRegistry
InterfaceRegistry returns InterfaceRegistry
func (*ProtoCodec) Marshal ¶ added in v0.43.0
func (pc *ProtoCodec) Marshal(o gogoproto.Message) ([]byte, error)
Marshal implements BinaryMarshaler.Marshal method. NOTE: this function must be used with a concrete type which implements proto.Message. For interface please use the codec.MarshalInterface
func (*ProtoCodec) MarshalAminoJSON ¶ added in v0.50.0
func (pc *ProtoCodec) MarshalAminoJSON(msg gogoproto.Message) ([]byte, error)
MarshalAminoJSON provides aminojson.Encoder compatibility for gogoproto messages. x/tx/signing/aminojson cannot marshal gogoproto messages directly since this type does not implement the standard library google.golang.org/protobuf/proto.Message. We convert gogo types to dynamicpb messages and then marshal that directly to amino JSON.
func (*ProtoCodec) MarshalInterface ¶ added in v0.40.0
func (pc *ProtoCodec) MarshalInterface(i gogoproto.Message) ([]byte, error)
MarshalInterface is a convenience function for proto marshaling interfaces. It packs the provided value, which must be an interface, in an Any and then marshals it to bytes. NOTE: to marshal a concrete type, you should use Marshal instead
func (*ProtoCodec) MarshalInterfaceJSON ¶ added in v0.40.0
func (pc *ProtoCodec) MarshalInterfaceJSON(x gogoproto.Message) ([]byte, error)
MarshalInterfaceJSON is a convenience function for proto marshaling interfaces. It packs the provided value in an Any and then marshals it to bytes. NOTE: to marshal a concrete type, you should use MarshalJSON instead
func (*ProtoCodec) MarshalJSON ¶
func (pc *ProtoCodec) MarshalJSON(o gogoproto.Message) ([]byte, error)
MarshalJSON implements JSONCodec.MarshalJSON method, it marshals to JSON using proto codec. NOTE: this function must be used with a concrete type which implements proto.Message. For interface please use the codec.MarshalInterfaceJSON
func (*ProtoCodec) MarshalLengthPrefixed ¶ added in v0.43.0
func (pc *ProtoCodec) MarshalLengthPrefixed(o gogoproto.Message) ([]byte, error)
MarshalLengthPrefixed implements BinaryMarshaler.MarshalLengthPrefixed method.
func (*ProtoCodec) MustMarshal ¶ added in v0.43.0
func (pc *ProtoCodec) MustMarshal(o gogoproto.Message) []byte
MustMarshal implements BinaryMarshaler.MustMarshal method. NOTE: this function must be used with a concrete type which implements proto.Message. For interface please use the codec.MarshalInterface
func (*ProtoCodec) MustMarshalJSON ¶
func (pc *ProtoCodec) MustMarshalJSON(o gogoproto.Message) []byte
MustMarshalJSON implements JSONCodec.MustMarshalJSON method, it executes MarshalJSON except it panics upon failure. NOTE: this function must be used with a concrete type which implements proto.Message. For interface please use the codec.MarshalInterfaceJSON
func (*ProtoCodec) MustMarshalLengthPrefixed ¶ added in v0.43.0
func (pc *ProtoCodec) MustMarshalLengthPrefixed(o gogoproto.Message) []byte
MustMarshalLengthPrefixed implements BinaryMarshaler.MustMarshalLengthPrefixed method.
func (*ProtoCodec) MustUnmarshal ¶ added in v0.43.0
func (pc *ProtoCodec) MustUnmarshal(bz []byte, ptr gogoproto.Message)
MustUnmarshal implements BinaryMarshaler.MustUnmarshal method. NOTE: this function must be used with a concrete type which implements proto.Message. For interface please use the codec.UnmarshalInterface
func (*ProtoCodec) MustUnmarshalJSON ¶
func (pc *ProtoCodec) MustUnmarshalJSON(bz []byte, ptr gogoproto.Message)
MustUnmarshalJSON implements JSONCodec.MustUnmarshalJSON method, it executes UnmarshalJSON except it panics upon failure. NOTE: this function must be used with a concrete type which implements proto.Message. For interface please use the codec.UnmarshalInterfaceJSON
func (*ProtoCodec) MustUnmarshalLengthPrefixed ¶ added in v0.43.0
func (pc *ProtoCodec) MustUnmarshalLengthPrefixed(bz []byte, ptr gogoproto.Message)
MustUnmarshalLengthPrefixed implements BinaryMarshaler.MustUnmarshalLengthPrefixed method.
func (*ProtoCodec) Unmarshal ¶ added in v0.43.0
func (pc *ProtoCodec) Unmarshal(bz []byte, ptr gogoproto.Message) error
Unmarshal implements BinaryMarshaler.Unmarshal method. NOTE: this function must be used with a concrete type which implements proto.Message. For interface please use the codec.UnmarshalInterface
func (*ProtoCodec) UnmarshalInterface ¶ added in v0.40.0
func (pc *ProtoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error
UnmarshalInterface is a convenience function for proto unmarshaling interfaces. It unmarshals an Any from bz bytes and then unpacks it to the `ptr`, which must be a pointer to a non empty interface with registered implementations. NOTE: to unmarshal a concrete type, you should use Unmarshal instead
Example:
var x MyInterface err := cdc.UnmarshalInterface(bz, &x)
func (*ProtoCodec) UnmarshalInterfaceJSON ¶ added in v0.40.0
func (pc *ProtoCodec) UnmarshalInterfaceJSON(bz []byte, iface interface{}) error
UnmarshalInterfaceJSON is a convenience function for proto unmarshaling interfaces. It unmarshals an Any from bz bytes and then unpacks it to the `iface`, which must be a pointer to a non empty interface, implementing proto.Message with registered implementations. NOTE: to unmarshal a concrete type, you should use UnmarshalJSON instead
Example:
var x MyInterface // must implement proto.Message err := cdc.UnmarshalInterfaceJSON(&x, bz)
func (*ProtoCodec) UnmarshalJSON ¶
func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr gogoproto.Message) error
UnmarshalJSON implements JSONCodec.UnmarshalJSON method, it unmarshals from JSON using proto codec. NOTE: this function must be used with a concrete type which implements proto.Message. For interface please use the codec.UnmarshalInterfaceJSON
func (*ProtoCodec) UnmarshalLengthPrefixed ¶ added in v0.43.0
func (pc *ProtoCodec) UnmarshalLengthPrefixed(bz []byte, ptr gogoproto.Message) error
UnmarshalLengthPrefixed implements BinaryMarshaler.UnmarshalLengthPrefixed method.
type ProtoCodecMarshaler ¶ added in v0.40.0
type ProtoCodecMarshaler interface { Codec }
ProtoCodecMarshaler defines an interface for codecs that utilize Protobuf for both binary and JSON encoding. Deprecated: Use Codec instead.
type ProtoMarshaler
deprecated
type ProtoMarshaler interface { proto.Message // for JSON serialization Marshal() ([]byte, error) MarshalTo(data []byte) (n int, err error) MarshalToSizedBuffer(dAtA []byte) (int, error) Size() int Unmarshal(data []byte) error }
ProtoMarshaler defines an interface a type must implement to serialize itself as a protocol buffer defined message.
Deprecated: Use proto.Message instead from github.com/cosmos/gogoproto/proto.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package legacy contains a global amino Cdc which is deprecated but still used in several places within the SDK.
|
Package legacy contains a global amino Cdc which is deprecated but still used in several places within the SDK. |
Package types defines a custom wrapper for google.protobuf.Any which supports cached values as well as InterfaceRegistry which keeps track of types which can be used with Any for both security and introspection
|
Package types defines a custom wrapper for google.protobuf.Any which supports cached values as well as InterfaceRegistry which keeps track of types which can be used with Any for both security and introspection |
unknownproto implements functionality to "type check" protobuf serialized byte sequences against an expected proto.Message to report:
|
unknownproto implements functionality to "type check" protobuf serialized byte sequences against an expected proto.Message to report: |