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

fix(types): return nil duration and timestamp #1292

Merged
merged 3 commits into from
Jul 22, 2022

Conversation

ryanchristo
Copy link
Member

@ryanchristo ryanchristo commented Jul 21, 2022

Description

Closes: #1272

Manual tests: https://hackmd.io/ioZPdD22REaHBE1YQg1YPg

This pull request updates timestamp conversion functions to return nil if timestamp or duration is nil rather than returning the zero-value timestamp and duration. This only affects query responses where a timestamp or duration is used and where these values are not required when being added to state (e.g. sell order expiration). This will also use nil rather than the zero-value timestamp for issuance date when querying batches if a batch is added between now and the upgrade.

For example, a sell order with no expiration previously returned:

sell_order:
  ask_amount: "1000000"
  ask_denom: stake
  batch_denom: C01-001-20200101-20210101-001
  disable_auto_retire: true
  expiration: "1970-01-01T00:00:00Z"
  id: "2"
  quantity: "100"
  seller: regen1mjj52fal48xsj2q3yypguzwuqccxfr3larwezy

Now, a sell order with no expiration returns:

sell_order:
  ask_amount: "1000000"
  ask_denom: stake
  batch_denom: C01-001-20200101-20210101-001
  disable_auto_retire: true
  expiration: null
  id: "2"
  quantity: "100"
  seller: regen1mjj52fal48xsj2q3yypguzwuqccxfr3larwezy

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 Jul 21, 2022

Codecov Report

Merging #1292 (f6ef2d2) into master (5ce8e9e) will increase coverage by 0.07%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1292      +/-   ##
==========================================
+ Coverage   77.51%   77.58%   +0.07%     
==========================================
  Files         213      213              
  Lines       16084    16084              
==========================================
+ Hits        12467    12479      +12     
+ Misses       2613     2597      -16     
- Partials     1004     1008       +4     
Flag Coverage Δ
experimental-codecov 77.61% <100.00%> (+0.04%) ⬆️
stable-codecov 77.35% <100.00%> (+0.07%) ⬆️

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

Impacted Files Coverage Δ
types/timestamp.go 40.74% <100.00%> (ø)
types/ormstore/store.go 39.73% <0.00%> (+3.90%) ⬆️

@ryanchristo ryanchristo marked this pull request as ready for review July 21, 2022 20:36
@ryanchristo ryanchristo added the backport/v4.0.x backport to release/v4.0.x branch label Jul 21, 2022
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!

@ryanchristo ryanchristo merged commit 727d41a into master Jul 22, 2022
@ryanchristo ryanchristo deleted the ryan/1272-timestamp-nil branch July 22, 2022 15:12
mergify bot pushed a commit that referenced this pull request Jul 22, 2022
* fix(types): return nil duration and timestamp

* update query sell order test with nil check

* add changelog

(cherry picked from commit 727d41a)
ryanchristo added a commit that referenced this pull request Jul 23, 2022
* fix(types): return nil duration and timestamp

* update query sell order test with nil check

* add changelog

(cherry picked from commit 727d41a)

Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
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.

Sell order with nil expiration returns invalid expiration date
3 participants