Skip to content

Commit

Permalink
feat: stake and pool certificates (#137)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Gianelloni <[email protected]>
  • Loading branch information
wolf31o2 authored Nov 8, 2024
1 parent a7f9639 commit 834c88c
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
models "github.com/blinklabs-io/cardano-models"
ouroboros "github.com/blinklabs-io/gouroboros"
"github.com/blinklabs-io/gouroboros/ledger"
lcommon "github.com/blinklabs-io/gouroboros/ledger/common"
"github.com/fxamacker/cbor/v2"
"github.com/gdamore/tcell/v2"
"github.com/kelseyhightower/envconfig"
Expand Down Expand Up @@ -335,6 +336,24 @@ func GetTransactions(oConn *ouroboros.Connection) string {
}
}

// Check if Tx has certificates and compare against known types
if tx.Certificates() != nil {
for _, certificate := range tx.Certificates() {
eject := false
switch certificate.(type) {
case *lcommon.StakeRegistrationCertificate, *lcommon.StakeDeregistrationCertificate, *lcommon.StakeDelegationCertificate:
icon = "🥩"
eject = true
case *lcommon.PoolRegistrationCertificate, *lcommon.PoolRetirementCertificate:
icon = "🏊"
eject = true
}
if eject {
break
}
}
}

spaces := "10"
if icon != "" {
spaces = "9"
Expand Down Expand Up @@ -379,7 +398,7 @@ func main() {
fmt.Sprintln(" [yellow](esc/q)[white] Quit | [yellow](p)[white] Pause"),
)
legendText.SetText(
fmt.Sprintf(" Legend: [white]%s\n %s",
fmt.Sprintf(" Legend: [white]%s\n %s\n %s",
fmt.Sprintf("%12s %12s %12s %12s %12s %12s",
"🏹 Dexhunter",
"🚰 DripDropz",
Expand All @@ -396,6 +415,10 @@ func main() {
"🦭 SealVM",
"🦸 Wingriders",
),
fmt.Sprintf("%18s %9s",
"🥩 Staking",
"🏊 SPOs",
),
),
)
flex.SetDirection(tview.FlexRow).
Expand All @@ -408,7 +431,7 @@ func main() {
6,
true).
AddItem(legendText,
2,
3,
0,
false).
AddItem(footerText,
Expand Down

0 comments on commit 834c88c

Please sign in to comment.