Skip to content

Commit

Permalink
fix(ux): remove irrelevant prompts (#940)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs authored Sep 15, 2024
1 parent cd7d0a2 commit 74323ef
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
9 changes: 5 additions & 4 deletions cmd/rollapp/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import (
cosmossdktypes "github.com/cosmos/cosmos-sdk/types"
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
dymensionseqtypes "github.com/dymensionxyz/dymension/v3/x/sequencer/types"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"

initconfig "github.com/dymensionxyz/roller/cmd/config/init"
"github.com/dymensionxyz/roller/cmd/consts"
initrollapp "github.com/dymensionxyz/roller/cmd/rollapp/init"
Expand All @@ -31,9 +35,6 @@ import (
"github.com/dymensionxyz/roller/utils/filesystem"
"github.com/dymensionxyz/roller/utils/rollapp"
sequencerutils "github.com/dymensionxyz/roller/utils/sequencer"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
)

// TODO: Test sequencing on 35-C and update the price
Expand Down Expand Up @@ -315,7 +316,7 @@ func Cmd() *cobra.Command {
}
}

err = sequencerutils.Register(*rollappConfig, desiredBond.String())
err = sequencerutils.Register(*rollappConfig, desiredBond)
if err != nil {
pterm.Error.Println("failed to register sequencer: ", err)
return
Expand Down
3 changes: 2 additions & 1 deletion utils/rollapp/rollappId.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ type ChainID struct {

// from Dymension source code `x/rollapp/types/chain_id.go` @20240911
func ValidateChainID(id string) (ChainID, error) {
spinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("validating rollapp id '%s'\n", id))
spinner, _ := pterm.DefaultSpinner.WithRemoveWhenDone().
Start(fmt.Sprintf("validating rollapp id '%s'\n", id))
chainID := strings.TrimSpace(id)

if chainID == "" {
Expand Down
13 changes: 10 additions & 3 deletions utils/sequencer/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import (
"github.com/dymensionxyz/roller/utils/bash"
"github.com/dymensionxyz/roller/utils/config"
"github.com/dymensionxyz/roller/utils/tx"
"github.com/pterm/pterm"
)

func Register(raCfg config.RollappConfig, desiredBond string) error {
func Register(raCfg config.RollappConfig, desiredBond cosmossdktypes.Coin) error {
seqPubKey, err := utils.GetSequencerPubKey(raCfg)
if err != nil {
return err
Expand All @@ -45,7 +46,7 @@ func Register(raCfg config.RollappConfig, desiredBond string) error {
"create-sequencer",
seqPubKey,
raCfg.RollappID,
desiredBond,
desiredBond.String(),
seqMetadataPath,
"--from", consts.KeysIds.HubSequencer,
"--keyring-backend", "test",
Expand All @@ -56,12 +57,17 @@ func Register(raCfg config.RollappConfig, desiredBond string) error {
"--node", raCfg.HubData.RPC_URL, "--chain-id", raCfg.HubData.ID,
)

displayBond, err := BaseDenomToDenom(desiredBond, 18)
if err != nil {
return err
}

txOutput, err := bash.ExecCommandWithInput(
cmd,
"signatures",
fmt.Sprintf(
"this transaction is going to register your sequencer with %s bond. do you want to continue?",
desiredBond,
pterm.Yellow(pterm.Bold.Sprint(displayBond.String())),
),
)
if err != nil {
Expand Down Expand Up @@ -143,6 +149,7 @@ func BaseDenomToDenom(
exp := cosmossdkmath.NewIntWithDecimal(1, exponent)

coin.Amount = coin.Amount.Quo(exp)
coin.Denom = coin.Denom[1:]

return coin, nil
}
Expand Down

0 comments on commit 74323ef

Please sign in to comment.