Skip to content

Commit

Permalink
rerfactor(server): alias AppOptions to core.DynamicConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Sep 13, 2024
1 parent 9fc6675 commit b146413
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 2 additions & 3 deletions server/types/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
cmttypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/gogoproto/grpc"

"cosmossdk.io/core/server"
corestore "cosmossdk.io/core/store"
"cosmossdk.io/log"
"cosmossdk.io/store/snapshots"
Expand All @@ -26,9 +27,7 @@ type (
// literal defined on the server Context. Note, casting Get calls may not yield
// the expected types and could result in type assertion errors. It is recommend
// to either use the cast package or perform manual conversion for safety.
AppOptions interface {
Get(string) interface{}
}
AppOptions = server.DynamicConfig

// Application defines an application interface that wraps abci.Application.
// The interface defines the necessary contracts to be implemented in order
Expand Down
4 changes: 4 additions & 0 deletions server/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,4 +492,8 @@ func (m mapGetter) Get(key string) interface{} {
return m[key]
}

func (m mapGetter) GetString(key string) string {
return m[key].(string)
}

var _ servertypes.AppOptions = mapGetter{}
9 changes: 9 additions & 0 deletions testutil/sims/app_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,15 @@ func (m AppOptionsMap) Get(key string) interface{} {
return v
}

func (m AppOptionsMap) GetString(key string) string {
v, ok := m[key]
if !ok {
return ""
}

return v.(string)
}

func NewAppOptionsWithFlagHome(homePath string) servertypes.AppOptions {
return AppOptionsMap{
flags.FlagHome: homePath,
Expand Down

0 comments on commit b146413

Please sign in to comment.