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: normalize query output for vesting contracts #130

Merged
merged 8 commits into from
Mar 6, 2024

Conversation

matthiasmatt
Copy link
Contributor

@matthiasmatt matthiasmatt commented Mar 6, 2024

Purpose

Align the query entry points between the various vesting and airdrop smart contracts

Summary by CodeRabbit

  • New Features

    • Introduced a whitelist and token denomination (denom) loading feature.
    • Added a new vesting schedule query calculation for more accurate vesting details.
    • Enhanced vesting data structure to include additional fields such as master_address, vesting_denom, vesting_amount, and a detailed vesting_schedule.
    • Implemented the ability to return multiple vesting entries for comprehensive vesting information.
  • Refactor

    • Restructured the VestingData struct and related query outputs for improved clarity and functionality.
    • Updated testing structures to align with the new vesting data model, ensuring accurate and effective testing of vesting functionalities.

Copy link
Contributor

coderabbitai bot commented Mar 6, 2024

Walkthrough

The comprehensive updates in the airdrop token vesting contract enhance functionality by introducing a whitelist, managing token denomination, refining vesting schedule calculations, and optimizing the VestingData structure. These changes aim to improve usability, enabling detailed management of vesting data and accommodating multiple vesting entries efficiently.

Changes

Files Change Summaries
contract.rs, msg.rs, testing.rs - Introduced whitelist and denom loading
- Updated VestingData struct
- Enhanced vesting schedule calculations and outputs
- Adjusted testing scenarios to align with new structures
.gitignore - Added entries to ignore generated smart contract schema JSON types
Cookbook.md - Introduced new contracts: Core shifter, Core token vesting, Nibi Stargate, Nibi Stargate Perp, and Nusd Valuator with specialized functionalities.
contracts/core-cw3-flex-msig/README.md - Enhanced CW3 Flexible Multisig smart contract to support multiple multisigs with different voting thresholds and dynamic groups.

🐰✨
Changes abound, in code, they weave,
A vesting tale, we aim to achieve.
With whitelist in hand, and denom so bright,
Our tokens vest, day and night.
Through tests, we hop, with joy, we cheer,
For improvements made, to all, so dear.
🌟🐇

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@matthiasmatt matthiasmatt changed the title fix: make new contract with the same query output format as the previ… fix: normalize query output for vesting contracts Mar 6, 2024
Copy link

codecov bot commented Mar 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.41%. Comparing base (902b788) to head (58e3517).
Report is 10 commits behind head on main.

❗ Current head 58e3517 differs from pull request most recent head 7d0e432. Consider uploading reports for the commit 7d0e432 to get more accurate results

Additional details and impacted files
Files Coverage Δ
contracts/airdrop-token-vesting/src/contract.rs 98.17% <100.00%> (ø)
contracts/airdrop-token-vesting/src/msg.rs 84.70% <100.00%> (ø)
contracts/airdrop-token-vesting/src/testing.rs 98.25% <100.00%> (ø)

... and 7 files with indirect coverage changes

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1049e84 and b04ad64.
Files ignored due to path filters (3)
  • Cargo.lock is excluded by: !**/*.lock
  • contracts/airdrop-token-vesting/schema/execute_msg.json is excluded by: !**/*.json
  • contracts/airdrop-token-vesting/schema/vesting_account_response.json is excluded by: !**/*.json
Files selected for processing (3)
  • contracts/airdrop-token-vesting/src/contract.rs (2 hunks)
  • contracts/airdrop-token-vesting/src/msg.rs (3 hunks)
  • contracts/airdrop-token-vesting/src/testing.rs (4 hunks)
Additional comments: 7
contracts/airdrop-token-vesting/src/msg.rs (3)
  • 104-107: The addition of new fields master_address, vesting_denom, vesting_amount, and vesting_schedule to the VestingData struct aligns with the PR objectives to enhance the contract's functionality and maintain consistency in query output formats. However, ensure that all instances where VestingData is constructed or modified throughout the codebase are updated to include these new fields.
  • 124-132: The introduction of the VestingScheduleQueryOutput enum is a significant enhancement. It provides a structured way to handle legacy queries and ensures that the vesting schedule can be easily converted into a query-friendly output format. This change supports the PR's goal of maintaining consistency in query outputs while improving the contract's flexibility.
  • 134-152: The from_vesting_to_query_output function is a crucial addition for converting VestingSchedule instances into the new VestingScheduleQueryOutput format. This function directly supports the PR's objective of enhancing the contract's functionality and maintaining consistency in query output formats. Ensure that this function is used wherever necessary to convert vesting schedules for query outputs.
contracts/airdrop-token-vesting/src/contract.rs (1)
  • 423-452: The modifications to the vesting_account function, including the addition of whitelist and denom loading, a new vesting_schedule_query calculation, and adjustments to the VestingData struct fields, are well-aligned with the PR objectives. These changes enhance the contract's data handling capabilities and ensure the return format of vesting entries is consistent with previous outputs. However, ensure comprehensive testing is conducted to verify the correct behavior of these modifications, especially in edge cases and failure scenarios.
contracts/airdrop-token-vesting/src/testing.rs (3)
  • 7-7: The addition of VestingScheduleQueryOutput in the import statements indicates the introduction of a new enum or struct to handle vesting schedules in a query-friendly manner. This aligns with the PR objectives to enhance the contract's flexibility and interoperability with different query formats. Ensure that this new type is thoroughly tested and documented to facilitate understanding and maintenance.
  • 682-697: The modifications to the VestingData structure within VestingAccountResponse include the addition of master_address, vesting_schedule, vesting_denom, and adjustments to related fields like vesting_amount, cliff_amount, and vested_amount for native token vesting. This change is crucial for aligning the testing framework with the new contract specifications and ensuring that testing accurately reflects the contract's operational logic. It's important to verify that these changes do not introduce any inconsistencies in the data model and that they are compatible with existing contract functionalities. Additionally, ensure that all new fields are properly validated and handled in the contract logic to prevent potential issues.
  • 798-813: Similar to the previous comment, the modifications to the VestingData structure within VestingAccountResponse for the claim_native test case include the addition of master_address, vesting_schedule, vesting_denom, and adjustments to related fields like vesting_amount, cliff_amount, vested_amount, and claimable_amount for native token vesting. This ensures that the testing framework is aligned with the new contract specifications. It's essential to verify that these changes are consistent across all test cases and that they accurately reflect the intended contract behavior. Additionally, consider adding more test cases to cover edge cases and ensure comprehensive coverage of the new functionalities introduced in the contract.

@Unique-Divine
Copy link
Member

Building artifacts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b04ad64 and 58e3517.
Files ignored due to path filters (6)
  • Cargo.lock is excluded by: !**/*.lock
  • contracts/core-token-vesting/schema/cw20_hook_msg.json is excluded by: !**/*.json
  • contracts/core-token-vesting/schema/execute_msg.json is excluded by: !**/*.json
  • contracts/core-token-vesting/schema/instantiate_msg.json is excluded by: !**/*.json
  • contracts/core-token-vesting/schema/query_msg.json is excluded by: !**/*.json
  • contracts/core-token-vesting/schema/vesting_account_response.json is excluded by: !**/*.json
Files selected for processing (3)
  • .gitignore (1 hunks)
  • Cookbook.md (25 hunks)
  • contracts/core-cw3-flex-msig/README.md (4 hunks)
Additional comments: 7
.gitignore (1)
  • 1-4: The additions to the .gitignore file are appropriate and ensure that generated smart contract schema JSON types are ignored by version control. This is a good practice for maintaining a clean repository.
contracts/core-cw3-flex-msig/README.md (2)
  • 3-17: The documentation provides a comprehensive overview of the CW3 Flexible Multisig smart contract, including its advantages and how it builds upon the cw3-fixed-multisig. The examples and explanations are clear and informative.
  • 1-205: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [22-245]

The usage guide, including instantiation, execution, and query examples, is well-detailed and provides clear instructions for interacting with the contract. This will be very helpful for developers looking to implement or interact with the contract.

Cookbook.md (4)
  • 3-45: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [6-95]

The introduction of new contracts and their respective sections in the Cookbook provides clear and detailed instructions for instantiation, execution, and querying. This is valuable for developers looking to understand or interact with these contracts.

  • 86-114: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [99-163]

The section on "Core token vesting" is well-documented, providing clear examples for executing and querying vesting accounts. It's important to ensure that the examples provided match the actual contract implementation.

  • 245-251: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [238-313]

The documentation for "Nibi Stargate Perp" and "Nusd Valuator" contracts is comprehensive, providing detailed examples for various operations. Ensure that the examples are consistent with the contract's code and functionality.

  • 405-422: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [343-422]

The "Nusd Valuator" section provides clear instructions for instantiation, execution, and querying. It's important to verify that the examples and functionalities described match the actual contract implementation.

contracts/core-cw3-flex-msig/README.md Show resolved Hide resolved
Cookbook.md Show resolved Hide resolved
@Unique-Divine Unique-Divine added type: bug/fix A pull request that fixes someting (pull) OR a ticket that highlights a bug (issue). type: refactor A code change that neither fixes a bug nor adds a feature labels Mar 6, 2024
@Unique-Divine Unique-Divine merged commit 55404f2 into main Mar 6, 2024
3 checks passed
@Unique-Divine Unique-Divine deleted the mat/normalize-output-query branch March 6, 2024 16:14
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 58e3517 and 7d0e432.
Files ignored due to path filters (10)
  • artifacts/airdrop_token_vesting.wasm is excluded by: !**/*.wasm
  • artifacts/cw3_flex_multisig.wasm is excluded by: !**/*.wasm
  • artifacts/incentives.wasm is excluded by: !**/*.wasm
  • artifacts/lockup.wasm is excluded by: !**/*.wasm
  • artifacts/nibi_stargate.wasm is excluded by: !**/*.wasm
  • artifacts/nibi_stargate_perp.wasm is excluded by: !**/*.wasm
  • artifacts/nusd_valuator.wasm is excluded by: !**/*.wasm
  • artifacts/pricefeed.wasm is excluded by: !**/*.wasm
  • artifacts/shifter.wasm is excluded by: !**/*.wasm
  • artifacts/token_vesting.wasm is excluded by: !**/*.wasm
Files selected for processing (3)
  • artifacts/checksums.txt (1 hunks)
  • contracts/airdrop-token-vesting/src/contract.rs (7 hunks)
  • nibiru-std/src/proto/buf/nibiru.oracle.v1.rs (14 hunks)
Files skipped from review due to trivial changes (1)
  • nibiru-std/src/proto/buf/nibiru.oracle.v1.rs
Additional comments: 6
artifacts/checksums.txt (1)
  • 1-11: Checksum updates for various .wasm files are noted. This is a standard procedure following changes in the contract code to ensure that the deployed artifacts are up to date. Ensure that these new checksums are correctly generated from the updated .wasm files.
contracts/airdrop-token-vesting/src/contract.rs (5)
  • 34-37: Ensure that the error messages provided are clear and informative for the end-user. For instance, specifying the type of token expected can make the error message more helpful.
- "must deposit exactly one type of token"
+ "must deposit exactly one type of token, e.g., 'UST'"
- "must deposit some token"
+ "must deposit a non-zero amount of the token"
  • 41-41: Validating that the managers list is not empty is crucial for ensuring that there is at least one manager who can perform necessary operations. This is a good practice for maintaining the integrity of the contract's administrative functions.
  • 130-137: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [119-134]

The withdrawal functionality correctly checks for authorization and ensures that the amount to be withdrawn does not exceed the unallocated amount. Additionally, it properly updates the unallocated amount after withdrawal. This logic is crucial for maintaining the contract's financial integrity.

  • 319-319: The send_if_amount_is_not_zero function is a good practice to avoid unnecessary transactions and gas usage. It ensures that tokens are only transferred when there is a non-zero amount to send, optimizing contract performance and cost.
  • 419-448: The vesting_account query function has been updated to return multiple vesting entries in a vector format, aligning with the PR's objectives to ensure consistency in query output formats. This change enhances the flexibility and usability of the contract's query interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug/fix A pull request that fixes someting (pull) OR a ticket that highlights a bug (issue). type: refactor A code change that neither fixes a bug nor adds a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants