Skip to content

Commit

Permalink
chore: reinstate ecocredit v1alpha1 (#694)
Browse files Browse the repository at this point in the history
Co-authored-by: Aaron Craelius <aaron@regen.network>
  • Loading branch information
ryanchristo and aaronc committed Jan 24, 2022
1 parent b7cd49a commit 3ff0a1c
Show file tree
Hide file tree
Showing 7 changed files with 741 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ require (
golang.org/x/sys v0.0.0-20210903071746-97244b99971b // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20220114172242-44263ffb69e1 // indirect
google.golang.org/genproto v0.0.0-20220118154757-00ab72f36ad5 // indirect
google.golang.org/grpc v1.40.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/ini.v1 v1.63.2 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1535,8 +1535,8 @@ google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
google.golang.org/genproto v0.0.0-20220114172242-44263ffb69e1 h1:urkRJha5HC5u/IDXqy212/tSzWXRbU8eWMTj6yXP6u8=
google.golang.org/genproto v0.0.0-20220114172242-44263ffb69e1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20220118154757-00ab72f36ad5 h1:zzNejm+EgrbLfDZ6lu9Uud2IVvHySPl8vQzf04laR5Q=
google.golang.org/genproto v0.0.0-20220118154757-00ab72f36ad5/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o=
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
Expand Down
105 changes: 105 additions & 0 deletions proto/regen/ecocredit/v1alpha1/events.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
syntax = "proto3";

package regen.ecocredit.v1alpha1;

option go_package = "github.com/regen-network/regen-ledger/x/ecocredit";

// EventCreateClass is an event emitted when a credit class is created.
message EventCreateClass {

// class_id is the unique ID of credit class.
string class_id = 1;

// admin is the admin of the credit class.
string admin = 2;
}

// EventCreateBatch is an event emitted when a credit batch is created.
message EventCreateBatch {

// class_id is the unique ID of credit class.
string class_id = 1;

// batch_denom is the unique ID of credit batch.
string batch_denom = 2;

// issuer is the account address of the issuer of the credit batch.
string issuer = 3;

// total_amount is the total number of credits in the credit batch.
string total_amount = 4;

// start_date is the beginning of the period during which this credit batch
// was quantified and verified.
string start_date = 5;

// end_date is the end of the period during which this credit batch was
// 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.
string project_location = 7;
}

// EventReceive is an event emitted when credits are received either upon
// creation of a new batch or upon transfer. Each batch_denom created or
// transferred will result in a separate EventReceive for easy indexing.
message EventReceive {
// sender is the sender of the credits in the case that this event is the
// result of a transfer. It will not be set when credits are received at
// initial issuance.
string sender = 1;

// recipient is the recipient of the credits
string recipient = 2;

// batch_denom is the unique ID of credit batch.
string batch_denom = 3;

// tradable_amount is the decimal number of tradable credits received.
string tradable_amount = 4;

// retired_amount is the decimal number of retired credits received.
string retired_amount = 5;
}

// EventRetire is an event emitted when credits are retired. When credits are
// retired from multiple batches in the same transaction, a separate event is
// emitted for each batch_denom. This allows for easier indexing.
message EventRetire {

// retirer is the account which has done the "retiring". This will be the
// account receiving credits in the case that credits were retired upon
// issuance using Msg/CreateBatch or retired upon transfer using Msg/Send.
string retirer = 1;

// batch_denom is the unique ID of credit batch.
string batch_denom = 2;

// amount is the decimal number of credits that have been retired.
string amount = 3;

// location is the location of the beneficiary or buyer of the retired
// credits. It is a string of the form
// <country-code>[-<sub-national-code>[ <postal-code>]], with the first two
// fields conforming to ISO 3166-2, and postal-code being up to 64
// alphanumeric characters.
string location = 4;
}

// EventCancel is an event emitted when credits are cancelled. When credits are
// cancelled from multiple batches in the same transaction, a separate event is
// emitted for each batch_denom. This allows for easier indexing.
message EventCancel {

// canceller is the account which has cancelled the credits, which should be
// the holder of the credits.
string canceller = 1;

// batch_denom is the unique ID of credit batch.
string batch_denom = 2;

// amount is the decimal number of credits that have been cancelled.
string amount = 3;
}
57 changes: 57 additions & 0 deletions proto/regen/ecocredit/v1alpha1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
syntax = "proto3";
package regen.ecocredit.v1alpha1;

import "regen/ecocredit/v1alpha1/types.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/regen-network/regen-ledger/x/ecocredit";

// GenesisState defines ecocredit module's genesis state.
message GenesisState {
// Params contains the updateable global parameters for use with the x/params
// module
Params params = 1 [ (gogoproto.nullable) = false ];

// class_info is the list of credit class info.
repeated ClassInfo class_info = 2;

// batch_info is the list of credit batch info.
repeated BatchInfo batch_info = 3;

// sequences is the list of credit type sequence.
repeated CreditTypeSeq sequences = 4;

// balances is the list of credit batch tradable/retired units.
repeated Balance balances = 5;

// supplies is the list of credit batch tradable/retired supply.
repeated Supply supplies = 6;
}

// Balance represents tradable or retired units of a credit batch with an
// account address, batch_denom, and balance.
message Balance {
// address is the account address of the account holding credits.
string address = 1;

// batch_denom is the unique ID of the credit batch.
string batch_denom = 2;

// tradable_balance is the tradable balance of the credit batch.
string tradable_balance = 3;

// retired_balance is the retired balance of the credit batch.
string retired_balance = 4;
}

// Supply represents a tradable or retired supply of a credit batch.
message Supply {
// batch_denom is the unique ID of the credit batch.
string batch_denom = 1;

// tradable_supply is the tradable supply of the credit batch.
string tradable_supply = 2;

// retired_supply is the retired supply of the credit batch.
string retired_supply = 3;
}
179 changes: 179 additions & 0 deletions proto/regen/ecocredit/v1alpha1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
syntax = "proto3";

package regen.ecocredit.v1alpha1;
import "google/api/annotations.proto";
import "regen/ecocredit/v1alpha1/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.
service Query {
// Classes queries for all credit classes with pagination.
rpc Classes(QueryClassesRequest) returns (QueryClassesResponse) {
option (google.api.http).get =
"/regen/ecocredit/v1alpha1/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}";
}

// Batches queries for all batches in the given credit class with pagination.
rpc Batches(QueryBatchesRequest) returns (QueryBatchesResponse) {
option (google.api.http).get =
"/regen/ecocredit/v1alpha1/classes/{class_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}";
}

// 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}";
}

// 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";
}

// 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";
}

// Params queries the ecocredit module parameters.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get =
"/regen/ecocredit/v1alpha1/params";
}
}

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

// QueryParamsResponse is the Query/Params response type.
message QueryParamsResponse {
// params defines the parameters of the ecocredit module.
Params params = 1;
}

// QueryClassesRequest is the Query/Classes request type.
message QueryClassesRequest {
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

// QueryClassesResponse is the Query/Classes response type.
message QueryClassesResponse {
// classes are the fetched credit classes.
repeated ClassInfo classes = 1;

// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryClassInfoRequest is the Query/ClassInfo request type.
message QueryClassInfoRequest {

// class_id is the unique ID of credit class to query.
string class_id = 1;
}

// QueryClassInfoResponse is the Query/ClassInfo request type.
message QueryClassInfoResponse {

// info is the ClassInfo for the credit class.
ClassInfo 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;

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// QueryBatchesResponse is the Query/Batches response type.
message QueryBatchesResponse {
// batches are the fetched credit batches within the class.
repeated BatchInfo batches = 1;

// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryBatchInfoRequest is the Query/BatchInfo request type.
message QueryBatchInfoRequest {

// batch_denom is the unique ID of credit batch to query.
string batch_denom = 1;
}

// QueryBatchInfoResponse is the Query/BatchInfo response type.
message QueryBatchInfoResponse {

// info is the BatchInfo for the credit batch.
BatchInfo info = 1;
}

// QueryBalanceRequest is the Query/Balance request type.
message QueryBalanceRequest {

// account is the address of the account whose balance is being queried.
string account = 1;

// batch_denom is the unique ID of credit batch balance to query.
string batch_denom = 2;
}

// QueryBalanceResponse is the Query/Balance response type.
message QueryBalanceResponse {

// tradable_amount is the decimal number of tradable credits.
string tradable_amount = 1;

// retired_amount is the decimal number of retired credits.
string retired_amount = 2;
}

// QuerySupplyRequest is the Query/Supply request type.
message QuerySupplyRequest {

// batch_denom is the unique ID of credit batch to query.
string batch_denom = 1;
}

// QuerySupplyResponse is the Query/Supply response type.
message QuerySupplyResponse {

// tradable_supply is the decimal number of tradable credits in the batch
// supply.
string tradable_supply = 1;

// retired_supply is the decimal number of retired credits in the batch
// supply.
string retired_supply = 2;
}

// QueryCreditTypesRequest is the Query/Credit_Types request type
message QueryCreditTypesRequest {}

// QueryCreditTypesRequest is the Query/Credit_Types response type
message QueryCreditTypesResponse {
// list of credit types
repeated CreditType credit_types = 1;
}
Loading

0 comments on commit 3ff0a1c

Please sign in to comment.