6b04c0ee5e
* marshal and unmarshal * attributes proto * fix * process attributes and create secondary mappings * get records from attributes * fix * fix lint errors * fix gosec * lower case * go mod tidy * Fix tests * "add search test" * req attributes * grpc tests * fix tests * register interface * fix tests * Remove git diff from test workflows * fix workflow file * fix simulations * fix names and add checks for attributes in tests * Add comment for attribute prefix
108 lines
4.7 KiB
Go
108 lines
4.7 KiB
Go
package flags
|
|
|
|
import (
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
tmcli "github.com/tendermint/tendermint/libs/cli"
|
|
)
|
|
|
|
// Tendermint/cosmos-sdk full-node start flags
|
|
const (
|
|
WithTendermint = "with-tendermint"
|
|
Address = "address"
|
|
Transport = "transport"
|
|
TraceStore = "trace-store"
|
|
CPUProfile = "cpu-profile"
|
|
// The type of database for application and snapshots databases
|
|
AppDBBackend = "app-db-backend"
|
|
)
|
|
|
|
// GRPC-related flags.
|
|
const (
|
|
GRPCEnable = "grpc.enable"
|
|
GRPCAddress = "grpc.address"
|
|
GRPCWebEnable = "grpc-web.enable"
|
|
GRPCWebAddress = "grpc-web.address"
|
|
)
|
|
|
|
// Cosmos API flags
|
|
const (
|
|
RPCEnable = "api.enable"
|
|
EnabledUnsafeCors = "api.enabled-unsafe-cors"
|
|
)
|
|
|
|
// JSON-RPC flags
|
|
const (
|
|
JSONRPCEnable = "json-rpc.enable"
|
|
JSONRPCAPI = "json-rpc.api"
|
|
JSONRPCAddress = "json-rpc.address"
|
|
JSONWsAddress = "json-rpc.ws-address"
|
|
JSONRPCGasCap = "json-rpc.gas-cap"
|
|
JSONRPCEVMTimeout = "json-rpc.evm-timeout"
|
|
JSONRPCTxFeeCap = "json-rpc.txfee-cap"
|
|
JSONRPCFilterCap = "json-rpc.filter-cap"
|
|
JSONRPCLogsCap = "json-rpc.logs-cap"
|
|
JSONRPCBlockRangeCap = "json-rpc.block-range-cap"
|
|
JSONRPCHTTPTimeout = "json-rpc.http-timeout"
|
|
JSONRPCHTTPIdleTimeout = "json-rpc.http-idle-timeout"
|
|
JSONRPCAllowUnprotectedTxs = "json-rpc.allow-unprotected-txs"
|
|
JSONRPCMaxOpenConnections = "json-rpc.max-open-connections"
|
|
JSONRPCEnableIndexer = "json-rpc.enable-indexer"
|
|
)
|
|
|
|
// EVM flags
|
|
const (
|
|
EVMTracer = "evm.tracer"
|
|
EVMMaxTxGasWanted = "evm.max-tx-gas-wanted"
|
|
)
|
|
|
|
// TLS flags
|
|
const (
|
|
TLSCertPath = "tls.certificate-path"
|
|
TLSKeyPath = "tls.key-path"
|
|
)
|
|
|
|
// AddTxFlags adds common flags for commands to post tx
|
|
func AddTxFlags(cmd *cobra.Command) (*cobra.Command, error) {
|
|
cmd.PersistentFlags().String(flags.FlagChainID, "testnet", "Specify Chain ID for sending Tx")
|
|
cmd.PersistentFlags().String(flags.FlagFrom, "", "Name or address of private key with which to sign")
|
|
cmd.PersistentFlags().String(flags.FlagFees, "", "Fees to pay along with transaction; eg: 10aphoton")
|
|
cmd.PersistentFlags().String(flags.FlagGasPrices, "", "Gas prices to determine the transaction fee (e.g. 10aphoton)")
|
|
cmd.PersistentFlags().String(flags.FlagGas, "300000", "gas limit to set per-transaction; set to auto to calculate sufficient gas automatically. Note: auto option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of fees. (default 300000)")
|
|
cmd.PersistentFlags().String(flags.FlagNode, "tcp://localhost:26657", "<host>:<port> to tendermint rpc interface for this chain") //nolint:lll
|
|
cmd.PersistentFlags().Float64(flags.FlagGasAdjustment, flags.DefaultGasAdjustment, "adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored ") //nolint:lll
|
|
cmd.PersistentFlags().StringP(flags.FlagBroadcastMode, "b", flags.BroadcastSync, "Transaction broadcasting mode (sync|async|block)")
|
|
cmd.PersistentFlags().String(flags.FlagKeyringBackend, keyring.BackendOS, "Select keyring's backend")
|
|
cmd.PersistentFlags().BoolP(flags.FlagSkipConfirmation, "y", false, "Skip tx broadcasting prompt confirmation")
|
|
cmd.Flags().StringP(tmcli.OutputFlag, "o", "text", "Output format (text|json)")
|
|
|
|
// --gas can accept integers and "simulate"
|
|
// cmd.PersistentFlags().Var(&flags.GasFlagVar, "gas", fmt.Sprintf(
|
|
// "gas limit to set per-transaction; set to %q to calculate required gas automatically (default %d)",
|
|
// flags.GasFlagAuto, flags.DefaultGasLimit,
|
|
// ))
|
|
|
|
// viper.BindPFlag(flags.FlagTrustNode, cmd.Flags().Lookup(flags.FlagTrustNode))
|
|
if err := viper.BindPFlag(flags.FlagNode, cmd.PersistentFlags().Lookup(flags.FlagNode)); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := viper.BindPFlag(flags.FlagKeyringBackend, cmd.PersistentFlags().Lookup(flags.FlagKeyringBackend)); err != nil {
|
|
return nil, err
|
|
}
|
|
return cmd, nil
|
|
}
|
|
|
|
// AddGQLFlags adds gql flags for
|
|
func AddGQLFlags(cmd *cobra.Command) *cobra.Command {
|
|
// Add flags for GQL server.
|
|
cmd.PersistentFlags().Bool("gql-server", false, "Start GQL server.")
|
|
cmd.PersistentFlags().Bool("gql-playground", false, "Enable GQL playground.")
|
|
cmd.PersistentFlags().String("gql-playground-api-base", "", "GQL API base path to use in GQL playground.")
|
|
cmd.PersistentFlags().String("gql-port", "9473", "Port to use for the GQL server.")
|
|
cmd.PersistentFlags().String("log-file", "", "File to tail for GQL 'getLogs' API.")
|
|
|
|
return cmd
|
|
}
|