Skip to content

Commit

Permalink
fix: show da balance in status (#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs committed Sep 22, 2024
1 parent 2cf066d commit 8cd0106
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions cmd/rollapp/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
"slices"
"strconv"
"strings"
"time"

"github.com/pterm/pterm"
"github.com/spf13/cobra"

initconfig "github.com/dymensionxyz/roller/cmd/config/init"
"github.com/dymensionxyz/roller/cmd/consts"
"github.com/dymensionxyz/roller/cmd/utils"
datalayer "github.com/dymensionxyz/roller/data_layer"
"github.com/dymensionxyz/roller/sequencer"
"github.com/dymensionxyz/roller/utils/bash"
"github.com/dymensionxyz/roller/utils/config"
Expand Down Expand Up @@ -164,6 +164,12 @@ func PrintOutput(

if isHealthy {
seqAddrData, err := sequencerutils.GetSequencerData(rlpCfg)
daManager := datalayer.NewDAManager(consts.Celestia, rlpCfg.Home)
celAddrData, errCel := daManager.GetDAAccData(rlpCfg)
if err != nil {
return
}

if err != nil {
return
}
Expand All @@ -172,21 +178,16 @@ func PrintOutput(
fmt.Println("Sequencer Address:", seqAddrData[0].Address)
if withBalance && rlpCfg.NodeType == "sequencer" {
fmt.Println("Sequencer Balance:", seqAddrData[0].Balance.String())
go func() {
for {
// nolint: gosimple
select {
default:
seqAddrData, err := sequencerutils.GetSequencerData(rlpCfg)
if err == nil {
// Clear the previous line and print the updated balance
fmt.Print("\033[1A\033[K") // Move cursor up one line and clear it
fmt.Println("Sequencer Balance:", seqAddrData[0].Balance.String())
}
time.Sleep(5 * time.Second)
}
}
}()
}

if errCel != nil {
pterm.Error.Println("failed to retrieve DA address")
return
}

fmt.Println("Da Address:", celAddrData[0].Address)
if withBalance && rlpCfg.NodeType == "sequencer" && rlpCfg.HubData.ID != "mock" {
fmt.Println("Da Balance:", celAddrData[0].Balance.String())
}
}
}
Expand Down

0 comments on commit 8cd0106

Please sign in to comment.