Skip to content

Commit

Permalink
ITimelockUpgrade doc
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetbout committed Jun 10, 2024
1 parent 9fa61db commit 1ea568f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/contracts/interface.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,25 @@ pub trait IGiftFactory<TContractState> {

#[starknet::interface]
pub trait ITimelockUpgrade<TContractState> {
/// @notice Propose a new implementation for the contract to upgrade to
/// @dev There is a 7 day window to be able to perform the upgrade then the upgrade can be performed for a window of 7 days
/// @dev If there is an ongoing upgrade the previous proposition will be overwritten
/// @param new_implementation The class hash of the new implementation
fn propose_upgrade(ref self: TContractState, new_implementation: ClassHash);

/// @notice Cancel the upgrade proposition
/// @dev Will fail if there is no ongoing upgrade
fn cancel_upgrade(ref self: TContractState);

/// @notice Perform the upgrade to the proposed implementation
/// @dev There is a 7 day window to be able to perform the upgrade then the upgrade can be performed for a window of 7 days
/// @param calldata The calldata to be used for the upgrade by perform_upgrade()
fn upgrade(ref self: TContractState, calldata: Array<felt252>);

/// @notice Gets the proposed implementation
fn get_proposed_implementation(self: @TContractState) -> ClassHash;

/// @notice Gets the upgrade ready at timestamp
fn get_upgrade_ready_at(self: @TContractState) -> u64;
}

Expand Down
2 changes: 0 additions & 2 deletions src/contracts/timelock_upgrade.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ pub mod TimelockUpgradeComponent {
fn propose_upgrade(ref self: ComponentState<TContractState>, new_implementation: ClassHash) {
self.assert_only_owner();
assert(new_implementation.is_non_zero(), 'upgrade/new-implementation-null');
// TODO If ongoing upgrade, should it fail?
// Atm we don't care and we just overwrite the previous upgrade
self.pending_implementation.write(new_implementation);
let ready_at = get_block_timestamp() + MIN_SECURITY_PERIOD;
self.ready_at.write(ready_at);
Expand Down

0 comments on commit 1ea568f

Please sign in to comment.