Fix skip confirm logic (#7085)
* Fix skip confirm logic * Fix dry run * Update gh actions * Replace switch with if * revert liveness fix * Add key.Sum validation Co-authored-by: Alessio Treglia <alessio@tendermint.com>
This commit is contained in:
parent
7c0f46ce7f
commit
2e1fbaed9c
@ -100,7 +100,7 @@ func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error {
|
||||
}
|
||||
|
||||
if !clientCtx.SkipConfirm {
|
||||
out, err := clientCtx.JSONMarshaler.MarshalJSON(tx)
|
||||
out, err := clientCtx.TxConfig.TxJSONEncoder()(tx.GetTx())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -20,6 +20,13 @@ var _ types.PublicKeyCodec = DefaultPublicKeyCodec{}
|
||||
|
||||
// Decode implements the PublicKeyCodec.Decode method
|
||||
func (cdc DefaultPublicKeyCodec) Decode(key *types.PublicKey) (crypto.PubKey, error) {
|
||||
// key being nil is allowed as all fields in proto are optional
|
||||
if key == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if key.Sum == nil {
|
||||
return nil, nil
|
||||
}
|
||||
switch key := key.Sum.(type) {
|
||||
case *types.PublicKey_Secp256K1:
|
||||
n := len(key.Secp256K1)
|
||||
@ -68,6 +75,9 @@ func (cdc DefaultPublicKeyCodec) Decode(key *types.PublicKey) (crypto.PubKey, er
|
||||
|
||||
// Encode implements the PublicKeyCodec.Encode method
|
||||
func (cdc DefaultPublicKeyCodec) Encode(key crypto.PubKey) (*types.PublicKey, error) {
|
||||
if key == nil {
|
||||
return &types.PublicKey{}, nil
|
||||
}
|
||||
switch key := key.(type) {
|
||||
case secp256k1.PubKey:
|
||||
return &types.PublicKey{Sum: &types.PublicKey_Secp256K1{Secp256K1: key}}, nil
|
||||
|
||||
@ -25,6 +25,10 @@ func roundTripTest(t *testing.T, pubKey crypto.PubKey) {
|
||||
}
|
||||
|
||||
func TestDefaultPublicKeyCodec(t *testing.T) {
|
||||
roundTripTest(t, nil)
|
||||
|
||||
roundTripTest(t, crypto.PubKey(nil))
|
||||
|
||||
pubKeySecp256k1 := secp256k1.GenPrivKey().PubKey()
|
||||
roundTripTest(t, pubKeySecp256k1)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user