Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(x/ecocredit/v3/client): add/update independent project CLI commands #2202

Closed
wants to merge 87 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
89e7630
feat(x/ecocredit): independent project API
aaronc Jan 30, 2024
c54af2a
feat(x/ecocredit): independent project API
aaronc Jan 30, 2024
d98b364
fixes and proto-gen
aaronc Jan 30, 2024
78d71e1
updates
aaronc Jan 30, 2024
cf50830
add credit class to batch
aaronc Jan 30, 2024
0139192
Merge branch 'main' of github.com:regen-network/regen-ledger into aar…
aaronc Feb 6, 2024
4a7370e
update to multiple credit classes per project
aaronc Feb 6, 2024
f4146a3
updates
aaronc Feb 6, 2024
864c63b
add queries
aaronc Feb 6, 2024
7f0af0d
add queries
aaronc Feb 6, 2024
f6d3f93
add events
aaronc Feb 6, 2024
041af55
Update proto/regen/ecocredit/v1/tx.proto
aaronc Feb 7, 2024
ea41f12
Update proto/regen/ecocredit/v1/tx.proto
aaronc Feb 7, 2024
c3c15cd
address review comments
aaronc Feb 7, 2024
d13c13c
proto-gen
aaronc Feb 7, 2024
809c089
fix build errors
aaronc Feb 7, 2024
fe74b46
fix tests with msg stubs
aaronc Feb 7, 2024
1798de5
add msg_create_unregistered_project.feature
aaronc Feb 7, 2024
b571c1f
udpates
aaronc Feb 8, 2024
ad6b522
update design
aaronc Feb 8, 2024
a03d165
docs
aaronc Feb 8, 2024
4c81f78
fixes
aaronc Feb 8, 2024
89e986f
Merge branch 'aaronc/independent-projects' into aaronc/independent-pr…
aaronc Feb 12, 2024
222a6af
tests
aaronc Feb 12, 2024
d5feae9
tests
aaronc Feb 12, 2024
4921fbe
tests and validation
aaronc Feb 12, 2024
84ac1a4
add project creation fee
aaronc Feb 13, 2024
5faa1ae
Merge branch 'aaronc/independent-projects' into aaronc/independent-pr…
aaronc Feb 13, 2024
72f1d54
WIP
aaronc Feb 13, 2024
8e58525
WIP
aaronc Feb 13, 2024
fc61689
Merge branch 'main' of github.com:regen-network/regen-ledger into aar…
aaronc Feb 16, 2024
5450d06
proto updates
aaronc Feb 16, 2024
2e523c8
update logic
aaronc Feb 21, 2024
53fbaf6
add fee logic
aaronc Feb 21, 2024
5faccb5
refactoring
aaronc Feb 21, 2024
9bbe3eb
query logic, refactoring
aaronc Feb 21, 2024
7008513
refactoring
aaronc Feb 22, 2024
81ef202
refactoring, fixing tests
aaronc Feb 22, 2024
b2ad50c
WIP on fixing tests
aaronc Feb 26, 2024
0d98f57
better queries
aaronc Feb 26, 2024
8d0cbb4
bridge fix
aaronc Feb 26, 2024
33afc48
fix project state tests
aaronc Feb 26, 2024
bff1c32
remove over aggressive project and batch ID validation
aaronc Feb 26, 2024
fe45d70
test fixes
aaronc Feb 26, 2024
75616f9
test fixes
aaronc Feb 26, 2024
18c0c7f
WIP on bridge fixes
aaronc Feb 26, 2024
b29c249
ref id fixes
aaronc Feb 27, 2024
e7aa7be
refactor get credit type from batch
aaronc Feb 28, 2024
65a9758
remove reference_id from MsgCreateUnregisteredProject, WIP on fixing …
aaronc Mar 6, 2024
6fabbf7
Merge branch 'main' of github.com:regen-network/regen-ledger into aar…
aaronc Mar 18, 2024
ea8f17b
proto gen
aaronc Mar 18, 2024
fa5a465
proto gen
aaronc Mar 18, 2024
6e60592
Fix missing Batch.ClassKey
aaronc Mar 19, 2024
a5aa435
test fixes
aaronc Mar 19, 2024
0aabd0b
test fixes
aaronc Mar 19, 2024
84ba6f9
test fixes
aaronc Mar 19, 2024
8a18b1a
test fixes
aaronc Mar 19, 2024
1657932
test fixes
aaronc Mar 19, 2024
8d6299f
test fixes
aaronc Mar 19, 2024
c00ce61
test fixes
aaronc Mar 19, 2024
c952a45
test fixes
aaronc Mar 19, 2024
19c4aff
test fixes
aaronc Mar 19, 2024
e97f26f
all existing tests passing
aaronc Mar 19, 2024
7fdcf70
add gherkin stubs
aaronc Mar 19, 2024
8f0840d
add migration
aaronc Mar 19, 2024
b365045
register migration
aaronc Mar 19, 2024
6c837f6
create or update application tests
aaronc Mar 28, 2024
7b37ed0
create unregistered project tests
aaronc Mar 28, 2024
d089a80
WIP on update project enrollment tests
aaronc Mar 28, 2024
a135011
update project enrollment tests
aaronc Mar 28, 2024
7279a19
update project enrollment tests
aaronc Mar 28, 2024
17362c0
update project fee tests
aaronc Mar 28, 2024
454d7d4
add tests stubs
aaronc Mar 28, 2024
47507e1
WIP on validation tests
aaronc Mar 28, 2024
86a4180
MsgUpdateProjectFee validation tests
aaronc Mar 31, 2024
d047dd7
QueryProjectEnrollment test
aaronc Mar 31, 2024
cc428ad
QueryProjectEnrollments test
aaronc Mar 31, 2024
48a9dc7
MsgUpdateProjectEnrollment validation tests
aaronc Mar 31, 2024
cafe075
migration test
aaronc Mar 31, 2024
b3a7eb3
docs, fix sims/tests
aaronc Mar 31, 2024
497de7b
lint fix
aaronc Mar 31, 2024
38b631a
lint
aaronc Mar 31, 2024
4aff001
lint
aaronc Mar 31, 2024
a53fe68
lint
aaronc Mar 31, 2024
5d5249e
add CHANGELOG entries
aaronc Mar 31, 2024
ab7cc06
feat(x/ecocredit/v3/client): add/update independent project CLI commands
aaronc Apr 9, 2024
5724801
query commands
aaronc Apr 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

#### Added
- [#2107](https://github.com/regen-network/regen-ledger/pull/2107) Add `BurnRegen` method.
- [#2167](https://github.com/regen-network/regen-ledger/pull/2167) Add `CreateUnregisteredProject`, `CreateOrUpdateApplication`, `UpdateProjectEnrollment` and `UpdateProjectFee` methods and `ProjectEnrollment` and `ProjectEnrollments` queries. These additions allow:
- projects to be created without being already enrolled in a credit class
- projects to apply for one or more credit class and for project-credit class relationships to be dynamically managed on-chain

#### Changed
- [#2167](https://github.com/regen-network/regen-ledger/pull/2167):
- `FormatProjectID` just takes a sequence number and doesn't need a class ID.
- `FormatBatchDenom` requires a class ID because the class is no longer implied by the project ID.
- the credit type `P` is now reserved because this is the new project prefix
- project and batch string validation is now more lenient and just checks for a non-empty string
- `GetCreditTypeFromBatchDenom` takes a `*Denom` parameter instead of a string.

#### Deprecated
- [#2167](https://github.com/regen-network/regen-ledger/pull/2167):
- `regen.ecocredit.v1.Project.class_key`
- `regen.ecocredit.v1.ProjectSequence`
- `regen.ecocredit.v1.ProjectInfo.class_id`

#### Removed
- [#2167](https://github.com/regen-network/regen-ledger/pull/2167): the `GetClassIDFromProjectID` and `GetProjectIDFromBatchDenom` have been removed and a state lookup must now be used to resolved these references.
-

## [v5.1.2](https://github.com/regen-network/regen-ledger/releases/tag/v5.1.2) - 2023-06-28

Expand Down
2,094 changes: 1,468 additions & 626 deletions api/regen/ecocredit/v1/query.pulsar.go

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions api/regen/ecocredit/v1/query_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

374 changes: 189 additions & 185 deletions api/regen/ecocredit/v1/state.pulsar.go

Large diffs are not rendered by default.

1,088 changes: 506 additions & 582 deletions api/regen/ecocredit/v1/tx.pulsar.go

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions api/regen/ecocredit/v1/tx_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 32 additions & 8 deletions proto/regen/ecocredit/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@
};
}

// ProjectEnrollments queries all credit class enrollments associated with a
// project.
// ProjectEnrollments queries all credit class enrollments and allows for filtering by
// project or credit class.
rpc ProjectEnrollments(QueryProjectEnrollmentsRequest) returns (QueryProjectEnrollmentsResponse) {
option (google.api.http) = {
get : "/regen/ecocredit/v1/project/{project_id}/enrollments"
Expand Down Expand Up @@ -702,9 +702,8 @@
// admin is the admin of the project.
string admin = 2;

// class_id is the unique identifier of the credit class within which the
// project was created.
string class_id = 3;
// Deprecated: use ProjectEnrollment instead.
string class_id = 3 [deprecated = true];

// jurisdiction is the jurisdiction of the project. Full documentation can be
// found in MsgCreateProject.jurisdiction.
Expand Down Expand Up @@ -863,16 +862,21 @@
message QueryProjectEnrollmentResponse {

// project_class is the fetched project class relationship.
ProjectEnrollment project_class = 1;
EnrollmentInfo enrollment = 1;

Check failure on line 865 in proto/regen/ecocredit/v1/query.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "1" with name "enrollment" on message "QueryProjectEnrollmentResponse" changed option "json_name" from "projectClass" to "enrollment".

Check failure on line 865 in proto/regen/ecocredit/v1/query.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "1" on message "QueryProjectEnrollmentResponse" changed type from "regen.ecocredit.v1.ProjectEnrollment" to "regen.ecocredit.v1.EnrollmentInfo".

Check failure on line 865 in proto/regen/ecocredit/v1/query.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "1" on message "QueryProjectEnrollmentResponse" changed name from "project_class" to "enrollment".
}

// QueryProjectEnrollmentsRequest is the Query/ProjectEnrollments request type.
//
// Since Revision 3
message QueryProjectEnrollmentsRequest {
// project_id is the unique identifier of the project to query.
// project_id is the unique identifier of the project to filter enrollments
// by. If not set, enrollments for all projects will be returned.
string project_id = 1;

// class_id is the unique identifier of the credit class to filter enrollments
// by. If not set, enrollments for all credit classes will be returned.
string class_id = 3;

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}
Expand All @@ -883,8 +887,28 @@
message QueryProjectEnrollmentsResponse {

// enrollments are the fetched project credit class enrollments.
repeated ProjectEnrollment enrollments = 1;
repeated EnrollmentInfo enrollments = 1;

Check failure on line 890 in proto/regen/ecocredit/v1/query.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "1" on message "QueryProjectEnrollmentsResponse" changed type from "regen.ecocredit.v1.ProjectEnrollment" to "regen.ecocredit.v1.EnrollmentInfo".

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

// EnrollmentInfo is the human-readable project enrollment information.
message EnrollmentInfo {
// project_id is the unique identifier of the project to query.
string project_id = 1;

// class_id is the unique identifier of the credit class to query.
string class_id = 2;

// status is the status of the enrollment.
ProjectEnrollmentStatus status = 4;

// application_metadata is any arbitrary metadata set by the project
// admin related to its application to the credit class.
string application_metadata = 5;

// enrollment_metadata is any arbitrary metadata set by the credit class
// admin evaluating the project's application to the credit class.
string enrollment_metadata = 6;
}
15 changes: 8 additions & 7 deletions proto/regen/ecocredit/v1/state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ message CreditType {

// abbreviation is a 1-3 character uppercase abbreviation of the CreditType
// name, used in batch denominations within the CreditType. It must be unique.
// The letter P is reserved as the project prefix and cannot be used as a
// credit type to avoid confusion.
string abbreviation = 1;

// name is the name of the credit type (e.g. carbon, biodiversity).
Expand Down Expand Up @@ -91,16 +93,14 @@ message Project {
// efficient lookups. This identifier is auto-incrementing.
uint64 key = 1;

// id is the unique identifier of the project either auto-generated from the
// credit class id and project sequence number or provided upon creation.
// id is the auto-generated unique identifier of the project.
string id = 2;

// admin is the admin of the project.
bytes admin = 3;

// class_key is the table row identifier of the credit class used internally
// for efficient lookups. This links a project to a credit class.
uint64 class_key = 4;
// Deprecated: use ProjectEnrollment instead.
uint64 class_key = 4 [deprecated = true];

// jurisdiction is the jurisdiction of the project.
// Full documentation can be found in MsgCreateProject.jurisdiction.
Expand Down Expand Up @@ -183,9 +183,10 @@ message ClassSequence {
uint64 next_sequence = 2;
}

// ProjectSequence stores and increments the sequence number for projects within
// a credit class.
// Deprecated: No longer used.
message ProjectSequence {
option deprecated = true;

option (cosmos.orm.v1.table) = {
id : 7,
primary_key : {fields : "class_key"}
Expand Down
13 changes: 5 additions & 8 deletions proto/regen/ecocredit/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
// CreateOrUpdateApplicaton creates a new project credit class application, updates
// the metadata for an existing one when changes have been requested, or withdraws
// the application. When an application is withdrawn, its data will be deleted from
// state and the project may apply again to the same credit class in the future.
// state and the project may apply again to the same credit class in the future. Any
// new metadata will be passed to EventUpdateApplication including for withdrawals.
//
// Since Revision 3
rpc CreateOrUpdateApplication(MsgCreateOrUpdateApplication)
Expand Down Expand Up @@ -157,8 +158,8 @@
// the scope of the provided credit class, the credits will be minted to the
// existing credit batch, otherwise the credits will be issued in a new credit
// batch. The new credit batch will be created under an existing project if a
// project with a matching reference id already exists within the scope of the
// credit class, otherwise a new project will be created.
// project with a matching reference id already exists, otherwise a new project
// will be created.
rpc BridgeReceive(MsgBridgeReceive) returns (MsgBridgeReceiveResponse);

// AddCreditType is a governance method that allows the addition of new
Expand Down Expand Up @@ -328,7 +329,7 @@
}

// MsgCreateUnregisteredProject is the Msg/CreateUnregisteredProject request type.
message MsgCreateUnregisteredProject {

Check failure on line 332 in proto/regen/ecocredit/v1/tx.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present field "5" with name "fee" on message "MsgCreateUnregisteredProject" was deleted.
option (cosmos.msg.v1.signer) = "admin";

// admin is the address of the account creating the project that will become
Expand All @@ -348,16 +349,12 @@
// increased precision.
string jurisdiction = 3;

// reference_id is any arbitrary string used to reference the project with a
// maximum length of 32 characters.
string reference_id = 4;

// fee is the project creation fee. An equal fee is required if the project
// creation fee parameter is set. The provided fee can be greater than the
// parameter, but only the amount in the parameter will be charged.
//
// Since Revision 3
cosmos.base.v1beta1.Coin fee = 5;
cosmos.base.v1beta1.Coin fee = 4;

Check failure on line 357 in proto/regen/ecocredit/v1/tx.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "4" with name "fee" on message "MsgCreateUnregisteredProject" changed option "json_name" from "referenceId" to "fee".

Check failure on line 357 in proto/regen/ecocredit/v1/tx.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "4" on message "MsgCreateUnregisteredProject" changed type from "string" to "message".

Check failure on line 357 in proto/regen/ecocredit/v1/tx.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "4" on message "MsgCreateUnregisteredProject" changed name from "reference_id" to "fee".
}

// MsgCreateUnregisteredProjectResponse is the Msg/CreateUnregisteredProject response type.
Expand Down
63 changes: 63 additions & 0 deletions x/ecocredit/base/client/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,3 +667,66 @@ func QueryAllowedBridgeChainsCmd() *cobra.Command {
flags.AddPaginationFlagsToCmd(cmd, "allowed-bridge-chains")
return qflags(cmd)
}

func QueryProjectEnrollment() *cobra.Command {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consistency

Suggested change
func QueryProjectEnrollment() *cobra.Command {
func QueryProjectEnrollmentCmd() *cobra.Command {

cmd := &cobra.Command{
Use: "project-enrollment [project-id] [class-id]",
Short: "Retrieve project enrollment information",
Long: "Retrieve project enrollment information.",
Example: "regen q ecocredit project-enrollment P001 C01",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
c, ctx, err := mkQueryClient(cmd)
if err != nil {
return err
}
res, err := c.ProjectEnrollment(cmd.Context(), &types.QueryProjectEnrollmentRequest{
ProjectId: args[0],
ClassId: args[1],
})
return printQueryResponse(ctx, res, err)
},
}
return qflags(cmd)
}

func QueryProjectEnrollments() *cobra.Command {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consistency

Suggested change
func QueryProjectEnrollments() *cobra.Command {
func QueryProjectEnrollmentsCmd() *cobra.Command {

var projectID, classID string

cmd := &cobra.Command{
Use: "project-enrollments",
Short: "Retrieve project enrollments",
Long: `Retrieve project enrollments with optional pagination and filtering by project or credit class.

Flags:
--project string Filter by project ID
--class string Filter by credit class ID
`,
Example: `regen q ecocredit project-enrollments --limit 10 --offset 10
regen q ecocredit project-enrollments --project P001
regen q ecocredit project-enrollments --class C01`,
RunE: func(cmd *cobra.Command, args []string) error {
c, ctx, err := mkQueryClient(cmd)
if err != nil {
return err
}

pagination, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}

res, err := c.ProjectEnrollments(cmd.Context(), &types.QueryProjectEnrollmentsRequest{
ProjectId: projectID,
ClassId: classID,
Pagination: pagination,
})
return printQueryResponse(ctx, res, err)
},
}

cmd.Flags().StringVar(&projectID, FlagProject, "", "Filter by project ID")
cmd.Flags().StringVar(&classID, FlagClass, "", "Filter by credit class ID")

return qflags(cmd)
}
Loading
Loading