From 675e57b66f5945b9a12ccb3eb1b35b3d68adcb3b Mon Sep 17 00:00:00 2001 From: Matt Kocubinski Date: Thu, 14 Nov 2024 16:23:01 -0600 Subject: [PATCH] add registration --- x/tx/signing/aminojson/options.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/x/tx/signing/aminojson/options.go b/x/tx/signing/aminojson/options.go index c5c9462ef106..9a87cd56726b 100644 --- a/x/tx/signing/aminojson/options.go +++ b/x/tx/signing/aminojson/options.go @@ -8,6 +8,7 @@ import ( "github.com/pkg/errors" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" "google.golang.org/protobuf/runtime/protoimpl" "google.golang.org/protobuf/types/descriptorpb" @@ -103,7 +104,7 @@ func (enc Encoder) getMessageEncoder(message protoreflect.Message) MessageEncode return nil } -var customTypeExtension = protoimpl.ExtensionInfo{ +var customTypeExtension = &protoimpl.ExtensionInfo{ ExtendedType: (*descriptorpb.FieldOptions)(nil), ExtensionType: gogo.E_Customtype.ExtensionType, Field: gogo.E_Customtype.Field, @@ -112,6 +113,10 @@ var customTypeExtension = protoimpl.ExtensionInfo{ Filename: gogo.E_Customtype.Filename, } +func init() { + protoregistry.GlobalTypes.RegisterExtension(customTypeExtension) +} + func (enc Encoder) getFieldEncoder(field protoreflect.FieldDescriptor) FieldEncoder { opts := field.Options() if proto.HasExtension(opts, amino.E_Encoding) { @@ -129,7 +134,7 @@ func (enc Encoder) getFieldEncoder(field protoreflect.FieldDescriptor) FieldEnco // For example: // https://github.com/cosmos/cosmos-sdk/blob/9076487d035e43d39fe54e8498da1ce31b9c845c/x/gov/proto/cosmos/gov/v1/gov.proto#L274 if scalar == cosmosDecType { - customType := proto.GetExtension(opts, &customTypeExtension) + customType := proto.GetExtension(opts, customTypeExtension) if customType != "cosmossdk.io/math.LegacyDec" { return nil }