Skip to content

Commit

Permalink
feat(sponsorship): added proto contracts (#990)
Browse files Browse the repository at this point in the history
  • Loading branch information
keruch authored Jul 17, 2024
1 parent 31156de commit 54c0fca
Show file tree
Hide file tree
Showing 12 changed files with 5,833 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ proto-swagger-gen:
@echo "Generating Protobuf Swagger"
$(protoCosmosImage) sh ./scripts/protoc-swagger-gen.sh

proto-format:
@$(protoCosmosImage) find ./ -name "*.proto" -exec clang-format -i {} \;

proto-lint:
@$(protoCosmosImage) buf lint --error-format=json

SWAGGER_DIR=./swagger-proto
THIRD_PARTY_DIR=$(SWAGGER_DIR)/third_party

Expand Down Expand Up @@ -250,3 +256,5 @@ proto-download-deps:

mkdir -p "$(THIRD_PARTY_DIR)/confio/ics23" && \
curl -sSL https://raw.githubusercontent.com/confio/ics23/$(DEPS_CONFIO_ICS23_VERSION)/proofs.proto > "$(THIRD_PARTY_DIR)/proofs.proto"

.PHONY: proto-gen proto-swagger-gen proto-format proto-lint proto-download-deps
35 changes: 35 additions & 0 deletions proto/dymensionxyz/dymension/sponsorship/events.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
syntax = "proto3";
package dymensionxyz.dymension.sponsorship;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "dymensionxyz/dymension/sponsorship/sponsorship.proto";

option go_package = "github.com/dymensionxyz/dymension/v3/x/sponsorship/types";

message EventUpdateParams {
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
Params new_params = 2 [ (gogoproto.nullable) = false ];
Params old_params = 3 [ (gogoproto.nullable) = false ];
}

message EventVote {
string voter = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
Vote vote = 2 [ (gogoproto.nullable) = false ];
}

message EventRevokeVote {
string voter = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

message EventUpdateVotingPower {
string voter = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string new_voting_power = 2 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"
];
string old_voting_power = 3 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"
];
}
13 changes: 13 additions & 0 deletions proto/dymensionxyz/dymension/sponsorship/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
syntax = "proto3";
package dymensionxyz.dymension.sponsorship;

import "gogoproto/gogo.proto";
import "dymensionxyz/dymension/sponsorship/sponsorship.proto";

option go_package = "github.com/dymensionxyz/dymension/v3/x/sponsorship/types";

// GenesisState defines the sponsorship module's genesis state.
message GenesisState {
// Params defines params for x/sponsorship module.
Params params = 1 [ (gogoproto.nullable) = false ];
}
59 changes: 59 additions & 0 deletions proto/dymensionxyz/dymension/sponsorship/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
syntax = "proto3";
package dymensionxyz.dymension.sponsorship;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "google/api/annotations.proto";
import "dymensionxyz/dymension/sponsorship/sponsorship.proto";

option go_package = "github.com/dymensionxyz/dymension/v3/x/sponsorship/types";

// Query defines the gRPC querier service.
service Query {
// Param queries the parameters of the module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/dymensionxyz/dymension/sponsorship/params";
}

// Vote returns the vote for the specified address.
rpc Vote(QueryVoteRequest) returns (QueryVoteResponse) {
option (google.api.http).get =
"/dymensionxyz/dymension/sponsorship/vote/{voter}";
}

// Distribution returns the current distribution plan.
rpc Distribution(QueryDistributionRequest)
returns (QueryDistributionResponse) {
option (google.api.http).get =
"/dymensionxyz/dymension/streamer/distribution";
}
}

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

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

// QueryVoteRequest is the request type for the Query/Vote RPC method.
message QueryVoteRequest {
// Voter is the bech32 encoded address of the voted user.
string voter = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// QueryVoteResponse is the response type for the Query/Vote RPC method.
message QueryVoteResponse {
// Vote is the user's vote.
Vote vote = 1 [ (gogoproto.nullable) = false ];
}

// QueryVoteRequest is the request type for the Query/Distribution RPC method.
message QueryDistributionRequest {}

// QueryVoteResponse is the response type for the Query/Distribution RPC method.
message QueryDistributionResponse {
// Distribution is the current voting power distribution among gauges.
Distribution distribution = 1 [ (gogoproto.nullable) = false ];
}
71 changes: 71 additions & 0 deletions proto/dymensionxyz/dymension/sponsorship/sponsorship.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
syntax = "proto3";
package dymensionxyz.dymension.sponsorship;

import "gogoproto/gogo.proto";

option go_package = "github.com/dymensionxyz/dymension/v3/x/sponsorship/types";

// Params is a module parameters.
message Params {
// MinAllocationWeight is a minimum portion of the user's voting power that
// one can allocate to a single gauge. The value must fall between 0 and 100,
// inclusively. For example, if this parameter is 20%, then the min allocation
// is 20%, and consequently, the user can vote on a max of 5 gauges (100 / 20
// = 5).
string min_allocation_weight = 1 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"
];
// MinVotingPower is a minimum voting power a user must have in order to be
// able to vote.
string min_voting_power = 2 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"
];
}

// Distribution holds the distribution plan among gauges.
message Distribution {
// TotalVotingPower is the total voting power that the plan holds.
string total_voting_power = 1 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"
];
// Gauges is a breakdown of the users' votes for different gauges.
repeated Gauge gauges = 2;
}

// Gauge represents a single gauge with its absolute power.
message Gauge {
// GaugeID is the ID of the gauge.
uint64 gauge_id = 1;
// Power is a total voting power distributed to this gauge.
string power = 2 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"
];
}

// Vote represents the user's vote.
message Vote {
// Voting power is a total voting power of the vote.
string voting_power = 1 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"
];
// Weights is a breakdown of the user's vote for different gauges.
repeated GaugeWeight weights = 2 [ (gogoproto.nullable) = false ];
}

// Weight is a weight distributed to the specified gauge.
message GaugeWeight {
// GaugeID is the ID of the gauge.
uint64 gauge_id = 1;
// Weight is a portion of the voting power that the user wants to allocate for
// the given gauge. The value must fall between Params.MinAllocationWeight and
// 100, inclusive.
string weight = 2 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"
];
}
58 changes: 58 additions & 0 deletions proto/dymensionxyz/dymension/sponsorship/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
syntax = "proto3";
package dymensionxyz.dymension.sponsorship;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";
import "dymensionxyz/dymension/sponsorship/sponsorship.proto";

option go_package = "github.com/dymensionxyz/dymension/v3/x/sponsorship/types";

// Msg defines the Msg service.
service Msg {
option (cosmos.msg.v1.service) = true;

// UpdateParams is used for updating module params.
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);

// Vote allows a user to cast their vote. The user specifies a desired weight
// breakdown among existing gauges.
rpc Vote(MsgVote) returns (MsgVoteResponse);

// RevokeVote allows a user to revoke their vote.
rpc RevokeVote(MsgRevokeVote) returns (MsgRevokeVoteResponse);
}

// MsgUpdateParams allows to update module params.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";

// Authority is the address that controls the module.
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// NewParams should be fully populated.
Params new_params = 2 [ (gogoproto.nullable) = false ];
}

message MsgUpdateParamsResponse {}

// MsgVote defines a message to cast a vote.
message MsgVote {
option (cosmos.msg.v1.signer) = "voter";

// Voter is the bech32 encoded address of the user sending the vote.
string voter = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// Weights is a breakdown of the user's vote for different gauges.
repeated GaugeWeight weights = 2 [ (gogoproto.nullable) = false ];
}

message MsgVoteResponse {}

// MsgRevoke defines a message to revoke the vote.
message MsgRevokeVote {
option (cosmos.msg.v1.signer) = "voter";

// Voter is the bech32 encoded address of the user sending the vote.
string voter = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

message MsgRevokeVoteResponse {}
Loading

0 comments on commit 54c0fca

Please sign in to comment.