Skip to content

Commit

Permalink
add registration
Browse files Browse the repository at this point in the history
  • Loading branch information
kocubinski committed Nov 14, 2024
1 parent 565b711 commit 675e57b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions x/tx/signing/aminojson/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand All @@ -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
}
Expand Down

0 comments on commit 675e57b

Please sign in to comment.