-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
153 additions
and
0 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,41 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "forge-std/Script.sol"; | ||
import "openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
import "openzeppelin/proxy/transparent/ProxyAdmin.sol"; | ||
|
||
import "../../../src/Rewarder.sol"; | ||
|
||
contract RewarderDeployer is Script { | ||
function run() public returns (address, address, address) { | ||
vm.createSelectFork(stdChains["fuji"].rpcUrl); | ||
|
||
uint256 deployerPrivateKey = vm.envUint("DEPLOY_PRIVATE_KEY"); | ||
|
||
/** | ||
* Start broadcasting the transaction to the network. | ||
*/ | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
ProxyAdmin admin = new ProxyAdmin(); | ||
|
||
Rewarder implementation = new Rewarder(); | ||
|
||
TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy( | ||
address(implementation), | ||
address(admin), | ||
"" | ||
); | ||
|
||
Rewarder(payable(address(proxy))).initialize(30 days); | ||
|
||
vm.stopBroadcast(); | ||
/** | ||
* Stop broadcasting the transaction to the network. | ||
*/ | ||
|
||
return (address(proxy), address(implementation), address(admin)); | ||
} | ||
} |
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,54 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "forge-std/Script.sol"; | ||
import "openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
import "openzeppelin/proxy/transparent/ProxyAdmin.sol"; | ||
|
||
import "../../../src/Rewarder.sol"; | ||
|
||
contract RewarderUpgrader is Script { | ||
IVBS public constant vbs = IVBS(0xFFC08538077a0455E0F4077823b1A0E3e18Faf0b); | ||
|
||
ProxyAdmin public constant admin = ProxyAdmin(0x46709dbc09656292B27ad91EE2c5d324270D3387); | ||
|
||
TransparentUpgradeableProxy public constant proxy = | ||
TransparentUpgradeableProxy(payable(0x1D336E165CbA662fa49B935fFdD7362C09Cc93ec)); | ||
|
||
function run() public returns (address) { | ||
vm.createSelectFork(stdChains["fuji"].rpcUrl, 17_891_593); | ||
|
||
uint256 deployerPrivateKey = vm.envUint("DEPLOY_PRIVATE_KEY"); | ||
|
||
/** | ||
* Start broadcasting the transaction to the network. | ||
*/ | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
Rewarder implementation = new Rewarder(); | ||
|
||
vbs.call( | ||
address(admin), abi.encodeWithSelector(admin.upgrade.selector, address(proxy), address(implementation)) | ||
); | ||
|
||
vm.stopBroadcast(); | ||
/** | ||
* Stop broadcasting the transaction to the network. | ||
*/ | ||
|
||
return address(implementation); | ||
} | ||
} | ||
|
||
interface IVBS { | ||
function getOwner(uint256 _index) external view returns (address owner); | ||
|
||
function getNumberOfOwners() external view returns (uint256 nbOfAdmins); | ||
|
||
function addOwner(address _owner) external; | ||
|
||
function removeOwner(address _owner) external; | ||
|
||
function call(address _target, bytes calldata _data) external payable; | ||
} |
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,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "forge-std/Test.sol"; | ||
|
||
import "../script/deployment/fuji/Rewarder.deploy.sol"; | ||
|
||
contract RewarderDeployTest is Test { | ||
RewarderDeployer public deployer; | ||
|
||
function setUp() public { | ||
deployer = new RewarderDeployer(); | ||
} | ||
|
||
function testDeploy() public { | ||
(address proxy, address implementation, address admin) = deployer.run(); | ||
|
||
vm.startPrank(admin); | ||
assertEq(TransparentUpgradeableProxy(payable(proxy)).admin(), admin, "proxy admin"); | ||
assertEq(TransparentUpgradeableProxy(payable(proxy)).implementation(), implementation, "proxy implementation"); | ||
vm.stopPrank(); | ||
} | ||
} |
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,34 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "forge-std/Test.sol"; | ||
|
||
import "../script/deployment/fuji/Rewarder.upgrade.sol"; | ||
|
||
contract RewarderUpgradeTest is Test { | ||
RewarderUpgrader public upgrader; | ||
|
||
function setUp() public { | ||
vm.createSelectFork(stdChains["fuji"].rpcUrl); | ||
|
||
upgrader = new RewarderUpgrader(); | ||
} | ||
|
||
function testUpgrade() public { | ||
address admin = address(upgrader.admin()); | ||
address proxy = address(upgrader.proxy()); | ||
|
||
vm.prank(admin); | ||
address implementation = TransparentUpgradeableProxy(payable(proxy)).implementation(); | ||
|
||
address newImplementation = upgrader.run(); | ||
|
||
assertTrue(address(implementation) != newImplementation, "new implementation"); | ||
|
||
vm.prank(admin); | ||
assertEq( | ||
TransparentUpgradeableProxy(payable(proxy)).implementation(), newImplementation, "proxy implementation" | ||
); | ||
} | ||
} |