Skip to content

Commit

Permalink
feat: add rpc-host as first argument (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno authored May 19, 2024
1 parent 78d2424 commit 1392422
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,26 @@ Then just run it:

To run it for a sovereign Cosmos-based chain, something like this should be enough:
```
./tmtop --rpc-host <RPC host address>
./tmtop <RPC host address>
```

To run it for a sovereign chain that is not Cosmos-based (for example, Nomic), something like this should be enough
(this will limit the app possibilities, as in, it won't display validators monikers,
upgrades status etc.):
```
./tmtop --rpc-host <RPC host address> --chain-type tendermint
./tmtop <RPC host address> --chain-type tendermint
```

If a chain is not Cosmos-based, but exposes a webserver that is compatible with LCD REST API of cosmos-sdk,
you can try running it this way to fetch data from LCD (the `--lcd-host` parameter is not used in other cases):
```
./tmtop --rpc-host <RPC host address> --chain-type cosmos-lcd --lcd-host <LCD host address>
./tmtop <RPC host address> --chain-type cosmos-lcd --lcd-host <LCD host address>
```

To run it for a Cosmos-based consumer chains (like Stride or Neutron),
something like this should be enough:
```
./tmtop --rpc-host <RPC host address> --provider-rpc-host <provider RPC host> --consumer-chain-id <consumer chain ID>
./tmtop <RPC host address> --provider-rpc-host <provider RPC host> --consumer-chain-id <consumer chain ID>
```

There are more parameters to tweak, for all the possible arguments, see `./tmtop --help`.
Expand Down
14 changes: 10 additions & 4 deletions cmd/tmtop.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ var (
version = "unknown"
)

func Execute(config configPkg.Config) {
func Execute(config configPkg.Config, args []string) {
if len(args) == 0 || args[0] == "" {
config.RPCHost = "http://localhost:26657"
} else {
config.RPCHost = args[0]
}

app := pkg.NewApp(config, version)
app.Start()
}
Expand All @@ -22,18 +28,18 @@ func main() {
var config configPkg.Config

rootCmd := &cobra.Command{
Use: "tmtop",
Use: "tmtop [RPC host URL]",
Long: "Observe the pre-voting status of any Tendermint-based blockchain.",
Version: version,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return config.Validate()
},
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Execute(config)
Execute(config, args)
},
}

rootCmd.PersistentFlags().StringVar(&config.RPCHost, "rpc-host", "http://localhost:26657", "RPC host URL")
rootCmd.PersistentFlags().StringVar(&config.ProviderRPCHost, "provider-rpc-host", "", "Provider chain RPC host URL")
rootCmd.PersistentFlags().StringVar(&config.ConsumerChainID, "consumer-chain-id", "", "Consumer chain ID")
rootCmd.PersistentFlags().DurationVar(&config.RefreshRate, "refresh-rate", time.Second, "Refresh rate")
Expand Down

0 comments on commit 1392422

Please sign in to comment.