Skip to content

Commit

Permalink
Merge pull request ChihuahuaChain#123 from Victor118/main
Browse files Browse the repository at this point in the history
V8.0.0
  • Loading branch information
woof-chihuahua authored Aug 23, 2024
2 parents 7c0a3a2 + 32c95cb commit 6ae466b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 11 deletions.
34 changes: 33 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ import (

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"cosmossdk.io/client/v2/autocli"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/log"
"cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/circuit"
circuitkeeper "cosmossdk.io/x/circuit/keeper"
circuittypes "cosmossdk.io/x/circuit/types"
abci "github.com/cometbft/cometbft/abci/types"
tmos "github.com/cometbft/cometbft/libs/os"
Expand Down Expand Up @@ -50,6 +54,7 @@ import (
"github.com/rakyll/statik/fs"

sdkbank "github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
sdkbanktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/consensus"
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
Expand Down Expand Up @@ -334,6 +339,7 @@ type App struct {
GroupKeeper groupkeeper.Keeper
NFTKeeper nftkeeper.Keeper
ConsensusParamsKeeper consensuskeeper.Keeper
CircuitKeeper circuitkeeper.Keeper

IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCFeeKeeper ibcfeekeeper.Keeper
Expand Down Expand Up @@ -460,6 +466,8 @@ func New(
Bech32Prefix,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
app.CircuitKeeper = circuitkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[circuittypes.StoreKey]), authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AccountKeeper.AddressCodec())
app.BaseApp.SetCircuitBreaker(&app.CircuitKeeper)
app.AuthzKeeper = authzkeeper.NewKeeper(
runtime.NewKVStoreService(keys[authzkeeper.StoreKey]),
appCodec,
Expand Down Expand Up @@ -786,6 +794,7 @@ func New(
// NOTE: Any module instantiated in the module manager that is later modified
// must be passed by reference here.
app.mm = module.NewManager(

genutil.NewAppModule(
app.AccountKeeper,
app.StakingKeeper,
Expand All @@ -794,7 +803,7 @@ func New(
),
auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)),
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(sdkbanktypes.ModuleName)),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)),
capability.NewAppModule(appCodec, *app.CapabilityKeeper, false),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)),
Expand All @@ -819,6 +828,7 @@ func New(
alliancemodule.NewAppModule(appCodec, app.AllianceKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry, app.GetSubspace(alliancemoduletypes.ModuleName)),
tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(tokenfactorytypes.ModuleName)),
liquidity.NewAppModule(appCodec, app.LiquidityKeeper, app.AccountKeeper, app.BankKeeper, app.DistrKeeper),
circuit.NewAppModule(appCodec, app.CircuitKeeper),
)

// BasicModuleManager defines the module BasicManager is in charge of setting up basic,
Expand Down Expand Up @@ -910,6 +920,7 @@ func New(
wasmtypes.ModuleName,
alliancemoduletypes.ModuleName,
tokenfactorytypes.ModuleName,
circuittypes.ModuleName,
}
app.mm.SetOrderInitGenesis(genesisModuleOrder...)
app.mm.SetOrderExportGenesis(genesisModuleOrder...)
Expand Down Expand Up @@ -1315,3 +1326,24 @@ func (app *App) SimulationManager() *module.SimulationManager {
func (a *App) DefaultGenesis() map[string]json.RawMessage {
return a.BasicModuleManager.DefaultGenesis(a.appCodec)
}

// 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
}
}
}

return autocli.AppOptions{
Modules: modules,
ModuleOptions: runtimeservices.ExtractAutoCLIOptions(app.mm.Modules),
AddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()),
ValidatorAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()),
ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()),
}
}
25 changes: 16 additions & 9 deletions cmd/chihuahuad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"cosmossdk.io/math"
"cosmossdk.io/math/unsafe"
confixcmd "cosmossdk.io/tools/confix/cmd"
wasmcli "github.com/CosmWasm/wasmd/x/wasm/client/cli"
cmtconfig "github.com/cometbft/cometbft/config"
tmcfg "github.com/cometbft/cometbft/config"
cmttime "github.com/cometbft/cometbft/types/time"
Expand Down Expand Up @@ -190,7 +191,15 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
}

initRootCmd(rootCmd, encodingConfig, tempApp.BasicModuleManager)
// add keyring to autocli opts
autoCliOpts := tempApp.AutoCliOpts()
initClientCtx, _ = config.ReadFromClientConfig(initClientCtx)
autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring)
autoCliOpts.ClientCtx = initClientCtx

if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil {
panic(err)
}
return rootCmd, encodingConfig
}

Expand Down Expand Up @@ -698,7 +707,7 @@ Example:

func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, basicManager module.BasicManager) {
rootCmd.AddCommand(
genutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome),
genutilcli.InitCmd(basicManager, app.DefaultNodeHome),
NewTestnetCmd(basicManager, banktypes.GenesisBalancesIterator{}),
debug.Cmd(),
confixcmd.ConfigCommand(),
Expand All @@ -707,12 +716,12 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, b
)

server.AddCommands(rootCmd, app.DefaultNodeHome, newApp, appExport, addModuleInitFlags)

wasmcli.ExtendUnsafeResetAllCmd(rootCmd)
// add keybase, auxiliary RPC, query, and tx child commands
rootCmd.AddCommand(
server.StatusCommand(),
genesisCommand(encodingConfig),
queryCommand(),
genesisCommand(encodingConfig.TxConfig, basicManager),
queryCommand(basicManager),
txCommand(basicManager),
keys.Commands(),
)
Expand All @@ -725,16 +734,16 @@ func addModuleInitFlags(startCmd *cobra.Command) {
}

// genesisCommand builds genesis-related `simd genesis` command. Users may provide application specific commands as a parameter
func genesisCommand(encodingConfig params.EncodingConfig, cmds ...*cobra.Command) *cobra.Command {
cmd := genutilcli.GenesisCoreCommand(encodingConfig.TxConfig, app.ModuleBasics, app.DefaultNodeHome)
func genesisCommand(txConfig client.TxConfig, basicManager module.BasicManager, cmds ...*cobra.Command) *cobra.Command {
cmd := genutilcli.Commands(txConfig, basicManager, app.DefaultNodeHome)

for _, subCmd := range cmds {
cmd.AddCommand(subCmd)
}
return cmd
}

func queryCommand() *cobra.Command {
func queryCommand(basicManager module.BasicManager) *cobra.Command {
cmd := &cobra.Command{
Use: "query",
Aliases: []string{"q"},
Expand All @@ -753,7 +762,6 @@ func queryCommand() *cobra.Command {
server.QueryBlockResultsCmd(),
)

app.ModuleBasics.AddQueryCommands(cmd)
cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID")

return cmd
Expand All @@ -780,7 +788,6 @@ func txCommand(bm module.BasicManager) *cobra.Command {
authcmd.GetSimulateCmd(),
)

bm.AddTxCommands(cmd)
cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID")

return cmd
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ require (

require (
cosmossdk.io/api v0.7.5
cosmossdk.io/client/v2 v2.0.0-beta.1
cosmossdk.io/core v0.11.1
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.4.1
cosmossdk.io/math v1.3.0
Expand Down Expand Up @@ -59,7 +61,6 @@ require (
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/storage v1.38.0 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/core v0.11.1 // indirect
cosmossdk.io/depinject v1.0.0 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
Expand Down

0 comments on commit 6ae466b

Please sign in to comment.