File tree 3 files changed +48
-0
lines changed
3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 6
6
"encoding/json"
7
7
"errors"
8
8
"fmt"
9
+ "io"
9
10
"regexp"
11
+ "strconv"
10
12
"strings"
11
13
12
14
"github.com/ethereum/go-ethereum/common"
@@ -122,6 +124,20 @@ func (c *AccountID) Scan(src interface{}) error {
122
124
return nil
123
125
}
124
126
127
+ func (c AccountID ) MarshalGQL (w io.Writer ) {
128
+ fmt .Fprint (w , strconv .Quote (strings .ToUpper (c .String ())))
129
+ }
130
+
131
+ func (c * AccountID ) UnmarshalGQL (v interface {}) error {
132
+ if id , ok := v .(string ); ok {
133
+ if err := c .Parse (id ); err != nil {
134
+ return fmt .Errorf ("unmarshalling account id: %w" , err )
135
+ }
136
+ }
137
+
138
+ return nil
139
+ }
140
+
125
141
type EVMAccountID struct {
126
142
EVMAddressable
127
143
AccountID
Original file line number Diff line number Diff line change 6
6
"encoding/json"
7
7
"errors"
8
8
"fmt"
9
+ "io"
9
10
"regexp"
11
+ "strconv"
10
12
"strings"
11
13
12
14
"github.com/ethereum/go-ethereum/common"
@@ -130,6 +132,20 @@ func (a *AssetID) Scan(src interface{}) error {
130
132
return nil
131
133
}
132
134
135
+ func (a AssetID ) MarshalGQL (w io.Writer ) {
136
+ fmt .Fprint (w , strconv .Quote (strings .ToUpper (a .String ())))
137
+ }
138
+
139
+ func (a * AssetID ) UnmarshalGQL (v interface {}) error {
140
+ if id , ok := v .(string ); ok {
141
+ if err := a .Parse (id ); err != nil {
142
+ return fmt .Errorf ("unmarshalling asset id: %w" , err )
143
+ }
144
+ }
145
+
146
+ return nil
147
+ }
148
+
133
149
type EVMAssetID struct {
134
150
EVMAddressable
135
151
AssetID
Original file line number Diff line number Diff line change 6
6
"encoding/json"
7
7
"errors"
8
8
"fmt"
9
+ "io"
9
10
"regexp"
11
+ "strconv"
10
12
"strings"
11
13
)
12
14
@@ -116,3 +118,17 @@ func (c *ChainID) Scan(src interface{}) error {
116
118
117
119
return nil
118
120
}
121
+
122
+ func (c ChainID ) MarshalGQL (w io.Writer ) {
123
+ fmt .Fprint (w , strconv .Quote (strings .ToUpper (c .String ())))
124
+ }
125
+
126
+ func (c * ChainID ) UnmarshalGQL (v interface {}) error {
127
+ if id , ok := v .(string ); ok {
128
+ if err := c .Parse (id ); err != nil {
129
+ return fmt .Errorf ("unmarshalling account id: %w" , err )
130
+ }
131
+ }
132
+
133
+ return nil
134
+ }
You can’t perform that action at this time.
0 commit comments