Skip to content

Commit

Permalink
Commitment refactoring (#448)
Browse files Browse the repository at this point in the history
* commitment refactoring update

* add codec for MsgClaimVesting

* resolve unit test

* fix upgrade-assure build issue

* add wasm binding for commitment claim vesting

---------

Co-authored-by: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com>
  • Loading branch information
jelysn and cosmic-vagabond authored Apr 8, 2024
1 parent 27e529d commit 62f8807
Show file tree
Hide file tree
Showing 46 changed files with 3,352 additions and 1,112 deletions.
3 changes: 1 addition & 2 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ genesis:
vesting_infos:
- base_denom: ueden
vesting_denom: uelys
epoch_identifier: tenseconds
num_epochs: "100"
num_blocks: "100"
vest_now_factor: "90"
num_max_vestings: "10"
commitments:
Expand Down
98 changes: 66 additions & 32 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39275,16 +39275,31 @@ paths:
type: string
vesting_denom:
type: string
epoch_identifier:
type: string
num_epochs:
num_blocks:
type: string
format: int64
vest_now_factor:
type: string
num_max_vestings:
type: string
format: int64
total_committed:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the
custom method

signatures required by gogoproto.
description: >-
QueryParamsResponse is response type for the Query/Params RPC
method.
Expand Down Expand Up @@ -39385,14 +39400,12 @@ paths:
type: string
total_amount:
type: string
unvested_amount:
type: string
epoch_identifier:
claimed_amount:
type: string
num_epochs:
num_blocks:
type: string
format: int64
current_epoch:
start_block:
type: string
format: int64
vest_started_timestamp:
Expand Down Expand Up @@ -84065,14 +84078,12 @@ definitions:
type: string
total_amount:
type: string
unvested_amount:
type: string
epoch_identifier:
claimed_amount:
type: string
num_epochs:
num_blocks:
type: string
format: int64
current_epoch:
start_block:
type: string
format: int64
vest_started_timestamp:
Expand Down Expand Up @@ -84162,6 +84173,8 @@ definitions:
format: uint64
elys.commitment.MsgCancelVestResponse:
type: object
elys.commitment.MsgClaimVestingResponse:
type: object
elys.commitment.MsgCommitClaimedRewardsResponse:
type: object
elys.commitment.MsgCommitLiquidTokensResponse:
Expand Down Expand Up @@ -84204,16 +84217,28 @@ definitions:
type: string
vesting_denom:
type: string
epoch_identifier:
type: string
num_epochs:
num_blocks:
type: string
format: int64
vest_now_factor:
type: string
num_max_vestings:
type: string
format: int64
total_committed:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
description: Params defines the parameters for the module.
elys.commitment.QueryParamsResponse:
type: object
Expand All @@ -84231,16 +84256,31 @@ definitions:
type: string
vesting_denom:
type: string
epoch_identifier:
type: string
num_epochs:
num_blocks:
type: string
format: int64
vest_now_factor:
type: string
num_max_vestings:
type: string
format: int64
total_committed:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the custom
method

signatures required by gogoproto.
description: QueryParamsResponse is response type for the Query/Params RPC method.
elys.commitment.QueryShowCommitmentsResponse:
type: object
Expand Down Expand Up @@ -84312,14 +84352,12 @@ definitions:
type: string
total_amount:
type: string
unvested_amount:
type: string
epoch_identifier:
claimed_amount:
type: string
num_epochs:
num_blocks:
type: string
format: int64
current_epoch:
start_block:
type: string
format: int64
vest_started_timestamp:
Expand Down Expand Up @@ -84401,9 +84439,7 @@ definitions:
type: string
vesting_denom:
type: string
epoch_identifier:
type: string
num_epochs:
num_blocks:
type: string
format: int64
vest_now_factor:
Expand All @@ -84418,14 +84454,12 @@ definitions:
type: string
total_amount:
type: string
unvested_amount:
claimed_amount:
type: string
epoch_identifier:
type: string
num_epochs:
num_blocks:
type: string
format: int64
current_epoch:
start_block:
type: string
format: int64
vest_started_timestamp:
Expand Down
70 changes: 70 additions & 0 deletions proto/elys/commitment/commitments.proto
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,57 @@ message RewardsUnclaimed {
}

message VestingTokens {
string denom = 1;
string total_amount = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
string claimed_amount = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
int64 num_blocks = 5;
int64 start_block = 6;
int64 vest_started_timestamp = 7;
}


// GenesisState defines the commitment module's genesis state.
message LegacyCommitments {
string creator = 1;
repeated CommittedTokens committed_tokens = 2;
repeated cosmos.base.v1beta1.Coin rewards_unclaimed = 3 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
repeated cosmos.base.v1beta1.Coin claimed = 4 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
repeated LegacyVestingTokens vesting_tokens = 5;

repeated cosmos.base.v1beta1.Coin rewards_by_elys_unclaimed = 6 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];

repeated cosmos.base.v1beta1.Coin rewards_by_eden_unclaimed = 7 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];

repeated cosmos.base.v1beta1.Coin rewards_by_edenb_unclaimed = 8 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];

repeated cosmos.base.v1beta1.Coin rewards_by_usdc_unclaimed = 9 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

message LegacyVestingTokens {
string denom = 1;
string total_amount = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
Expand All @@ -85,4 +136,23 @@ message VestingTokens {
int64 num_epochs = 5;
int64 current_epoch = 6;
int64 vest_started_timestamp = 7;
}

message LegacyVestingInfo {
string base_denom = 1;
string vesting_denom = 2;
string epoch_identifier = 3;
int64 num_epochs = 4;
string vest_now_factor = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
int64 num_max_vestings = 6;
}

// Params defines the parameters for the module.
message LegacyParams {
option (gogoproto.goproto_stringer) = false;

repeated LegacyVestingInfo vesting_infos = 1;
}
13 changes: 9 additions & 4 deletions proto/elys/commitment/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,30 @@ syntax = "proto3";
package elys.commitment;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/elys-network/elys/x/commitment/types";

// Params defines the parameters for the module.
message Params {
option (gogoproto.goproto_stringer) = false;
repeated VestingInfo vesting_infos = 1;
repeated cosmos.base.v1beta1.Coin total_committed = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

message VestingInfo {
string base_denom = 1;
string vesting_denom = 2;
string epoch_identifier = 3;
int64 num_epochs = 4;
string vest_now_factor = 5 [
int64 num_blocks = 3;
string vest_now_factor = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
int64 num_max_vestings = 6;
int64 num_max_vestings = 5;
}

enum EarnType {
Expand Down
19 changes: 13 additions & 6 deletions proto/elys/commitment/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ option go_package = "github.com/elys-network/elys/x/commitment/types";

// Msg defines the Msg service.
service Msg {

// CommitLiquidTokens commit the tokens from user's balance
rpc CommitLiquidTokens (MsgCommitLiquidTokens) returns (MsgCommitLiquidTokensResponse);

Expand All @@ -31,6 +30,9 @@ service Msg {

// CancelVest cancel the user's vesting and the user reject to get vested tokens
rpc CancelVest (MsgCancelVest) returns (MsgCancelVestResponse);

// ClaimVesting claims already vested amount
rpc ClaimVesting (MsgClaimVesting) returns (MsgClaimVestingResponse);

// UpdateVestingInfo add/update specific vesting info by denom on Params
rpc UpdateVestingInfo (MsgUpdateVestingInfo) returns (MsgUpdateVestingInfoResponse);
Expand Down Expand Up @@ -88,6 +90,12 @@ message MsgCancelVest {

message MsgCancelVestResponse {}

message MsgClaimVesting {
string sender = 1;
}

message MsgClaimVestingResponse {}

message MsgVestNow {
string creator = 1;
string amount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
Expand All @@ -97,13 +105,12 @@ message MsgVestNow {
message MsgVestNowResponse {}

message MsgUpdateVestingInfo {
string authority = 1;
string authority = 1;
string base_denom = 2;
string vesting_denom = 3;
string epoch_identifier = 4;
int64 num_epochs = 5;
int64 vest_now_factor = 6;
int64 num_max_vestings = 7;
int64 num_blocks = 4;
int64 vest_now_factor = 5;
int64 num_max_vestings = 6;
}

message MsgUpdateVestingInfoResponse {}
Expand Down
12 changes: 6 additions & 6 deletions proto/elys/commitment/types_cw.proto
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ message QueryVestingInfoRequest {
message VestingDetail {
string id = 1;
// The total vest for the current vest
BalanceAvailable total_vest = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
BalanceAvailable total_vesting = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
// The balance that's already vested
BalanceAvailable balance_vested = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
// The remaining amount to vest
BalanceAvailable remaining_vest = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
// Remaining time to vest. Javascript timestamp.
int64 remaining_time = 5;
BalanceAvailable claimed = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
// The amount vested so far
BalanceAvailable vested_so_far = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
// Remaining blocks
int64 remaining_blocks = 5;
}

message QueryVestingInfoResponse {
Expand Down
Loading

0 comments on commit 62f8807

Please sign in to comment.