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

feat(marketplace): Buy ORM #899

Merged
merged 64 commits into from
Mar 30, 2022
Merged

feat(marketplace): Buy ORM #899

merged 64 commits into from
Mar 30, 2022

Conversation

technicallyty
Copy link
Contributor

@technicallyty technicallyty commented Mar 16, 2022

Description

  • adds direct buy ordering with ORM

ref: #856


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)

x/ecocredit/expected_keepers.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
x/ecocredit/server/marketplace/buy.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/buy.go 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
return err
}
supply.RetiredAmount = supplyRetired.String()
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

lot of repeated "decode + add". Would be good to create a helper function for that

Copy link
Collaborator

Choose a reason for hiding this comment

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

BTW, why did we decide to store numbers as string rather than bytes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure, just how its been done so far. perhaps we need an issue/discussion on it

Copy link
Member

Choose a reason for hiding this comment

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

BTW, why did we decide to store numbers as string rather than bytes?

I thought we talked about this several times and everyone understood why. Since it's not clear can someone please make sure this is well documented so it doesn't keep coming up?

  1. we have no agreed upon standard for encoding big decimals or bid integers as bytes within the SDK, let alone in client applications
  2. decimal and integer types often need to be signed in transactions and need to be human readable for Ledger signing
  3. trying to find a solution for the above has always been seen as a premature optimization that will make debugging harder

at some point, a bytes standard may be useful, but for now I would consider it very low priority

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, let's continue in an issue - it's the same discussion as we have for addresses. Just for note that ledger eventually will use different serialization anyway.

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.

Looking generally very good but a few issues I see that should be addressed

x/ecocredit/server/marketplace/buy.go Outdated Show resolved Hide resolved
if err != nil {
return nil, fmt.Errorf("sell order %d: %w", selection.SellOrderId, err)
}
if sellOrder.DisableAutoRetire != order.DisableAutoRetire {
Copy link
Member

Choose a reason for hiding this comment

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

They don't need to be equal. If order.DisableAutoRetire == true, then sellOrder.Disable must == true. Otherwise we don't care.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

we should also make the error specific. it's not a mismatch, it's that we're trying to avoid retiring credits when they must be retired

return err
}
supply.RetiredAmount = supplyRetired.String()
}
Copy link
Member

Choose a reason for hiding this comment

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

BTW, why did we decide to store numbers as string rather than bytes?

I thought we talked about this several times and everyone understood why. Since it's not clear can someone please make sure this is well documented so it doesn't keep coming up?

  1. we have no agreed upon standard for encoding big decimals or bid integers as bytes within the SDK, let alone in client applications
  2. decimal and integer types often need to be signed in transactions and need to be human readable for Ledger signing
  3. trying to find a solution for the above has always been seen as a premature optimization that will make debugging harder

at some point, a bytes standard may be useful, but for now I would consider it very low priority

x/ecocredit/server/marketplace/buy.go Outdated Show resolved Hide resolved
x/ecocredit/server/marketplace/buy.go Show resolved Hide resolved
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

func TestBuy_ValidTradable(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Would really like to see BDD tests... by the time I got to this part of the PR my attention span was like 😴

Copy link
Member

Choose a reason for hiding this comment

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

Can you review #902 when you get a chance? I think we need to establish a standard for writing acceptance tests before we try implementing them throughout.

Copy link
Member

Choose a reason for hiding this comment

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

That PR looks good to me. Any particular questions you have @ryanchristo ?

Copy link
Member

Choose a reason for hiding this comment

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

Not at the moment but I'm sure I will have questions when migrating the existing acceptance tests (#895), especially on how we can reduce complexity and reuse initial setup for multiple test cases.

Copy link
Member

Choose a reason for hiding this comment

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

I think we'll want to 1) follow best practices for writing Gherkin - which hopefully that book will help with and 2) come up with best practices for implementing in golang.

I notice you needed to use gomock AnyTimes... things like that might be hard to figure out each time and it would be good to document best practices + tips

@technicallyty technicallyty enabled auto-merge (squash) March 30, 2022 23:04
@technicallyty technicallyty merged commit 44af8d1 into master Mar 30, 2022
@technicallyty technicallyty deleted the ty/856-buy_orm branch March 30, 2022 23:06
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.

None yet

4 participants