forked from sphinx-labs/sphinx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ct): Support opt-in manager upgrades (sphinx-labs#602)
- Loading branch information
Showing
14 changed files
with
282 additions
and
90 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@chugsplash/contracts': patch | ||
'@chugsplash/core': patch | ||
--- | ||
|
||
Add support for opt-in manager upgrades |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.9; | ||
|
||
import { Proxy } from "./libraries/Proxy.sol"; | ||
import { ChugSplashRegistry } from "./ChugSplashRegistry.sol"; | ||
import { IChugSplashManager } from "./interfaces/IChugSplashManager.sol"; | ||
import { IChugSplashRegistry } from "./interfaces/IChugSplashRegistry.sol"; | ||
|
||
/** | ||
* @title ChugSplashManagerProxy | ||
* @notice Designed to be upgradable only by the end user and to allow upgrades only to | ||
* new manager versions that whitelisted by the ChugSplashRegistry. | ||
*/ | ||
contract ChugSplashManagerProxy is Proxy { | ||
/** | ||
* @notice Address of the ChugSplashRegistry. | ||
*/ | ||
ChugSplashRegistry public immutable registry; | ||
|
||
/** | ||
* @param _registry The ChugSplashRegistry's address. | ||
* @param _admin Owner of this contract. | ||
*/ | ||
constructor(ChugSplashRegistry _registry, address _admin) payable Proxy(_admin) { | ||
registry = _registry; | ||
} | ||
|
||
modifier isNotExecuting() { | ||
require( | ||
_getImplementation() == address(0) || | ||
IChugSplashManager(_getImplementation()).isExecuting() == false, | ||
"ChugSplashManagerProxy: execution in progress" | ||
); | ||
_; | ||
} | ||
|
||
modifier isApprovedImplementation(address _implementation) { | ||
require( | ||
registry.versions(_implementation) == true, | ||
"ChugSplashManagerProxy: unapproved manager" | ||
); | ||
_; | ||
} | ||
|
||
/** | ||
* @inheritdoc Proxy | ||
*/ | ||
function upgradeTo( | ||
address _implementation | ||
) public override proxyCallIfNotAdmin isNotExecuting isApprovedImplementation(_implementation) { | ||
super.upgradeTo(_implementation); | ||
} | ||
|
||
/** | ||
* @inheritdoc Proxy | ||
*/ | ||
function upgradeToAndCall( | ||
address _implementation, | ||
bytes calldata _data | ||
) | ||
public | ||
payable | ||
override | ||
proxyCallIfNotAdmin | ||
isNotExecuting | ||
isApprovedImplementation(_implementation) | ||
returns (bytes memory) | ||
{ | ||
return super.upgradeToAndCall(_implementation, _data); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.