Documentation
¶
Overview ¶
Package types defines the InterfaceRegistry type as well as aliases for types that now live in the github.com/cosmos/gogoproto/types/any package for backwards compatibility with legacy code.
Index ¶
- Variables
- func MsgTypeURL(msg proto.Message) string
- func UnpackInterfaces(x interface{}, unpacker gogoprotoany.AnyUnpacker) error
- type AminoJSONPacker
- type AminoJSONUnpacker
- type AminoPacker
- type AminoUnpacker
- type Any
- type AnyUnpacker
- type InterfaceRegistry
- type InterfaceRegistryOptions
- type ProtoJSONPacker
- type UnpackInterfacesMessage
Constants ¶
This section is empty.
Variables ¶
var ( // MaxUnpackAnySubCalls extension point that defines the maximum number of sub-calls allowed during the unpacking // process of protobuf Any messages. MaxUnpackAnySubCalls = 100 // MaxUnpackAnyRecursionDepth extension point that defines the maximum allowed recursion depth during protobuf Any // message unpacking. MaxUnpackAnyRecursionDepth = 10 )
var Debug = true
Deprecated: this is no longer used for anything.
var NewAnyWithValue = gogoany.NewAnyWithCacheWithValue
NewAnyWithValue is an alias for github.com/cosmos/gogoproto/types/any.NewAnyWithCacheWithValue.
var UnsafePackAny = gogoany.UnsafePackAnyWithCache
UnsafePackAny is an alias for github.com/cosmos/gogoproto/types/any.UnsafePackAnyWithCache.
Functions ¶
func MsgTypeURL ¶ added in v0.50.0
MsgTypeURL returns the TypeURL of a `sdk.Msg`.
func UnpackInterfaces ¶
func UnpackInterfaces(x interface{}, unpacker gogoprotoany.AnyUnpacker) error
UnpackInterfaces is a convenience function that calls UnpackInterfaces on x if x implements UnpackInterfacesMessage
Types ¶
type AminoJSONPacker ¶
type AminoJSONPacker = gogoany.AminoJSONPacker
AminoJSONPacker is an alias for github.com/cosmos/gogoproto/types/any.AminoJSONPacker.
type AminoJSONUnpacker ¶
type AminoJSONUnpacker = gogoany.AminoJSONUnpacker
AminoJSONUnpacker is an alias for github.com/cosmos/gogoproto/types/any.AminoJSONUnpacker.
type AminoPacker ¶
type AminoPacker = gogoany.AminoPacker
AminoPacker is an alias for github.com/cosmos/gogoproto/types/any.AminoPacker.
type AminoUnpacker ¶
type AminoUnpacker = gogoany.AminoUnpacker
AminoUnpacker is an alias for github.com/cosmos/gogoproto/types/any.AminoUnpacker.
type AnyUnpacker ¶
type AnyUnpacker = gogoprotoany.AnyUnpacker
AnyUnpacker is an alias for github.com/cosmos/gogoproto/types/any.AnyUnpacker.
type InterfaceRegistry ¶
type InterfaceRegistry interface { gogoprotoany.AnyUnpacker jsonpb.AnyResolver // RegisterInterface associates protoName as the public name for the // interface passed in as iface. This is to be used primarily to create // a public facing registry of interface implementations for clients. // protoName should be a well-chosen public facing name that remains stable. // RegisterInterface takes an optional list of impls to be registered // as implementations of iface. // // Ex: // registry.RegisterInterface("cosmos.base.v1beta1.Msg", (*sdk.Msg)(nil)) RegisterInterface(protoName string, iface any, impls ...proto.Message) // RegisterImplementations registers impls as concrete implementations of // the interface iface. // // Ex: // registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSend{}, &MsgMultiSend{}) RegisterImplementations(iface any, impls ...proto.Message) // ListAllInterfaces list the type URLs of all registered interfaces. ListAllInterfaces() []string // ListImplementations lists the valid type URLs for the given interface name that can be used // for the provided interface type URL. ListImplementations(ifaceTypeURL string) []string // EnsureRegistered ensures there is a registered interface for the given concrete type. EnsureRegistered(iface any) error protodesc.Resolver // RangeFiles iterates over all registered files and calls f on each one. This // implements the part of protoregistry.Files that is needed for reflecting over // the entire FileDescriptorSet. RangeFiles(f func(protoreflect.FileDescriptor) bool) SigningContext() *signing.Context // contains filtered or unexported methods }
InterfaceRegistry provides a mechanism for registering interfaces and implementations that can be safely unpacked from Any
func NewInterfaceRegistry ¶
func NewInterfaceRegistry() InterfaceRegistry
NewInterfaceRegistry returns a new InterfaceRegistry
func NewInterfaceRegistryWithOptions ¶ added in v0.50.0
func NewInterfaceRegistryWithOptions(options InterfaceRegistryOptions) (InterfaceRegistry, error)
NewInterfaceRegistryWithOptions returns a new InterfaceRegistry with the given options.
type InterfaceRegistryOptions ¶ added in v0.50.0
type InterfaceRegistryOptions struct { // ProtoFiles is the set of files to use for the registry. It is required. ProtoFiles signing.ProtoFileResolver // SigningOptions are the signing options to use for the registry. SigningOptions signing.Options }
InterfaceRegistryOptions are options for creating a new InterfaceRegistry.
type ProtoJSONPacker ¶ added in v0.40.0
type ProtoJSONPacker = gogoany.ProtoJSONPacker
ProtoJSONPacker is an alias for github.com/cosmos/gogoproto/types/any.ProtoJSONPacker.
type UnpackInterfacesMessage ¶
type UnpackInterfacesMessage interface { // UnpackInterfaces is implemented in order to unpack values packed within // Any's using the AnyUnpacker. It should generally be implemented as // follows: // func (s *MyStruct) UnpackInterfaces(unpacker AnyUnpacker) error { // var x AnyInterface // // where X is an Any field on MyStruct // err := unpacker.UnpackAny(s.X, &x) // if err != nil { // return nil // } // // where Y is a field on MyStruct that implements UnpackInterfacesMessage itself // err = s.Y.UnpackInterfaces(unpacker) // if err != nil { // return nil // } // return nil // } UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error }
UnpackInterfacesMessage is meant to extend protobuf types (which implement proto.Message) to support a post-deserialization phase which unpacks types packed within Any's using the whitelist provided by AnyUnpacker