Skip to content

Commit

Permalink
Merge pull request #456 from ComposableFi/dz/20
Browse files Browse the repository at this point in the history
devnet support ported from v7
  • Loading branch information
dzmitry-lahoda authored Feb 28, 2024
2 parents 99d0d9b + aeba6c1 commit eea1da3
Show file tree
Hide file tree
Showing 9 changed files with 1,673 additions and 7 deletions.
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ func NewComposableApp(
encodingConfig EncodingConfig,
appOpts servertypes.AppOptions,
wasmOpts []wasm.Option,
devnetGov *string,
baseAppOptions ...func(*baseapp.BaseApp),
) *ComposableApp {
appCodec := encodingConfig.Marshaler
Expand Down Expand Up @@ -332,6 +333,7 @@ func NewComposableApp(
appOpts,
wasmOpts,
enabledProposals,
devnetGov,
)

transferModule := transfer.NewAppModule(app.TransferKeeper)
Expand Down
1 change: 1 addition & 0 deletions app/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func setup(withGenesis bool, invCheckPeriod uint, opts ...wasm.Option) (*composa
encCdc,
EmptyAppOptions{},
opts,
nil,
)
if withGenesis {
return app, composable.NewDefaultGenesisState()
Expand Down
10 changes: 8 additions & 2 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appOpts servertypes.AppOptions,
wasmOpts []wasm.Option,
enabledProposals []wasm.ProposalType,
devnetGov *string,
) {
// add keepers
appKeepers.AccountKeeper = authkeeper.NewAccountKeeper(
Expand Down Expand Up @@ -252,7 +253,12 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appCodec, appKeepers.keys[ibchost.StoreKey], appKeepers.GetSubspace(ibchost.ModuleName), appKeepers.StakingKeeper, appKeepers.UpgradeKeeper, appKeepers.ScopedIBCKeeper,
)

appKeepers.Wasm08Keeper = wasm08Keeper.NewKeeper(appCodec, appKeepers.keys[wasm08types.StoreKey], authorityAddress, homePath, &appKeepers.IBCKeeper.ClientKeeper)
govModuleAuthority := authtypes.NewModuleAddress(govtypes.ModuleName).String()
if devnetGov != nil {
govModuleAuthority = *devnetGov
}

appKeepers.Wasm08Keeper = wasm08Keeper.NewKeeper(appCodec, appKeepers.keys[wasm08types.StoreKey], govModuleAuthority, homePath, &appKeepers.IBCKeeper.ClientKeeper)

// ICA Host keeper
appKeepers.ICAHostKeeper = icahostkeeper.NewKeeper(
Expand Down Expand Up @@ -395,7 +401,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
wasmDir,
wasmConfig,
availableCapabilities,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
govModuleAuthority,
wasmOpts...,
)

Expand Down
1 change: 1 addition & 0 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func setup(tb testing.TB, withGenesis bool, invCheckPeriod uint) (*ComposableApp
MakeEncodingConfig(),
EmptyBaseAppOptions{},
wasmOpts,
nil,
baseAppOpts...)
if withGenesis {
return app, NewDefaultGenesisState()
Expand Down
19 changes: 16 additions & 3 deletions cmd/centaurid/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ import (
// this line is used by starport scaffolding # stargate/root/import
)

const (
// if set, than uses specific key for governance instead of default (default is production; this override for local devtest)
flagDevnetGov = "devnet-gov"
)

var ChainID string

// NewRootCmd creates a new root command for simd. It is called once in the
Expand Down Expand Up @@ -75,7 +80,6 @@ func NewRootCmd() (*cobra.Command, app.EncodingConfig) {
if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil {
return err
}

customAppTemplate, customAppConfig := initAppConfig()

customTMConfig := initTendermintConfig()
Expand Down Expand Up @@ -184,8 +188,8 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig app.EncodingConfig) {
// this line is used by starport scaffolding # stargate/root/commands
)

a := appCreator{encodingConfig}
server.AddCommands(rootCmd, app.DefaultNodeHome, a.newApp, a.appExport, addModuleInitFlags)
appCreator := appCreator{encodingConfig}
server.AddCommands(rootCmd, app.DefaultNodeHome, appCreator.newApp, appCreator.appExport, addModuleInitFlags)

// add keybase, auxiliary RPC, query, and tx child commands
rootCmd.AddCommand(
Expand All @@ -198,6 +202,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig app.EncodingConfig) {

func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
startCmd.Flags().String(flagDevnetGov, "", "Sets the devnet governance key (if not set, uses the default production key)")
// this line is used by starport scaffolding # stargate/root/initFlags
}

Expand Down Expand Up @@ -267,6 +272,11 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a
skipUpgradeHeights[h] = true
}

var devnetGov *string
devnetGovOption, _ := appOpts.Get(flagDevnetGov).(string)
if devnetGovOption != "" {
devnetGov = &devnetGovOption
}
baseappOptions := server.DefaultBaseappOptions(appOpts)

var emptyWasmOpts []wasm.Option
Expand All @@ -280,6 +290,7 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a
// this line is used by starport scaffolding # stargate/root/appArgument
appOpts,
emptyWasmOpts,
devnetGov,
baseappOptions...,
)

Expand Down Expand Up @@ -312,6 +323,7 @@ func (a appCreator) appExport(
a.encCfg,
appOpts,
emptyWasmOpts,
nil,
)

if err := anApp.LoadHeight(height); err != nil {
Expand All @@ -330,6 +342,7 @@ func (a appCreator) appExport(
a.encCfg,
appOpts,
emptyWasmOpts,
nil,
)
}

Expand Down
Loading

0 comments on commit eea1da3

Please sign in to comment.