Skip to content

Commit

Permalink
Fix skip confirm logic (#7085)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
sahith-narahari and Alessio Treglia authored Aug 21, 2020
1 parent 7c0f46c commit 2e1fbae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/tx/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 10 additions & 0 deletions std/pubkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions std/pubkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 2e1fbae

Please sign in to comment.