@@ -10,6 +10,7 @@ import (
10
10
11
11
"github.com/gnolang/gno/pkgs/amino"
12
12
"github.com/gnolang/gno/pkgs/bft/rpc/client"
13
+ "github.com/gnolang/gno/pkgs/crypto"
13
14
"github.com/gnolang/gno/pkgs/std"
14
15
15
16
"github.com/gorilla/mux"
@@ -35,16 +36,15 @@ type AuthAccount struct {
35
36
}
36
37
37
38
type CosmosAccount struct {
38
- Type string `json:"@type"`
39
- Address string `json:"address"`
40
- PubKey AuthKey `json:"pub_key"`
41
- AccountNumber string `json:"account_number"`
42
- Sequence string `json:"sequence"`
39
+ Type string `json:"@type"`
40
+ Address crypto. Address `json:"address"`
41
+ PubKey crypto. PubKey `json:"pub_key"`
42
+ AccountNumber uint64 `json:"account_number"`
43
+ Sequence uint64 `json:"sequence"`
43
44
}
44
45
45
- type AuthKey struct {
46
- Type string `json:"@type"`
47
- Key string `json:"key"`
46
+ type GnoAccount struct {
47
+ std.BaseAccount
48
48
}
49
49
50
50
func GnoRenderQueryHandler (cli client.ABCIClient ) http.HandlerFunc {
@@ -82,33 +82,32 @@ func AuthQueryHandler(cli client.ABCIClient) http.HandlerFunc {
82
82
return
83
83
}
84
84
85
- var account std. Account
85
+ var account GnoAccount
86
86
err = amino .UnmarshalJSON (res .Response .Data , & account )
87
87
if err != nil {
88
88
writeError (w , err )
89
89
return
90
90
}
91
91
92
- if account == nil {
92
+ if account . Address . IsZero () {
93
93
w .WriteHeader (http .StatusNotFound )
94
94
return
95
95
}
96
96
97
97
result := AuthAccount {
98
98
Account : CosmosAccount {
99
- Type : "/cosmos.auth.v1beta1.BaseAccount" ,
100
- Address : account .GetAddress ().String (),
101
- PubKey : AuthKey {
102
- Type : "/tm.PubKeySecp256k1" ,
103
- Key : base64 .StdEncoding .EncodeToString (account .GetPubKey ().Bytes ()),
104
- },
105
- AccountNumber : strconv .FormatUint (account .GetAccountNumber (), 10 ),
106
- Sequence : strconv .FormatUint (account .GetSequence (), 10 ),
99
+ Type : "/cosmos.auth.v1beta1.BaseAccount" ,
100
+ Address : account .GetAddress (),
101
+ PubKey : account .GetPubKey (),
102
+ AccountNumber : account .GetAccountNumber (),
103
+ Sequence : account .GetSequence (),
107
104
},
108
105
}
106
+
107
+ json , _ := amino .MarshalJSONIndent (result , "" , " " )
109
108
w .WriteHeader (http .StatusOK )
110
109
w .Header ().Set ("Content-Type" , "application/json" )
111
- json . NewEncoder ( w ). Encode ( result )
110
+ fmt . Fprint ( w , string ( json ) )
112
111
}
113
112
}
114
113
0 commit comments