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: add new amounts to a periodic vesting account #136

Merged
merged 1 commit into from
Nov 4, 2021

Conversation

JimLarson
Copy link

@JimLarson JimLarson commented Nov 2, 2021

Description

Refs: Agoric/agoric-sdk#3956

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)

Copy link
Collaborator

@michaelfig michaelfig left a comment

Choose a reason for hiding this comment

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

Looking really good! I'm convinced that this is close to the minimal (tested) change needed for this feature.

I would like to see a separate consume(...) helper. Ping me again when you want another review.

x/auth/vesting/msg_server.go Outdated Show resolved Hide resolved
x/auth/vesting/handler_test.go Outdated Show resolved Hide resolved
Comment on lines 129 to 136
period := types.Period{
Length: nextP - time,
Amount: p[iP].Amount,
}
merged = append(merged, period)
timeP = nextP
time = nextP
iP++
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please factor this logic out into a consume function? It could be either a local-to-mergePeriods closure to avoid passing common arguments, or a file-level helper function.

That would help keep things DRY, make it easier for me to review, and avoid copy-pasta errors.

Copy link
Author

Choose a reason for hiding this comment

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

I've refactored along the lines you suggested and I think it's a net improvement. It still uses a grab-bag of function-local variables to hold the iteration state, but I think data abstraction would be more trouble than it's worth.

Another approach I considered was to convert the vesting schedules to use absolute time, merge the schedules more simply, then convert back to relative times. Again, I don't think it's worth the effort.

x/auth/vesting/msg_server.go Show resolved Hide resolved
@JimLarson
Copy link
Author

PTAL. Look especially at msg_server.go:220-225 to ensure that I'm updating the vesting account data correctly, and that the test coverage in handler_test.go looks sufficient.

Copy link
Collaborator

@michaelfig michaelfig left a comment

Choose a reason for hiding this comment

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

Looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants