Skip to content

Commit

Permalink
feat(x/ecocredit): forward contract proof-of-concept
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanchristo committed Aug 30, 2022
1 parent b58cb0f commit b55e0c5
Show file tree
Hide file tree
Showing 3 changed files with 191 additions and 0 deletions.
45 changes: 45 additions & 0 deletions proto/regen/ecocredit/contract/v1alpha1/state.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
syntax = "proto3";

package regen.ecocredit.contract.v1alpha1;

import "cosmos/base/v1beta1/coin.proto";
import "cosmos/orm/v1alpha1/orm.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "regen/ecocredit/contract/v1alpha1/types.proto";

// Contract defines a forward contract and the table within which the forward
// contract is stored.
message Contract {
option (cosmos.orm.v1alpha1.table) = {
id : 1,
primary_key : {fields : "id", auto_increment : true}
};

// id is the table row identifier of the contract.
uint64 id = 1;

// project_id is the unique identifier of the project.
string project_id = 2;

// status is the status of the contract (e.g. "proposed", "approved").
ContractStatus status = 3;

// funds_to_collect is the denom and amount the project is collecting.
cosmos.base.v1beta1.Coin funds_to_collect = 4;

// volume_percentage is the percent of all credits issued that will be
// available to purchase in shares.
cosmos.base.v1beta1.Coin volume_percentage = 5;

// start_date is the delivery start date.
google.protobuf.Timestamp start_date = 6 [ (gogoproto.stdtime) = true ];

// end_date is the delivery end date.
google.protobuf.Timestamp end_date = 7 [ (gogoproto.stdtime) = true ];

// metadata is any arbitrary string that includes or references additional
// information about the contract such as estimated total supply, forward
// contract supply, and estimated price per credit type unit.
google.protobuf.Timestamp metadata = 8;
}
126 changes: 126 additions & 0 deletions proto/regen/ecocredit/contract/v1alpha1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
syntax = "proto3";

package regen.ecocredit.contract.v1alpha1;

import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";

// Msg is the regen.ecocredit.contract.v1alpha1 Msg service.
service Msg {

// Create creates a new forward contract. A new contract starts with status
// proposed and only the class admin can approve the contract.
rpc Create(MsgCreate) returns (MsgCreateResponse);

// Update updates a proposed forward contract. A contract can only be updated
// by the project admin before the contract is accepted.
rpc Update(MsgUpdate) returns (MsgUpdateResponse);

// Cancel cancels a forward contract. A contract can only be cancelled by the
// project admin before the contract is accepted.
rpc Cancel(MsgCancel) returns (MsgCancelResponse);

// Approve approves a proposed forward contract, changing the status of the
// contract to accepted and preventing any further changes. Only an approved
// credit class issuer can accept the contract.
rpc Approve(MsgApprove) returns (MsgApproveResponse);
}

// MsgCreate is the Msg/Create request type.
message MsgCreate {
option (cosmos.msg.v1.signer) = "project_admin";

// project_id is the unique identifier of the project.
string project_id = 1;

// project_admin is the admin of the project.
string project_admin = 2;

// funds_to_collect is the denom and amount the project is collecting.
cosmos.base.v1beta1.Coin funds_to_collect = 3;

// volume_percentage is the percent of all credits issued that will be
// available to purchase in shares.
cosmos.base.v1beta1.Coin volume_percentage = 4;

// start_date is the delivery start date.
google.protobuf.Timestamp start_date = 5 [ (gogoproto.stdtime) = true ];

// end_date is the delivery end date.
google.protobuf.Timestamp end_date = 6 [ (gogoproto.stdtime) = true ];

// metadata is any arbitrary string that includes or references additional
// information about the contract such as estimated total supply, forward
// contract supply, and estimated price per credit type unit.
google.protobuf.Timestamp metadata = 7;
}

// MsgCreateResponse is the Msg/Create response type.
message MsgCreateResponse {

// id is the unique identifier of the created contract.
uint64 id = 1;
}

// MsgUpdate is the Msg/Update request type.
message MsgUpdate {
option (cosmos.msg.v1.signer) = "funder";

// id is the unique identifier of the contract.
uint64 id = 1;

// project_admin is the admin of the project.
string project_admin = 2;

// funds_to_collect is the denom and amount the project is collecting.
cosmos.base.v1beta1.Coin funds_to_collect = 3;

// volume_percentage is the percent of all credits issued that will be
// available to purchase in shares.
cosmos.base.v1beta1.Coin volume_percentage = 4;

// start_date is the delivery start date.
google.protobuf.Timestamp start_date = 5 [ (gogoproto.stdtime) = true ];

// end_date is the delivery end date.
google.protobuf.Timestamp end_date = 6 [ (gogoproto.stdtime) = true ];

// metadata is any arbitrary string that includes or references additional
// information about the contract such as estimated total supply, forward
// contract supply, and estimated price per credit type unit.
google.protobuf.Timestamp metadata = 7;
}

// MsgUpdateResponse is the Msg/Update response type.
message MsgUpdateResponse {}

// MsgCancel is the Msg/Cancel request type.
message MsgCancel {
option (cosmos.msg.v1.signer) = "project_admin";

// id is the unique identifier of the contract.
uint64 id = 1;

// project_admin is the admin of the project.
string project_admin = 2;
}

// MsgCancelResponse is the Msg/Cancel response type.
message MsgCancelResponse {}

// MsgApprove is the Msg/Approve request type.
message MsgApprove {
option (cosmos.msg.v1.signer) = "class_issuer";

// id is the unique identifier of the contract.
uint64 id = 1;

// class_issuer is the address of the credit class issuer that is approving
// the contract on behalf of the credit class.
string class_issuer = 2;
}

// MsgApproveResponse is the Msg/Approve response type.
message MsgApproveResponse {}
20 changes: 20 additions & 0 deletions proto/regen/ecocredit/contract/v1alpha1/types.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";

package regen.ecocredit.contract.v1alpha1;

// ContractStatus is the status of a forward contract.
enum ContractStatus {

// CONTRACT_STATUS_UNSPECIFIED
CONTRACT_STATUS_UNSPECIFIED = 0;

// CONTRACT_STATUS_PROPOSED is the initial state of a contract after the
// contract has been created. When the contract status is "proposed", the
// contract can be updated or cancelled by the project admin.
CONTRACT_STATUS_PROPOSED = 1;

// CONTRACT_STATUS_APPROVED is the state of the contract after the contract
// has been approved by a credit class issuer. When the contract status is
// "approved", the contract cannot be updated or cancelled.
CONTRACT_STATUS_APPROVED = 2;
}

0 comments on commit b55e0c5

Please sign in to comment.