Skip to content

Commit

Permalink
chore: improve init output (#818)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs authored Jul 19, 2024
1 parent d040895 commit f5c30a8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
19 changes: 15 additions & 4 deletions cmd/config/init/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"strings"

"github.com/pterm/pterm"

"github.com/dymensionxyz/roller/cmd/consts"
"github.com/dymensionxyz/roller/cmd/utils"
"github.com/dymensionxyz/roller/config"
Expand All @@ -30,16 +32,25 @@ func formatAddresses(
return filteredAddresses
}

func FormatTokenSupplyLine(rollappConfig config.RollappConfig) string {
return fmt.Sprintf(
"💰 Total Token Supply: %s %s. Note that 1 %s == 1 * 10^%d %s (like 1 ETH == 1 * 10^18 wei).",
func PrintTokenSupplyLine(rollappConfig config.RollappConfig) {
pterm.DefaultSection.WithIndentCharacter("💰").Printf(
"Total Token Supply: %s %s.",
addCommasToNum(
"1000000000",
consts.DefaultTokenSupply[:len(consts.DefaultTokenSupply)-int(rollappConfig.Decimals)],
),
rollappConfig.Denom,
)

pterm.DefaultBasicText.Printf(
"Note that 1 %s == 1 * 10^%d %s (like 1 ETH == 1 * 10^18 wei).\nThe total supply in base denom (%s) is "+pterm.Yellow(
"%s%s",
),
rollappConfig.Denom,
rollappConfig.Decimals,
rollappConfig.BaseDenom,
rollappConfig.BaseDenom,
consts.DefaultTokenSupply,
rollappConfig.BaseDenom,
)
}

Expand Down
1 change: 0 additions & 1 deletion cmd/config/init/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func generateSequencersKeys(initConfig config.RollappConfig) ([]utils.KeyInfo, e
}

func getSequencerKeysConfig(rollappConfig config.RollappConfig) []utils.KeyConfig {
fmt.Println(rollappConfig.HubData)
if rollappConfig.HubData.ID == consts.MockHubID {
return []utils.KeyConfig{
{
Expand Down
2 changes: 1 addition & 1 deletion cmd/config/init/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (o *OutputHandler) PrintInitOutput(
"💈 RollApp '%s' configuration files have been successfully generated on your local machine. Congratulations!\n\n",
rollappId,
)
fmt.Println(FormatTokenSupplyLine(rollappConfig))
PrintTokenSupplyLine(rollappConfig)
fmt.Println()
utils.PrintAddressesWithTitle(addresses)

Expand Down
3 changes: 0 additions & 3 deletions cmd/rollapp/init/utils.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package initrollapp

import (
"encoding/json"
"errors"
"fmt"
"os"
Expand Down Expand Up @@ -230,8 +229,6 @@ func runInit(cmd *cobra.Command, opts ...Option) error {

/* ------------------------------ Print output ------------------------------ */

j, _ := json.MarshalIndent(addresses, "", " ")
fmt.Println(string(j))
outputHandler.StopSpinner()
outputHandler.PrintInitOutput(initConfig, addresses, initConfig.RollappID)

Expand Down
3 changes: 2 additions & 1 deletion cmd/utils/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ func (ki *KeyInfo) Print(o ...KeyInfoOption) {

if ki.PrintMnemonic {
fmt.Printf("\t%s\n", ki.Mnemonic)
fmt.Println(pterm.LightYellow("save the information and keep it safe"))
fmt.Println()
fmt.Println(pterm.LightYellow("💡 save the information and keep it safe"))
}

fmt.Println()
Expand Down

0 comments on commit f5c30a8

Please sign in to comment.