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): clean up commands and examples #1288

Merged
merged 8 commits into from
Jul 21, 2022

Conversation

ryanchristo
Copy link
Member

@ryanchristo ryanchristo commented Jul 21, 2022

Description

Closes: #1271


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)

@ryanchristo ryanchristo changed the title refactor(x/ecocredit): clean up commands and command examples refactor(x/ecocredit): clean up commands and examples Jul 21, 2022
@ryanchristo ryanchristo marked this pull request as ready for review July 21, 2022 00:10
@ryanchristo ryanchristo added the backport/v4.0.x backport to release/v4.0.x branch label Jul 21, 2022
Comment on lines +39 to +40

- name: the name used to create a bank denom for this basket token
Copy link
Member Author

Choose a reason for hiding this comment

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

This format improves the generated documentation rather than everything being bundled into a paragraph.

curator explicitly acknowledges paying this fee and is not surprised to learn that the
paid a big fee and didn't know beforehand.
- description: the description to be used in the basket coin's bank denom metadata.`),
Example: `regen tx ecocredit create-basket NCT --credit-type-abbrev C --allowed_classes C01,C02 basket-fee 100000000uregen description "NCT basket"`,
Copy link
Member Author

Choose a reason for hiding this comment

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

I was not entirely sure on the best format for example but ultimately decided no line break before and no line break after so that it is properly formatted in the help text and the generated documentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, this was the only case but no $ so that it can be easily copied.

Copy link
Member Author

Choose a reason for hiding this comment

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

And this was also the only case, but no multiple line examples (unless multiple examples of course).

regen q ecocredit balance C01-001-20200101-20210101-001 regen1r9pl9gvr56kmclgkpjg3ynh4rm5am66f2a6y38
`,
Args: cobra.ExactArgs(2),
Use: "batch-balance [batch-denom] [account]",
Copy link
Member Author

Choose a reason for hiding this comment

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

Although balance corresponds with the ecocredit module, we have basket and marketplace submodule commands that exist alongside the ecocredit commands so batch-balance made more sense in this context.

I think in general we should try to match the name of the command with the message or query name but we might need to rethink client architecture with submodules and probably best to do so alongside sdk v1 updates.

regen q ecocredit supply C01-001-20200101-20210101-001
`,
Args: cobra.ExactArgs(1),
Use: "batch-supply [batch-denom]",
Copy link
Member Author

Choose a reason for hiding this comment

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

Same as batch-balance, batch-supply made more sense in this context.

regen query ecocredit types
`,
Args: cobra.ExactArgs(0),
Use: "credit-types",
Copy link
Member Author

Choose a reason for hiding this comment

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

Same name as query method and we have credit-type. Also more descriptive.

cmd := &cobra.Command{
Use: "buy-direct-batch [orders]",
Use: "buy-direct-bulk [orders-json]",
Copy link
Member Author

Choose a reason for hiding this comment

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

Aligns with send-bulk and batch might be confusing with credit batches.

// represent a new credit batch.
func TxGenBatchJSONCmd() *cobra.Command {
cmd := &cobra.Command{
Use: `gen-batch-json [issuer] [project-id] [issuance-count] [metadata] [start-date] [end-date]`,
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure how valuable this command is given we provide example JSON in create-batch. I switched this to arguments rather than flags but maybe flags were being used because of the number of arguments. Although all are required and to be consistent with how we are using flags, arguments made more sense to me.

@codecov
Copy link

codecov bot commented Jul 21, 2022

Codecov Report

Merging #1288 (f65ebbc) into master (d83d79a) will increase coverage by 0.28%.
The diff coverage is 96.74%.

@@            Coverage Diff             @@
##           master    #1288      +/-   ##
==========================================
+ Coverage   77.29%   77.57%   +0.28%     
==========================================
  Files         212      212              
  Lines       16110    15973     -137     
==========================================
- Hits        12452    12391      -61     
+ Misses       2661     2593      -68     
+ Partials      997      989       -8     
Flag Coverage Δ
experimental-codecov 77.57% <96.74%> (?)
stable-codecov ?

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

Impacted Files Coverage Δ
x/ecocredit/client/tx.go 85.32% <91.72%> (+3.11%) ⬆️
x/ecocredit/client/basket/query.go 76.74% <100.00%> (ø)
x/ecocredit/client/basket/tx.go 71.06% <100.00%> (-2.65%) ⬇️
x/ecocredit/client/marketplace/query.go 73.91% <100.00%> (-2.28%) ⬇️
x/ecocredit/client/marketplace/tx.go 88.43% <100.00%> (+0.78%) ⬆️
x/ecocredit/client/query.go 78.94% <100.00%> (-2.11%) ⬇️
x/ecocredit/client/testsuite/query.go 99.34% <100.00%> (ø)
x/ecocredit/client/testsuite/suite.go 96.07% <100.00%> (ø)
x/ecocredit/client/testsuite/tx_basket.go 100.00% <100.00%> (ø)
x/ecocredit/client/testsuite/tx_marketplace.go 100.00% <100.00%> (ø)
... and 8 more

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.

lgtm - most of my review comments arent really related to the changes but figured we could clean em up here anyway 😄

x/ecocredit/client/basket/tx.go Outdated Show resolved Hide resolved
x/ecocredit/client/basket/tx.go Outdated Show resolved Hide resolved
x/ecocredit/client/basket/tx.go Outdated Show resolved Hide resolved
x/ecocredit/client/basket/tx.go Outdated Show resolved Hide resolved
@ryanchristo ryanchristo merged commit 5ce8e9e into master Jul 21, 2022
@ryanchristo ryanchristo deleted the ryan/1271-cli-examples branch July 21, 2022 17:46
mergify bot pushed a commit that referenced this pull request Jul 21, 2022
* refactor(x/ecocredit): clean up commands and command examples

* refactor(x/ecocredit): clean up commands and command examples

* fix format and import

* update credit types query

* Apply suggestions from code review

Co-authored-by: Tyler <[email protected]>

* update changelog

* improve basket query examples and update test batch denom

Co-authored-by: Tyler <[email protected]>
(cherry picked from commit 5ce8e9e)
ryanchristo added a commit that referenced this pull request Jul 21, 2022
* refactor(x/ecocredit): clean up commands and command examples

* refactor(x/ecocredit): clean up commands and command examples

* fix format and import

* update credit types query

* Apply suggestions from code review

Co-authored-by: Tyler <[email protected]>

* update changelog

* improve basket query examples and update test batch denom

Co-authored-by: Tyler <[email protected]>
(cherry picked from commit 5ce8e9e)

Co-authored-by: Ryan Christoffersen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v4.0.x backport to release/v4.0.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve command examples and consistent format
3 participants