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): move empty string validation into utils.go #1317

Merged
merged 2 commits into from
Aug 3, 2022

Conversation

wgwz
Copy link
Contributor

@wgwz wgwz commented Jul 29, 2022

Description

Ref: #1245


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)

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.

Thanks for the contribution! Looks like a good start.

The issue was not very specific so my apologies. Although the parse error previously being used in the utility functions is defined in the ecocredit module, it is registered as an sdk error.

ErrParseFailure        = sdkerrors.Register(ModuleName, 2, "parse error")

I think this error still makes sense to use for invalid format, and we should avoid using sdkerrors.ErrInvalidRequest within the utility functions given the utility functions may be used outside the context of a request.

I've added a note to an issue proposing guidelines for better use of sdk errors, which is currently being used to track examples until those guidelines are written (#1147 (comment)). I left an example in the issue and some initial review comments below to point out how parse error and invalid request might be used together.

x/ecocredit/basket/features/msg_create.feature Outdated Show resolved Hide resolved
x/ecocredit/basket/features/msg_put.feature Outdated Show resolved Hide resolved
x/ecocredit/basket/msg_put.go Outdated Show resolved Hide resolved
x/ecocredit/core/features/msg_bridge_receive.feature Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jul 29, 2022

Codecov Report

Merging #1317 (c065e89) into master (cb68013) will increase coverage by 0.06%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1317      +/-   ##
==========================================
+ Coverage   77.50%   77.56%   +0.06%     
==========================================
  Files         221      220       -1     
  Lines       16160    16009     -151     
==========================================
- Hits        12524    12417     -107     
+ Misses       2621     2589      -32     
+ Partials     1015     1003      -12     
Flag Coverage Δ
experimental-codecov 77.56% <100.00%> (-0.05%) ⬇️
stable-codecov ?

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

Impacted Files Coverage Δ
x/ecocredit/basket/msg_put.go 95.23% <ø> (-0.42%) ⬇️
x/ecocredit/core/msg_bridge_receive.go 94.00% <ø> (-0.45%) ⬇️
x/ecocredit/core/types_class.go 11.11% <ø> (+2.02%) ⬆️
x/ecocredit/marketplace/msg_buy_direct.go 96.87% <ø> (-0.35%) ⬇️
x/ecocredit/marketplace/msg_sell.go 96.55% <ø> (-0.23%) ⬇️
x/ecocredit/basket/msg_create.go 95.83% <100.00%> (-0.60%) ⬇️
x/ecocredit/core/msg_bridge.go 88.00% <100.00%> (-0.89%) ⬇️
x/ecocredit/core/msg_create_batch.go 92.00% <100.00%> (-0.60%) ⬇️
x/ecocredit/core/msg_create_class.go 93.33% <100.00%> (-0.42%) ⬇️
x/ecocredit/core/msg_create_project.go 87.50% <100.00%> (-2.50%) ⬇️
... and 14 more

@wgwz
Copy link
Contributor Author

wgwz commented Aug 1, 2022

hey @ryanchristo 👋 i made another pass at this and pushed a new commit. i have still only done the refactoring work for x/ecocredit/core/utils.go. it should be closer now, LMK what you think, thanks!

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.

This looks good to me. The added scenario is a duplicate but otherwise I think this is ready if you want to open a separate pull request to address basket and marketplace utils.

x/ecocredit/core/features/msg_retire.feature Outdated Show resolved Hide resolved
@ryanchristo ryanchristo changed the title refactor: move empty string validation into utils.go refactor(x/ecocredit): move empty string validation into utils.go Aug 1, 2022
@wgwz
Copy link
Contributor Author

wgwz commented Aug 2, 2022

@ryanchristo I do like the idea of merging this and then addressing the other locations in separate PRs. because i may not have the time this week to handle the others. should we open new separate issues? or favor keeping #1245 open and adding a todo list?

@wgwz wgwz marked this pull request as ready for review August 2, 2022 15:06
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.

Looks good to me. Thanks for the contribution!

Copy link
Contributor

@technicallyty technicallyty left a comment

Choose a reason for hiding this comment

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

👍🏻

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.

3 participants