-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update scripts and tests for new deployer template
- Loading branch information
Showing
6 changed files
with
50 additions
and
77 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.22; | ||
|
||
import "forge-std/Script.sol"; | ||
import "script/util/ScriptHelpers.sol"; | ||
|
||
import "script/deployers/CounterDeployer.s.sol"; | ||
|
||
contract Deploy is Script, ScriptHelpers, CounterDeployer { | ||
using stdJson for string; | ||
|
||
function run() public { | ||
address proxyAdmin = address(0); | ||
uint256 initialNumber = 5; | ||
deployCounterTransparent(proxyAdmin, initialNumber); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
39 changes: 21 additions & 18 deletions
39
script/deployers/DeployCounter.s.sol → script/deployers/CounterDeployer.s.sol
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 |
---|---|---|
@@ -1,40 +1,43 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.22; | ||
pragma solidity ^0.8.0; | ||
|
||
//////////////////////////////////////////////////// | ||
// AUTOGENERATED - DO NOT EDIT THIS FILE DIRECTLY // | ||
//////////////////////////////////////////////////// | ||
|
||
import "forge-std/Script.sol"; | ||
|
||
import "src/Counter.sol"; | ||
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; | ||
import {TransparentUpgradeableProxy, ITransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
|
||
struct CounterInput { | ||
uint256 number; | ||
} | ||
|
||
abstract contract CounterDeployer is Script { | ||
Counter internal counter; | ||
ProxyAdmin internal counterProxyAdmin; | ||
address internal counterLogic; | ||
|
||
function deployCounter(address proxyAdminOwner, CounterInput memory input) internal { | ||
bytes memory initData = abi.encodeCall(Counter.initialize, (input.number)); | ||
|
||
_deployCounter(proxyAdminOwner, initData); | ||
} | ||
address internal counterImplementation; | ||
|
||
function deployCounter_NoInit(address proxyAdminOwner) internal { | ||
_deployCounter(proxyAdminOwner, ""); | ||
} | ||
function deployCounterTransparent(address proxyAdminOwner, uint256 initialNumber) | ||
internal | ||
returns (address implementation, address proxyAdmin, address proxy) | ||
{ | ||
bytes memory initData = abi.encodeCall(Counter.initialize, (initialNumber)); | ||
|
||
function _deployCounter(address proxyAdminOwner, bytes memory initData) private { | ||
vm.startBroadcast(vm.envUint("PRIVATE_KEY")); | ||
|
||
counterLogic = address(new Counter()); | ||
counter = Counter(address(new TransparentUpgradeableProxy(counterLogic, proxyAdminOwner, initData))); | ||
counterImplementation = address(new Counter()); | ||
counter = Counter(address(new TransparentUpgradeableProxy(counterImplementation, proxyAdminOwner, initData))); | ||
|
||
vm.stopBroadcast(); | ||
|
||
counterProxyAdmin = | ||
ProxyAdmin(address(uint160(uint256(vm.load(address(counter), hex"b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103"))))); | ||
|
||
return (counterImplementation, address(counterProxyAdmin), address(counter)); | ||
} | ||
|
||
function deployCounterImplementation() internal returns (address implementation) { | ||
vm.startBroadcast(vm.envUint("PRIVATE_KEY")); | ||
implementation = address(new Counter()); | ||
vm.stopBroadcast(); | ||
} | ||
} |
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