Skip to content

Commit

Permalink
Revert "feat: Add loading spinner with status on roller init, registe…
Browse files Browse the repository at this point in the history
…r and run (#166)"

This reverts commit 63d166d.
  • Loading branch information
mtsitrin committed Jul 4, 2023
1 parent b0a5972 commit e5ccda2
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 41 deletions.
9 changes: 1 addition & 8 deletions cmd/config/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ func InitCmd() *cobra.Command {
return nil
},
Run: func(cmd *cobra.Command, args []string) {
spin := utils.GetLoadingSpinner()
spin.Suffix = consts.SpinnerMsgs.UniqueIdVerification
spin.Start()
initConfig, err := GetInitConfig(cmd, args)
utils.PrettifyErrorIfExists(err)

Expand All @@ -56,21 +53,18 @@ func InitCmd() *cobra.Command {
isRootExist, err := dirNotEmpty(initConfig.Home)
utils.PrettifyErrorIfExists(err)
if isRootExist {
spin.Stop()
shouldOverwrite, err := promptOverwriteConfig(initConfig.Home)
utils.PrettifyErrorIfExists(err)
if shouldOverwrite {
utils.PrettifyErrorIfExists(os.RemoveAll(initConfig.Home))
} else {
os.Exit(0)
}
spin.Start()
}
utils.PrettifyErrorIfExists(os.MkdirAll(initConfig.Home, 0755))

//TODO: create all dirs here
spin.Suffix = " Initializing RollApp configuration files..."
spin.Restart()

/* ---------------------------- Initilize relayer --------------------------- */
utils.PrettifyErrorIfExists(initializeRelayerConfig(ChainConfig{
ID: initConfig.RollappID,
Expand Down Expand Up @@ -108,7 +102,6 @@ func InitCmd() *cobra.Command {
utils.PrettifyErrorIfExists(config.WriteConfigToTOML(initConfig))

/* ------------------------------ Print output ------------------------------ */
spin.Stop()
printInitOutput(initConfig, addresses, initConfig.RollappID)
},
}
Expand Down
8 changes: 0 additions & 8 deletions cmd/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,3 @@ const (

// TODO: Check DA LC write price on arabica and update this value.
var OneDAWritePrice = big.NewInt(1)

var SpinnerMsgs = struct {
UniqueIdVerification string
BalancesVerification string
}{
UniqueIdVerification: " Verifying unique RollApp ID...\n",
BalancesVerification: " Verifying balances...\n",
}
12 changes: 1 addition & 11 deletions cmd/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"bytes"
"errors"
"fmt"
"github.com/dymensionxyz/roller/cmd/consts"
"math/big"

"strings"

"encoding/json"
Expand All @@ -24,28 +24,18 @@ func Cmd() *cobra.Command {
Use: "register",
Short: "Registers the rollapp and the sequencer to the Dymension hub.",
Run: func(cmd *cobra.Command, args []string) {
spin := utils.GetLoadingSpinner()
spin.Suffix = consts.SpinnerMsgs.BalancesVerification
spin.Start()
home := cmd.Flag(utils.FlagNames.Home).Value.String()
rollappConfig, err := config.LoadConfigFromTOML(home)
utils.PrettifyErrorIfExists(err)
notFundedAddrs, err := utils.GetSequencerInsufficientAddrs(rollappConfig, *registerUdymPrice)
utils.PrettifyErrorIfExists(err)
utils.PrintInsufficientBalancesIfAny(notFundedAddrs)
spin.Suffix = consts.SpinnerMsgs.UniqueIdVerification
spin.Restart()
utils.PrettifyErrorIfExists(initconfig.VerifyUniqueRollappID(rollappConfig.RollappID, rollappConfig))
spin.Suffix = " Registering RollApp to hub...\n"
spin.Restart()
utils.PrettifyErrorIfExists(registerRollapp(rollappConfig))
registerSequencerCmd, err := getRegisterSequencerCmd(rollappConfig)
utils.PrettifyErrorIfExists(err)
spin.Suffix = " Registering RollApp sequencer...\n"
spin.Restart()
_, err = utils.ExecBashCommand(registerSequencerCmd)
utils.PrettifyErrorIfExists(err)
spin.Stop()
printRegisterOutput(rollappConfig)
},
}
Expand Down
10 changes: 2 additions & 8 deletions cmd/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ func Cmd() *cobra.Command {
Use: "run",
Short: "Runs the rollapp on the local machine.",
Run: func(cmd *cobra.Command, args []string) {
spin := utils.GetLoadingSpinner()
spin.Suffix = consts.SpinnerMsgs.BalancesVerification
spin.Start()
home := cmd.Flag(utils.FlagNames.Home).Value.String()
rollappConfig, err := config.LoadConfigFromTOML(home)
utils.PrettifyErrorIfExists(err)
Expand All @@ -38,19 +35,16 @@ func Cmd() *cobra.Command {
}

/* ------------------------------ run processes ----------------------------- */
spin.Suffix = " Starting RollApp services..."
spin.Restart()
runDaWithRestarts(rollappConfig, serviceConfig)
runSequencerWithRestarts(rollappConfig, serviceConfig)
runRelayerWithRestarts(rollappConfig, serviceConfig)

/* ------------------------------ render output ----------------------------- */
PrintServicesStatus(rollappConfig)
cancel()
spin.Suffix = " Killing subprocesses..."
spin.Restart()
logger.Println("Killing subprocesses")
waitingGroup.Wait()
spin.Stop()
logger.Println("killed them")
},
}

Expand Down
6 changes: 0 additions & 6 deletions cmd/utils/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ package utils
import (
"errors"
"fmt"
"github.com/briandowns/spinner"
"github.com/olekukonko/tablewriter"
"math/big"
"os"
"time"
)

func PrintInsufficientBalancesIfAny(addressesData []NotFundedAddressData) {
Expand Down Expand Up @@ -46,7 +44,3 @@ type NotFundedAddressData struct {
RequiredBalance *big.Int
Denom string
}

func GetLoadingSpinner() *spinner.Spinner {
return spinner.New(spinner.CharSets[9], 100*time.Millisecond)
}

0 comments on commit e5ccda2

Please sign in to comment.