Skip to content

Commit 1410734

Browse files
authored
Merge branch 'restake-init' into master-feed
2 parents abc3bb4 + 9e862da commit 1410734

22 files changed

+386
-351
lines changed

proto/restake/v1beta1/query.proto

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ service Query {
2222

2323
// Rewards returns rewards for a specific address.
2424
rpc Rewards(QueryRewardsRequest) returns (QueryRewardsResponse) {
25-
option (google.api.http).get = "/restake/v1beta1/lockers/{locker_address}/rewards";
25+
option (google.api.http).get = "/restake/v1beta1/stakers/{staker_address}/rewards";
2626
}
2727

2828
// Reward returns a reward for a specific address and a key.
2929
rpc Reward(QueryRewardRequest) returns (QueryRewardResponse) {
30-
option (google.api.http).get = "/restake/v1beta1/lockers/{locker_address}/rewards/{key}";
30+
option (google.api.http).get = "/restake/v1beta1/stakers/{staker_address}/rewards/{key}";
3131
}
3232

3333
// Locks returns all lock information for a specific address.
3434
rpc Locks(QueryLocksRequest) returns (QueryLocksResponse) {
35-
option (google.api.http).get = "/restake/v1beta1/lockers/{locker_address}/locks";
35+
option (google.api.http).get = "/restake/v1beta1/stakers/{staker_address}/locks";
3636
}
3737

3838
// Lock returns a lock information for a specific address and a key.
3939
rpc Lock(QueryLockRequest) returns (QueryLockResponse) {
40-
option (google.api.http).get = "/restake/v1beta1/lockers/{locker_address}/locks/{key}";
40+
option (google.api.http).get = "/restake/v1beta1/stakers/{staker_address}/locks/{key}";
4141
}
4242
}
4343

@@ -70,16 +70,16 @@ message QueryKeyResponse {
7070

7171
// QueryRewardsRequest represents the request type for the Query/Rewards RPC method.
7272
message QueryRewardsRequest {
73-
// locker_address is the target address to query rewards.
74-
string locker_address = 1;
73+
// staker_address is the target address to query rewards.
74+
string staker_address = 1;
7575

7676
// pagination defines optional pagination parameters.
7777
cosmos.base.query.v1beta1.PageRequest pagination = 2;
7878
}
7979

8080
// QueryRewardsResponse represents the response type for the Query/Rewards RPC method.
8181
message QueryRewardsResponse {
82-
// rewards is a list of rewards for the locker.
82+
// rewards is a list of rewards for the staker.
8383
repeated Reward rewards = 1;
8484

8585
// pagination defines pagination parameters in the response.
@@ -88,31 +88,31 @@ message QueryRewardsResponse {
8888

8989
// QueryRewardRequest represents the request type for the Query/Reward RPC method.
9090
message QueryRewardRequest {
91-
// locker_address is the target address to query reward.
92-
string locker_address = 1;
91+
// staker_address is the target address to query reward.
92+
string staker_address = 1;
9393

9494
// key is the target key to query reward.
9595
string key = 2;
9696
}
9797

9898
// QueryRewardResponse represents the response type for the Query/Reward RPC method.
9999
message QueryRewardResponse {
100-
// reward is the reward for the locker and the key.
100+
// reward is the reward for the staker and the key.
101101
Reward reward = 1 [(gogoproto.nullable) = false];
102102
}
103103

104104
// QueryLocksRequest represents the request type for the Query/Locks RPC method.
105105
message QueryLocksRequest {
106-
// locker_address is the target address to query locks.
107-
string locker_address = 1;
106+
// staker_address is the target address to query locks.
107+
string staker_address = 1;
108108

109109
// pagination defines optional pagination parameters.
110110
cosmos.base.query.v1beta1.PageRequest pagination = 2;
111111
}
112112

113113
// QueryLocksResponse represents the response type for the Query/Locks RPC method.
114114
message QueryLocksResponse {
115-
// locks is a list of locks of the locker.
115+
// locks is a list of locks of the staker.
116116
repeated LockResponse locks = 1;
117117

118118
// pagination defines pagination parameters in the response.
@@ -121,15 +121,15 @@ message QueryLocksResponse {
121121

122122
// QueryLockRequest represents the request type for the Query/Lock RPC method.
123123
message QueryLockRequest {
124-
// locker_address is the target address to query lock.
125-
string locker_address = 1;
124+
// staker_address is the target address to query lock.
125+
string staker_address = 1;
126126

127127
// key is the target key to query reward.
128128
string key = 2;
129129
}
130130

131131
// QueryLockResponse represents the response type for the Query/Lock RPC method.
132132
message QueryLockResponse {
133-
// lock is the lock of the locker and the key.
133+
// lock is the lock of the staker and the key.
134134
LockResponse lock = 1 [(gogoproto.nullable) = false];
135135
}

proto/restake/v1beta1/tx.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ service Msg {
1515

1616
// MsgClaimRewards is the request message type for claiming rewards.
1717
message MsgClaimRewards {
18-
option (cosmos.msg.v1.signer) = "locker_address";
18+
option (cosmos.msg.v1.signer) = "staker_address";
1919
option (amino.name) = "restake/MsgClaimRewards";
2020

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

2424
// key is the key that want to claim rewards from.
2525
string key = 2;

proto/restake/v1beta1/types.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ message Key {
4949
message Lock {
5050
option (gogoproto.equal) = true;
5151

52-
// locker_address is the owner's address of the locker.
53-
string locker_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
52+
// staker_address is the owner's address of the staker.
53+
string staker_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
5454

5555
// key is the key that this lock is locked to.
5656
string key = 2;

x/restake/client/cli/query.go

Lines changed: 80 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package cli
22

33
import (
4-
"context"
5-
64
"github.com/cosmos/cosmos-sdk/client"
75
"github.com/cosmos/cosmos-sdk/client/flags"
86
"github.com/spf13/cobra"
@@ -21,33 +19,37 @@ func GetQueryCmd() *cobra.Command {
2119
}
2220

2321
queryCmd.AddCommand(
24-
GetQueryCmdKey(),
2522
GetQueryCmdKeys(),
23+
GetQueryCmdKey(),
2624
GetQueryCmdRewards(),
2725
GetQueryCmdReward(),
28-
GetQueryCmdLocks(),
2926
GetQueryCmdLock(),
27+
GetQueryCmdLocks(),
3028
)
3129

3230
return queryCmd
3331
}
3432

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

45-
res, err := queryClient.Key(
46-
context.Background(),
47-
&types.QueryKeyRequest{
48-
Key: args[0],
49-
},
50-
)
47+
pageReq, err := client.ReadPageRequest(cmd.Flags())
48+
if err != nil {
49+
return err
50+
}
51+
52+
res, err := queryClient.Keys(cmd.Context(), &types.QueryKeysRequest{Pagination: pageReq})
5153
if err != nil {
5254
return err
5355
}
@@ -56,27 +58,32 @@ func GetQueryCmdKey() *cobra.Command {
5658
},
5759
}
5860

61+
flags.AddPaginationFlagsToCmd(cmd, "keys")
5962
flags.AddQueryFlagsToCmd(cmd)
6063

6164
return cmd
6265
}
6366

64-
// GetQueryCmdKeys implements the keys query command.
65-
func GetQueryCmdKeys() *cobra.Command {
67+
// GetQueryCmdKey implements the key query command.
68+
func GetQueryCmdKey() *cobra.Command {
6669
cmd := &cobra.Command{
67-
Use: "keys",
68-
Short: "shows all keys",
69-
Args: cobra.NoArgs,
70+
Use: "key [name]",
71+
Short: "shows information of the key",
72+
Args: cobra.ExactArgs(1),
7073
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())
74+
clientCtx, err := client.GetClientQueryContext(cmd)
7575
if err != nil {
7676
return err
7777
}
7878

79-
res, err := queryClient.Keys(context.Background(), &types.QueryKeysRequest{Pagination: pageReq})
79+
queryClient := types.NewQueryClient(clientCtx)
80+
81+
res, err := queryClient.Key(
82+
cmd.Context(),
83+
&types.QueryKeyRequest{
84+
Key: args[0],
85+
},
86+
)
8087
if err != nil {
8188
return err
8289
}
@@ -85,7 +92,6 @@ func GetQueryCmdKeys() *cobra.Command {
8592
},
8693
}
8794

88-
flags.AddPaginationFlagsToCmd(cmd, "keys")
8995
flags.AddQueryFlagsToCmd(cmd)
9096

9197
return cmd
@@ -94,15 +100,25 @@ func GetQueryCmdKeys() *cobra.Command {
94100
// GetQueryCmdRewards implements the rewards query command.
95101
func GetQueryCmdRewards() *cobra.Command {
96102
cmd := &cobra.Command{
97-
Use: "rewards [locker_address]",
103+
Use: "rewards [staker_address]",
98104
Short: "shows all rewards of an address",
99105
Args: cobra.ExactArgs(1),
100106
RunE: func(cmd *cobra.Command, args []string) error {
101-
clientCtx := client.GetClientContextFromCmd(cmd)
107+
clientCtx, err := client.GetClientQueryContext(cmd)
108+
if err != nil {
109+
return err
110+
}
111+
102112
queryClient := types.NewQueryClient(clientCtx)
103113

104-
res, err := queryClient.Rewards(context.Background(), &types.QueryRewardsRequest{
105-
LockerAddress: args[0],
114+
pageReq, err := client.ReadPageRequest(cmd.Flags())
115+
if err != nil {
116+
return err
117+
}
118+
119+
res, err := queryClient.Rewards(cmd.Context(), &types.QueryRewardsRequest{
120+
StakerAddress: args[0],
121+
Pagination: pageReq,
106122
})
107123
if err != nil {
108124
return err
@@ -121,15 +137,19 @@ func GetQueryCmdRewards() *cobra.Command {
121137
// GetQueryCmdReward implements the reward query command.
122138
func GetQueryCmdReward() *cobra.Command {
123139
cmd := &cobra.Command{
124-
Use: "reward [locker_address] [key_name]",
125-
Short: "shows the reward of an locker address for the key",
140+
Use: "reward [staker_address] [key_name]",
141+
Short: "shows the reward of an staker address for the key",
126142
Args: cobra.ExactArgs(2),
127143
RunE: func(cmd *cobra.Command, args []string) error {
128-
clientCtx := client.GetClientContextFromCmd(cmd)
144+
clientCtx, err := client.GetClientQueryContext(cmd)
145+
if err != nil {
146+
return err
147+
}
148+
129149
queryClient := types.NewQueryClient(clientCtx)
130150

131-
res, err := queryClient.Reward(context.Background(), &types.QueryRewardRequest{
132-
LockerAddress: args[0],
151+
res, err := queryClient.Reward(cmd.Context(), &types.QueryRewardRequest{
152+
StakerAddress: args[0],
133153
Key: args[1],
134154
})
135155
if err != nil {
@@ -148,15 +168,25 @@ func GetQueryCmdReward() *cobra.Command {
148168
// GetQueryCmdLocks implements the locks query command.
149169
func GetQueryCmdLocks() *cobra.Command {
150170
cmd := &cobra.Command{
151-
Use: "locks [locker_address]",
152-
Short: "shows all locks of an locker address",
171+
Use: "locks [staker_address]",
172+
Short: "shows all locks of an staker address",
153173
Args: cobra.ExactArgs(1),
154174
RunE: func(cmd *cobra.Command, args []string) error {
155-
clientCtx := client.GetClientContextFromCmd(cmd)
175+
clientCtx, err := client.GetClientQueryContext(cmd)
176+
if err != nil {
177+
return err
178+
}
179+
156180
queryClient := types.NewQueryClient(clientCtx)
157181

158-
res, err := queryClient.Locks(context.Background(), &types.QueryLocksRequest{
159-
LockerAddress: args[0],
182+
pageReq, err := client.ReadPageRequest(cmd.Flags())
183+
if err != nil {
184+
return err
185+
}
186+
187+
res, err := queryClient.Locks(cmd.Context(), &types.QueryLocksRequest{
188+
StakerAddress: args[0],
189+
Pagination: pageReq,
160190
})
161191
if err != nil {
162192
return err
@@ -175,15 +205,19 @@ func GetQueryCmdLocks() *cobra.Command {
175205
// GetQueryCmdLock implements the lock query command.
176206
func GetQueryCmdLock() *cobra.Command {
177207
cmd := &cobra.Command{
178-
Use: "lock [locker_address] [key_name]",
179-
Short: "shows the lock of an locker address for the key",
208+
Use: "lock [staker_address] [key_name]",
209+
Short: "shows the lock of an staker address for the key",
180210
Args: cobra.ExactArgs(2),
181211
RunE: func(cmd *cobra.Command, args []string) error {
182-
clientCtx := client.GetClientContextFromCmd(cmd)
212+
clientCtx, err := client.GetClientQueryContext(cmd)
213+
if err != nil {
214+
return err
215+
}
216+
183217
queryClient := types.NewQueryClient(clientCtx)
184218

185-
res, err := queryClient.Lock(context.Background(), &types.QueryLockRequest{
186-
LockerAddress: args[0],
219+
res, err := queryClient.Lock(cmd.Context(), &types.QueryLockRequest{
220+
StakerAddress: args[0],
187221
Key: args[1],
188222
})
189223
if err != nil {

x/restake/client/cli/tx.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func GetTxCmdClaimRewards() *cobra.Command {
5353
pageSize := uint64(1000)
5454
for {
5555
respRewards, err := queryClient.Rewards(context.Background(), &types.QueryRewardsRequest{
56-
LockerAddress: clientCtx.GetFromAddress().String(),
56+
StakerAddress: clientCtx.GetFromAddress().String(),
5757
Pagination: &query.PageRequest{
5858
Offset: offset,
5959
Limit: pageSize,

0 commit comments

Comments
 (0)