Skip to content

Commit

Permalink
partial backport of #21989
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Oct 3, 2024
1 parent 1b3269d commit 552e103
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions simapp/v2/app_di.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ func NewSimApp[T transaction.Tx](
viper *viper.Viper,
) *SimApp[T] {
var (
app = &SimApp[T]{}
appBuilder *runtime.AppBuilder[T]
err error
storeOptions = &root.Options{}
app = &SimApp[T]{}
appBuilder *runtime.AppBuilder[T]
err error

// merge the AppConfig and other configuration in one config
appConfig = depinject.Configs(
Expand Down Expand Up @@ -149,6 +148,19 @@ func NewSimApp[T transaction.Tx](
)
)

// the subsection of config that contains the store options (in app.toml [store.options] header)
// is unmarshaled into a store.Options struct and passed to the store builder.
// future work may move this specification and retrieval into store/v2.
// If these options are not specified then default values will be used.
if sub := viper.Sub("store.options"); sub != nil {
storeOptions := &root.Options{}
err := sub.Unmarshal(storeOptions)
if err != nil {
panic(err)
}
appConfig = depinject.Configs(appConfig, depinject.Supply(storeOptions))
}

if err := depinject.Inject(appConfig,
&appBuilder,
&app.appCodec,
Expand All @@ -160,15 +172,7 @@ func NewSimApp[T transaction.Tx](
panic(err)
}

var builderOpts []runtime.AppBuilderOption[T]
if sub := viper.Sub("store.options"); sub != nil {
err = sub.Unmarshal(storeOptions)
if err != nil {
panic(err)
}
builderOpts = append(builderOpts, runtime.AppBuilderWithStoreOptions[T](storeOptions))
}
app.App, err = appBuilder.Build(builderOpts...)
app.App, err = appBuilder.Build()
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 552e103

Please sign in to comment.