Skip to content

Commit

Permalink
chore: tmp fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fedealconada committed Jan 23, 2024
1 parent d09fac1 commit cceee1a
Showing 1 changed file with 58 additions and 20 deletions.
78 changes: 58 additions & 20 deletions script/migrations/21-multiple_upgrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ contract KintoMigration21DeployScript is Create2Helper, ArtifactsReader, UserOp
bytes memory bytecode =
abi.encodePacked(type(SponsorPaymasterV4).creationCode, abi.encode(_getChainDeployment("EntryPoint")));

vm.broadcast(deployerPrivateKey);
_paymasterImpl = _walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0));
// vm.broadcast(deployerPrivateKey);
// _paymasterImpl = _walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0));
_paymasterImpl = 0x77222bdac39671db6C91c7fFc85E0909B76177c8;

// (3). upgrade paymaster to new implementation
// vm.broadcast(); // requires LEDGER_ADMIN
vm.prank(vm.envAddress("LEDGER_ADMIN"));
vm.broadcast(); // requires LEDGER_ADMIN
// vm.prank(vm.envAddress("LEDGER_ADMIN"));
SponsorPaymaster(payable(paymasterProxy)).upgradeTo(address(_paymasterImpl));
}

Expand All @@ -76,12 +77,14 @@ contract KintoMigration21DeployScript is Create2Helper, ArtifactsReader, UserOp
bytes memory bytecode =
abi.encodePacked(type(KintoAppRegistryV3).creationCode, abi.encode(address(_walletFactory)));

vm.broadcast(deployerPrivateKey);
_registryImpl =
_walletFactory.deployContract{value: 0}(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32("1"));
// vm.broadcast(deployerPrivateKey);
// _registryImpl =
// _walletFactory.deployContract{value: 0}(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32("1"));
_registryImpl =0xA82F30210F7dB1642bc20a5adCECbB16f766435B;

// (2). upgrade registry to new implementation
_upgradeTo(payable(registryProxy), _registryImpl, deployerPrivateKey);
_transferOwnership(registryProxy, deployerPrivateKey, vm.envAddress("LEDGER_ADMIN"));
}

function upgradeWallet() public returns (address _walletImpl) {
Expand All @@ -94,12 +97,14 @@ contract KintoMigration21DeployScript is Create2Helper, ArtifactsReader, UserOp
IKintoAppRegistry(_getChainDeployment("KintoAppRegistry"))
)
);
vm.broadcast(deployerPrivateKey);
_walletImpl = _walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0));

// vm.broadcast(deployerPrivateKey);
// _walletImpl = _walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0));
_walletImpl = 0xAe84C7E23240Dc11f0B2711C20aEDE81E5a28fF2;

// (2). upgrade all implementations
// vm.broadcast(); // requires LEDGER_ADMIN
vm.prank(vm.envAddress("LEDGER_ADMIN"));
vm.broadcast(); // requires LEDGER_ADMIN
// vm.prank(vm.envAddress("LEDGER_ADMIN"));
_walletFactory.upgradeAllWalletImplementations(IKintoWallet(_walletImpl));
}

Expand All @@ -116,12 +121,13 @@ contract KintoMigration21DeployScript is Create2Helper, ArtifactsReader, UserOp
abi.encode(_walletImpl) // Encoded constructor arguments
);

vm.broadcast(deployerPrivateKey);
_factoryImpl = _walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0));
// vm.broadcast(deployerPrivateKey);
// _factoryImpl = _walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0));
_factoryImpl = 0x63495C71a036Fb886e65b6F41BA2A26d406E8108;

// (2). upgrade factory to new implementation
// vm.broadcast(); // requires LEDGER_ADMIN
vm.prank(vm.envAddress("LEDGER_ADMIN"));
vm.broadcast(); // requires LEDGER_ADMIN
// vm.prank(vm.envAddress("LEDGER_ADMIN"));
KintoWalletFactory(payable(factoryProxy)).upgradeTo(address(_factoryImpl));
}

Expand All @@ -133,16 +139,19 @@ contract KintoMigration21DeployScript is Create2Helper, ArtifactsReader, UserOp
// (1). deploy KYCViewerV2 implementation
bytes memory bytecode = abi.encodePacked(type(KYCViewerV2).creationCode, abi.encode(_walletFactory));

vm.broadcast(deployerPrivateKey);
_kycViewerImpl = _walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0));
// vm.broadcast(deployerPrivateKey);
// _kycViewerImpl = _walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0));
_kycViewerImpl = 0x8f33D61F5d1e53cD239e8CC603A64fE782f5CF90;

// (2). deploy KYCViewerV2 proxy
bytecode = abi.encodePacked(type(UUPSProxy).creationCode, abi.encode(address(_kycViewerImpl), ""));

vm.broadcast(deployerPrivateKey);
_proxy = _walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0));
// vm.broadcast(deployerPrivateKey);
// _proxy = _walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0));
_proxy = 0x2c377958A3bcF3C6B3e5D521f4057950b3513557;

_initialize(_proxy, deployerPrivateKey);
// _initialize(_proxy, deployerPrivateKey);
_transferOwnership(_proxy, deployerPrivateKey, vm.envAddress("LEDGER_ADMIN"));
}

function _upgradeTo(address _proxy, address _newImpl, uint256 _signerPk) internal {
Expand Down Expand Up @@ -196,4 +205,33 @@ contract KintoMigration21DeployScript is Create2Helper, ArtifactsReader, UserOp
vm.broadcast(deployerPrivateKey);
IEntryPoint(_getChainDeployment("EntryPoint")).handleOps(userOps, payable(vm.addr(_signerPk)));
}

function _transferOwnership(address _proxy, uint256 _signerPk, address _newOwner) internal {
address payable _from = payable(_getChainDeployment("KintoWallet-admin"));

// // fund _proxy in the paymaster
// ISponsorPaymaster _paymaster = ISponsorPaymaster(_getChainDeployment("SponsorPaymaster"));
// vm.broadcast(deployerPrivateKey);
// _paymaster.addDepositFor{value: 0.00000001 ether}(_proxy);
// assertEq(_paymaster.balances(_proxy), 0.00000001 ether);

// prep upgradeTo user op
uint256 nonce = IKintoWallet(_from).getNonce();
uint256[] memory privateKeys = new uint256[](1);
privateKeys[0] = _signerPk;
UserOperation[] memory userOps = new UserOperation[](1);
userOps[0] = _createUserOperation(
block.chainid,
_from,
_proxy,
0,
nonce,
privateKeys,
abi.encodeWithSelector(Ownable.transferOwnership.selector, _newOwner),
_getChainDeployment("SponsorPaymaster")
);

vm.broadcast(deployerPrivateKey);
IEntryPoint(_getChainDeployment("EntryPoint")).handleOps(userOps, payable(vm.addr(_signerPk)));
}
}

0 comments on commit cceee1a

Please sign in to comment.