Skip to content

Commit 828ccc6

Browse files
committed
additional proto fields and query refactor
1 parent 9cb6a55 commit 828ccc6

File tree

9 files changed

+1468
-420
lines changed

9 files changed

+1468
-420
lines changed

proto/umee/incentive/v1/genesis.proto

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@ import "umee/incentive/v1/incentive.proto";
1010
// GenesisState defines the x/incentive module's genesis state.
1111
message GenesisState {
1212
Params params = 1 [(gogoproto.nullable) = false];
13-
repeated IncentiveProgram programs = 2 [(gogoproto.nullable) = false];
14-
uint32 next_program_id = 3;
15-
repeated cosmos.base.v1beta1.Coin total_bonded = 4 [
13+
repeated IncentiveProgram completed_programs = 2 [(gogoproto.nullable) = false];
14+
repeated IncentiveProgram ongoing_programs = 3 [(gogoproto.nullable) = false];
15+
repeated IncentiveProgram upcoming_programs = 4 [(gogoproto.nullable) = false];
16+
uint32 next_program_id = 5;
17+
uint64 last_rewards_time = 6;
18+
repeated cosmos.base.v1beta1.Coin total_bonded = 7 [
1619
(gogoproto.nullable) = false,
1720
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
1821
];
19-
repeated BondAmount bond_amounts = 5 [(gogoproto.nullable) = false];
20-
repeated PendingReward pending_rewards = 6 [(gogoproto.nullable) = false];
21-
repeated RewardBasis reward_bases = 7 [(gogoproto.nullable) = false];
22-
repeated RewardAccumulator reward_accumulators = 8 [(gogoproto.nullable) = false];
23-
repeated Unbonding unbondings = 9 [(gogoproto.nullable) = false];
22+
repeated BondAmount bond_amounts = 8 [(gogoproto.nullable) = false];
23+
repeated PendingReward pending_rewards = 9 [(gogoproto.nullable) = false];
24+
repeated RewardBasis reward_bases = 10 [(gogoproto.nullable) = false];
25+
repeated RewardAccumulator reward_accumulators = 11 [(gogoproto.nullable) = false];
26+
repeated Unbonding unbondings = 12 [(gogoproto.nullable) = false];
2427
}
2528

2629
// BondAmount tracks the amount of coins of one uToken denomination bonded to a

proto/umee/incentive/v1/incentive.proto

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ message Params {
1313
// max_unbondings defines the maximum amount of concurrent unbondings an address can have.
1414
uint32 max_unbondings = 1;
1515

16-
// unbonding_duration_long defines the unbonding duration (in blocks) of the long tier.
16+
// unbonding_duration_long defines the unbonding duration (in seconds) of the long tier.
1717
uint64 unbonding_duration_long = 2;
1818

19-
// unbonding_duration_middle defines the unbonding duration (in blocks) of the middle tier.
19+
// unbonding_duration_middle defines the unbonding duration (in seconds) of the middle tier.
2020
uint64 unbonding_duration_middle = 3;
2121

22-
// unbonding_duration_short defines the unbonding duration (in blocks) of the short tier.
22+
// unbonding_duration_short defines the unbonding duration (in seconds) of the short tier.
2323
uint64 unbonding_duration_short = 4;
2424

2525
// The tier_weight_short defines how the proportion of rewards assets locked
@@ -48,10 +48,10 @@ message IncentiveProgram {
4848
// It is zero when the program is being proposed by governance.
4949
uint32 id = 1;
5050

51-
// start_height is the block height at which the incentives begin.
52-
uint64 start_height = 2;
51+
// start_time is the block time at which the incentives begin.
52+
uint64 start_time = 2;
5353

54-
// duration is the length of the incentive program in blocks.
54+
// duration is the length of the incentive program in seconds.
5555
uint64 duration = 3;
5656

5757
// denom defines the denomination of the incentivized collateral uToken.

proto/umee/incentive/v1/query.proto

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,52 +11,88 @@ option go_package = "github.com/umee-network/umee/v3/x/incentive";
1111
// Query defines the gRPC querier service.
1212
service Query {
1313
// Params queries the parameters of the x/incentive module.
14-
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
14+
rpc Params(QueryParams) returns (QueryParamsResponse) {
1515
option (google.api.http).get = "/umee/incentive/v1/params";
1616
}
1717

18-
// IncentivePrograms queries for all incentives programs that have been passed
19-
// by governance, including upcoming and completed ones.
20-
rpc IncentivePrograms(QueryIncentiveProgramsRequest)
21-
returns (QueryIncentiveProgramsResponse) {
22-
option (google.api.http).get = "/umee/incentive/v1/incentive_programs";
18+
// CompletedIncentivePrograms queries for all incentives programs that have been passed
19+
// by governance, and either run to completion or expired immediately due to not being funded.
20+
rpc CompletedIncentivePrograms(QueryCompletedIncentivePrograms)
21+
returns (QueryCompletedIncentiveProgramsResponse) {
22+
option (google.api.http).get = "/umee/incentive/v1/incentive_programs/completed";
23+
}
24+
25+
// OngoingIncentivePrograms queries for all incentives programs that have been passed
26+
// by governance, funded, and started but not yet completed.
27+
rpc OngoingIncentivePrograms(QueryOngoingIncentivePrograms)
28+
returns (QueryOngoingIncentiveProgramsResponse) {
29+
option (google.api.http).get = "/umee/incentive/v1/incentive_programs/ongoing";
30+
}
31+
32+
// UpcomingIncentivePrograms queries for all incentives programs that have been passed
33+
// by governance, but not yet started. They may or may not have been funded.
34+
rpc UpcomingIncentivePrograms(QueryUpcomingIncentivePrograms)
35+
returns (QueryUpcomingIncentiveProgramsResponse) {
36+
option (google.api.http).get = "/umee/incentive/v1/incentive_programs/upcoming";
2337
}
2438

2539
// IncentiveProgram queries a single incentive program by ID.
26-
rpc IncentiveProgram(QueryIncentiveProgramRequest)
40+
rpc IncentiveProgram(QueryIncentiveProgram)
2741
returns (QueryIncentiveProgramResponse) {
2842
option (google.api.http).get = "/umee/incentive/v1/incentive_program/{id}";
2943
}
3044
}
3145

32-
// QueryParamsRequest defines the request structure for the Params gRPC service
46+
// QueryParams defines the request structure for the Params gRPC service
3347
// handler.
34-
message QueryParamsRequest {}
48+
message QueryParams {}
3549

3650
// QueryParamsResponse defines the response structure for the Params gRPC
3751
// service handler.
3852
message QueryParamsResponse {
3953
Params params = 1 [(gogoproto.nullable) = false];
4054
}
4155

42-
// QueryIncentiveProgramsRequest defines the request structure for the IncentivePrograms
43-
// gRPC service handler.
44-
message QueryIncentiveProgramsRequest {
56+
// QueryUpcomingIncentivePrograms defines the request structure for the
57+
// OngoingIncentivePrograms and UpcomingIncentivePrograms gRPC service handlers.
58+
message QueryUpcomingIncentivePrograms {
59+
}
60+
61+
// QueryUpcomingIncentiveProgramsResponse defines the response structure for the
62+
// OngoingIncentivePrograms and UpcomingIncentivePrograms gRPC service handlers.
63+
message QueryUpcomingIncentiveProgramsResponse {
64+
repeated IncentiveProgram programs = 1 [(gogoproto.nullable) = false];
65+
}
66+
67+
// QueryOngoingIncentivePrograms defines the request structure for the
68+
// OngoingIncentivePrograms and UpcomingIncentivePrograms gRPC service handlers.
69+
message QueryOngoingIncentivePrograms {
70+
}
71+
72+
// QueryOngoingIncentiveProgramsResponse defines the response structure for the
73+
// OngoingIncentivePrograms and UpcomingIncentivePrograms gRPC service handlers.
74+
message QueryOngoingIncentiveProgramsResponse {
75+
repeated IncentiveProgram programs = 1 [(gogoproto.nullable) = false];
76+
}
77+
78+
// QueryCompletedIncentivePrograms defines the request structure for the
79+
// CompletedIncentivePrograms gRPC service handler.
80+
message QueryCompletedIncentivePrograms {
4581
// pagination defines an optional pagination for the request.
4682
cosmos.base.query.v1beta1.PageRequest pagination = 1;
4783
}
4884

49-
// QueryIncentiveProgramsResponse defines the response structure for the
50-
// IncentivePrograms gRPC service handler.
51-
message QueryIncentiveProgramsResponse {
85+
// QueryCompletedIncentiveProgramsResponse defines the response structure for the
86+
// CompletedIncentivePrograms gRPC service handler.
87+
message QueryCompletedIncentiveProgramsResponse {
5288
repeated IncentiveProgram programs = 1 [(gogoproto.nullable) = false];
5389
// pagination defines an optional pagination for the request.
5490
cosmos.base.query.v1beta1.PageRequest pagination = 2;
5591
}
5692

57-
// QueryIncentiveProgramRequest defines the request structure for the IncentiveProgram
93+
// QueryIncentiveProgram defines the request structure for the IncentiveProgram
5894
// gRPC service handler.
59-
message QueryIncentiveProgramRequest {
95+
message QueryIncentiveProgram {
6096
// ID specifies which program to query for
6197
uint32 id = 1;
6298
}

x/incentive/genesis.go

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ import (
1010
// NewGenesisState creates a new GenesisState object
1111
func NewGenesisState(
1212
params Params,
13-
programs []IncentiveProgram,
13+
upcomingPrograms []IncentiveProgram,
14+
ongoingPrograms []IncentiveProgram,
15+
completedPrograms []IncentiveProgram,
1416
nextID uint32,
17+
lastRewardsTime uint64,
1518
totalBonded sdk.Coins,
1619
bondAmounts []BondAmount,
1720
pendingRewards []PendingReward,
@@ -21,7 +24,10 @@ func NewGenesisState(
2124
) *GenesisState {
2225
return &GenesisState{
2326
Params: params,
24-
Programs: programs,
27+
UpcomingPrograms: upcomingPrograms,
28+
OngoingPrograms: ongoingPrograms,
29+
CompletedPrograms: completedPrograms,
30+
LastRewardsTime: lastRewardsTime,
2531
NextProgramId: nextID,
2632
TotalBonded: totalBonded,
2733
BondAmounts: bondAmounts,
@@ -35,8 +41,9 @@ func NewGenesisState(
3541
// DefaultGenesis returns the default genesis state of the x/incentive module.
3642
func DefaultGenesis() *GenesisState {
3743
return &GenesisState{
38-
Params: DefaultParams(),
39-
NextProgramId: 1,
44+
Params: DefaultParams(),
45+
NextProgramId: 1,
46+
LastRewardsTime: 0,
4047
}
4148
}
4249

@@ -50,7 +57,17 @@ func (gs GenesisState) Validate() error {
5057
// TODO: Finish validation logic - includes in-progress programs
5158
// all ID < NextID (and NextID = len(programs) + 1)
5259

53-
for _, p := range gs.Programs {
60+
for _, p := range gs.UpcomingPrograms {
61+
if err := p.Validate(); err != nil {
62+
return err
63+
}
64+
}
65+
for _, p := range gs.OngoingPrograms {
66+
if err := p.Validate(); err != nil {
67+
return err
68+
}
69+
}
70+
for _, p := range gs.CompletedPrograms {
5471
if err := p.Validate(); err != nil {
5572
return err
5673
}

0 commit comments

Comments
 (0)