7
7
"fmt"
8
8
"github.com/ethereum/go-ethereum/common"
9
9
"github.com/ethereum/go-ethereum/common/hexutil"
10
+ "google.golang.org/protobuf/types/known/structpb"
10
11
"reflect"
11
12
"strconv"
12
13
"time"
@@ -17,16 +18,41 @@ import (
17
18
// --------------------
18
19
19
20
type Address struct { common.Hash }
21
+
22
+ func (s * Address ) MarshalStructpb () * structpb.Value {
23
+ return structpb .NewStringValue (s .String ())
24
+ }
25
+
20
26
type AssetId struct { common.Hash }
27
+
28
+ func (s * AssetId ) MarshalStructpb () * structpb.Value {
29
+ return structpb .NewStringValue (s .String ())
30
+ }
31
+
21
32
type BlockId struct { common.Hash }
33
+
34
+ func (s * BlockId ) MarshalStructpb () * structpb.Value {
35
+ return structpb .NewStringValue (s .String ())
36
+ }
37
+
22
38
type Boolean bool
23
39
24
40
func (s * Boolean ) String () string {
25
41
return strconv .FormatBool (bool (* s ))
26
42
}
27
43
28
44
type Bytes32 struct { common.Hash }
45
+
46
+ func (s * Bytes32 ) MarshalStructpb () * structpb.Value {
47
+ return structpb .NewStringValue (s .String ())
48
+ }
49
+
29
50
type ContractId struct { common.Hash }
51
+
52
+ func (s * ContractId ) MarshalStructpb () * structpb.Value {
53
+ return structpb .NewStringValue (s .String ())
54
+ }
55
+
30
56
type Float float64
31
57
32
58
func (s * Float ) UnmarshalJSON (raw []byte ) error {
@@ -47,6 +73,11 @@ func (s *Float) String() string {
47
73
}
48
74
49
75
type HexString struct { hexutil.Bytes }
76
+
77
+ func (s * HexString ) MarshalStructpb () * structpb.Value {
78
+ return structpb .NewStringValue (s .String ())
79
+ }
80
+
50
81
type ID string
51
82
type Int int32
52
83
@@ -70,9 +101,24 @@ func (s *Int) String() string {
70
101
type Nonce string
71
102
type Salt string
72
103
type Signature struct { hexutil.Bytes }
104
+
105
+ func (s * Signature ) MarshalStructpb () * structpb.Value {
106
+ return structpb .NewStringValue (s .String ())
107
+ }
108
+
73
109
type String string
74
110
type Tai64Timestamp struct { time.Time }
111
+
112
+ func (s * Tai64Timestamp ) MarshalStructpb () * structpb.Value {
113
+ return structpb .NewStringValue (s .String ())
114
+ }
115
+
75
116
type TransactionId struct { common.Hash }
117
+
118
+ func (s * TransactionId ) MarshalStructpb () * structpb.Value {
119
+ return structpb .NewStringValue (s .String ())
120
+ }
121
+
76
122
type TxPointer string
77
123
type U32 uint32
78
124
@@ -133,6 +179,10 @@ func (s *U8) String() string {
133
179
134
180
type UtxoId struct { hexutil.Bytes }
135
181
182
+ func (s * UtxoId ) MarshalStructpb () * structpb.Value {
183
+ return structpb .NewStringValue (s .String ())
184
+ }
185
+
136
186
func UnmarshalJSONUInt (raw []byte ) (uint64 , error ) {
137
187
if len (raw ) >= 2 && raw [0 ] == '"' && raw [len (raw )- 1 ] == '"' {
138
188
raw = raw [1 : len (raw )- 1 ]
0 commit comments