Skip to content

Commit

Permalink
support toml config file for be-json-rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbcdev committed Apr 2, 2024
1 parent f5fd1b1 commit cfe4a54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions cmd/rollappd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/evmos/evmos/v12/crypto/hd"

berpcconfig "github.com/bcdevtools/block-explorer-rpc-cosmos/be_rpc/config"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand Down Expand Up @@ -105,6 +106,9 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
chainID := client.GetClientContextFromCmd(cmd).ChainID
dymintconf.EnsureRoot(home, dymintconf.DefaultConfig(home, chainID))

//create Block Explorer Json-RPC toml config file
berpcconfig.EnsureRoot(home, berpcconfig.DefaultBeJsonRpcConfig())

return nil
},
}
Expand Down
17 changes: 9 additions & 8 deletions cmd/rollappd/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,15 @@ which accepts a path for the resulting pprof file.
return err
}

beJsonRpcConfig := berpccfg.DefaultBeJsonRpcConfig()
err = beJsonRpcConfig.GetViperConfig(cmd, serverCtx.Viper.GetString(flags.FlagHome))
if err != nil {
return err
}

// amino is needed here for backwards compatibility of REST routes
err = wrapCPUProfile(serverCtx, func() error {
return startInProcess(serverCtx, clientCtx, dymconfig, appCreator)
return startInProcess(serverCtx, clientCtx, dymconfig, beJsonRpcConfig, appCreator)
})
errCode, ok := err.(server.ErrorCode)
if !ok {
Expand Down Expand Up @@ -242,7 +248,7 @@ which accepts a path for the resulting pprof file.
return cmd
}

func startInProcess(ctx *server.Context, clientCtx client.Context, nodeConfig *dymintconf.NodeConfig, appCreator types.AppCreator) error {
func startInProcess(ctx *server.Context, clientCtx client.Context, nodeConfig *dymintconf.NodeConfig, beRpcCfg *berpccfg.BeJsonRpcConfig, appCreator types.AppCreator) error {
cfg := ctx.Config
home := cfg.RootDir

Expand All @@ -267,11 +273,6 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, nodeConfig *d
return err
}

beRpcCfg, err := berpccfg.GetConfig(ctx.Viper)
if err != nil {
return err
}

if err := beRpcCfg.Validate(); err != nil {
return err
}
Expand Down Expand Up @@ -520,7 +521,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, nodeConfig *d
ctx,
clientCtx,
genDoc.ChainID,
beRpcCfg,
*beRpcCfg,
idxer,
nil, // external services modifier
func(evmberpcbackend.EvmBackendI) {
Expand Down

0 comments on commit cfe4a54

Please sign in to comment.