diff --git a/ui/modal/testdata/Test_Snapshot/InfoModal.golden b/ui/modal/testdata/Test_Snapshot/InfoModal.golden index 3e28416a..6c8b273f 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 fa9b2073..44a95a14 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