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(ecocredit/marketplace): BuyDirect #967

Merged
merged 36 commits into from
Apr 11, 2022
Merged

Conversation

technicallyty
Copy link
Contributor

@technicallyty technicallyty commented Mar 31, 2022

Description

  • refactors Buy to only deal with filtered buy orders
  • creates new BuyDirect rpc method for purchasing directly from sell orders.
  • fixes an issue with calculating the total cost
  • adds test case for fractional purchase

Closes: #905


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)

@codecov
Copy link

codecov bot commented Mar 31, 2022

Codecov Report

Merging #967 (b0a45d3) into master (404cc06) will decrease coverage by 0.07%.
The diff coverage is 57.54%.

❗ Current head b0a45d3 differs from pull request most recent head 1c05433. Consider uploading reports for the commit 1c05433 to get more accurate results

@@            Coverage Diff             @@
##           master     #967      +/-   ##
==========================================
- Coverage   72.25%   72.17%   -0.08%     
==========================================
  Files         212      212              
  Lines       23521    23681     +160     
==========================================
+ Hits        16994    17091      +97     
- Misses       5168     5216      +48     
- Partials     1359     1374      +15     
Flag Coverage Δ
experimental-codecov 72.08% <57.54%> (-0.07%) ⬇️
stable-codecov 67.06% <57.54%> (-0.04%) ⬇️

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

Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

int64 roundtrip doesn't look good. Let's revisit.

x/ecocredit/marketplace/msg_buy_direct.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/buy.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/buy.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/buy.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/buy_direct.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/buy.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

int64 roundtrip doesn't look good. Let's revisit.

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. Should we use bid_price rather than changing the name? Do we want to support multiple orders in the same message as we do for Sell and Buy?

proto/regen/ecocredit/marketplace/v1/tx.proto Outdated Show resolved Hide resolved
proto/regen/ecocredit/marketplace/v1/tx.proto Outdated Show resolved Hide resolved
proto/regen/ecocredit/marketplace/v1/tx.proto Outdated Show resolved Hide resolved
x/ecocredit/marketplace/msg_buy_direct.go Outdated Show resolved Hide resolved
x/ecocredit/marketplace/msg_buy_direct_test.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/buy.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/buy.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/buy.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/buy.go Outdated Show resolved Hide resolved
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.

I think we should support multiple buy orders. Otherwise looks good.

proto/regen/ecocredit/marketplace/v1/tx.proto Outdated Show resolved Hide resolved
@ryanchristo
Copy link
Member

We'll also need a followup task for updating the CLI command.

@technicallyty
Copy link
Contributor Author

We'll also need a followup task for updating the CLI command.

#983

aaronc
aaronc previously requested changes Apr 6, 2022
Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

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

Please delete the Buy method and also buy.go so the diff shows buy_direct.go renamed to buy.go. That will be easier to review

proto/regen/ecocredit/marketplace/v1/tx.proto Outdated Show resolved Hide resolved
x/ecocredit/marketplace/msg_buy_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

pre-approving. Left few suggestions.

x/ecocredit/marketplace/msg_buy_test.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/utils.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/utils.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/utils.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/utils.go Outdated Show resolved Hide resolved
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.

Pre-approving with a few minor suggestions.

x/ecocredit/marketplace/msg_buy_direct_test.go Outdated Show resolved Hide resolved
assert.NilError(t, err)
} else {
assert.Check(t, err != nil)
assert.ErrorContains(t, err, tt.errMsg)
Copy link
Member

Choose a reason for hiding this comment

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

Might be nice to provide the whole error and use equals rather than contains but ok leave as is.

x/ecocredit/server/marketplace/buy_direct.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/buy_direct.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/utils.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/utils.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/utils.go Outdated Show resolved Hide resolved
technicallyty and others added 4 commits April 8, 2022 10:45
Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
@aaronc aaronc dismissed their stale review April 8, 2022 20:00

Addressed

@technicallyty technicallyty merged commit 43fe06e into master Apr 11, 2022
@technicallyty technicallyty deleted the ty/905-buy_direct branch April 11, 2022 17:25
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.

Implement standalone BuyDirect msg
4 participants