Skip to content

Commit

Permalink
Merge PR cosmos#4346: report card minor fixes
Browse files Browse the repository at this point in the history
* report card minor fixes

* fix
  • Loading branch information
rigelrozanski authored May 17, 2019
1 parent 4b7d295 commit 5b7690e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 39 deletions.
12 changes: 6 additions & 6 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ func (app *BaseApp) getContextForTx(mode runTxMode, txBytes []byte) (ctx sdk.Con
}

// runMsgs iterates through all the messages and executes them.
// nolint: gocyclo
func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (result sdk.Result) {
idxLogs := make([]sdk.ABCIMessageLog, 0, len(msgs)) // a list of JSON-encoded logs with msg index

Expand Down Expand Up @@ -782,7 +783,7 @@ func (app *BaseApp) cacheTxContext(ctx sdk.Context, txBytes []byte) (
return ctx.WithMultiStore(msCache), msCache
}

// runTx processes a transaction. The transactions is proccessed via an
// runTx processes a transaction. The transactions is processed via an
// anteHandler. The provided txBytes may be nil in some cases, eg. in tests. For
// further details on transaction execution, reference the BaseApp SDK
// documentation.
Expand All @@ -797,8 +798,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk

// only run the tx if there is block gas remaining
if mode == runTxModeDeliver && ctx.BlockGasMeter().IsOutOfGas() {
result = sdk.ErrOutOfGas("no block gas left to run tx").Result()
return
return sdk.ErrOutOfGas("no block gas left to run tx").Result()
}

var startingGas uint64
Expand Down Expand Up @@ -883,7 +883,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk
}

if mode == runTxModeCheck {
return
return result
}

// Create a new context based off of the existing context with a cache wrapped
Expand All @@ -893,15 +893,15 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk
result.GasWanted = gasWanted

if mode == runTxModeSimulate {
return
return result
}

// only update state if all messages pass
if result.IsOK() {
msCache.Write()
}

return
return result
}

// EndBlock implements the ABCI interface.
Expand Down
3 changes: 2 additions & 1 deletion cmd/gaia/cli_test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ func TestGaiaCLIQueryRewards(t *testing.T) {
genDoc, err := tmtypes.GenesisDocFromFile(genFile)
require.NoError(t, err)
genDoc.AppState, err = cdc.MarshalJSON(genesisState)
require.NoError(t, err)
require.NoError(t, genDoc.SaveAs(genFile))

// start gaiad server
Expand Down Expand Up @@ -860,7 +861,7 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))

// Test broadcast
success, stdout, _ = f.TxBroadcast(signedTxFile.Name())
success, _, _ = f.TxBroadcast(signedTxFile.Name())
require.True(t, success)
tests.WaitForNextNBlocksTM(1, f.Port)

Expand Down
2 changes: 1 addition & 1 deletion crypto/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func checkAminoJSON(t *testing.T, src interface{}, dst interface{}, isNil bool)
require.Nil(t, err, "%+v", err)
}

//nolint
// nolint: vet
func ExamplePrintRegisteredTypes() {
cdc.PrintTypes(os.Stdout)
// Output: | Type | Name | Prefix | Length | Notes |
Expand Down
4 changes: 2 additions & 2 deletions crypto/keys/hd/hdpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func mnemonicToSeed(mnemonic string) []byte {
return bip39.NewSeed(mnemonic, defaultBIP39Passphrase)
}

//nolint
// nolint: vet
func ExampleStringifyPathParams() {
path := NewParams(44, 0, 0, false, 0)
fmt.Println(path.String())
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestParamsFromPath(t *testing.T) {

}

//nolint
// nolint: vet
func ExampleSomeBIP32TestVecs() {

seed := mnemonicToSeed("barrel original fuel morning among eternal " +
Expand Down
58 changes: 29 additions & 29 deletions x/auth/client/cli/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (

"github.com/spf13/cobra"
"github.com/spf13/viper"
amino "github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/crypto/multisig"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/utils"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
Expand All @@ -28,7 +28,7 @@ const (
)

// GetSignCommand returns the transaction sign command.
func GetSignCommand(codec *amino.Codec) *cobra.Command {
func GetSignCommand(codec *codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "sign [file]",
Short: "Sign transactions generated offline",
Expand Down Expand Up @@ -92,11 +92,11 @@ func preSignCmd(cmd *cobra.Command, _ []string) {
}
}

func makeSignCmd(cdc *amino.Codec) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) (err error) {
func makeSignCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
stdTx, err := utils.ReadStdTxFromFile(cdc, args[0])
if err != nil {
return
return err
}

offline := viper.GetBool(flagOffline)
Expand Down Expand Up @@ -137,35 +137,14 @@ func makeSignCmd(cdc *amino.Codec) func(cmd *cobra.Command, args []string) error
return err
}

var json []byte

switch generateSignatureOnly {
case true:
switch cliCtx.Indent {
case true:
json, err = cdc.MarshalJSONIndent(newTx.Signatures[0], "", " ")

default:
json, err = cdc.MarshalJSON(newTx.Signatures[0])
}

default:
switch cliCtx.Indent {
case true:
json, err = cdc.MarshalJSONIndent(newTx, "", " ")

default:
json, err = cdc.MarshalJSON(newTx)
}
}

json, err := getSignatureJSON(cdc, newTx, cliCtx.Indent, generateSignatureOnly)
if err != nil {
return err
}

if viper.GetString(flagOutfile) == "" {
fmt.Printf("%s\n", json)
return
return nil
}

fp, err := os.OpenFile(
Expand All @@ -178,7 +157,28 @@ func makeSignCmd(cdc *amino.Codec) func(cmd *cobra.Command, args []string) error
defer fp.Close()
fmt.Fprintf(fp, "%s\n", json)

return
return nil
}
}

func getSignatureJSON(cdc *codec.Codec, newTx auth.StdTx, indent, generateSignatureOnly bool) ([]byte, error) {
switch generateSignatureOnly {
case true:
switch indent {
case true:
return cdc.MarshalJSONIndent(newTx.Signatures[0], "", " ")

default:
return cdc.MarshalJSON(newTx.Signatures[0])
}
default:
switch indent {
case true:
return cdc.MarshalJSONIndent(newTx, "", " ")

default:
return cdc.MarshalJSON(newTx)
}
}
}

Expand Down

0 comments on commit 5b7690e

Please sign in to comment.