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

refactor(x/ecocredit): update project id and batch denom #1046

Merged
merged 27 commits into from
May 4, 2022
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
eb12874
fix(x/ecocredit): project id and batch denom
ryanchristo Apr 21, 2022
dc98186
Merge branch 'master' into ryan/1032-project-id-batch-denom
ryanchristo Apr 22, 2022
dc07ae8
Merge branch 'master' into ryan/1032-project-id-batch-denom
ryanchristo Apr 22, 2022
d3ea05c
revised project id and batch denom
ryanchristo Apr 24, 2022
e66cc5a
revert implementation updates
ryanchristo Apr 24, 2022
b22a59a
revert implementation updates
ryanchristo Apr 24, 2022
2af559d
revise create batch steps
ryanchristo Apr 24, 2022
1db45d3
Merge branch 'master' into ryan/1032-project-id-batch-denom
ryanchristo Apr 25, 2022
b23cbe9
Merge branch 'master' into ryan/1032-project-id-batch-denom
ryanchristo Apr 25, 2022
482294d
Merge branch 'master' into ryan/1032-project-id-batch-denom
ryanchristo Apr 26, 2022
34d47ad
update project id and batch denom
ryanchristo Apr 27, 2022
a4363c8
update project id and batch denom
ryanchristo Apr 27, 2022
cf96344
Merge branch 'master' into ryan/1032-project-id-batch-denom
ryanchristo Apr 27, 2022
a4b6006
remove support for custom project ids
ryanchristo Apr 27, 2022
21c205d
remove support for custom project ids
ryanchristo Apr 27, 2022
9438b3a
update scenarios and clean up
ryanchristo Apr 27, 2022
63a57e8
clean up format comments
ryanchristo Apr 27, 2022
e58922e
clean up utils and regex
ryanchristo Apr 27, 2022
097df0a
clean up utils and regex
ryanchristo Apr 27, 2022
d740565
Update x/ecocredit/core/utils.go
ryanchristo Apr 28, 2022
80ac074
Merge branch 'master' into ryan/1032-project-id-batch-denom
ryanchristo Apr 28, 2022
93415ff
fix jurisdiction error check
ryanchristo Apr 28, 2022
78d9884
update simulations
ryanchristo Apr 29, 2022
c49fc2d
Merge branch 'master' into ryan/1032-project-id-batch-denom
ryanchristo Apr 29, 2022
03ee483
Merge branch 'master' into ryan/1032-project-id-batch-denom
ryanchristo May 4, 2022
a52bf97
address review comment
ryanchristo May 4, 2022
39a603a
Merge branch 'master' into ryan/1032-project-id-batch-denom
ryanchristo May 4, 2022
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
Prev Previous commit
Next Next commit
clean up format comments
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

ryanchristo committed Apr 27, 2022
commit 63a57e8f4e37f00af57dc8cddde8ff6b2c372eb5
36 changes: 22 additions & 14 deletions x/ecocredit/core/utils.go
Original file line number Diff line number Diff line change
@@ -30,22 +30,32 @@ var (
regexJurisdiction = regexp.MustCompile(`^([A-Z]{2})(?:-([A-Z0-9]{1,3})(?: ([a-zA-Z0-9 \-]{1,64}))?)?$`)
)

// FormatClassId formats the ID to use for a new credit class, based on the credit type and
// sequence number. This format may evolve over time, but will maintain backwards compatibility.
// FormatClassId formats the unique identifier for a new credit class, based
// on the credit type abbreviation and the credit class sequence number. This
// format may evolve over time, but will maintain backwards compatibility.
//
// The current version has the format:
// <credit type abbreviation><class seq no>
// <credit-type-abbrev><class-sequence>
//
// <credit-type-abbrev> is the unique identifier of the credit type
// <class-sequence> is the sequence number of the credit class, padded to at
// least three digits
//
// e.g. C01
func FormatClassId(creditTypeAbbreviation string, classSeqNo uint64) string {
return fmt.Sprintf("%s%02d", creditTypeAbbreviation, classSeqNo)
}

// FormatProjectId formats the ID to use for a new project, based on the credit class id and
// sequence number. This format may evolve over time, but will maintain backwards compatibility.
// FormatProjectId formats the ID to use for a new project, based on the credit
// class id and project sequence number. This format may evolve over time, but
// will maintain backwards compatibility.
//
// The current version has the format:
// <credit_class_id>-<project_sequence>
// <class-id>-<project-sequence>
//
// <class-id> is the unique identifier of the credit class (see FormatClassId)
// <project-sequence> is the sequence number of the project, padded to at least
// three digits
//
// e.g. C01-001
func FormatProjectId(classId string, projectSeqNo uint64) string {
@@ -56,15 +66,13 @@ func FormatProjectId(classId string, projectSeqNo uint64) string {
// time, but will maintain backwards compatibility.
//
// The current version has the format:
// <project_id>-<start_date>-<end_date>-<batch_sequence>
// <project-id>-<start_date>-<end_date>-<batch_sequence>
//
// where:
// - <project id> is the unique identifier of the project and has the format:
// <credit_type_abbrev><class_id>-<project_sequence> (see FormatProjectId)
// - <start date> is the start date of the credit batch and has the format YYYYMMDD
// - <end date> is the end date of the credit batch and has the format YYYYMMDD
// - <batch seq no> is the sequence number of the credit batch, padded to at least
// three digits
// <project-id> is the unique identifier of the project (see FormatProjectId)
// <start-date> is the start date of the credit batch with the format YYYYMMDD
// <end-date> is the end date of the credit batch with the format YYYYMMDD
// <batch-sequence> is the sequence number of the credit batch, padded to at least
// three digits
//
// e.g. C01-001-20190101-20200101-001
func FormatDenom(projectId string, batchSeqNo uint64, startDate, endDate *time.Time) (string, error) {
4 changes: 2 additions & 2 deletions x/ecocredit/server/core/features/msg_create_project.feature
Original file line number Diff line number Diff line change
@@ -6,14 +6,14 @@ Feature: CreateProject

Rule: A project id is always unique

Scenario: two projects from the same credit class
Scenario: multiple projects from the same credit class
Given a credit type exists with abbreviation "A"
And alice has created a credit class with credit type "A"
And alice has created a project with credit class id "A01"
When alice creates a project with credit class id "A01"
Then the project exists with project id "A01-002"

Scenario: two projects from different credit classes
Scenario: multiple projects from different credit classes
Given a credit type exists with abbreviation "A"
And a credit type exists with abbreviation "B"
And alice has created a credit class with credit type "A"