Skip to content

Commit

Permalink
Problem: multisig account failed on threshold encode after send tx (c…
Browse files Browse the repository at this point in the history
…osmos#808)

* fix(x/tx): don't shadow Amino marshalling error messages (cosmos#19955)

* use directly instead of cast

---------

Co-authored-by: Antonio Pitasi <[email protected]>
  • Loading branch information
2 people authored and dudong2 committed Oct 30, 2024
1 parent 847a5c3 commit 9a094ea
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 @@ -11,7 +11,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 @@ -166,24 +165,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 9a094ea

Please sign in to comment.