feat: add autocli app wiring + remote info support (#13281)

This commit is contained in:
Aaron Craelius
2022-11-01 21:34:59 +00:00
committed by GitHub
parent e0a9500cf7
commit b9e65b6d41
21 changed files with 429 additions and 8 deletions
+26 -5
View File
@@ -5,13 +5,17 @@ import (
"encoding/json"
"fmt"
modulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/depinject"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
"cosmossdk.io/depinject"
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
"cosmossdk.io/core/appmodule"
modulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@@ -99,6 +103,19 @@ type AppModule struct {
legacySubspace exported.Subspace
}
var _ appmodule.AppModule = AppModule{}
// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (am AppModule) IsOnePerModuleType() {}
// IsAppModule implements the appmodule.AppModule interface.
func (am AppModule) IsAppModule() {}
// AutoCLIOptions implements the autocli.HasAutoCLIConfig interface.
func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
return types.AutoCLIOptions
}
// NewAppModule creates a new AppModule object
func NewAppModule(cdc codec.Codec, accountKeeper keeper.AccountKeeper, randGenAccountsFn types.RandomGenesisAccountsFn, ss exported.Subspace) AppModule {
return AppModule{
@@ -184,7 +201,10 @@ func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.Weighte
func init() {
appmodule.Register(&modulev1.Module{},
appmodule.Provide(ProvideModuleBasic, ProvideModule),
appmodule.Provide(
ProvideModuleBasic,
ProvideModule,
),
)
}
@@ -211,6 +231,7 @@ type AuthOutputs struct {
AccountKeeper keeper.AccountKeeper
Module runtime.AppModuleWrapper
NewAppModule appmodule.AppModule
}
func ProvideModule(in AuthInputs) AuthOutputs {
@@ -236,5 +257,5 @@ func ProvideModule(in AuthInputs) AuthOutputs {
k := keeper.NewAccountKeeper(in.Cdc, in.Key, in.AccountI, maccPerms, in.Config.Bech32Prefix, authority.String())
m := NewAppModule(in.Cdc, k, in.RandomGenesisAccountsFn, in.LegacySubspace)
return AuthOutputs{AccountKeeper: k, Module: runtime.WrapAppModule(m)}
return AuthOutputs{AccountKeeper: k, Module: runtime.WrapAppModule(m), NewAppModule: m}
}
+1
View File
@@ -10,6 +10,7 @@ import (
"sigs.k8s.io/yaml"
"cosmossdk.io/depinject"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
+26
View File
@@ -0,0 +1,26 @@
package types
import autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
var AutoCLIOptions = &autocliv1.ModuleOptions{
Query: &autocliv1.ServiceCommandDescriptor{
Service: _Query_serviceDesc.ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "Account",
Use: "account [address]",
Short: "query account by address",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "address"}},
},
{
RpcMethod: "AccountAddressByID",
Use: "address-by-id [id]",
Short: "query account address by account ID",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "id"}},
},
},
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: _Msg_serviceDesc.ServiceName,
},
}
+2
View File
@@ -8,6 +8,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
"cosmossdk.io/depinject"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@@ -17,6 +18,7 @@ import (
modulev1 "cosmossdk.io/api/cosmos/vesting/module/v1"
"cosmossdk.io/core/appmodule"
"github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli"
"github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
+1
View File
@@ -14,6 +14,7 @@ import (
modulev1 "cosmossdk.io/api/cosmos/capability/module/v1"
"cosmossdk.io/depinject"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
+2
View File
@@ -12,6 +12,7 @@ import (
"cosmossdk.io/core/appmodule"
"cosmossdk.io/depinject"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@@ -22,6 +23,7 @@ import (
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
modulev1 "cosmossdk.io/api/cosmos/evidence/module/v1"
eviclient "github.com/cosmos/cosmos-sdk/x/evidence/client"
"github.com/cosmos/cosmos-sdk/x/evidence/client/cli"
"github.com/cosmos/cosmos-sdk/x/evidence/keeper"