diff --git a/CHANGELOG.md b/CHANGELOG.md index f8629ea1a..5c3190842 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ IMPROVEMENTS FIXES * [lcd] Switch to bech32 for addresses on all human readable inputs and outputs +* [cli] Added `--gas` flag to specify transaction gas limit ## 0.18.0 diff --git a/client/context/helpers.go b/client/context/helpers.go index f47cc7ff4..880c4adb3 100644 --- a/client/context/helpers.go +++ b/client/context/helpers.go @@ -114,7 +114,7 @@ func (ctx CoreContext) SignAndBuild(name, passphrase string, msg sdk.Msg, cdc *w ChainID: chainID, Sequences: []int64{sequence}, Msg: msg, - Fee: auth.NewStdFee(10000, sdk.Coin{}), // TODO run simulate to estimate gas? + Fee: auth.NewStdFee(ctx.Gas, sdk.Coin{}), // TODO run simulate to estimate gas? } keybase, err := keys.GetKeyBase() diff --git a/client/context/types.go b/client/context/types.go index da15b3293..e9c97ffbc 100644 --- a/client/context/types.go +++ b/client/context/types.go @@ -10,6 +10,7 @@ import ( type CoreContext struct { ChainID string Height int64 + Gas int64 TrustNode bool NodeURI string FromAddressName string @@ -31,6 +32,12 @@ func (c CoreContext) WithHeight(height int64) CoreContext { return c } +// WithGas - return a copy of the context with an updated gas +func (c CoreContext) WithGas(gas int64) CoreContext { + c.Gas = gas + return c +} + // WithTrustNode - return a copy of the context with an updated TrustNode flag func (c CoreContext) WithTrustNode(trustNode bool) CoreContext { c.TrustNode = trustNode diff --git a/client/context/viper.go b/client/context/viper.go index 4b3007f12..081c9f5c2 100644 --- a/client/context/viper.go +++ b/client/context/viper.go @@ -30,6 +30,7 @@ func NewCoreContextFromViper() CoreContext { return CoreContext{ ChainID: chainID, Height: viper.GetInt64(client.FlagHeight), + Gas: viper.GetInt64(client.FlagGas), TrustNode: viper.GetBool(client.FlagTrustNode), FromAddressName: viper.GetString(client.FlagName), NodeURI: nodeURI, diff --git a/client/flags.go b/client/flags.go index 0b907604a..f4ee4279b 100644 --- a/client/flags.go +++ b/client/flags.go @@ -7,6 +7,7 @@ const ( FlagChainID = "chain-id" FlagNode = "node" FlagHeight = "height" + FlagGas = "gas" FlagTrustNode = "trust-node" FlagName = "name" FlagSequence = "sequence" @@ -25,6 +26,7 @@ func GetCommands(cmds ...*cobra.Command) []*cobra.Command { c.Flags().String(FlagChainID, "", "Chain ID of tendermint node") c.Flags().String(FlagNode, "tcp://localhost:46657", ": to tendermint rpc interface for this chain") c.Flags().Int64(FlagHeight, 0, "block height to query, omit to get most recent provable block") + c.Flags().Int64(FlagGas, 200000, "gas limit to set per-transaction") } return cmds } diff --git a/client/lcd/lcd_test.go b/client/lcd/lcd_test.go index 19eff52c4..1b1257f34 100644 --- a/client/lcd/lcd_test.go +++ b/client/lcd/lcd_test.go @@ -22,11 +22,11 @@ import ( tmcfg "github.com/tendermint/tendermint/config" nm "github.com/tendermint/tendermint/node" p2p "github.com/tendermint/tendermint/p2p" + pvm "github.com/tendermint/tendermint/privval" "github.com/tendermint/tendermint/proxy" ctypes "github.com/tendermint/tendermint/rpc/core/types" tmrpc "github.com/tendermint/tendermint/rpc/lib/server" tmtypes "github.com/tendermint/tendermint/types" - pvm "github.com/tendermint/tendermint/privval" "github.com/tendermint/tmlibs/cli" dbm "github.com/tendermint/tmlibs/db" "github.com/tendermint/tmlibs/log" @@ -385,6 +385,7 @@ func startTMAndLCD() (*nm.Node, net.Listener, error) { return nil, nil, err } viper.Set(cli.HomeFlag, dir) + viper.Set(client.FlagGas, 200000) kb, err := keys.GetKeyBase() // dbm.NewMemDB()) // :( if err != nil { return nil, nil, err