Skip to content

Commit

Permalink
Refactor deployment scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
eloi010 committed Dec 11, 2023
1 parent b8312e0 commit 99c8d06
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 17 deletions.
File renamed without changes.
File renamed without changes.
13 changes: 8 additions & 5 deletions script/deployManagedAccounts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ contract ManagedOpenfortDeploy is Script {
uint256 private constant LOCK_PERIOD = 5 days;
address private OPENFORT_GUARDIAN = vm.envAddress("PAYMASTER_OWNER_TESTNET");

function run() public {
function run()
public
returns (ManagedOpenfortAccount managedOpenfortAccountImpl, ManagedOpenfortFactory openfortFactory)
{
bytes32 versionSalt = vm.envBytes32("VERSION_SALT");
vm.startBroadcast(deployPrivKey);

// Create an acccount to serve as implementation
ManagedOpenfortAccount managedOpenfortAccountImpl = new ManagedOpenfortAccount{salt: versionSalt}();
managedOpenfortAccountImpl = new ManagedOpenfortAccount{salt: versionSalt}();
// deploy account factory (beacon)
ManagedOpenfortFactory openfortFactory = new ManagedOpenfortFactory{salt: versionSalt}(
openfortFactory = new ManagedOpenfortFactory{salt: versionSalt}(
deployAddress,
address(entryPoint),
address(managedOpenfortAccountImpl),
Expand All @@ -34,9 +37,9 @@ contract ManagedOpenfortDeploy is Script {
LOCK_PERIOD,
OPENFORT_GUARDIAN
);

vm.stopBroadcast();

address accountImpl = openfortFactory.implementation();
console.log("Account implementation: ", accountImpl);

Expand Down
8 changes: 3 additions & 5 deletions script/deployMock.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ contract DeployMock is Script {
uint256 internal deployPrivKey = vm.envUint("PK_PAYMASTER_OWNER_TESTNET");
address internal deployAddress = vm.addr(deployPrivKey);

function run() public {
function run() public returns (MockERC20 mockERC20, MockERC721 mockERC721) {
bytes32 versionSalt = bytes32(0x0);
vm.startBroadcast(deployPrivKey);

MockERC20 mockERC20 = new MockERC20{salt: versionSalt}();
(mockERC20);
MockERC721 mockERC721 = new MockERC721{salt: versionSalt}();
(mockERC721);
mockERC20 = new MockERC20{salt: versionSalt}();
mockERC721 = new MockERC721{salt: versionSalt}();

vm.stopBroadcast();
}
Expand Down
7 changes: 3 additions & 4 deletions script/deployOpenfortPaymasterV2.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ import {IEntryPoint} from "lib/account-abstraction/contracts/interfaces/IEntryPo
import {OpenfortPaymasterV2} from "../contracts/paymaster/OpenfortPaymasterV2.sol";

contract OpenfortPaymasterV2Deploy is Script {
uint256 internal deployPrivKey = vm.envUint("PK_PAYMASTER_OWNER_MAINNET");
uint256 internal deployPrivKey = vm.envUint("PK_PAYMASTER_OWNER_TESTNET");
address internal deployAddress = vm.addr(deployPrivKey);
IEntryPoint internal entryPoint = IEntryPoint((payable(vm.envAddress("ENTRY_POINT_ADDRESS"))));
uint32 internal constant UNSTAKEDELAYSEC = 8600;

function run() public {
function run() public returns (OpenfortPaymasterV2 openfortPaymaster) {
bytes32 versionSalt = vm.envBytes32("VERSION_SALT");
vm.startBroadcast(deployPrivKey);

OpenfortPaymasterV2 openfortPaymaster = new OpenfortPaymasterV2{salt: versionSalt}(entryPoint, deployAddress);

openfortPaymaster = new OpenfortPaymasterV2{salt: versionSalt}(entryPoint, deployAddress);
entryPoint.depositTo{value: 1.5 ether}(address(openfortPaymaster));
openfortPaymaster.addStake{value: 0.015 ether}(UNSTAKEDELAYSEC);

Expand Down
9 changes: 6 additions & 3 deletions script/deployUpgradeableAccounts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ contract UpgradeableOpenfortDeploy is Script {
uint256 private constant LOCK_PERIOD = 5 days;
address private OPENFORT_GUARDIAN = vm.envAddress("PAYMASTER_OWNER_TESTNET");

function run() public {
function run()
public
returns (UpgradeableOpenfortAccount upgradeableOpenfortAccountImpl, UpgradeableOpenfortFactory openfortFactory)
{
bytes32 versionSalt = vm.envBytes32("VERSION_SALT");
vm.startBroadcast(deployPrivKey);

// Create an acccount to serve as implementation
UpgradeableOpenfortAccount upgradeableOpenfortAccountImpl = new UpgradeableOpenfortAccount{salt: versionSalt}();
upgradeableOpenfortAccountImpl = new UpgradeableOpenfortAccount{salt: versionSalt}();
// deploy account factory (beacon)
UpgradeableOpenfortFactory openfortFactory = new UpgradeableOpenfortFactory{salt: versionSalt}(
openfortFactory = new UpgradeableOpenfortFactory{salt: versionSalt}(
deployAddress,
address(entryPoint),
address(upgradeableOpenfortAccountImpl),
Expand Down

0 comments on commit 99c8d06

Please sign in to comment.