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
Merged
Show file tree
Hide file tree
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
update project id and batch denom
  • Loading branch information
ryanchristo committed Apr 27, 2022
commit a4363c888bae9a50ba6d971f10be1afcb4d8188c
1 change: 0 additions & 1 deletion x/ecocredit/client/testsuite/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,6 @@ func (s *IntegrationTestSuite) TestCreateProject() {
ClassId: classId,
Metadata: "hi",
ProjectJurisdiction: "US-OR",
ProjectId: "C01-456",
}),
false,
"",
Expand Down
2 changes: 1 addition & 1 deletion x/ecocredit/core/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ func TestGenesisValidate(t *testing.T) {
{
"issuer": "OfVGZ+vChK/1gQfbXZ6rxsz3QNQ=",
"project_key": "2",
"denom":"C01-001-00000000-00000000-002",
"denom":"C01-002-00000000-00000000-001",
"start_date":"2021-04-08T10:40:10.774108556Z",
"end_date":"2022-04-08T10:40:10.774108556Z",
"metadata":"meta-data"
Expand Down
28 changes: 0 additions & 28 deletions x/ecocredit/core/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"sort"
"strings"
"time"
"unicode"

sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

Expand Down Expand Up @@ -53,17 +52,6 @@ func FormatProjectId(classId string, projectSeqNo uint64) string {
return fmt.Sprintf("%s-%03d", classId, projectSeqNo)
}

// FormatCustomProjectId formats the ID to use for a new project, based on the credit class id and
// custom project id. This format may evolve over time, but will maintain backwards compatibility.
//
// The current version has the format:
// <credit_class_id>-<custom_project_id>
//
// e.g. C01-VERRA1
func FormatCustomProjectId(classId string, customId string) string {
return fmt.Sprintf("%s-%s", classId, customId)
}

// FormatDenom formats the denomination to use for a credit batch. This format may evolve over
// time, but will maintain backwards compatibility.
//
Expand Down Expand Up @@ -164,22 +152,6 @@ func GetClassIdFromBatchDenom(denom string) string {
return s.String()
}

// NormalizeCreditTypeName credit type name by removing whitespace and converting to lowercase.
func NormalizeCreditTypeName(name string) string {
return fastRemoveWhitespace(strings.ToLower(name))
}

func fastRemoveWhitespace(str string) string {
var b strings.Builder
b.Grow(len(str))
for _, ch := range str {
if !unicode.IsSpace(ch) {
b.WriteRune(ch)
}
}
return b.String()
}

// exponent prefix map https://en.wikipedia.org/wiki/Metric_prefix
var exponentPrefixMap = map[uint32]string{
0: "",
Expand Down
5 changes: 2 additions & 3 deletions x/ecocredit/server/testsuite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,10 @@ func (s *IntegrationTestSuite) TestScenario() {
Issuer: issuer1,
Metadata: "metadata",
ProjectJurisdiction: "AQ",
ProjectId: "C01-123",
})
s.Require().NoError(err)
s.Require().NotNil(createProjectRes)
s.Require().Equal("C01-123", createProjectRes.ProjectId)
s.Require().Equal("C02-001", createProjectRes.ProjectId)

// create batch
t0, t1, t2 := "10.37", "1007.3869", "100"
Expand All @@ -436,7 +435,7 @@ func (s *IntegrationTestSuite) TestScenario() {
// Batch creation should succeed with StartDate before EndDate, and valid data
createBatchRes, err := s.msgClient.CreateBatch(s.ctx, &core.MsgCreateBatch{
Issuer: issuer1,
ProjectId: "C01-123",
ProjectId: "C02-001",
StartDate: &time1,
EndDate: &time2,
Issuance: []*core.BatchIssuance{
Expand Down