This repository contains smart contracts for the StellarFlow Network with a time-locked upgrade mechanism to prevent "flash-upgrades" by enforcing a 48-hour delay between contract upgrade proposals and execution.
- Time-Locked Upgrades: 48-hour mandatory delay between upgrade proposal and execution
- Pending State Management: Secure storage of new WASM hash in pending state
- Timestamp Validation: Uses
ledger().timestamp()for accurate time validation - Admin-Only Operations: Only contract administrators can propose and execute upgrades
- Upgrade Cancellation: Ability to cancel pending upgrades before execution
- Timelock Monitoring: Functions to check remaining timelock time
- Storage Optimization: Vault storage footprint audit completed for sub-map balance tracking.
-
PendingUpgrade Struct: Stores information about pending upgrades
new_wasm_hash: The hash of the new contract codeproposed_at: Timestamp when the upgrade was proposedproposer: Address of who proposed the upgrade
-
ContractData Struct: Stores contract state
admin: Administrator address with upgrade permissionsvalue: Sample storage value for testing
initialize(): Sets up the contract with an admin addresspropose_upgrade(): Initiates the 48-hour timelock periodexecute_upgrade(): Executes the upgrade after timelock expirescancel_upgrade(): Cancels a pending upgradeget_pending_upgrade(): Returns pending upgrade info