Skip to content

Commit

Permalink
Feature/nft staking (#2)
Browse files Browse the repository at this point in the history
* replace nft module and update funds allocating

* forbid to withdraw allocated tokens

* update queries

* admin vesting

* test vesting

* update nft staking

* nft staking

* remove useless logs

* add amount field to delegation

* update accumulator proto
  • Loading branch information
MarkCherepovskyi authored Jul 24, 2024
1 parent 03a0140 commit 234dfc8
Show file tree
Hide file tree
Showing 122 changed files with 9,384 additions and 12,516 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ require (
github.com/tendermint/tm-db v0.6.7
github.com/tidwall/btree v1.5.0
golang.org/x/crypto v0.21.0
golang.org/x/exp v0.0.0-20230310171629-522b1b587ee0
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
golang.org/x/net v0.23.0
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237
google.golang.org/grpc v1.64.0
Expand Down Expand Up @@ -102,6 +102,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
Expand Down
11 changes: 6 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,9 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64=
github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
Expand Down Expand Up @@ -1227,8 +1228,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
golang.org/x/exp v0.0.0-20230310171629-522b1b587ee0 h1:LGJsf5LRplCck6jUCH3dBL2dmycNruWNF5xugkSlfXw=
golang.org/x/exp v0.0.0-20230310171629-522b1b587ee0/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
Expand Down Expand Up @@ -1256,7 +1257,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -1576,7 +1577,7 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
28 changes: 28 additions & 0 deletions proto/cosmos/accumulator/admin.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
syntax = "proto3";
package cosmos.accumulator;

import "google/protobuf/any.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "google/api/annotations.proto";
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

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

message Admin {
string address = 1;

int64 vesting_period = 2;

cosmos.base.v1beta1.Coin reward_per_period = 3 [(gogoproto.nullable) = false];

int64 vesting_periods_count = 4;

int64 last_vesting_time = 5;

int64 vesting_counter = 6;

string denom = 7;
}


7 changes: 5 additions & 2 deletions proto/cosmos/accumulator/genesis.proto
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
syntax = "proto3";
package accumulator;
package cosmos.accumulator;

import "gogoproto/gogo.proto";
import "cosmos/accumulator/params.proto";
import "cosmos/accumulator/admin.proto";

// this line is used by starport scaffolding # genesis/proto/import

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

// GenesisState defines the bruhaccumulator module's genesis state.
// GenesisState defines the accumulator module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
repeated cosmos.accumulator.Admin admins = 2 [(gogoproto.nullable) = false];

// this line is used by starport scaffolding # genesis/proto/state
}
3 changes: 2 additions & 1 deletion proto/cosmos/accumulator/params.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package accumulator;
package cosmos.accumulator;

import "gogoproto/gogo.proto";
// this line is used by starport scaffolding # proto/tx/import
Expand All @@ -9,4 +9,5 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/accumulator/types";

// Params defines the parameters for the module.
message Params {
string super_admin = 1;
}
2 changes: 1 addition & 1 deletion proto/cosmos/accumulator/query.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package accumulator;
package cosmos.accumulator;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
Expand Down
24 changes: 22 additions & 2 deletions proto/cosmos/accumulator/tx.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package accumulator;
package cosmos.accumulator;

// this line is used by starport scaffolding # proto/tx/import
import "gogoproto/gogo.proto";
Expand All @@ -10,6 +10,26 @@ import "cosmos/base/v1beta1/coin.proto";

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

service Msg {}
service Msg {
rpc AddAdmin(MsgAddAdmin) returns (MsgAddAdminResponse);
}

// this line is used by starport scaffolding # proto/tx/message

message MsgAddAdmin {
string creator = 1;

string address = 2;

cosmos.base.v1beta1.Coin reward_per_period = 3 [(gogoproto.nullable) = false];

int64 vesting_periods_count = 4;

string denom = 5;

int64 vesting_period = 6;

}

message MsgAddAdminResponse {}

7 changes: 6 additions & 1 deletion proto/cosmos/distribution/v1beta1/distribution.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ message Params {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
bool withdraw_addr_enabled = 4;
string nft_proposer_reward = 4 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
bool withdraw_addr_enabled = 5;
}

// ValidatorHistoricalRewards represents historical rewards for a validator.
Expand Down
19 changes: 19 additions & 0 deletions proto/cosmos/nft/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
syntax = "proto3";
package cosmos.nft;

import "gogoproto/gogo.proto";
import "cosmos/nft/params.proto";
import "cosmos/nft/nft.proto";


// this line is used by starport scaffolding # genesis/proto/import

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

// GenesisState defines the nft module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
repeated cosmos.nft.NFT nfts = 2 [(gogoproto.nullable) = false];

// this line is used by starport scaffolding # genesis/proto/state
}
35 changes: 35 additions & 0 deletions proto/cosmos/nft/nft.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
syntax = "proto3";
package cosmos.nft;

import "google/protobuf/any.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "google/api/annotations.proto";
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

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

// NFT defines the NFT.
message NFT {
string address = 1;

string owner = 2;

string uri = 3;

int64 vesting_period = 4;

cosmos.base.v1beta1.Coin reward_per_period = 5 [(gogoproto.nullable) = false];

int64 vesting_periods_count = 6;

cosmos.base.v1beta1.Coin available_to_withdraw = 7 [(gogoproto.nullable) = false];

int64 last_vesting_time = 8;

int64 vesting_counter = 9;

string denom = 10;
}


11 changes: 11 additions & 0 deletions proto/cosmos/nft/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";
package cosmos.nft;

import "gogoproto/gogo.proto";
import "cosmos/nft/nft.proto";

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

// Params defines the parameters for the module.
message Params {
}
42 changes: 42 additions & 0 deletions proto/cosmos/nft/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

// this line is used by starport scaffolding #
syntax = "proto3";
package cosmos.nft;
import "google/api/annotations.proto";


import "gogoproto/gogo.proto";
import "cosmos/nft/params.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "google/protobuf/any.proto";
import "cosmos/nft/nft.proto";

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

// Query defines the gRPC querier service.
service Query {
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/cosmos/nft/params";
}

rpc GetNFTByAddress(QueryNFTByAddress) returns (QueryNFTByAddressResponse) {
option (google.api.http).get = "/cosmos/nft/{address}";
}
}

// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false];
}

message QueryNFTByAddress {
string address = 1; // address of nft
}

message QueryNFTByAddressResponse {
cosmos.nft.NFT nft = 1;
}
73 changes: 73 additions & 0 deletions proto/cosmos/nft/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
syntax = "proto3";
package cosmos.nft;

import "cosmos/base/v1beta1/coin.proto";
import "google/protobuf/timestamp.proto";
import "gogoproto/gogo.proto";
import "cosmos/nft/params.proto";
import "google/protobuf/any.proto";

// this line is used by starport scaffolding # proto/tx/import
option go_package = "github.com/cosmos/cosmos-sdk/x/nft/types";

// Msg defines the Msg service.
service Msg {
// Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721
rpc Undelegate(MsgUndelegate) returns (MsgUndelegateResponse);

rpc Delegate(MsgDelegate) returns (MsgDelegateResponse);

// Class queries an NFT class based on its id
rpc Send(MsgSend) returns (MsgSendResponse);

rpc Withdraw (MsgWithdrawal) returns (MsgWithdrawalResponse);

rpc Redelegate ( MsgRedelegate) returns (MsgRedelegateResponse);
}

message MsgWithdrawal {
string creator = 1;
string address = 2;
cosmos.base.v1beta1.Coin amount = 5 [(gogoproto.nullable) = false];

}

message MsgWithdrawalResponse {}

message MsgDelegate {
string creator = 1;
string address = 2;
string validator = 3;
cosmos.base.v1beta1.Coin amount = 5 [(gogoproto.nullable) = false];
}

message MsgDelegateResponse {}

message MsgUndelegate {
string creator = 1;
string address = 2;
string validator = 3;
cosmos.base.v1beta1.Coin amount = 5 [(gogoproto.nullable) = false];

}

message MsgUndelegateResponse {}

message MsgSend {
string creator = 1;
string address = 2;
string recipient = 3;
cosmos.base.v1beta1.Coin amount = 5 [(gogoproto.nullable) = false];
}

message MsgSendResponse {}

message MsgRedelegate {
string creator = 1;
string address = 2;
string validatorSrc = 3;
string validatorNew = 4;
cosmos.base.v1beta1.Coin amount = 5 [(gogoproto.nullable) = false];
}

message MsgRedelegateResponse {}
26 changes: 0 additions & 26 deletions proto/cosmos/nft/v1beta1/event.proto

This file was deleted.

Loading

0 comments on commit 234dfc8

Please sign in to comment.