Documentation ¶
Index ¶
- Variables
- func CollInterfaceValue[T proto.Message](codec BinaryCodec) collcodec.ValueCodec[T]
- func CollValue[T any, PT protoMessage[T]](cdc interface{ ... }) 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 ProvideAddressCodec(in AddressCodecInputs) (address.Codec, address.ValidatorAddressCodec, address.ConsensusAddressCodec)
- func ProvideInterfaceRegistry(addressCodec address.Codec, ...) (types.InterfaceRegistry, registry.InterfaceRegistrar, error)
- func ProvideLegacyAmino() legacy.Amino
- func RegisterEvidences(cdc legacy.Amino)
- type AddressCodecInputs
- 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)
- func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *legacy.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, protoreflect.Message, error)
- func (pc *ProtoCodec) GetMsgSigners(msg gogoproto.Message) ([][]byte, protoreflect.Message, error)
- func (pc *ProtoCodec) GetReflectMsgSigners(msg protoreflect.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 ¶
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 ¶
func CollValue[T any, PT protoMessage[T]](cdc interface { Marshal(proto.Message) ([]byte, error) Unmarshal([]byte, proto.Message) error }, ) collcodec.ValueCodec[T]
CollValue inits a collections.ValueCodec for a generic gogo protobuf message.
func CollValueV2 ¶
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 ¶
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 ProvideAddressCodec ¶
func ProvideAddressCodec(in AddressCodecInputs) (address.Codec, address.ValidatorAddressCodec, address.ConsensusAddressCodec)
ProvideAddressCodec provides an address.Codec to the container for any modules that want to do address string <> bytes conversion.
func ProvideInterfaceRegistry ¶
func ProvideInterfaceRegistry( addressCodec address.Codec, validatorAddressCodec address.ValidatorAddressCodec, customGetSigners []signing.CustomGetSigner, ) (types.InterfaceRegistry, registry.InterfaceRegistrar, error)
func ProvideLegacyAmino ¶
func RegisterEvidences ¶
RegisterEvidences registers CometBFT evidence types with the provided Amino codec.
Types ¶
type AddressCodecInputs ¶
type AddressCodecInputs struct { depinject.In AuthConfig *authmodulev1.Module `optional:"true"` StakingConfig *stakingmodulev1.Module `optional:"true"` AddressCodecFactory func() address.Codec `optional:"true"` ValidatorAddressCodecFactory func() address.ValidatorAddressCodec `optional:"true"` ConsensusAddressCodecFactory func() address.ConsensusAddressCodec `optional:"true"` }
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 ¶
func (ac *AminoCodec) Marshal(o proto.Message) ([]byte, error)
Marshal implements BinaryMarshaler.Marshal method.
func (*AminoCodec) MarshalInterface ¶
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 ¶
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 ¶
func (ac *AminoCodec) MarshalLengthPrefixed(o proto.Message) ([]byte, error)
MarshalLengthPrefixed implements BinaryMarshaler.MarshalLengthPrefixed method.
func (*AminoCodec) MustMarshal ¶
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 ¶
func (ac *AminoCodec) MustMarshalLengthPrefixed(o proto.Message) []byte
MustMarshalLengthPrefixed implements BinaryMarshaler.MustMarshalLengthPrefixed method.
func (*AminoCodec) MustUnmarshal ¶
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 ¶
func (ac *AminoCodec) MustUnmarshalLengthPrefixed(bz []byte, ptr proto.Message)
MustUnmarshalLengthPrefixed implements BinaryMarshaler.MustUnmarshalLengthPrefixed method.
func (*AminoCodec) Unmarshal ¶
func (ac *AminoCodec) Unmarshal(bz []byte, ptr proto.Message) error
Unmarshal implements BinaryMarshaler.Unmarshal method.
func (*AminoCodec) UnmarshalInterface ¶
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 ¶
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 ¶
func (ac *AminoCodec) UnmarshalLengthPrefixed(bz []byte, ptr proto.Message) error
UnmarshalLengthPrefixed implements BinaryMarshaler.UnmarshalLengthPrefixed method.
type AminoMarshaler ¶
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 ¶
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) // UnmarshalLengthPrefixed 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 protoreflect.Message that was used to extract the // signers so that this can be used in other context where proto reflection // is needed. GetMsgAnySigners(msg *types.Any) ([][]byte, protoreflect.Message, error) // GetMsgSigners returns the signers of the given message plus the // decoded protoreflect.Message that was used to extract the // signers so that this can be used in other context where proto reflection // is needed. GetMsgSigners(msg proto.Message) ([][]byte, protoreflect.Message, error) // GetReflectMsgSigners returns the signers of the given reflected proto message. GetReflectMsgSigners(msg protoreflect.Message) ([][]byte, error) // contains filtered or unexported methods }
Codec defines a functionality for serializing other objects. Users can define 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 ¶
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 ¶
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 ¶
type LegacyAmino struct {
Amino *amino.Codec
}
LegacyAmino defines a wrapper for an Amino codec that properly handles protobuf types with Any's. Deprecated.
func NewLegacyAmino ¶
func NewLegacyAmino() *LegacyAmino
func (*LegacyAmino) Marshal ¶
func (cdc *LegacyAmino) Marshal(o interface{}) ([]byte, error)
func (*LegacyAmino) MarshalJSON ¶
func (cdc *LegacyAmino) MarshalJSON(o interface{}) ([]byte, error)
MarshalJSON implements codec.Codec interface
func (*LegacyAmino) MarshalJSONIndent ¶
func (cdc *LegacyAmino) MarshalJSONIndent(o interface{}, prefix, indent string) ([]byte, error)
func (*LegacyAmino) MarshalLengthPrefixed ¶
func (cdc *LegacyAmino) MarshalLengthPrefixed(o interface{}) ([]byte, error)
func (*LegacyAmino) MustMarshal ¶
func (cdc *LegacyAmino) MustMarshal(o interface{}) []byte
func (*LegacyAmino) MustMarshalJSON ¶
func (cdc *LegacyAmino) MustMarshalJSON(o interface{}) []byte
func (*LegacyAmino) MustMarshalLengthPrefixed ¶
func (cdc *LegacyAmino) MustMarshalLengthPrefixed(o interface{}) []byte
func (*LegacyAmino) MustUnmarshal ¶
func (cdc *LegacyAmino) MustUnmarshal(bz []byte, ptr interface{})
func (*LegacyAmino) MustUnmarshalJSON ¶
func (cdc *LegacyAmino) MustUnmarshalJSON(bz []byte, ptr interface{})
func (*LegacyAmino) MustUnmarshalLengthPrefixed ¶
func (cdc *LegacyAmino) MustUnmarshalLengthPrefixed(bz []byte, ptr interface{})
func (*LegacyAmino) PrintTypes ¶
func (cdc *LegacyAmino) PrintTypes(out io.Writer) error
func (*LegacyAmino) RegisterConcrete ¶
func (cdc *LegacyAmino) RegisterConcrete(o interface{}, name string)
func (*LegacyAmino) RegisterInterface ¶
func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *legacy.InterfaceOptions)
func (*LegacyAmino) Seal ¶
func (cdc *LegacyAmino) Seal()
func (*LegacyAmino) Unmarshal ¶
func (cdc *LegacyAmino) Unmarshal(bz []byte, ptr interface{}) error
func (*LegacyAmino) UnmarshalJSON ¶
func (cdc *LegacyAmino) UnmarshalJSON(bz []byte, ptr interface{}) error
UnmarshalJSON implements codec.Codec interface
func (*LegacyAmino) UnmarshalLengthPrefixed ¶
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 ProvideProtoCodec ¶
func ProvideProtoCodec(interfaceRegistry types.InterfaceRegistry) *ProtoCodec
func (*ProtoCodec) GRPCCodec ¶
func (pc *ProtoCodec) GRPCCodec() encoding.Codec
GRPCCodec returns the gRPC Codec for this specific ProtoCodec
func (ProtoCodec) GetMsgAnySigners ¶
func (pc ProtoCodec) GetMsgAnySigners(msg *types.Any) ([][]byte, protoreflect.Message, error)
func (*ProtoCodec) GetMsgSigners ¶
func (pc *ProtoCodec) GetMsgSigners(msg gogoproto.Message) ([][]byte, protoreflect.Message, error)
func (*ProtoCodec) GetReflectMsgSigners ¶
func (pc *ProtoCodec) GetReflectMsgSigners(msg protoreflect.Message) ([][]byte, error)
func (*ProtoCodec) InterfaceRegistry ¶
func (pc *ProtoCodec) InterfaceRegistry() types.InterfaceRegistry
InterfaceRegistry returns InterfaceRegistry
func (*ProtoCodec) Marshal ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (pc *ProtoCodec) MarshalLengthPrefixed(o gogoproto.Message) ([]byte, error)
MarshalLengthPrefixed implements BinaryMarshaler.MarshalLengthPrefixed method.
func (*ProtoCodec) MustMarshal ¶
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 ¶
func (pc *ProtoCodec) MustMarshalLengthPrefixed(o gogoproto.Message) []byte
MustMarshalLengthPrefixed implements BinaryMarshaler.MustMarshalLengthPrefixed method.
func (*ProtoCodec) MustUnmarshal ¶
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 ¶
func (pc *ProtoCodec) MustUnmarshalLengthPrefixed(bz []byte, ptr gogoproto.Message)
MustUnmarshalLengthPrefixed implements BinaryMarshaler.MustUnmarshalLengthPrefixed method.
func (*ProtoCodec) Unmarshal ¶
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 ¶
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 ¶
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 ¶
func (pc *ProtoCodec) UnmarshalLengthPrefixed(bz []byte, ptr gogoproto.Message) error
UnmarshalLengthPrefixed implements BinaryMarshaler.UnmarshalLengthPrefixed method.
type ProtoCodecMarshaler ¶
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 |
Package unknownproto implements functionality to "type check" protobuf serialized byte sequences against an expected proto.Message to report:
|
Package unknownproto implements functionality to "type check" protobuf serialized byte sequences against an expected proto.Message to report: |