Skip to content

Commit

Permalink
fix(simapp/v2): full AutoCLI support (#22410)
Browse files Browse the repository at this point in the history
(cherry picked from commit fdccc84)

# Conflicts:
#	client/v2/go.mod
#	go.mod
#	orm/go.mod
#	orm/go.sum
#	runtime/v2/go.mod
#	runtime/v2/go.sum
#	server/v2/command_factory.go
#	simapp/go.mod
#	simapp/v2/go.mod
#	tests/go.mod
#	tools/confix/go.mod
#	tools/confix/go.sum
#	tools/cosmovisor/go.mod
#	tools/cosmovisor/go.sum
#	tools/hubl/go.mod
#	tools/hubl/go.sum
#	x/accounts/defaults/base/go.mod
#	x/accounts/defaults/lockup/go.mod
#	x/accounts/defaults/multisig/go.mod
#	x/accounts/go.mod
#	x/authz/go.mod
#	x/bank/go.mod
#	x/circuit/go.mod
#	x/consensus/go.mod
#	x/distribution/go.mod
#	x/epochs/go.mod
#	x/evidence/go.mod
#	x/feegrant/go.mod
#	x/gov/go.mod
#	x/group/go.mod
#	x/mint/go.mod
#	x/nft/go.mod
#	x/params/go.mod
#	x/protocolpool/go.mod
#	x/slashing/go.mod
#	x/staking/go.mod
#	x/upgrade/go.mod
  • Loading branch information
kocubinski authored and mergify[bot] committed Nov 6, 2024
1 parent 84f29c8 commit e1572d4
Show file tree
Hide file tree
Showing 69 changed files with 4,279 additions and 66 deletions.
60 changes: 57 additions & 3 deletions client/v2/autocli/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package autocli

import (
"github.com/cosmos/gogoproto/proto"
"github.com/spf13/cobra"
"google.golang.org/grpc"
"google.golang.org/protobuf/reflect/protoregistry"
Expand All @@ -9,12 +10,15 @@ import (
"cosmossdk.io/client/v2/autocli/flag"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/depinject"
"cosmossdk.io/log"
"cosmossdk.io/x/tx/signing"

"github.com/cosmos/cosmos-sdk/client"
sdkflags "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec/types"
)

// AppOptions are autocli options for an app. These options can be built via depinject based on an app config. Ex:
// AppOptions are input options for an autocli enabled app. These options can be built via depinject based on an app config.
// Ex:
//
// var autoCliOpts autocli.AppOptions
Expand All @@ -36,6 +40,8 @@ type AppOptions struct {

// ClientCtx contains the necessary information needed to execute the commands.
ClientCtx client.Context

skipValidation bool
}

// EnhanceRootCommand enhances the provided root command with autocli AppOptions,
Expand Down Expand Up @@ -76,8 +82,10 @@ func (appOptions AppOptions) EnhanceRootCommand(rootCmd *cobra.Command) error {
}

func (appOptions AppOptions) EnhanceRootCommandWithBuilder(rootCmd *cobra.Command, builder *Builder) error {
if err := builder.ValidateAndComplete(); err != nil {
return err
if !appOptions.skipValidation {
if err := builder.ValidateAndComplete(); err != nil {
return err
}
}

// extract any custom commands from modules
Expand Down Expand Up @@ -127,3 +135,49 @@ func (appOptions AppOptions) EnhanceRootCommandWithBuilder(rootCmd *cobra.Comman

return nil
}

// NewAppOptionsFromConfig returns AppOptions for an app based on the provided modulesConfig and moduleOptions.
// It returns an AppOptions instance usable for CLI parsing but not execution. For an execution usable AppOptions
// see ProvideAppOptions, which expects input to be filled by depinject.
func NewAppOptionsFromConfig(
modulesConfig depinject.Config,
moduleOptions map[string]*autocliv1.ModuleOptions,
) (AppOptions, error) {
interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{
ProtoFiles: proto.HybridResolver,
SigningOptions: signing.Options{
AddressCodec: nopAddressCodec{},
ValidatorAddressCodec: nopAddressCodec{},
},
})
if err != nil {
return AppOptions{}, err
}
cfg := struct {
depinject.In
Modules map[string]appmodule.AppModule
}{
Modules: nil,
}
err = depinject.Inject(depinject.Configs(
modulesConfig,
depinject.Supply(
log.NewNopLogger(),
)), &cfg)
if err != nil {
return AppOptions{}, err
}

return AppOptions{
Modules: cfg.Modules,
ClientCtx: client.Context{InterfaceRegistry: interfaceRegistry},
ModuleOptions: moduleOptions,
skipValidation: true,
}, nil
}

type nopAddressCodec struct{}

func (nopAddressCodec) StringToBytes(_ string) ([]byte, error) { return nil, nil }

func (nopAddressCodec) BytesToString(_ []byte) (string, error) { return "", nil }
8 changes: 7 additions & 1 deletion client/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ module cosmossdk.io/client/v2
go 1.23.1

require (
<<<<<<< HEAD
cosmossdk.io/api v0.8.0
cosmossdk.io/core v1.0.0-alpha.5 // main
cosmossdk.io/depinject v1.0.0
=======
cosmossdk.io/api v0.7.6
cosmossdk.io/core v1.0.0-alpha.5
cosmossdk.io/depinject v1.1.0
>>>>>>> fdccc8455 (fix(simapp/v2): full AutoCLI support (#22410))
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
cosmossdk.io/x/gov v0.0.0-20231113122742-912390d5fc4a
cosmossdk.io/x/tx v1.0.0-alpha.1 // main
Expand All @@ -26,7 +32,7 @@ require (
cosmossdk.io/collections v0.4.1-0.20241031202146-5b7fc8ae90a7 // indirect
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/log v1.4.1
cosmossdk.io/math v1.3.0
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 // indirect
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6 // indirect
Expand Down
4 changes: 2 additions & 2 deletions client/v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ cosmossdk.io/core v1.0.0-alpha.5 h1:McjYXAQ6XcT20v2uHyH7PhoWH8V+mebzfVFqT3GinsI=
cosmossdk.io/core v1.0.0-alpha.5/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 h1:NxxUo0GMJUbIuVg0R70e3cbn9eFTEuMr7ev1AFvypdY=
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29/go.mod h1:8s2tPeJtSiQuoyPmr2Ag7meikonISO4Fv4MoO8+ORrs=
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
cosmossdk.io/depinject v1.1.0 h1:wLan7LG35VM7Yo6ov0jId3RHWCGRhe8E8bsuARorl5E=
cosmossdk.io/depinject v1.1.0/go.mod h1:kkI5H9jCGHeKeYWXTqYdruogYrEeWvBQCw1Pj4/eCFI=
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U=
cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ require (
cosmossdk.io/api v0.8.0 // main
cosmossdk.io/collections v0.4.1-0.20241031202146-5b7fc8ae90a7 // main
cosmossdk.io/core v1.0.0-alpha.5
<<<<<<< HEAD
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // main
cosmossdk.io/depinject v1.0.0
=======
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29
cosmossdk.io/depinject v1.1.0
>>>>>>> fdccc8455 (fix(simapp/v2): full AutoCLI support (#22410))
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.4.1
cosmossdk.io/math v1.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ cosmossdk.io/core v1.0.0-alpha.5 h1:McjYXAQ6XcT20v2uHyH7PhoWH8V+mebzfVFqT3GinsI=
cosmossdk.io/core v1.0.0-alpha.5/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 h1:NxxUo0GMJUbIuVg0R70e3cbn9eFTEuMr7ev1AFvypdY=
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29/go.mod h1:8s2tPeJtSiQuoyPmr2Ag7meikonISO4Fv4MoO8+ORrs=
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
cosmossdk.io/depinject v1.1.0 h1:wLan7LG35VM7Yo6ov0jId3RHWCGRhe8E8bsuARorl5E=
cosmossdk.io/depinject v1.1.0/go.mod h1:kkI5H9jCGHeKeYWXTqYdruogYrEeWvBQCw1Pj4/eCFI=
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U=
cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
Expand Down
73 changes: 73 additions & 0 deletions orm/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
module cosmossdk.io/orm

go 1.23

require (
cosmossdk.io/api v0.7.6
cosmossdk.io/core v1.0.0-alpha.5
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29
cosmossdk.io/depinject v1.1.0
cosmossdk.io/errors v1.0.1
github.com/cosmos/cosmos-db v1.0.3-0.20240829004618-717cba019b33
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/google/go-cmp v0.6.0
github.com/iancoleman/strcase v0.3.0
github.com/regen-network/gocuke v1.1.1
github.com/stretchr/testify v1.9.0
go.uber.org/mock v0.5.0
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
google.golang.org/grpc v1.67.1
google.golang.org/protobuf v1.35.1
gotest.tools/v3 v3.5.1
pgregory.net/rapid v1.1.0
)

require (
cosmossdk.io/schema v0.3.0 // indirect
github.com/DataDog/zstd v1.4.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v1.1.0 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cosmos/gogoproto v1.7.0 // indirect
github.com/cucumber/gherkin/go/v27 v27.0.0 // indirect
github.com/cucumber/messages/go/v22 v22.0.0 // indirect
github.com/cucumber/tag-expressions/go/v6 v6.1.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/klauspost/compress v1.17.10 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/linxGnu/grocksdb v1.8.12 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/gomega v1.20.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tidwall/btree v1.7.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit e1572d4

Please sign in to comment.