Skip to content

Commit 8e65d2d

Browse files
authored
Merge pull request #114 from algorandfoundation/fix/keys-view-base64-encoding
Fix: participation key rendering from base64url to base64
2 parents 0772f8d + bdf279a commit 8e65d2d

File tree

4 files changed

+36
-29
lines changed

4 files changed

+36
-29
lines changed

ui/modal/testdata/Test_Snapshot/InfoModal.golden

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@
3131

3232

3333

34-
╭──Key Information────────────
35-
36-
│ Account: ABC
37-
│ Participation ID: 123
38-
39-
│ Vote Key: VEVTVEtFWQ │
40-
│ Selection Key: VEVTVEtFWQ │
41-
│ State Proof Key: VEVTVEtFWQ
42-
43-
│ Vote First Valid: 0
44-
│ Vote Last Valid: 30000
45-
│ Vote Key Dilution: 100
46-
47-
╰──( (d)elete | (o)nline )────╯
34+
╭──Key Information──────────────╮
35+
36+
│ Account: ABC
37+
│ Participation ID: 123
38+
39+
│ Vote Key: VEVTVEtFWQ==
40+
│ Selection Key: VEVTVEtFWQ==
41+
│ State Proof Key: VEVTVEtFWQ== │
42+
43+
│ Vote First Valid: 0
44+
│ Vote Last Valid: 30000
45+
│ Vote Key Dilution: 100
46+
47+
╰────( (d)elete | (o)nline )────╯
4848

4949

5050

ui/modals/info/info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ func (m ViewModel) View() string {
9292
}
9393
account := style.Cyan.Render("Account: ") + m.Participation.Address
9494
id := style.Cyan.Render("Participation ID: ") + m.Participation.Id
95-
selection := style.Yellow.Render("Selection Key: ") + *utils.UrlEncodeBytesPtrOrNil(m.Participation.Key.SelectionParticipationKey[:])
96-
vote := style.Yellow.Render("Vote Key: ") + *utils.UrlEncodeBytesPtrOrNil(m.Participation.Key.VoteParticipationKey[:])
97-
stateProof := style.Yellow.Render("State Proof Key: ") + *utils.UrlEncodeBytesPtrOrNil(*m.Participation.Key.StateProofKey)
95+
selection := style.Yellow.Render("Selection Key: ") + *utils.Base64EncodeBytesPtrOrNil(m.Participation.Key.SelectionParticipationKey[:])
96+
vote := style.Yellow.Render("Vote Key: ") + *utils.Base64EncodeBytesPtrOrNil(m.Participation.Key.VoteParticipationKey[:])
97+
stateProof := style.Yellow.Render("State Proof Key: ") + *utils.Base64EncodeBytesPtrOrNil(*m.Participation.Key.StateProofKey)
9898
voteFirstValid := style.Purple("Vote First Valid: ") + utils.IntToStr(m.Participation.Key.VoteFirstValid)
9999
voteLastValid := style.Purple("Vote Last Valid: ") + utils.IntToStr(m.Participation.Key.VoteLastValid)
100100
voteKeyDilution := style.Purple("Vote Key Dilution: ") + utils.IntToStr(m.Participation.Key.VoteKeyDilution)
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
2-
Account: ABC
3-
Participation ID: 123
4-
5-
Vote Key: VEVTVEtFWQ
6-
Selection Key: VEVTVEtFWQ
7-
State Proof Key: VEVTVEtFWQ
8-
9-
Vote First Valid: 0
10-
Vote Last Valid: 30000
11-
Vote Key Dilution: 100
12-
1+
2+
Account: ABC
3+
Participation ID: 123
4+
5+
Vote Key: VEVTVEtFWQ==
6+
Selection Key: VEVTVEtFWQ==
7+
State Proof Key: VEVTVEtFWQ==
8+
9+
Vote First Valid: 0
10+
Vote Last Valid: 30000
11+
Vote Key Dilution: 100
12+

ui/utils/utils.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import (
77

88
func toPtr[T any](constVar T) *T { return &constVar }
99

10+
func Base64EncodeBytesPtrOrNil(b []byte) *string {
11+
if b == nil || len(b) == 0 || isZeros(b) {
12+
return nil
13+
}
14+
return toPtr(base64.StdEncoding.EncodeToString(b))
15+
}
16+
1017
func UrlEncodeBytesPtrOrNil(b []byte) *string {
1118
if b == nil || len(b) == 0 || isZeros(b) {
1219
return nil

0 commit comments

Comments
 (0)