Skip to content

Commit 4266a7b

Browse files
authored
Merge branch 'feat/ibc-v10' into tests/ibc-testcases
2 parents e1e2b8b + 77e425e commit 4266a7b

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

Diff for: cmd/evmd/cmd/root.go

+30-9
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,10 @@ func newApp(
318318
panic(err)
319319
}
320320

321-
homeDir := cast.ToString(appOpts.Get(flags.FlagHome))
322-
chainID := cast.ToString(appOpts.Get(flags.FlagChainID))
323-
if chainID == "" {
324-
chainID, err = evmdconfig.GetChainIDFromHome(homeDir)
325-
if err != nil {
326-
panic(err)
327-
}
321+
// get the chain id
322+
chainID, err := getChainIDFromOpts(appOpts)
323+
if err != nil {
324+
panic(err)
328325
}
329326

330327
snapshotStore, err := sdkserver.GetSnapshotStore(appOpts)
@@ -399,15 +396,39 @@ func appExport(
399396
viperAppOpts.Set(sdkserver.FlagInvCheckPeriod, 1)
400397
appOpts = viperAppOpts
401398

399+
// get the chain id
400+
chainID, err := getChainIDFromOpts(appOpts)
401+
if err != nil {
402+
return servertypes.ExportedApp{}, err
403+
}
404+
402405
if height != -1 {
403-
exampleApp = evmd.NewExampleApp(logger, db, traceStore, false, appOpts, evmd.EvmAppOptions)
406+
exampleApp = evmd.NewExampleApp(logger, db, traceStore, false, appOpts, evmd.EvmAppOptions, baseapp.SetChainID(chainID))
404407

405408
if err := exampleApp.LoadHeight(height); err != nil {
406409
return servertypes.ExportedApp{}, err
407410
}
408411
} else {
409-
exampleApp = evmd.NewExampleApp(logger, db, traceStore, true, appOpts, evmd.EvmAppOptions)
412+
exampleApp = evmd.NewExampleApp(logger, db, traceStore, true, appOpts, evmd.EvmAppOptions, baseapp.SetChainID(chainID))
410413
}
411414

412415
return exampleApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport)
413416
}
417+
418+
// getChainIDFromOpts returns the chain Id from app Opts
419+
// It first tries to get from the chainId flag, if not available
420+
// it will load from home
421+
func getChainIDFromOpts(appOpts servertypes.AppOptions) (chainID string, err error) {
422+
// Get the chain Id from appOpts
423+
chainID = cast.ToString(appOpts.Get(flags.FlagChainID))
424+
if chainID == "" {
425+
// If not available load from home
426+
homeDir := cast.ToString(appOpts.Get(flags.FlagHome))
427+
chainID, err = evmdconfig.GetChainIDFromHome(homeDir)
428+
if err != nil {
429+
return "", err
430+
}
431+
}
432+
433+
return
434+
}

Diff for: evmd/config.go

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ func EvmAppOptions(chainID string) error {
5151
}
5252

5353
id := strings.Split(chainID, "-")[0]
54-
fmt.Printf("ChainID: %v\n", chainID)
5554
coinInfo, found := ChainsCoinInfo[id]
5655
if !found {
5756
return fmt.Errorf("unknown chain id: %s", id)

0 commit comments

Comments
 (0)