Skip to content

Commit 331bdcd

Browse files
committed
fix format
1 parent 9f2d8e4 commit 331bdcd

File tree

5 files changed

+74
-38
lines changed

5 files changed

+74
-38
lines changed

proto/restake/v1beta1/tx.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ message MsgClaimRewards {
1818
option (cosmos.msg.v1.signer) = "locker_address";
1919
option (amino.name) = "restake/MsgClaimRewards";
2020

21-
// lockerAddress is the address that will claim the rewards.
21+
// locker_address is the address that will claim the rewards.
2222
string locker_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
2323

2424
// key is the key that want to claim rewards from.

x/restake/client/cli/query.go

Lines changed: 65 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,37 @@ func GetQueryCmd() *cobra.Command {
2121
}
2222

2323
queryCmd.AddCommand(
24-
GetQueryCmdKey(),
2524
GetQueryCmdKeys(),
25+
GetQueryCmdKey(),
2626
GetQueryCmdRewards(),
2727
GetQueryCmdReward(),
28-
GetQueryCmdLocks(),
2928
GetQueryCmdLock(),
29+
GetQueryCmdLocks(),
3030
)
3131

3232
return queryCmd
3333
}
3434

35-
// GetQueryCmdKey implements the key query command.
36-
func GetQueryCmdKey() *cobra.Command {
35+
// GetQueryCmdKeys implements the keys query command.
36+
func GetQueryCmdKeys() *cobra.Command {
3737
cmd := &cobra.Command{
38-
Use: "key [name]",
39-
Short: "shows information of the key",
40-
Args: cobra.ExactArgs(1),
38+
Use: "keys",
39+
Short: "shows all keys",
40+
Args: cobra.NoArgs,
4141
RunE: func(cmd *cobra.Command, args []string) error {
42-
clientCtx := client.GetClientContextFromCmd(cmd)
42+
clientCtx, err := client.GetClientQueryContext(cmd)
43+
if err != nil {
44+
return err
45+
}
46+
4347
queryClient := types.NewQueryClient(clientCtx)
4448

45-
res, err := queryClient.Key(
46-
context.Background(),
47-
&types.QueryKeyRequest{
48-
Key: args[0],
49-
},
50-
)
49+
pageReq, err := client.ReadPageRequest(cmd.Flags())
50+
if err != nil {
51+
return err
52+
}
53+
54+
res, err := queryClient.Keys(context.Background(), &types.QueryKeysRequest{Pagination: pageReq})
5155
if err != nil {
5256
return err
5357
}
@@ -56,27 +60,32 @@ func GetQueryCmdKey() *cobra.Command {
5660
},
5761
}
5862

63+
flags.AddPaginationFlagsToCmd(cmd, "keys")
5964
flags.AddQueryFlagsToCmd(cmd)
6065

6166
return cmd
6267
}
6368

64-
// GetQueryCmdKeys implements the keys query command.
65-
func GetQueryCmdKeys() *cobra.Command {
69+
// GetQueryCmdKey implements the key query command.
70+
func GetQueryCmdKey() *cobra.Command {
6671
cmd := &cobra.Command{
67-
Use: "keys",
68-
Short: "shows all keys",
69-
Args: cobra.NoArgs,
72+
Use: "key [name]",
73+
Short: "shows information of the key",
74+
Args: cobra.ExactArgs(1),
7075
RunE: func(cmd *cobra.Command, args []string) error {
71-
clientCtx := client.GetClientContextFromCmd(cmd)
72-
queryClient := types.NewQueryClient(clientCtx)
73-
74-
pageReq, err := client.ReadPageRequest(cmd.Flags())
76+
clientCtx, err := client.GetClientQueryContext(cmd)
7577
if err != nil {
7678
return err
7779
}
7880

79-
res, err := queryClient.Keys(context.Background(), &types.QueryKeysRequest{Pagination: pageReq})
81+
queryClient := types.NewQueryClient(clientCtx)
82+
83+
res, err := queryClient.Key(
84+
context.Background(),
85+
&types.QueryKeyRequest{
86+
Key: args[0],
87+
},
88+
)
8089
if err != nil {
8190
return err
8291
}
@@ -85,7 +94,6 @@ func GetQueryCmdKeys() *cobra.Command {
8594
},
8695
}
8796

88-
flags.AddPaginationFlagsToCmd(cmd, "keys")
8997
flags.AddQueryFlagsToCmd(cmd)
9098

9199
return cmd
@@ -98,11 +106,21 @@ func GetQueryCmdRewards() *cobra.Command {
98106
Short: "shows all rewards of an address",
99107
Args: cobra.ExactArgs(1),
100108
RunE: func(cmd *cobra.Command, args []string) error {
101-
clientCtx := client.GetClientContextFromCmd(cmd)
109+
clientCtx, err := client.GetClientQueryContext(cmd)
110+
if err != nil {
111+
return err
112+
}
113+
102114
queryClient := types.NewQueryClient(clientCtx)
103115

116+
pageReq, err := client.ReadPageRequest(cmd.Flags())
117+
if err != nil {
118+
return err
119+
}
120+
104121
res, err := queryClient.Rewards(context.Background(), &types.QueryRewardsRequest{
105122
LockerAddress: args[0],
123+
Pagination: pageReq,
106124
})
107125
if err != nil {
108126
return err
@@ -125,7 +143,11 @@ func GetQueryCmdReward() *cobra.Command {
125143
Short: "shows the reward of an locker address for the key",
126144
Args: cobra.ExactArgs(2),
127145
RunE: func(cmd *cobra.Command, args []string) error {
128-
clientCtx := client.GetClientContextFromCmd(cmd)
146+
clientCtx, err := client.GetClientQueryContext(cmd)
147+
if err != nil {
148+
return err
149+
}
150+
129151
queryClient := types.NewQueryClient(clientCtx)
130152

131153
res, err := queryClient.Reward(context.Background(), &types.QueryRewardRequest{
@@ -152,11 +174,21 @@ func GetQueryCmdLocks() *cobra.Command {
152174
Short: "shows all locks of an locker address",
153175
Args: cobra.ExactArgs(1),
154176
RunE: func(cmd *cobra.Command, args []string) error {
155-
clientCtx := client.GetClientContextFromCmd(cmd)
177+
clientCtx, err := client.GetClientQueryContext(cmd)
178+
if err != nil {
179+
return err
180+
}
181+
156182
queryClient := types.NewQueryClient(clientCtx)
157183

184+
pageReq, err := client.ReadPageRequest(cmd.Flags())
185+
if err != nil {
186+
return err
187+
}
188+
158189
res, err := queryClient.Locks(context.Background(), &types.QueryLocksRequest{
159190
LockerAddress: args[0],
191+
Pagination: pageReq,
160192
})
161193
if err != nil {
162194
return err
@@ -179,7 +211,11 @@ func GetQueryCmdLock() *cobra.Command {
179211
Short: "shows the lock of an locker address for the key",
180212
Args: cobra.ExactArgs(2),
181213
RunE: func(cmd *cobra.Command, args []string) error {
182-
clientCtx := client.GetClientContextFromCmd(cmd)
214+
clientCtx, err := client.GetClientQueryContext(cmd)
215+
if err != nil {
216+
return err
217+
}
218+
183219
queryClient := types.NewQueryClient(clientCtx)
184220

185221
res, err := queryClient.Lock(context.Background(), &types.QueryLockRequest{

x/restake/keeper/grpc_query.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ func (k Querier) Rewards(
7171
return nil, err
7272
}
7373

74-
keyStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.LocksByAddressStoreKey(addr))
74+
lockStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.LocksByAddressStoreKey(addr))
7575

7676
filteredRewards, pageRes, err := query.GenericFilteredPaginate(
7777
k.cdc,
78-
keyStore,
78+
lockStore,
7979
req.Pagination,
8080
func(key []byte, s *types.Lock) (*types.Reward, error) {
8181
reward := k.getReward(ctx, *s)
@@ -124,11 +124,11 @@ func (k Querier) Locks(
124124
return nil, err
125125
}
126126

127-
keyStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.LocksByAddressStoreKey(addr))
127+
lockStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.LocksByAddressStoreKey(addr))
128128

129129
filteredLocks, pageRes, err := query.GenericFilteredPaginate(
130130
k.cdc,
131-
keyStore,
131+
lockStore,
132132
req.Pagination,
133133
func(key []byte, s *types.Lock) (*types.LockResponse, error) {
134134
if !k.IsActiveKey(ctx, s.Key) || s.Amount.IsZero() {

x/restake/types/msgs.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package types
22

33
import (
44
sdk "github.com/cosmos/cosmos-sdk/types"
5+
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
56
)
67

78
var _ sdk.Msg = &MsgClaimRewards{}
@@ -36,9 +37,8 @@ func (m MsgClaimRewards) GetSignBytes() []byte {
3637

3738
// ValidateBasic implements the sdk.Msg interface.
3839
func (m MsgClaimRewards) ValidateBasic() error {
39-
_, err := sdk.AccAddressFromBech32(m.LockerAddress)
40-
if err != nil {
41-
return err
40+
if _, err := sdk.AccAddressFromBech32(m.LockerAddress); err != nil {
41+
return sdkerrors.ErrInvalidAddress.Wrapf("invalid locker address: %s", err)
4242
}
4343

4444
if len(m.Key) == 0 {

x/restake/types/tx.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)