Skip to content

Commit

Permalink
add notice for ledger
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Oct 12, 2023
1 parent e64c916 commit d094739
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions cmd/zetacored/main.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package main

import (
"fmt"
"os"
"strings"

"github.com/cosmos/cosmos-sdk/server"
cmdcfg "github.com/zeta-chain/zetacore/cmd/zetacored/config"

svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/zeta-chain/zetacore/app"
cmdcfg "github.com/zeta-chain/zetacore/cmd/zetacored/config"
)

func main() {
Expand All @@ -16,12 +17,37 @@ func main() {
rootCmd, _ := NewRootCmd()

if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {

switch e := err.(type) {
case server.ErrorCode:
os.Exit(e.Code)

default:
processError(e)
os.Exit(1)
}
}
}

func processError(err error) {
// --ledger flag can't be used with Ethereum HD path
if strings.Contains(err.Error(), "cannot set custom bip32 path with ledger") {
printNotice([]string{
"note: --ledger flag can't be used with Ethereum HD path (used by default)",
"use --hd-path=\"\" in the command to use Cosmos HD path",
})
os.Exit(1)
}
}

func printNotice(messages []string) {
if len(messages) == 0 {
return
}
border := strings.Repeat("*", len(messages[0])+4) // 4 to account for padding
fmt.Println(border)
for _, message := range messages {
fmt.Printf("* %s \n", message)
}
fmt.Println(border)
}

0 comments on commit d094739

Please sign in to comment.