@@ -2,21 +2,24 @@ package common
22
33import (
44 "context"
5+ "encoding/base64"
56 "encoding/json"
67 "fmt"
78 "strings"
89 "unicode/utf8"
910
11+ "github.com/spf13/cobra"
12+
1013 "github.com/oasisprotocol/oasis-core/go/common"
1114 coreSignature "github.com/oasisprotocol/oasis-core/go/common/crypto/signature"
1215 consensusPretty "github.com/oasisprotocol/oasis-core/go/common/prettyprint"
1316 "github.com/oasisprotocol/oasis-sdk/client-sdk/go/config"
1417 "github.com/oasisprotocol/oasis-sdk/client-sdk/go/crypto/signature"
1518 "github.com/oasisprotocol/oasis-sdk/client-sdk/go/types"
16- "github.com/spf13/cobra"
1719
1820 "github.com/oasisprotocol/oasis-core/go/common/cbor"
1921 "github.com/oasisprotocol/oasis-sdk/client-sdk/go/modules/contracts"
22+ "github.com/oasisprotocol/oasis-sdk/client-sdk/go/modules/rofl"
2023)
2124
2225// PrettyJSONMarshal returns pretty-printed JSON encoding of v.
@@ -46,6 +49,40 @@ func JSONMarshalKey(k interface{}) (keyJSON []byte, err error) {
4649 return
4750}
4851
52+ // JSONPrettyPrintRoflAppConfig is a wrapper around rofl.AppConfig that implements custom JSON marshaling.
53+ type JSONPrettyPrintRoflAppConfig rofl.AppConfig
54+
55+ // MarshalJSON implements custom JSON marshaling.
56+ func (a JSONPrettyPrintRoflAppConfig ) MarshalJSON () ([]byte , error ) {
57+ type alias JSONPrettyPrintRoflAppConfig
58+ out := struct {
59+ alias
60+ // Overrides alias field so JSON marshaler uses this base64 string.
61+ SEK string `json:"sek"`
62+ }{
63+ alias : alias (a ),
64+ SEK : base64 .StdEncoding .EncodeToString (a .SEK [:]),
65+ }
66+ return json .Marshal (out )
67+ }
68+
69+ // JSONPrettyPrintRoflRegistration is a wrapper around rofl.Registration that implements custom JSON marshaling.
70+ type JSONPrettyPrintRoflRegistration rofl.Registration
71+
72+ // MarshalJSON implements custom JSON marshaling.
73+ func (r JSONPrettyPrintRoflRegistration ) MarshalJSON () ([]byte , error ) {
74+ type alias JSONPrettyPrintRoflRegistration
75+ out := struct {
76+ alias
77+ // Overrides alias field so JSON marshaler uses this base64 string.
78+ REK string `json:"rek"`
79+ }{
80+ alias : alias (r ),
81+ REK : base64 .StdEncoding .EncodeToString (r .REK [:]),
82+ }
83+ return json .Marshal (out )
84+ }
85+
4986// JSONPrintKeyValueTuple traverses potentially large number of items and prints JSON representation
5087// of them.
5188//
0 commit comments