Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move genesis commands to a sub-command and add the SDK's auto-cli commands. #1971

Merged
merged 28 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fe8f694
[1760]: Add all the auto-cli commands.
SpicyLemon May 14, 2024
12ffc31
[1760]: Add new query and tx commdands provided by the SDK.
SpicyLemon May 14, 2024
76cc9ae
[1760]: Move the genesis-related commands into the new genesis comman…
SpicyLemon May 14, 2024
fab740d
[1760]: Update the scripts that use the genesis commands.
SpicyLemon May 14, 2024
d5efe47
[1760]: Update the upgrade-config script to update the correct fields…
SpicyLemon May 14, 2024
441bd64
[1760]: Add a changelog entry about the commands being moved to genesis.
SpicyLemon May 14, 2024
92b1483
[1760]: Remove the enable-cli-autocomplete command because cobra now …
SpicyLemon May 14, 2024
43447a2
[1760]: Remove the genesis- part out of all the genesis commands sinc…
SpicyLemon May 14, 2024
1ce56eb
[1760]: Remove the calls to AddTxCommands and AddQueryCommands since …
SpicyLemon May 14, 2024
44244ed
[1760]: Add links to changelog entries.
SpicyLemon May 14, 2024
5c11015
[1760]: Take the table out of the changelog and put it in the PR desc…
SpicyLemon May 14, 2024
8b267f7
[1760]: Bump the blocksPerVotingPeriod to 8 (from 6) in the sanction …
SpicyLemon May 15, 2024
0881797
[1760]: Invoke grep directly instead of cat pipe grep.
SpicyLemon May 15, 2024
1ed19a8
Merge branch 'main' into dwedul/1760-auto-cli
SpicyLemon May 15, 2024
cc36fba
[1760]: Rename genaccounts.go to genesis.go since that file is for ge…
SpicyLemon May 15, 2024
da42897
[1760]: Add aliases for the genesis commands so that they also have t…
SpicyLemon May 15, 2024
e4f6080
[1760]: Align the aliases of the tx and query commands for each module.
SpicyLemon May 15, 2024
583fba1
[1760]: Add some cli sanity unit tests.
SpicyLemon May 15, 2024
cea6659
[1760]: Fix the wasm instantiate2 aliases.
SpicyLemon May 15, 2024
f160d3b
[1760]: Fix comment grammar.
SpicyLemon May 15, 2024
c93823d
[1760]: Disable address caching in the config command tests because i…
SpicyLemon May 15, 2024
fbd1c9b
[1760]: Create a hidden tree command that will list all possible comm…
SpicyLemon May 15, 2024
4284406
[1760]: Add the alias e to the provenacned metaaddress encode command…
SpicyLemon May 15, 2024
fbcf2e0
[1760]: Disable address caching for a bunch more tests because I can'…
SpicyLemon May 15, 2024
61b6b67
[1760]: Tweak the tree use-line to include the aliases flag but hide …
SpicyLemon May 15, 2024
c8601d3
[1760]: Move the tree command to its own file so that its easier to s…
SpicyLemon May 15, 2024
703abf1
[1760]: Add unit tests for the tree command.
SpicyLemon May 15, 2024
9c51585
Merge branch 'main' into dwedul/1760-auto-cli
SpicyLemon May 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Clean up all the module codecs [#1957](https://github.com/provenance-io/provenance/pull/1957).
* Switch to auto-generated `String` and `Equal` methods for most proto messages [#1957](https://github.com/provenance-io/provenance/pull/1957).
* Clean up the marker module's expected BankKeeper interface [#1954](https://github.com/provenance-io/provenance/pull/1954).
* Add the auto-cli commands and a few others newly added by the SDK [#1971](https://github.com/provenance-io/provenance/pull/1971).
SpicyLemon marked this conversation as resolved.
Show resolved Hide resolved

### Client Breaking

* The `provenanced query account` command has been removed. It is still available as `provenanced query auth account` [#1971](https://github.com/provenance-io/provenance/pull/1971).
* Move the genesis-related commands into a new `genesis` sub-command, and remove the `genesis-` parts of their names [#1971](https://github.com/provenance-io/provenance/pull/1971).
* Many of the SDK's query commands have had their usage altered [#1971](https://github.com/provenance-io/provenance/pull/1971).
SpicyLemon marked this conversation as resolved.
Show resolved Hide resolved

### Deprecated

Expand Down
25 changes: 25 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
abci "github.com/cometbft/cometbft/abci/types"
cmtos "github.com/cometbft/cometbft/libs/os"

"cosmossdk.io/client/v2/autocli"

Check failure on line 22 in app/app.go

View workflow job for this annotation

GitHub Actions / golangci-lint

import 'cosmossdk.io/client/v2/autocli' is not allowed from list 'main' (depguard)
"cosmossdk.io/core/appmodule"
"cosmossdk.io/log"
sdkmath "cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
Expand All @@ -42,6 +44,7 @@
"github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/runtime"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
"github.com/cosmos/cosmos-sdk/server/api"
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand Down Expand Up @@ -1320,6 +1323,28 @@
nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg)
}

// AutoCliOpts returns the autocli options for the app.
func (app *App) AutoCliOpts() autocli.AppOptions {
modules := make(map[string]appmodule.AppModule, 0)
for _, m := range app.mm.Modules {
if moduleWithName, ok := m.(module.HasName); ok {
moduleName := moduleWithName.Name()
if appModule, ok := moduleWithName.(appmodule.AppModule); ok {
modules[moduleName] = appModule
}
}
}

cfg := sdk.GetConfig()
return autocli.AppOptions{
Modules: modules,
ModuleOptions: runtimeservices.ExtractAutoCLIOptions(app.mm.Modules),
AddressCodec: authcodec.NewBech32Codec(cfg.GetBech32AccountAddrPrefix()),
ValidatorAddressCodec: authcodec.NewBech32Codec(cfg.GetBech32ValidatorAddrPrefix()),
ConsensusAddressCodec: authcodec.NewBech32Codec(cfg.GetBech32ConsensusAddrPrefix()),
}
}

// RegisterSwaggerAPI registers swagger route with API Server
func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router) {
statikFS, err := fs.New()
Expand Down
57 changes: 0 additions & 57 deletions cmd/provenanced/cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil/client/cli"

"github.com/provenance-io/provenance/cmd/provenanced/cmd"
"github.com/provenance-io/provenance/testutil/assertions"
)

func TestInitCmd(t *testing.T) {
Expand All @@ -28,59 +27,3 @@ func TestInitCmd(t *testing.T) {
err := cmd.Execute(rootCmd)
require.NoError(t, err)
}

func TestGenAutoCompleteCmd(t *testing.T) {
home := t.TempDir()

tests := []struct {
name string
args []string
err string
}{
{
name: "failure - missing arg",
err: "accepts 1 arg(s), received 0",
},
{
name: "failure - too many args",
args: []string{"bash", "fish"},
err: "accepts 1 arg(s), received 2",
},
{
name: "failure - invalid shell type",
args: []string{"badshellname"},
err: "shell badshellname is not supported",
},
{
name: "success - works with bash",
args: []string{"bash"},
},
{
name: "success - works with zsh",
args: []string{"zsh"},
},
{
name: "success - works with fish",
args: []string{"fish"},
},
{
name: "success - works with powershell",
args: []string{"powershell"},
},
}

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
args := []string{"--home", home, "enable-cli-autocomplete"}
args = append(args, tc.args...)

rootCmd, _ := cmd.NewRootCmd(false)
rootCmd.SetArgs(args)
rootCmd.SetOut(io.Discard)
rootCmd.SetErr(io.Discard)

err := cmd.Execute(rootCmd)
assertions.AssertErrorValue(t, err, tc.err, "should have the correct output value")
})
}
}
Loading
Loading