From ab7859504456bbab9a88207ca6d073698035c847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matev=C5=BE=20Jekovec?= Date: Mon, 18 Nov 2024 15:52:13 +0100 Subject: [PATCH] client-sdk: Add PrettyPrint to StakeThresholds --- client-sdk/go/modules/rofl/types.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/client-sdk/go/modules/rofl/types.go b/client-sdk/go/modules/rofl/types.go index a406e7fef1..478c34d38f 100644 --- a/client-sdk/go/modules/rofl/types.go +++ b/client-sdk/go/modules/rofl/types.go @@ -1,6 +1,10 @@ package rofl import ( + "context" + "fmt" + "io" + "github.com/oasisprotocol/curve25519-voi/primitives/x25519" beacon "github.com/oasisprotocol/oasis-core/go/beacon/api" @@ -141,3 +145,16 @@ type Event struct { type StakeThresholds struct { AppCreate *types.BaseUnits `json:"app_create"` } + +// PrettyPrint writes a pretty-printed representation of the stake thresholds to the given writer. +func (st *StakeThresholds) PrettyPrint(ctx context.Context, prefix string, w io.Writer) { + fmt.Fprintf(w, "%sStake thresholds:\n", prefix) + fmt.Fprintf(w, "%s App create: ", prefix) + st.AppCreate.PrettyPrint(ctx, "", w) + fmt.Fprint(w, "\n") +} + +// PrettyType returns a representation of the type that can be used for pretty printing. +func (st *StakeThresholds) PrettyType() (interface{}, error) { + return st, nil +}