Skip to content

Commit

Permalink
use directly instead of cast
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Sep 27, 2024
1 parent 2a329c0 commit 4d8162a
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions x/tx/signing/aminojson/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4d8162a

Please sign in to comment.