-
Notifications
You must be signed in to change notification settings - Fork 11
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(airdrop-token-vesting): improve cliff validation logic #132
fix(airdrop-token-vesting): improve cliff validation logic #132
Conversation
WalkthroughThe recent update streamlines the airdrop token vesting contract by removing dependency on block time for vesting account registration and user rewards. It simplifies error handling by discarding the Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this 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
Files ignored due to path filters (1)
Cargo.lock
is excluded by:!**/*.lock
Files selected for processing (4)
- contracts/airdrop-token-vesting/src/contract.rs (4 hunks)
- contracts/airdrop-token-vesting/src/errors.rs (2 hunks)
- contracts/airdrop-token-vesting/src/msg.rs (5 hunks)
- contracts/airdrop-token-vesting/src/testing.rs (4 hunks)
Additional comments: 10
contracts/airdrop-token-vesting/src/errors.rs (2)
- 23-26: The
InvalidTimeRange
error variant now includescliff_time
, which aligns with the PR's objective to refine cliff validation logic. This change enhances the error's descriptiveness by including all relevant time parameters.- 29-33: The addition of the
ExcessiveAmount
variant toVestingError
is a good practice for explicitly handling cases where thecliff_amount
exceeds thevesting_amount
. This makes error handling more precise and informative.contracts/airdrop-token-vesting/src/msg.rs (2)
- 67-70: The update to
RewardUserRequest
'svalidate
method to include theExcessiveAmount
error is a positive change. It ensures that thecliff_amount
does not exceed thevesting_amount
, aligning with the PR's objectives for improved error handling.- 169-193: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [161-187]
The
validate
method inVestingSchedule
has been significantly updated to include checks forstart_time
,end_time
, andcliff_time
. This aligns with the PR's objectives to support retroactive grants and improve time validation logic. However, there's a potential redundancy in the checks forcliff_time < start_time
andcliff_time > end_time
, as these conditions are already covered by the other checks. Consider simplifying this logic to avoid unnecessary complexity.- if cliff_time < start_time { - return Err(VestingError::InvalidTimeRange { - start_time: start_time.u64(), - cliff_time: cliff_time.u64(), - end_time: end_time.u64(), - }); - }contracts/airdrop-token-vesting/src/contract.rs (2)
- 163-163: The call to
vesting_schedule.validate()
in thereward_users
function aligns with the PR's objectives to improve time validation logic. This ensures that the vesting schedule is validated before proceeding with rewarding users, enhancing the contract's robustness.- 216-216: Similarly, the call to
vesting_schedule.validate()
inregister_vesting_account
ensures that the vesting schedule is validated upon account registration. This is a crucial step for maintaining the integrity of the vesting process.contracts/airdrop-token-vesting/src/testing.rs (4)
- 3-3: The import of
VestingError
fromcrate::errors
is correctly updated to reflect the consolidation of error types, aligning with the PR's objective to streamline error handling by using a singleInvalidTimeRange
error for time validation issues.- 294-298: The replacement of
CliffError::InvalidTime
withVestingError::InvalidTimeRange
and the adjustment of error handling with updated time parameters in theregister_cliff_vesting_account_with_native_token
function align with the PR's objective to consolidate time-related validation errors. This change simplifies error management by using a single error type for time validation issues.- 310-310: The use of
VestingError::InvalidTimeRange
for handling the case where the end time is less than the start time is consistent with the PR's goal of error handling refinement. This ensures that time validation errors are managed in a unified manner across the contract.- 324-324: The replacement of
CliffError::ExcessiveAmount
withVestingError::ExcessiveAmount
in the context of cliff amount validation is a logical change that aligns with the PR's objective of error consolidation. This maintains consistency in error handling across different types of validation errors within the contract.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
|
InvalidTimeRange
Cliff
structSummary by CodeRabbit