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

Update utility functions to check empty and return consistent errors #1245

Closed
4 tasks
ryanchristo opened this issue Jul 7, 2022 · 5 comments · Fixed by #1393
Closed
4 tasks

Update utility functions to check empty and return consistent errors #1245

ryanchristo opened this issue Jul 7, 2022 · 5 comments · Fixed by #1393
Assignees
Labels
Scope: x/ecocredit Issues that update the x/ecocredit module Type: Refactor A code change that neither fixes a bug nor adds a feature

Comments

@ryanchristo
Copy link
Member

ryanchristo commented Jul 7, 2022

Summary

Ref: #1233 (comment)

Currently we check for an empty string inside basic message validation for credit class, project id, batch denom, etc. We should check for empty string within the validation functions defined in utils.go. We should also make sure we are returning consistent errors for these validation functions, i.e. all should include the expected format and consistent sdk errors.

Problem Definition

We are duplicating a lot of empty string checks in message validation and returning inconsistent errors and errors that could provide more information about the expected format.

Proposal

Add empty string checks for validation functions in utils.go (for core, basket, and marketplace) and remove the empty string checks in basic message validation. Also make sure all errors returned include the expected format within an sdk error.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@ryanchristo ryanchristo added Scope: x/ecocredit Issues that update the x/ecocredit module Type: Refactor A code change that neither fixes a bug nor adds a feature labels Jul 7, 2022
@wgwz
Copy link
Contributor

wgwz commented Jul 18, 2022

@ryanchristo i'm interested in working on this one if you agree it could be a good one to work on.

@ryanchristo
Copy link
Member Author

Yea, I think this would be a good one. I'll assign to you and feel free to reach out with any questions.

@wgwz
Copy link
Contributor

wgwz commented Jul 29, 2022

Hey @ryanchristo I have opened up a draft PR that is a start on this. I think I'm headed in the right direction. So far I started with the core module and refactored the validation functions within core/utils.go. Let me know what you think, thanks!

@ryanchristo
Copy link
Member Author

@wgwz thanks again for tackling the largest chunk of work in #1317! I think there are only a couple left for basket and it would be nice to get those updated now that we've added state validation checks that use the same utils. Unless you've started, do you mind if I finish off those changes?

@wgwz
Copy link
Contributor

wgwz commented Aug 23, 2022

@ryanchristo np, please feel free, i'll be glad to help with review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: x/ecocredit Issues that update the x/ecocredit module Type: Refactor A code change that neither fixes a bug nor adds a feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants