feat(contracts): implement claim timelock and disputes holding window#873
Open
Dopezapha wants to merge 1 commit into
Open
feat(contracts): implement claim timelock and disputes holding window#873Dopezapha wants to merge 1 commit into
Dopezapha wants to merge 1 commit into
Conversation
|
@Dopezapha Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
@Dopezapha |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #841
PR Description
This PR implements a disputes holding window (claim timelock) for the digital inheritance contracts.
When a payout is triggered by calling
claim, the funds do not leave the contract immediately. Instead, the contract records the claim's timestamp in persistent storage (ClaimStatus) to start the timelock grace window. During this lock period, if the owner is still active or disputes the claim, they can callcancel_claimto reset the inactivity timer and reactivate the plan, or callreclaimto withdraw all vault assets back to their wallet and delete the plan.After the configured timelock duration expires,
trigger_payoutcan be called (pulled) to execute the asset distribution to beneficiaries.Changes Made
contracts/inheritance-contract/src/lib.rs:timelock_durationto thePlanstruct and updatedcreate_planto configure it.claimto store the start of the timelock in persistent storage underClaimStatuswith the current ledger timestamp.cancel_claimallowing the owner to delete the claim lock and reactivate the plan.reclaimallowing the owner to cancel the lock, delete the plan, and withdraw all vault assets.trigger_payoutto verify the timelock has expired before distributing the funds.TimelockNotExpiredandPayoutNotTriggerederror variants.contracts/inheritance-contract/src/test.rs:timelock_durationargument and test sequences.test_cancel_claim_successandtest_reclaim_successunit tests.Testing
Run the contract unit tests using Cargo:
cargo test --manifest-path contracts/inheritance-contract/Cargo.tomlResult: All 15 tests passed successfully.