refactor(runtime/v2): use StoreBuilder (#21989)
This commit is contained in:
+17
-13
@@ -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(
|
||||
@@ -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,
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user