Skip to content

Commit

Permalink
Fix: participation key rendering from base64url to base64
Browse files Browse the repository at this point in the history
  • Loading branch information
Tasos Bitsios committed Jan 17, 2025
1 parent 3270dc2 commit df28fcc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
28 changes: 14 additions & 14 deletions ui/modal/testdata/Test_Snapshot/InfoModal.golden
Original file line number Diff line number Diff line change
Expand Up @@ -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 )─────╯



Expand Down
6 changes: 3 additions & 3 deletions ui/modals/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions ui/modals/info/testdata/Test_Snapshot/Visible.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Account: ABC
Participation ID: 123

Vote Key: VEVTVEtFWQ
Selection Key: VEVTVEtFWQ
State Proof Key: VEVTVEtFWQ
Vote Key: VEVTVEtFWQ==
Selection Key: VEVTVEtFWQ==
State Proof Key: VEVTVEtFWQ==

Vote First Valid: 0
Vote Last Valid: 30000
Expand Down
7 changes: 7 additions & 0 deletions ui/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit df28fcc

Please sign in to comment.