From 4d8162ae3f7a705db78417778d9fb08b119488a1 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 27 Sep 2024 13:07:56 +0800 Subject: [PATCH] use directly instead of cast --- x/tx/signing/aminojson/encoder.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/x/tx/signing/aminojson/encoder.go b/x/tx/signing/aminojson/encoder.go index 07a7c8ea0792..90ac7d5d0167 100644 --- a/x/tx/signing/aminojson/encoder.go +++ b/x/tx/signing/aminojson/encoder.go @@ -10,7 +10,6 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" authapi "cosmossdk.io/api/cosmos/auth/v1beta1" - "cosmossdk.io/api/cosmos/crypto/multisig" "cosmossdk.io/math" ) @@ -143,24 +142,15 @@ func moduleAccountEncoder(_ *Encoder, msg protoreflect.Message, w io.Writer) err // also see: // https://github.com/cosmos/cosmos-sdk/blob/b49f948b36bc991db5be431607b475633aed697e/proto/cosmos/crypto/multisig/keys.proto#L15/ func thresholdStringEncoder(enc *Encoder, msg protoreflect.Message, w io.Writer) error { - pk, ok := msg.Interface().(*multisig.LegacyAminoPubKey) - if !ok { - return errors.New("thresholdStringEncoder: msg not a multisig.LegacyAminoPubKey") - } - _, err := fmt.Fprintf(w, `{"threshold":"%d","pubkeys":`, pk.Threshold) + fields := msg.Descriptor().Fields() + thresholdField := fields.ByName("threshold") + threshold := msg.Get(thresholdField).Uint() + _, err := fmt.Fprintf(w, `{"threshold":"%d","pubkeys":`, threshold) if err != nil { return err } - - if len(pk.PublicKeys) == 0 { - _, err = io.WriteString(w, `[]}`) - return err - } - - fields := msg.Descriptor().Fields() pubkeysField := fields.ByName("public_keys") pubkeys := msg.Get(pubkeysField).List() - err = enc.marshalList(pubkeys, pubkeysField, w) if err != nil { return err