Skip to content

Commit

Permalink
feat: add proto for Clawback Vesting Account (#171)
Browse files Browse the repository at this point in the history
* Add proto for Clawback Vesting Account

* Change field to int

* Change field to int64

* add place holder for clawback

* add handler and basic msgs methods

* Update x/auth/vesting/types/msgs.go

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
  • Loading branch information
mattverse and alexanderbez authored Apr 6, 2022
1 parent 2cf2a43 commit 0d45507
Show file tree
Hide file tree
Showing 8 changed files with 1,898 additions and 160 deletions.
210 changes: 149 additions & 61 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -575,20 +575,25 @@

- [Query](#cosmos.upgrade.v1beta1.Query)

- [cosmos/vesting/v1beta1/tx.proto](#cosmos/vesting/v1beta1/tx.proto)
- [MsgCreateVestingAccount](#cosmos.vesting.v1beta1.MsgCreateVestingAccount)
- [MsgCreateVestingAccountResponse](#cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse)

- [Msg](#cosmos.vesting.v1beta1.Msg)

- [cosmos/vesting/v1beta1/vesting.proto](#cosmos/vesting/v1beta1/vesting.proto)
- [BaseVestingAccount](#cosmos.vesting.v1beta1.BaseVestingAccount)
- [ClawbackVestingAccount](#cosmos.vesting.v1beta1.ClawbackVestingAccount)
- [ContinuousVestingAccount](#cosmos.vesting.v1beta1.ContinuousVestingAccount)
- [DelayedVestingAccount](#cosmos.vesting.v1beta1.DelayedVestingAccount)
- [Period](#cosmos.vesting.v1beta1.Period)
- [PeriodicVestingAccount](#cosmos.vesting.v1beta1.PeriodicVestingAccount)
- [PermanentLockedAccount](#cosmos.vesting.v1beta1.PermanentLockedAccount)

- [cosmos/vesting/v1beta1/tx.proto](#cosmos/vesting/v1beta1/tx.proto)
- [MsgClawback](#cosmos.vesting.v1beta1.MsgClawback)
- [MsgClawbackResponse](#cosmos.vesting.v1beta1.MsgClawbackResponse)
- [MsgCreateClawbackVestingAccount](#cosmos.vesting.v1beta1.MsgCreateClawbackVestingAccount)
- [MsgCreateClawbackVestingAccountResponse](#cosmos.vesting.v1beta1.MsgCreateClawbackVestingAccountResponse)
- [MsgCreateVestingAccount](#cosmos.vesting.v1beta1.MsgCreateVestingAccount)
- [MsgCreateVestingAccountResponse](#cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse)

- [Msg](#cosmos.vesting.v1beta1.Msg)

- [Scalar Value Types](#scalar-value-types)


Expand Down Expand Up @@ -8182,83 +8187,49 @@ Since: cosmos-sdk 0.43 | GET|/cosmos/upgrade/v1beta1/module_versions|



<a name="cosmos/vesting/v1beta1/tx.proto"></a>
<a name="cosmos/vesting/v1beta1/vesting.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## cosmos/vesting/v1beta1/tx.proto
## cosmos/vesting/v1beta1/vesting.proto



<a name="cosmos.vesting.v1beta1.MsgCreateVestingAccount"></a>
<a name="cosmos.vesting.v1beta1.BaseVestingAccount"></a>

### MsgCreateVestingAccount
MsgCreateVestingAccount defines a message that enables creating a vesting
account.
### BaseVestingAccount
BaseVestingAccount implements the VestingAccount interface. It contains all
the necessary fields needed for any vesting account implementation.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `from_address` | [string](#string) | | |
| `to_address` | [string](#string) | | |
| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |
| `base_account` | [cosmos.auth.v1beta1.BaseAccount](#cosmos.auth.v1beta1.BaseAccount) | | |
| `original_vesting` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |
| `delegated_free` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |
| `delegated_vesting` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |
| `end_time` | [int64](#int64) | | |
| `delayed` | [bool](#bool) | | |






<a name="cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse"></a>

### MsgCreateVestingAccountResponse
MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type.





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->


<a name="cosmos.vesting.v1beta1.Msg"></a>

### Msg
Msg defines the bank Msg service.

| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `CreateVestingAccount` | [MsgCreateVestingAccount](#cosmos.vesting.v1beta1.MsgCreateVestingAccount) | [MsgCreateVestingAccountResponse](#cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse) | CreateVestingAccount defines a method that enables creating a vesting account. | |

<!-- end services -->


<a name="cosmos.vesting.v1beta1.ClawbackVestingAccount"></a>

<a name="cosmos/vesting/v1beta1/vesting.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## cosmos/vesting/v1beta1/vesting.proto



<a name="cosmos.vesting.v1beta1.BaseVestingAccount"></a>

### BaseVestingAccount
BaseVestingAccount implements the VestingAccount interface. It contains all
the necessary fields needed for any vesting account implementation.
### ClawbackVestingAccount
ClawbackVestingAccount implements the VestingAccount interface. It provides
an account that can hold contributions subject to "lockup" (like a
PeriodicVestingAccount), or vesting which is subject to clawback
of unvested tokens, or a combination (tokens vest, but are still locked).


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `base_account` | [cosmos.auth.v1beta1.BaseAccount](#cosmos.auth.v1beta1.BaseAccount) | | |
| `original_vesting` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |
| `delegated_free` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |
| `delegated_vesting` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |
| `end_time` | [int64](#int64) | | |
| `base_vesting_account` | [BaseVestingAccount](#cosmos.vesting.v1beta1.BaseVestingAccount) | | |
| `funder_address` | [string](#string) | | funder_address specifies the account which can perform clawback. |
| `start_time` | [int64](#int64) | | |
| `lockup_periods` | [Period](#cosmos.vesting.v1beta1.Period) | repeated | unlocking schedule relative to the BaseVestingAccount start_time. |
| `vesting_periods` | [Period](#cosmos.vesting.v1beta1.Period) | repeated | vesting (i.e. immunity from clawback) schedule relative to the BaseVestingAccount start_time. |



Expand Down Expand Up @@ -8361,6 +8332,123 @@ Since: cosmos-sdk 0.43



<a name="cosmos/vesting/v1beta1/tx.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## cosmos/vesting/v1beta1/tx.proto



<a name="cosmos.vesting.v1beta1.MsgClawback"></a>

### MsgClawback
MsgClawback defines a message that removes unvested tokens from a
ClawbackVestingAccount.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `funder_address` | [string](#string) | | funder_address is the address which funded the account |
| `address` | [string](#string) | | address is the address of the ClawbackVestingAccount to claw back from. |
| `dest_address` | [string](#string) | | dest_address specifies where the clawed-back tokens should be transferred to. If empty, the tokens will be transferred back to the original funder of the account. |






<a name="cosmos.vesting.v1beta1.MsgClawbackResponse"></a>

### MsgClawbackResponse
MsgClawbackResponse defines the MsgClawback response type.






<a name="cosmos.vesting.v1beta1.MsgCreateClawbackVestingAccount"></a>

### MsgCreateClawbackVestingAccount
MsgCreateClawbackVestingAccount defines a message that enables creating a ClawbackVestingAccount.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `from_address` | [string](#string) | | from_address specifies the account to provide the funds and sign the clawback request |
| `to_address` | [string](#string) | | to_address specifies the account to receive the funds |
| `start_time` | [int64](#int64) | | start_time defines the time at which the vesting period begins |
| `lockup_periods` | [Period](#cosmos.vesting.v1beta1.Period) | repeated | lockup_periods defines the unlocking schedule relative to the start_time |
| `vesting_periods` | [Period](#cosmos.vesting.v1beta1.Period) | repeated | vesting_periods defines the vesting schedule relative to the start_time |
| `merge` | [bool](#bool) | | merge specifies a creation mechanism for existing ClawbackVestingAccounts. If true, merge this new grant into an existing ClawbackVestingAccount, or create it if it does not exist. If false, creates a new account. New grants to an existing account must be from the same from_address. |






<a name="cosmos.vesting.v1beta1.MsgCreateClawbackVestingAccountResponse"></a>

### MsgCreateClawbackVestingAccountResponse
MsgCreateClawbackVestingAccountResponse defines the
MsgCreateClawbackVestingAccount response type.






<a name="cosmos.vesting.v1beta1.MsgCreateVestingAccount"></a>

### MsgCreateVestingAccount
MsgCreateVestingAccount defines a message that enables creating a vesting
account.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `from_address` | [string](#string) | | |
| `to_address` | [string](#string) | | |
| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |
| `end_time` | [int64](#int64) | | |
| `delayed` | [bool](#bool) | | |






<a name="cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse"></a>

### MsgCreateVestingAccountResponse
MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type.





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->


<a name="cosmos.vesting.v1beta1.Msg"></a>

### Msg
Msg defines the bank Msg service.

| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `CreateVestingAccount` | [MsgCreateVestingAccount](#cosmos.vesting.v1beta1.MsgCreateVestingAccount) | [MsgCreateVestingAccountResponse](#cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse) | CreateVestingAccount defines a method that enables creating a vesting account. | |
| `CreateClawbackVestingAccount` | [MsgCreateClawbackVestingAccount](#cosmos.vesting.v1beta1.MsgCreateClawbackVestingAccount) | [MsgCreateClawbackVestingAccountResponse](#cosmos.vesting.v1beta1.MsgCreateClawbackVestingAccountResponse) | CreateClawbackVestingAccount creats a vesting account that is subject to clawback and the configuration of vesting and lockup schedules. | |
| `Clawback` | [MsgClawback](#cosmos.vesting.v1beta1.MsgClawback) | [MsgClawbackResponse](#cosmos.vesting.v1beta1.MsgClawbackResponse) | Clawback removes the unvested tokens from a ClawbackVestingAccount. | |

<!-- end services -->



## Scalar Value Types

| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby |
Expand Down
52 changes: 51 additions & 1 deletion proto/cosmos/vesting/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cosmos.vesting.v1beta1;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "google/protobuf/timestamp.proto";
import "cosmos/vesting/v1beta1/vesting.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/auth/vesting/types";

Expand All @@ -11,6 +13,11 @@ service Msg {
// CreateVestingAccount defines a method that enables creating a vesting
// account.
rpc CreateVestingAccount(MsgCreateVestingAccount) returns (MsgCreateVestingAccountResponse);
// CreateClawbackVestingAccount creats a vesting account that is subject to
// clawback and the configuration of vesting and lockup schedules.
rpc CreateClawbackVestingAccount(MsgCreateClawbackVestingAccount) returns (MsgCreateClawbackVestingAccountResponse);
// Clawback removes the unvested tokens from a ClawbackVestingAccount.
rpc Clawback(MsgClawback) returns (MsgClawbackResponse);
}

// MsgCreateVestingAccount defines a message that enables creating a vesting
Expand All @@ -28,4 +35,47 @@ message MsgCreateVestingAccount {
}

// MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type.
message MsgCreateVestingAccountResponse {}
message MsgCreateVestingAccountResponse {}

// MsgCreateClawbackVestingAccount defines a message that enables creating a ClawbackVestingAccount.
message MsgCreateClawbackVestingAccount {
option (gogoproto.equal) = false;

// from_address specifies the account to provide the funds and sign the
// clawback request
string from_address = 1;
// to_address specifies the account to receive the funds
string to_address = 2;
// start_time defines the time at which the vesting period begins
int64 start_time = 3 [(gogoproto.moretags) = "yaml:\"start_time\""];
// lockup_periods defines the unlocking schedule relative to the start_time
repeated cosmos.vesting.v1beta1.Period lockup_periods = 4 [(gogoproto.nullable) = false];
// vesting_periods defines the vesting schedule relative to the start_time
repeated cosmos.vesting.v1beta1.Period vesting_periods = 5 [(gogoproto.nullable) = false];
// merge specifies a creation mechanism for existing
// ClawbackVestingAccounts. If true, merge this new grant into an existing
// ClawbackVestingAccount, or create it if it does not exist. If false,
// creates a new account. New grants to an existing account must be from the
// same from_address.
bool merge = 6;
}

// MsgCreateClawbackVestingAccountResponse defines the
// MsgCreateClawbackVestingAccount response type.
message MsgCreateClawbackVestingAccountResponse {}

// MsgClawback defines a message that removes unvested tokens from a
// ClawbackVestingAccount.
message MsgClawback {
// funder_address is the address which funded the account
string funder_address = 1;
// address is the address of the ClawbackVestingAccount to claw back from.
string address = 2;
// dest_address specifies where the clawed-back tokens should be transferred
// to. If empty, the tokens will be transferred back to the original funder of
// the account.
string dest_address = 3;
}

// MsgClawbackResponse defines the MsgClawback response type.
message MsgClawbackResponse {}
20 changes: 20 additions & 0 deletions proto/cosmos/vesting/v1beta1/vesting.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";
package cosmos.vesting.v1beta1;

import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/auth/v1beta1/auth.proto";

Expand Down Expand Up @@ -83,3 +84,22 @@ message PermanentLockedAccount {

BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true];
}

// ClawbackVestingAccount implements the VestingAccount interface. It provides
// an account that can hold contributions subject to "lockup" (like a
// PeriodicVestingAccount), or vesting which is subject to clawback
// of unvested tokens, or a combination (tokens vest, but are still locked).
message ClawbackVestingAccount {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true];

// funder_address specifies the account which can perform clawback.
string funder_address = 2 [(gogoproto.moretags) = "yaml:\"funder_address\""];
int64 start_time = 3 [(gogoproto.moretags) = "yaml:\"start_time\""];
// unlocking schedule relative to the BaseVestingAccount start_time.
repeated Period lockup_periods = 4 [(gogoproto.moretags) = "yaml:\"lockup_periods\"", (gogoproto.nullable) = false];
// vesting (i.e. immunity from clawback) schedule relative to the BaseVestingAccount start_time.
repeated Period vesting_periods = 5 [(gogoproto.moretags) = "yaml:\"vesting_periods\"", (gogoproto.nullable) = false];
}
6 changes: 6 additions & 0 deletions x/auth/vesting/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ func NewHandler(ak keeper.AccountKeeper, bk types.BankKeeper) sdk.Handler {
case *types.MsgCreateVestingAccount:
res, err := msgServer.CreateVestingAccount(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgCreateClawbackVestingAccount:
res, err := msgServer.CreateClawbackVestingAccount(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgClawback:
res, err := msgServer.Clawback(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)

default:
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg)
Expand Down
8 changes: 8 additions & 0 deletions x/auth/vesting/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,11 @@ func (s msgServer) CreateVestingAccount(goCtx context.Context, msg *types.MsgCre

return &types.MsgCreateVestingAccountResponse{}, nil
}

func (s msgServer) CreateClawbackVestingAccount(goCtx context.Context, msg *types.MsgCreateClawbackVestingAccount) (*types.MsgCreateClawbackVestingAccountResponse, error) {
return &types.MsgCreateClawbackVestingAccountResponse{}, nil
}

func (s msgServer) Clawback(goCtx context.Context, msg *types.MsgClawback) (*types.MsgClawbackResponse, error) {
return &types.MsgClawbackResponse{}, nil
}
Loading

0 comments on commit 0d45507

Please sign in to comment.