Skip to content

Commit

Permalink
fund-faucet-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rrecuero committed Jan 20, 2024
1 parent 315c895 commit ed079f9
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 1 deletion.
4 changes: 4 additions & 0 deletions script/migrations/19-fund2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import "../../test/helpers/UUPSProxy.sol";
import "forge-std/Script.sol";
import "forge-std/console.sol";

contract KintoWalletFactoryV5 is KintoWalletFactory {
constructor(IKintoWallet _implAddressP) KintoWalletFactory(_implAddressP) {}
}

contract KintoMigration16DeployScript is Create2Helper, ArtifactsReader {
using ECDSAUpgradeable for bytes32;

Expand Down
73 changes: 73 additions & 0 deletions script/migrations/20-faucet_fun_fix.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;

import "../../src/wallet/KintoWalletFactory.sol";
import "../../src/wallet/KintoWallet.sol";
import "../../src/paymasters/SponsorPaymaster.sol";
import "../../src/KintoID.sol";

import "../../test/helpers/Create2Helper.sol";
import "../../test/helpers/ArtifactsReader.sol";
import "../../test/helpers/UUPSProxy.sol";

import "forge-std/Script.sol";
import "forge-std/console.sol";

contract KintoMigration16DeployScript is Create2Helper, ArtifactsReader {
using ECDSAUpgradeable for bytes32;

KintoWalletFactoryV6 _factoryImpl;

function setUp() public {}

// NOTE: this migration must be run from the ledger admin
function run() public {
console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid));
// Execute this script with the ledger admin but first we use the hot wallet
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);
console.log("Executing with address", msg.sender, vm.envAddress("LEDGER_ADMIN"));
address factoryAddr = _getChainDeployment("KintoWalletFactory");
if (factoryAddr == address(0)) {
console.log("Need to execute main deploy script first", factoryAddr);
return;
}
address v5factory = _getChainDeployment("KintoWalletFactoryV5-impl");
if (v5factory != address(0)) {
console.log("V5 already deployed", v5factory);
return;
}

IKintoWalletFactory _walletFactory = IKintoWalletFactory(payable(_getChainDeployment("KintoWalletFactory")));

address newImpl = _getChainDeployment("KintoWalletV3-impl");
if (newImpl == address(0)) {
console.log("Need to deploy the new wallet first", newImpl);
return;
}

bytes memory bytecode = abi.encodePacked(
type(KintoWalletFactoryV6).creationCode,
abi.encode(newImpl) // Encoded constructor arguments
);

// 1) Deploy new wallet factory
_factoryImpl = KintoWalletFactoryV6(
payable(_walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0)))
);

vm.stopBroadcast();
// Start admin
vm.startBroadcast();
// 2) Upgrade wallet factory
KintoWalletFactory(address(_walletFactory)).upgradeTo(address(_factoryImpl));
// 3) Send ETH to test signer
address _faucet = _getChainDeployment("Faucet");
KintoWalletFactory(address(_walletFactory)).sendMoneyToAccount{value: 0.7 ether}(_faucet);
require(address(_faucet).balance >= 0.7 ether, "amount was not sent");
vm.stopBroadcast();
// writes the addresses to a file
console.log("Add these new addresses to the artifacts file");
console.log(string.concat('"KintoWalletFactoryV6-impl": "', vm.toString(address(_factoryImpl)), '"'));
}
}
2 changes: 1 addition & 1 deletion src/wallet/KintoWalletFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,6 @@ contract KintoWalletFactory is Initializable, UUPSUpgradeable, OwnableUpgradeabl
}
}

contract KintoWalletFactoryV5 is KintoWalletFactory {
contract KintoWalletFactoryV6 is KintoWalletFactory {
constructor(IKintoWallet _implAddressP) KintoWalletFactory(_implAddressP) {}
}

0 comments on commit ed079f9

Please sign in to comment.