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: add methods for updating a credit class #539

Merged
merged 9 commits into from
Sep 23, 2021
Merged

Conversation

technicallyty
Copy link
Contributor

@technicallyty technicallyty commented Sep 15, 2021

Description

Adds support for updating metadata, admin, and issuers for credit classes

Closes: #535


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

return err
}

if len(m.Issuers) == 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should we allow issuers to be empty in this method, so someone can wipe the issuer list?

Copy link
Member

Choose a reason for hiding this comment

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

Good question. We require issuers when creating a credit class, so I would lean towards requiring issuers when updating a credit class. I could however see wiping issuers as a way of disabling the credit class but the admin could also assign themselves as the only issuer to accomplish.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, leaving as is

return nil, sdkerrors.ErrUnauthorized.Wrapf("you are not the administrator of this class")
}

cInfo.Metadata = req.Metadata
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this should probably cost some gas as metadata can be variable length - doesnt look like we have a set hardcapped length for metadata length. we should also charge some gas based on the length itself

Copy link
Member

Choose a reason for hiding this comment

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

We have a max length of 256 following #540. We should make sure the metadata does not exceed this max length by adding a check in validate basic.

@technicallyty technicallyty marked this pull request as ready for review September 15, 2021 02:08
@codecov
Copy link

codecov bot commented Sep 15, 2021

Codecov Report

Merging #539 (c5d559c) into master (30765ed) will increase coverage by 0.53%.
The diff coverage is 93.81%.

❗ Current head c5d559c differs from pull request most recent head 059a45a. Consider uploading reports for the commit 059a45a to get more accurate results

@@            Coverage Diff             @@
##           master     #539      +/-   ##
==========================================
+ Coverage   75.47%   76.01%   +0.53%     
==========================================
  Files         104      104              
  Lines       13360    13764     +404     
==========================================
+ Hits        10084    10463     +379     
- Misses       2679     2696      +17     
- Partials      597      605       +8     
Flag Coverage Δ
experimental-codecov 76.01% <93.81%> (+0.53%) ⬆️
stable-codecov 67.34% <93.81%> (+0.92%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Member

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

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

Looking good. I think we should keep the update messages separate, which is the same as the group module. Also, we should check for metadata length following #540.

proto/regen/ecocredit/v1alpha1/tx.proto Outdated Show resolved Hide resolved
proto/regen/ecocredit/v1alpha1/tx.proto Show resolved Hide resolved
return err
}

if len(m.Issuers) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Good question. We require issuers when creating a credit class, so I would lean towards requiring issuers when updating a credit class. I could however see wiping issuers as a way of disabling the credit class but the admin could also assign themselves as the only issuer to accomplish.

return nil, sdkerrors.ErrUnauthorized.Wrapf("you are not the administrator of this class")
}

cInfo.Metadata = req.Metadata
Copy link
Member

Choose a reason for hiding this comment

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

We have a max length of 256 following #540. We should make sure the metadata does not exceed this max length by adding a check in validate basic.

x/ecocredit/msgs.go Show resolved Hide resolved
Comment on lines +205 to +209
testCases := []struct {
name string
msg ecocredit.MsgUpdateClassMetadata
expErr bool
}{
Copy link
Member

Choose a reason for hiding this comment

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

We should add a test case for metadata exceeding max length.

Copy link
Contributor Author

@technicallyty technicallyty Sep 21, 2021

Choose a reason for hiding this comment

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

added a test for this in msgs_test.go

Copy link
Member

@blushi blushi left a comment

Choose a reason for hiding this comment

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

Looks good overall, just a few comments

x/ecocredit/client/tx.go Outdated Show resolved Hide resolved
x/ecocredit/client/tx.go Outdated Show resolved Hide resolved
x/ecocredit/client/tx.go Outdated Show resolved Hide resolved
x/ecocredit/msgs_test.go Outdated Show resolved Hide resolved
Copy link
Member

@blushi blushi left a comment

Choose a reason for hiding this comment

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

utACK

Copy link
Contributor

@aleem1314 aleem1314 left a comment

Choose a reason for hiding this comment

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

LGTM

@clevinson clevinson enabled auto-merge (squash) September 23, 2021 15:22
@clevinson clevinson merged commit e8981ba into master Sep 23, 2021
@clevinson clevinson deleted the ty/535-credit_update branch September 23, 2021 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for updating a credit class
5 participants