diff --git a/internal/algod/mac/mac.go b/internal/algod/mac/mac.go index 3286ca15..09909552 100644 --- a/internal/algod/mac/mac.go +++ b/internal/algod/mac/mac.go @@ -113,11 +113,19 @@ func Upgrade(force bool) error { if !system.CmdExists("brew") { return errors.New("homebrew is not installed") } - - return system.RunAll(system.CmdsList{ + err := system.RunAll(system.CmdsList{ {"brew", "--prefix", "algorand", "--installed"}, + {"brew", "update"}, {"brew", "upgrade", "algorand", "--formula"}, }) + if err != nil { + return err + } + err = Stop(false) + if err != nil { + return err + } + return Start(false) } // Start algorand with launchd diff --git a/internal/algod/state.go b/internal/algod/state.go index e0a65521..e0ffab00 100644 --- a/internal/algod/state.go +++ b/internal/algod/state.go @@ -121,6 +121,7 @@ func (s *StateModel) Watch(cb func(model *StateModel, err error), ctx context.Co if !s.Watching { break } + // Abort on Fast-Catchup if s.Status.State == FastCatchupState { // Update current render @@ -137,6 +138,9 @@ func (s *StateModel) Watch(cb func(model *StateModel, err error), ctx context.Co cb(s, nil) continue } + // Fetch Keys + s.UpdateKeys(ctx, t) + cb(s, nil) // Wait for the next block s.Status, _, err = s.Status.Wait(ctx) @@ -145,9 +149,6 @@ func (s *StateModel) Watch(cb func(model *StateModel, err error), ctx context.Co continue } - // Fetch Keys - s.UpdateKeys(ctx, t) - if s.Status.State == SyncingState { cb(s, nil) continue @@ -181,18 +182,18 @@ func (s *StateModel) UpdateKeys(ctx context.Context, t system.Time) { if err == nil { s.Admin = true s.Accounts = ParticipationKeysToAccounts(s.ParticipationKeys) + + // For each account, update the data from the RPC endpoint for _, acct := range s.Accounts { - // For each account, update the data from the RPC endpoint - if s.Status.State == StableState { - // Skip eon errors - rpcAcct, err := GetAccount(s.Client, acct.Address) - if err != nil { - continue - } - - s.Accounts[acct.Address] = s.Accounts[acct.Address].Merge(rpcAcct) - s.Accounts[acct.Address] = s.Accounts[acct.Address].UpdateExpiredTime(t, s.ParticipationKeys, int(s.Status.LastRound), s.Metrics.RoundTime) + // Skip eon errors + rpcAcct, err := GetAccount(s.Client, acct.Address) + if err != nil { + continue } + + s.Accounts[acct.Address] = s.Accounts[acct.Address].Merge(rpcAcct) + s.Accounts[acct.Address] = s.Accounts[acct.Address].UpdateExpiredTime(t, s.ParticipationKeys, int(s.Status.LastRound), s.Metrics.RoundTime) } + } } diff --git a/main.go b/main.go index e6692df6..b4235688 100644 --- a/main.go +++ b/main.go @@ -27,7 +27,7 @@ func main() { var needsUpgrade = false resp, err := api.GetNodeKitReleaseWithResponse(new(api.HttpPkg)) if err == nil && resp.ResponseCode >= 200 && resp.ResponseCode < 300 { - if resp.JSON200 != version { + if version != "dev" && resp.JSON200 != version { needsUpgrade = true // Warn on all commands but version if len(os.Args) > 1 && os.Args[1] != "--version" { diff --git a/ui/modal/testdata/Test_Snapshot/InfoModal.golden b/ui/modal/testdata/Test_Snapshot/InfoModal.golden index 3e28416a..7e5459fc 100644 --- a/ui/modal/testdata/Test_Snapshot/InfoModal.golden +++ b/ui/modal/testdata/Test_Snapshot/InfoModal.golden @@ -31,20 +31,20 @@ - ╭──Key Information────────────╮ - │ │ - │ Account: ABC │ - │ Participation ID: 123 │ - │ │ - │ Vote Key: VEVTVEtFWQ │ - │ Selection Key: VEVTVEtFWQ │ - │ State Proof Key: VEVTVEtFWQ │ - │ │ - │ Vote First Valid: 0 │ - │ Vote Last Valid: 30000 │ - │ Vote Key Dilution: 100 │ - │ │ - ╰──( (d)elete | (o)nline )────╯ + ╭──Key Information──────────────╮ + │ │ + │ Account: ABC │ + │ Participation ID: 123 │ + │ │ + │ Vote Key: VEVTVEtFWQ== │ + │ Selection Key: VEVTVEtFWQ== │ + │ State Proof Key: VEVTVEtFWQ== │ + │ │ + │ Vote First Valid: 0 │ + │ Vote Last Valid: 30000 │ + │ Vote Key Dilution: 100 │ + │ │ + ╰────( (d)elete | (o)nline )────╯ diff --git a/ui/modals/info/info.go b/ui/modals/info/info.go index 74ee023a..ec749bfc 100644 --- a/ui/modals/info/info.go +++ b/ui/modals/info/info.go @@ -92,9 +92,9 @@ func (m ViewModel) View() string { } account := style.Cyan.Render("Account: ") + m.Participation.Address id := style.Cyan.Render("Participation ID: ") + m.Participation.Id - selection := style.Yellow.Render("Selection Key: ") + *utils.UrlEncodeBytesPtrOrNil(m.Participation.Key.SelectionParticipationKey[:]) - vote := style.Yellow.Render("Vote Key: ") + *utils.UrlEncodeBytesPtrOrNil(m.Participation.Key.VoteParticipationKey[:]) - stateProof := style.Yellow.Render("State Proof Key: ") + *utils.UrlEncodeBytesPtrOrNil(*m.Participation.Key.StateProofKey) + selection := style.Yellow.Render("Selection Key: ") + *utils.Base64EncodeBytesPtrOrNil(m.Participation.Key.SelectionParticipationKey[:]) + vote := style.Yellow.Render("Vote Key: ") + *utils.Base64EncodeBytesPtrOrNil(m.Participation.Key.VoteParticipationKey[:]) + stateProof := style.Yellow.Render("State Proof Key: ") + *utils.Base64EncodeBytesPtrOrNil(*m.Participation.Key.StateProofKey) voteFirstValid := style.Purple("Vote First Valid: ") + utils.IntToStr(m.Participation.Key.VoteFirstValid) voteLastValid := style.Purple("Vote Last Valid: ") + utils.IntToStr(m.Participation.Key.VoteLastValid) voteKeyDilution := style.Purple("Vote Key Dilution: ") + utils.IntToStr(m.Participation.Key.VoteKeyDilution) diff --git a/ui/modals/info/testdata/Test_Snapshot/Visible.golden b/ui/modals/info/testdata/Test_Snapshot/Visible.golden index e8bc0e8d..9ccb5058 100644 --- a/ui/modals/info/testdata/Test_Snapshot/Visible.golden +++ b/ui/modals/info/testdata/Test_Snapshot/Visible.golden @@ -1,12 +1,12 @@ - -Account: ABC -Participation ID: 123 - -Vote Key: VEVTVEtFWQ -Selection Key: VEVTVEtFWQ -State Proof Key: VEVTVEtFWQ - -Vote First Valid: 0 -Vote Last Valid: 30000 -Vote Key Dilution: 100 - \ No newline at end of file + +Account: ABC +Participation ID: 123 + +Vote Key: VEVTVEtFWQ== +Selection Key: VEVTVEtFWQ== +State Proof Key: VEVTVEtFWQ== + +Vote First Valid: 0 +Vote Last Valid: 30000 +Vote Key Dilution: 100 + \ No newline at end of file diff --git a/ui/utils/utils.go b/ui/utils/utils.go index af9d89fa..ac569ed9 100644 --- a/ui/utils/utils.go +++ b/ui/utils/utils.go @@ -7,6 +7,13 @@ import ( func toPtr[T any](constVar T) *T { return &constVar } +func Base64EncodeBytesPtrOrNil(b []byte) *string { + if b == nil || len(b) == 0 || isZeros(b) { + return nil + } + return toPtr(base64.StdEncoding.EncodeToString(b)) +} + func UrlEncodeBytesPtrOrNil(b []byte) *string { if b == nil || len(b) == 0 || isZeros(b) { return nil