Skip to content

Commit

Permalink
feat: cyber proto and codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpatrickdev committed Oct 26, 2024
1 parent 95338e2 commit 9b1c22f
Show file tree
Hide file tree
Showing 72 changed files with 15,702 additions and 110 deletions.
10 changes: 10 additions & 0 deletions protos/proto/cyber/bandwidth/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
syntax = "proto3";
package cyber.bandwidth.v1beta1;

import "gogoproto/gogo.proto";

import "cyber/bandwidth/v1beta1/types.proto";

option go_package = "github.com/cybercongress/go-cyber/x/bandwidth/types";

message GenesisState { Params params = 1 [ (gogoproto.nullable) = false ]; }
68 changes: 68 additions & 0 deletions protos/proto/cyber/bandwidth/v1beta1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
syntax = "proto3";
package cyber.bandwidth.v1beta1;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";

import "cyber/bandwidth/v1beta1/types.proto";

option go_package = "github.com/cybercongress/go-cyber/x/bandwidth/types";

service Query {
rpc Load(QueryLoadRequest) returns (QueryLoadResponse) {
option (google.api.http).get = "/cyber/bandwidth/v1beta1/bandwidth/load";
}

rpc Price(QueryPriceRequest) returns (QueryPriceResponse) {
option (google.api.http).get = "/cyber/bandwidth/v1beta1/bandwidth/price";
}

rpc TotalBandwidth(QueryTotalBandwidthRequest)
returns (QueryTotalBandwidthResponse) {
option (google.api.http).get = "/cyber/bandwidth/v1beta1/bandwidth/total";
}

rpc NeuronBandwidth(QueryNeuronBandwidthRequest)
returns (QueryNeuronBandwidthResponse) {
option (google.api.http).get =
"/cyber/bandwidth/v1beta1/bandwidth/neuron/{neuron}";
}

rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/cyber/bandwidth/v1beta1/bandwidth/params";
}
}

message QueryLoadRequest {}

message QueryLoadResponse {
string load = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

message QueryPriceRequest {}

message QueryPriceResponse {
string price = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

message QueryTotalBandwidthRequest {}

message QueryTotalBandwidthResponse { uint64 total_bandwidth = 1; }

message QueryNeuronBandwidthRequest { string neuron = 1; }

message QueryNeuronBandwidthResponse {
NeuronBandwidth neuron_bandwidth = 1 [ (gogoproto.nullable) = false ];
}

message QueryParamsRequest {}

message QueryParamsResponse {
Params params = 1 [ (gogoproto.nullable) = false ];
}
23 changes: 23 additions & 0 deletions protos/proto/cyber/bandwidth/v1beta1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
syntax = "proto3";
package cyber.bandwidth.v1beta1;

import "gogoproto/gogo.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "cyber/bandwidth/v1beta1/types.proto";

option go_package = "github.com/cybercongress/go-cyber/x/bandwidth/types";

service Msg {
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}

message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";

string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

Params params = 2 [ (gogoproto.nullable) = false ];
}

message MsgUpdateParamsResponse {}
42 changes: 42 additions & 0 deletions protos/proto/cyber/bandwidth/v1beta1/types.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
syntax = "proto3";
package cyber.bandwidth.v1beta1;

import "gogoproto/gogo.proto";

option go_package = "github.com/cybercongress/go-cyber/x/bandwidth/types";

message Params {
option (gogoproto.equal) = true;

uint64 recovery_period = 1;
uint64 adjust_price_period = 2;
string base_price = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string base_load = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
uint64 max_block_bandwidth = 5;
}

message NeuronBandwidth {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string neuron = 1;
uint64 remained_value = 2;
uint64 last_updated_block = 3;
uint64 max_value = 4;
}

message Price {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string price = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
13 changes: 13 additions & 0 deletions protos/proto/cyber/clock/v1/clock.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
syntax = "proto3";
package cyber.clock.v1;

option go_package = "github.com/cybercongress/go-cyber/x/clock/types";

// This object is used to store the contract address and the
// jail status of the contract.
message ClockContract {
// The address of the contract.
string contract_address = 1;
// The jail status of the contract.
bool is_jailed = 2;
}
25 changes: 25 additions & 0 deletions protos/proto/cyber/clock/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
syntax = "proto3";
package cyber.clock.v1;

import "gogoproto/gogo.proto";

option go_package = "github.com/cybercongress/go-cyber/x/clock/types";

// GenesisState - initial state of module
message GenesisState {
// Params of this module
Params params = 1 [
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "params,omitempty"
];
}

// Params defines the set of module parameters.
message Params {
// contract_gas_limit defines the maximum amount of gas that can be used by a
// contract.
uint64 contract_gas_limit = 1 [
(gogoproto.jsontag) = "contract_gas_limit,omitempty",
(gogoproto.moretags) = "yaml:\"contract_gas_limit\""
];
}
68 changes: 68 additions & 0 deletions protos/proto/cyber/clock/v1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
syntax = "proto3";
package cyber.clock.v1;

import "cosmos/base/query/v1beta1/pagination.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cyber/clock/v1/genesis.proto";
import "cyber/clock/v1/clock.proto";

option go_package = "github.com/cybercongress/go-cyber/x/clock/types";

// Query defines the gRPC querier service.
service Query {
// ClockContracts
rpc ClockContracts(QueryClockContracts)
returns (QueryClockContractsResponse) {
option (google.api.http).get = "/cyber/clock/v1/contracts";
}
// ClockContract
rpc ClockContract(QueryClockContract) returns (QueryClockContractResponse) {
option (google.api.http).get =
"/cyber/clock/v1/contracts/{contract_address}";
}
// Params
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/cyber/clock/v1/params";
}
}

// QueryClockContracts is the request type to get all contracts.
message QueryClockContracts {
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

// QueryClockContractsResponse is the response type for the Query/ClockContracts
// RPC method.
message QueryClockContractsResponse {
// clock_contracts are the clock contracts.
repeated ClockContract clock_contracts = 1 [ (gogoproto.nullable) = false ];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryClockContract is the request type to get a single contract.
message QueryClockContract {
// contract_address is the address of the contract to query.
string contract_address = 1;
}

// QueryClockContractResponse is the response type for the Query/ClockContract
// RPC method.
message QueryClockContractResponse {
// contract is the clock contract.
ClockContract clock_contract = 1 [ (gogoproto.nullable) = false ];
}

// QueryParams is the request type to get all module params.
message QueryParamsRequest {}

// QueryClockContractsResponse is the response type for the Query/ClockContracts
// RPC method.
message QueryParamsResponse {
Params params = 1 [
(gogoproto.jsontag) = "params",
(gogoproto.moretags) = "yaml:\"params\""
];
}
98 changes: 98 additions & 0 deletions protos/proto/cyber/clock/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
syntax = "proto3";
package cyber.clock.v1;

option go_package = "github.com/cybercongress/go-cyber/x/clock/types";

import "google/api/annotations.proto";
import "cosmos/msg/v1/msg.proto";
import "cyber/clock/v1/genesis.proto";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";

// Msg defines the Msg service.
service Msg {

// RegisterClockContract defines the endpoint for
// registering a new clock contract.
rpc RegisterClockContract(MsgRegisterClockContract)
returns (MsgRegisterClockContractResponse) {
option (google.api.http).post = "/cyber/clock/v1/tx/register";
};

// UnregisterClockContract defines the endpoint for
// unregistering a clock contract.
rpc UnregisterClockContract(MsgUnregisterClockContract)
returns (MsgUnregisterClockContractResponse) {
option (google.api.http).post = "/cyber/clock/v1/tx/unregister";
};

// UnjailClockContract defines the endpoint for
// unjailing a clock contract.
rpc UnjailClockContract(MsgUnjailClockContract)
returns (MsgUnjailClockContractResponse) {
option (google.api.http).post = "/cyber/clock/v1/tx/unjail";
};

// UpdateParams defines a governance operation for updating the x/clock module
// parameters. The authority is hard-coded to the x/gov module account.
//
// Since: cosmos-sdk 0.47
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}

// MsgRegisterClockContract is the Msg/RegisterClockContract request type.
message MsgRegisterClockContract {
// The address of the sender.
string sender_address = 1;
// The address of the contract to register.
string contract_address = 2;
}

// MsgRegisterClockContractResponse defines the response structure for executing
// a MsgRegisterClockContract message.
message MsgRegisterClockContractResponse {}

// MsgUnregisterClockContract is the Msg/UnregisterClockContract request type.
message MsgUnregisterClockContract {
// The address of the sender.
string sender_address = 1;
// The address of the contract to unregister.
string contract_address = 2;
}

// MsgUnregisterClockContractResponse defines the response structure for
// executing a MsgUnregisterClockContract message.
message MsgUnregisterClockContractResponse {}

// MsgUnjailClockContract is the Msg/UnjailClockContract request type.
message MsgUnjailClockContract {
// The address of the sender.
string sender_address = 1;
// The address of the contract to unjail.
string contract_address = 2;
}

// MsgUnjailClockContractResponse defines the response structure for executing a
// MsgUnjailClockContract message.
message MsgUnjailClockContractResponse {}

// MsgUpdateParams is the Msg/UpdateParams request type.
//
// Since: cosmos-sdk 0.47
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";

// authority is the address of the governance account.
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// params defines the x/clock parameters to update.
//
// NOTE: All parameters must be supplied.
Params params = 2 [ (gogoproto.nullable) = false ];
}

// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
//
// Since: cosmos-sdk 0.47
message MsgUpdateParamsResponse {}
10 changes: 10 additions & 0 deletions protos/proto/cyber/dmn/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
syntax = "proto3";
package cyber.dmn.v1beta1;

import "gogoproto/gogo.proto";

import "cyber/dmn/v1beta1/types.proto";

option go_package = "github.com/cybercongress/go-cyber/x/dmn/types";

message GenesisState { Params params = 1 [ (gogoproto.nullable) = false ]; }
Loading

0 comments on commit 9b1c22f

Please sign in to comment.