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

R4R: various: code clean up, refactoring #3580

Merged
merged 23 commits into from
Feb 14, 2019

Conversation

alessio
Copy link
Contributor

@alessio alessio commented Feb 10, 2019

client/rest: code cleanup and refactoring.

This heavy-weight refactoring sprang from an attempt of removing a duplicate PostProcessResponse() function located in client/keys/utils.go that turned out to be undoable without introducing import cycles. Thus I moved all x/modules-agnostic HTTP/REST basic request and response types and convenience functions into a new cosmos-sdk/types/rest standalone package.

The cosmos-sdk/client/rest package retains the txs handling functions that depend on CLIContext and TxBuilder provided by client/context and x/auth/client/txbuilder respectively.


  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote tests
  • Updated relevant documentation (docs/)
  • Added entries in PENDING.md with issue #
  • rereviewed Files changed in the github PR explorer

For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

Alessio Treglia added 2 commits February 9, 2019 21:30
This heavy-weight refactoring sprang from an attempt
of removing a duplicate PostProcessResponse() function
located in client/keys/utils.go that turned out to be
undoable without introducing import cycles.
Thus I moved all x/ modules-agnostic HTTP/REST basic
request and response types and convenience functions
into a new cosmos-sdk/types/rest standalone package.
The cosmos-sdk/client/rest package retains the txs
handling functions that depend on CLIContext and
TxBuilder provided by client/context and
x/auth/client/txbuilder respectively.
Disallow empty denoms.
@alessio alessio force-pushed the alessio/rest-types-refactoring branch from edd81ba to 0d176a6 Compare February 10, 2019 09:08
types/coin.go Outdated Show resolved Hide resolved
}

// UnjailReq request unjailing
type UnjailReq struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved all requests into this package

Copy link
Contributor

Choose a reason for hiding this comment

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

imho I don't think we should be doing this -- but I need to think on this some more after some coffee.

Copy link
Member

Choose a reason for hiding this comment

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

Agree with @alexanderbez here. I think each client/rest package should also have a types that exports the structs to call the endpoints.

@codecov
Copy link

codecov bot commented Feb 10, 2019

Codecov Report

Merging #3580 into develop will decrease coverage by 0.1%.
The diff coverage is 18.84%.

@@             Coverage Diff             @@
##           develop    #3580      +/-   ##
===========================================
- Coverage    60.92%   60.82%   -0.11%     
===========================================
  Files          188      189       +1     
  Lines        14084    14170      +86     
===========================================
+ Hits          8581     8619      +38     
- Misses        4959     5007      +48     
  Partials       544      544

@alessio alessio changed the title WIP: various: code clean up, refactoring R4R: various: code clean up, refactoring Feb 10, 2019
@cwgoes
Copy link
Contributor

cwgoes commented Feb 11, 2019

Fails the linter at present.

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Thanks @alessio. I left a few minor remarks. In addition, I don't think any of the coins stuff belongs here.

types/coin.go Outdated Show resolved Hide resolved
x/staking/client/rest/tx.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

It looks like types were just moved out of client/rest/types.go to types/rest/rest.go.

types/rest/rest.go Outdated Show resolved Hide resolved
types/rest/rest.go Outdated Show resolved Hide resolved
@alexanderbez
Copy link
Contributor

@alessio can you rebase and also remove any _ from the new tests in the client/keys package. This PR is blocking #3640.

@jackzampolin jackzampolin merged commit 1aa6c19 into develop Feb 14, 2019
@jackzampolin jackzampolin deleted the alessio/rest-types-refactoring branch February 14, 2019 16:53
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.

4 participants