feat: Escrow single init guard#138
Merged
mikewheeleer merged 3 commits intoLiquifact:mainfrom Apr 1, 2026
Merged
Conversation
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.
Summary
This PR implements a one-time initialization guard for the LiquiFact Escrow contract. It prevents an already initialized escrow instance from being re-initialized, ensuring that immutable parameters (such as the funding token, treasury, and yield tiers) cannot be overwritten after the initial setup.
What Changed
Core Logic
DataKey::Initializedto the storage schema in lib.rs to track the initialization state.Initializedkey is not already present and set it totrueupon successful setup.Initializedflag before attempting to read the escrow state, providing a descriptive panic message if the contract is accessed prematurely.Closes #2
Testing & Documentation
ESC-INI-001(Single Initialization Guard) to the README.md for audit traceability.Why This Matters
Without this guard, a malicious actor (or accidental operation) could potentially call
initon an existing contract instance to overwrite critical storage keys likeFundingTokenorTreasury. This change enforces the immutability of the escrow configuration once finalized.Validation
cargo test -p liquifact_escrow. All 100 tests passed, including the new initialization scenarios.get_escrow(used by all authenticated functions) fails safely if the contract is uninitialized.Example Commit Message
feat(escrow): prevent re-initialization of existing escrow