diff --git a/proto/regen/ecocredit/v1alpha1/events.proto b/proto/regen/ecocredit/v1alpha2/events.proto similarity index 90% rename from proto/regen/ecocredit/v1alpha1/events.proto rename to proto/regen/ecocredit/v1alpha2/events.proto index a8e270d726..b125ed15ad 100644 --- a/proto/regen/ecocredit/v1alpha1/events.proto +++ b/proto/regen/ecocredit/v1alpha2/events.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package regen.ecocredit.v1alpha1; +package regen.ecocredit.v1alpha2; import "cosmos/base/v1beta1/coin.proto"; @@ -16,6 +16,23 @@ message EventCreateClass { string admin = 2; } +// EventCreateProject is an event emitted when a project is created. +message EventCreateProject { + + // project_id is the unique ID of the project. + string project_id = 1; + + // class_id is the unique ID of credit class for this project. + string class_id = 2; + + // issuer is the issuer of the credit batches for this project. + string issuer = 3; + + // project_location is the location of the project. + // Full documentation can be found in MsgCreateProject.project_location. + string project_location = 4; +} + // EventCreateBatch is an event emitted when a credit batch is created. message EventCreateBatch { @@ -39,9 +56,12 @@ message EventCreateBatch { // quantified and verified. string end_date = 6; - // project_location is the location of the project backing the credits in this - // batch. Full documentation can be found in MsgCreateBatch.project_location. + // project_location is the location of the project. + // Full documentation can be found in MsgCreateProject.project_location. string project_location = 7; + + // project_id is the unique ID of the project this batch belongs to. + string project_id = 8; } // EventReceive is an event emitted when credits are received either upon diff --git a/proto/regen/ecocredit/v1alpha1/genesis.proto b/proto/regen/ecocredit/v1alpha2/genesis.proto similarity index 91% rename from proto/regen/ecocredit/v1alpha1/genesis.proto rename to proto/regen/ecocredit/v1alpha2/genesis.proto index b86bda62e0..7b995ee5ed 100644 --- a/proto/regen/ecocredit/v1alpha1/genesis.proto +++ b/proto/regen/ecocredit/v1alpha2/genesis.proto @@ -1,7 +1,7 @@ syntax = "proto3"; -package regen.ecocredit.v1alpha1; +package regen.ecocredit.v1alpha2; -import "regen/ecocredit/v1alpha1/types.proto"; +import "regen/ecocredit/v1alpha2/types.proto"; import "gogoproto/gogo.proto"; option go_package = "github.com/regen-network/regen-ledger/x/ecocredit"; @@ -26,6 +26,10 @@ message GenesisState { // supplies is the list of credit batch tradable/retired supply. repeated Supply supplies = 6; + + // project_info is the list of projects. + repeated ProjectInfo project_info = 7; + } // Balance represents tradable or retired units of a credit batch with an diff --git a/proto/regen/ecocredit/v1alpha1/query.proto b/proto/regen/ecocredit/v1alpha2/query.proto similarity index 83% rename from proto/regen/ecocredit/v1alpha1/query.proto rename to proto/regen/ecocredit/v1alpha2/query.proto index 2171e29cc2..49dec7e713 100644 --- a/proto/regen/ecocredit/v1alpha1/query.proto +++ b/proto/regen/ecocredit/v1alpha2/query.proto @@ -1,62 +1,76 @@ syntax = "proto3"; -package regen.ecocredit.v1alpha1; +package regen.ecocredit.v1alpha2; + import "google/api/annotations.proto"; -import "regen/ecocredit/v1alpha1/types.proto"; +import "regen/ecocredit/v1alpha2/types.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; option go_package = "github.com/regen-network/regen-ledger/x/ecocredit"; -// Msg is the regen.ecocredit.v1alpha1 Query service. +// Msg is the regen.ecocredit.v1alpha2 Query service. service Query { + // Classes queries for all credit classes with pagination. rpc Classes(QueryClassesRequest) returns (QueryClassesResponse) { option (google.api.http).get = - "/regen/ecocredit/v1alpha1/classes"; + "/regen/ecocredit/v1alpha2/classes"; } // ClassInfo queries for information on a credit class. rpc ClassInfo(QueryClassInfoRequest) returns (QueryClassInfoResponse) { option (google.api.http).get = - "/regen/ecocredit/v1alpha1/classes/{class_id}"; + "/regen/ecocredit/v1alpha2/classes/{class_id}"; + } + + // Projects queries for all projects within a class with pagination. + rpc Projects(QueryProjectsRequest) returns (QueryProjectsResponse) { + option (google.api.http).get = + "/regen/ecocredit/v1alpha2/classes/{class_id}/projects"; + } + + // ClassInfo queries for information on a project. + rpc ProjectInfo(QueryProjectInfoRequest) returns (QueryProjectInfoResponse) { + option (google.api.http).get = + "/regen/ecocredit/v1alpha2/projects/{project_id}"; } - // Batches queries for all batches in the given credit class with pagination. + // Batches queries for all batches in the given project with pagination. rpc Batches(QueryBatchesRequest) returns (QueryBatchesResponse) { option (google.api.http).get = - "/regen/ecocredit/v1alpha1/classes/{class_id}/batches"; + "/regen/ecocredit/v1alpha2/projects/{project_id}/batches"; } // BatchInfo queries for information on a credit batch. rpc BatchInfo(QueryBatchInfoRequest) returns (QueryBatchInfoResponse) { option (google.api.http).get = - "/regen/ecocredit/v1alpha1/batches/{batch_denom}"; + "/regen/ecocredit/v1alpha2/batches/{batch_denom}"; } // Balance queries the balance (both tradable and retired) of a given credit // batch for a given account. rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) { option (google.api.http).get = - "/regen/ecocredit/v1alpha1/batches/{batch_denom}/balance/{account}"; + "/regen/ecocredit/v1alpha2/batches/{batch_denom}/balance/{account}"; } // Supply queries the tradable and retired supply of a credit batch. rpc Supply(QuerySupplyRequest) returns (QuerySupplyResponse) { option (google.api.http).get = - "/regen/ecocredit/v1alpha1/batches/{batch_denom}/supply"; + "/regen/ecocredit/v1alpha2/batches/{batch_denom}/supply"; } // CreditTypes returns the list of allowed types that credit classes can have. // See Types/CreditType for more details. rpc CreditTypes(QueryCreditTypesRequest) returns (QueryCreditTypesResponse) { option (google.api.http).get = - "/regen/ecocredit/v1alpha1/credit-types"; + "/regen/ecocredit/v1alpha2/credit-types"; } // Params queries the ecocredit module parameters. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = - "/regen/ecocredit/v1alpha1/params"; + "/regen/ecocredit/v1alpha2/params"; } // SellOrder queries a sell order by its ID @@ -138,10 +152,45 @@ message QueryClassInfoResponse { ClassInfo info = 1; } +// QueryProjectsRequest is the Query/Projects request type. +message QueryProjectsRequest { + + // class_id is the unique ID of credit class to query. + string class_id = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryProjectsResponse is the Query/Projects response type. +message QueryProjectsResponse { + // projects are the fetched projects. + repeated ProjectInfo projects = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryProjectInfoRequest is the Query/Project request type. +message QueryProjectInfoRequest { + + // project_id is the unique ID of the project to query. + string project_id = 1; +} + +// QueryProjectInfoResponse is the Query/Project response type. +message QueryProjectInfoResponse { + + // info is the ProjectInfo for the project. + ProjectInfo info = 1; +} + + // QueryBatchesRequest is the Query/Batches request type. message QueryBatchesRequest { - // class_id is the unique ID of the credit class to query. - string class_id = 1; + + // project_id is the unique ID of the project to query. + string project_id = 1; // pagination defines an optional pagination for the request. cosmos.base.query.v1beta1.PageRequest pagination = 2; @@ -149,7 +198,8 @@ message QueryBatchesRequest { // QueryBatchesResponse is the Query/Batches response type. message QueryBatchesResponse { - // batches are the fetched credit batches within the class. + + // batches are the fetched credit batches within the project. repeated BatchInfo batches = 1; // pagination defines the pagination in the response. diff --git a/proto/regen/ecocredit/v1alpha1/tx.proto b/proto/regen/ecocredit/v1alpha2/tx.proto similarity index 93% rename from proto/regen/ecocredit/v1alpha1/tx.proto rename to proto/regen/ecocredit/v1alpha2/tx.proto index 5172c61d5b..c4af61897a 100644 --- a/proto/regen/ecocredit/v1alpha1/tx.proto +++ b/proto/regen/ecocredit/v1alpha2/tx.proto @@ -1,11 +1,11 @@ syntax = "proto3"; -package regen.ecocredit.v1alpha1; +package regen.ecocredit.v1alpha2; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; import "cosmos/base/v1beta1/coin.proto"; -import "regen/ecocredit/v1alpha1/types.proto"; +import "regen/ecocredit/v1alpha2/types.proto"; option go_package = "github.com/regen-network/regen-ledger/x/ecocredit"; @@ -16,7 +16,10 @@ service Msg { // optional metadata. rpc CreateClass(MsgCreateClass) returns (MsgCreateClassResponse); - // CreateBatch creates a new batch of credits for an existing credit class. + // CreateProject creates a new project within a credit class. + rpc CreateProject(MsgCreateProject) returns (MsgCreateProjectResponse); + + // CreateBatch creates a new batch of credits for an existing project. // This will create a new batch denom with a fixed supply. Issued credits can // be distributed to recipients in either tradable or retired form. rpc CreateBatch(MsgCreateBatch) returns (MsgCreateBatchResponse); @@ -88,7 +91,6 @@ service Msg { // MsgCreateClass is the Msg/CreateClass request type. message MsgCreateClass { - // admin is the address of the account that created the credit class. string admin = 1; @@ -104,19 +106,54 @@ message MsgCreateClass { // MsgCreateClassResponse is the Msg/CreateClass response type. message MsgCreateClassResponse { - // class_id is the unique ID of the newly created credit class. string class_id = 1; } +// MsgCreateProjectResponse is the Msg/CreateProject request type. +message MsgCreateProject { + // issuer is the address of an approved issuer for the credit class through + // which batches will be issued. It is not required, however, that this same + // issuer issue all batches for a project. + string issuer = 1; + + // class_id is the unique ID of the class within which the project is created. + string class_id = 2; + + // metadata is any arbitrary metadata attached to the project. + bytes metadata = 3; + + // project_location is the location of the project backing the credits in this + // batch. It is a string of the form + // [-[ ]], with the first two + // fields conforming to ISO 3166-2, and postal-code being up to 64 + // alphanumeric characters. country-code is required, while sub-national-code + // and postal-code can be added for increasing precision. + string project_location = 4; + + // project_id is an optional user-specified project ID which can be used + // instead of an auto-generated ID. If project_id is provided, it must be + // unique within the credit class and match the regex [A-Za-z0-9]{2,16} + // or else the operation will fail. If project_id is omitted an ID will + // automatically be generated. + string project_id = 5; +} + +// MsgCreateProjectResponse is the Msg/CreateProject response type. +message MsgCreateProjectResponse { + + // project_id is the ID of the newly created project. + string project_id = 1; +} + // MsgCreateBatch is the Msg/CreateBatch request type. message MsgCreateBatch { // issuer is the address of the batch issuer. string issuer = 1; - // class_id is the unique ID of the class. - string class_id = 2; + // project_id is the unique ID of the project this batch belongs to. + string project_id = 2; // issuance are the credits issued in the batch. repeated BatchIssuance issuance = 3; @@ -132,14 +169,6 @@ message MsgCreateBatch { // quantified and verified. google.protobuf.Timestamp end_date = 6 [ (gogoproto.stdtime) = true ]; - // project_location is the location of the project backing the credits in this - // batch. It is a string of the form - // [-[ ]], with the first two - // fields conforming to ISO 3166-2, and postal-code being up to 64 - // alphanumeric characters. country-code is required, while sub-national-code - // and postal-code can be added for increasing precision. - string project_location = 7; - // BatchIssuance represents the issuance of some credits in a batch to a // single recipient. message BatchIssuance { diff --git a/proto/regen/ecocredit/v1alpha1/types.proto b/proto/regen/ecocredit/v1alpha2/types.proto similarity index 92% rename from proto/regen/ecocredit/v1alpha1/types.proto rename to proto/regen/ecocredit/v1alpha2/types.proto index dfb4a3f2e0..477fcbb3c1 100644 --- a/proto/regen/ecocredit/v1alpha1/types.proto +++ b/proto/regen/ecocredit/v1alpha2/types.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package regen.ecocredit.v1alpha1; +package regen.ecocredit.v1alpha2; import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; @@ -30,18 +30,35 @@ message ClassInfo { uint64 num_batches = 6; } +// ProjectInfo represents the high-level on-chain information for a project. +message ProjectInfo { + + // project_id is the unique ID of the project. + string project_id = 1; + + // class_id is the unique ID of credit class for this project. + string class_id = 2; + + // issuer is the issuer of the credit batches for this project. + string issuer = 3; + + // project_location is the location of the project. + // Full documentation can be found in MsgCreateProject.project_location. + string project_location = 4; + + // metadata is any arbitrary metadata attached to the project. + bytes metadata = 5; +} + // BatchInfo represents the high-level on-chain information for a credit batch. message BatchInfo { - // class_id is the unique ID of credit class. - string class_id = 1; + // project_id is the unique ID of the project this batch belongs to. + string project_id = 1; // batch_denom is the unique ID of credit batch. string batch_denom = 2; - // issuer is the issuer of the credit batch. - string issuer = 3; - // total_amount is the total number of active credits in the credit batch. // Some of the issued credits may be cancelled and will be removed from // total_amount and tracked in amount_cancelled. total_amount and @@ -65,10 +82,6 @@ message BatchInfo { // end_date is the end of the period during which this credit batch was // quantified and verified. google.protobuf.Timestamp end_date = 8 [ (gogoproto.stdtime) = true ]; - - // project_location is the location of the project backing the credits in this - // batch. Full documentation can be found in MsgCreateBatch.project_location. - string project_location = 9; } // Params defines the updatable global parameters of the ecocredit module for