Skip to content

Commit

Permalink
fix(runtime/v2): provide default factory options if unset in app buil…
Browse files Browse the repository at this point in the history
…der (backport #21690) (#21710)

Co-authored-by: Matt Kocubinski <mkocubinski@gmail.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
3 people authored Sep 13, 2024
1 parent 869eb8f commit 18dd4cd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
8 changes: 5 additions & 3 deletions simapp/v2/app_di.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func NewSimApp[T transaction.Tx](
app = &SimApp[T]{}
appBuilder *runtime.AppBuilder[T]
err error
storeOptions = root.DefaultStoreOptions()
storeOptions = &root.Options{}

// merge the AppConfig and other configuration in one config
appConfig = depinject.Configs(
Expand Down Expand Up @@ -187,13 +187,15 @@ func NewSimApp[T transaction.Tx](
panic(err)
}

var builderOpts []runtime.AppBuilderOption[T]
if sub := viper.Sub("store.options"); sub != nil {
err = sub.Unmarshal(&storeOptions)
err = sub.Unmarshal(storeOptions)
if err != nil {
panic(err)
}
builderOpts = append(builderOpts, runtime.AppBuilderWithStoreOptions[T](storeOptions))
}
app.App, err = appBuilder.Build(runtime.AppBuilderWithStoreOptions[T](storeOptions))
app.App, err = appBuilder.Build(builderOpts...)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion simapp/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
cosmossdk.io/depinject v1.0.0
cosmossdk.io/log v1.4.1
cosmossdk.io/math v1.3.0
cosmossdk.io/runtime/v2 v2.0.0-20240912070812-0fc06f14104b // main
cosmossdk.io/runtime/v2 v2.0.0-20240913102804-9fc6675885f9 // main
cosmossdk.io/server/v2 v2.0.0-20240912070812-0fc06f14104b // main
cosmossdk.io/server/v2/cometbft v0.0.0-00010101000000-000000000000
cosmossdk.io/store/v2 v2.0.0-20240906090851-36d9b25e8981 // main
Expand Down
4 changes: 2 additions & 2 deletions simapp/v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
cosmossdk.io/runtime/v2 v2.0.0-20240912070812-0fc06f14104b h1:usuxpv4UZLKOXHK+L34KouKdVb0oUTUPoAJTz8ApWzA=
cosmossdk.io/runtime/v2 v2.0.0-20240912070812-0fc06f14104b/go.mod h1:kV5J0FOZvQIH6o23pCmkl5h+UdIAbQ1WU/BgVgrvbKQ=
cosmossdk.io/runtime/v2 v2.0.0-20240913102804-9fc6675885f9 h1:xAPMtcHd8bW8F+Nt/lRmoe3gAD/zghEkzHdXb/5hkwY=
cosmossdk.io/runtime/v2 v2.0.0-20240913102804-9fc6675885f9/go.mod h1:bIUuDyiXe4zAa/QbOhciGdtTsmyytU8kt1FjLVtcZ1Q=
cosmossdk.io/schema v0.2.0 h1:UH5CR1DqUq8yP+5Np8PbvG4YX0zAUsTN2Qk6yThmfMk=
cosmossdk.io/schema v0.2.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
cosmossdk.io/server/v2 v2.0.0-20240912070812-0fc06f14104b h1:rG8VQF/3yAEJOQewDgrcBWwr1xKzu+VwhrILW5hui/Y=
Expand Down
8 changes: 2 additions & 6 deletions simapp/v2/simdv2/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@ import (
v2 "github.com/cosmos/cosmos-sdk/x/genutil/v2/cli"
)

func newApp[T transaction.Tx](
logger log.Logger, viper *viper.Viper,
) serverv2.AppI[T] {
func newApp[T transaction.Tx](logger log.Logger, viper *viper.Viper) serverv2.AppI[T] {
viper.Set(serverv2.FlagHome, simapp.DefaultNodeHome)

return serverv2.AppI[T](
simapp.NewSimApp[T](logger, viper))
return serverv2.AppI[T](simapp.NewSimApp[T](logger, viper))
}

func initRootCmd[T transaction.Tx](
Expand Down

0 comments on commit 18dd4cd

Please sign in to comment.