Skip to content

Commit

Permalink
Migration 7 ran
Browse files Browse the repository at this point in the history
  • Loading branch information
rrecuero committed Jan 10, 2024
1 parent e2c7522 commit 299cfde
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 20 deletions.
61 changes: 61 additions & 0 deletions broadcast/07-deploy_kinto_app.sol/7887/run-1704844364.json

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions broadcast/07-deploy_kinto_app.sol/7887/run-latest.json

Large diffs are not rendered by default.

41 changes: 26 additions & 15 deletions script/migrations/07-deploy_kinto_app.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
pragma solidity ^0.8.23;

import "forge-std/Script.sol";
import "../../src/apps/KintoAppRegistry.sol";
Expand All @@ -17,37 +17,48 @@ contract KintoMigration7DeployScript is Create2Helper, ArtifactsReader {
using ECDSAUpgradeable for bytes32;

KintoAppRegistry _kintoApp;
KintoAppRegistry _kintoAppImpl;

function setUp() public {}

// solhint-disable code-complexity
function run() public {
console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid));
// If not using ledger, replace
// Execute this script with the admin
// uint256 deployerPrivateKey = vm.envUint('PRIVATE_KEY');
// vm.startBroadcast(deployerPrivateKey);
vm.startBroadcast();
// Execute this script with the hot wallet
uint256 deployerPrivateKey = vm.envUint('PRIVATE_KEY');
vm.startBroadcast(deployerPrivateKey);
console.log("Executing with address", msg.sender);
address ledgerAdmin = vm.envAddress('LEDGER_ADMIN');
console.log("Executing with ledger admin as", ledgerAdmin);

address appAddr = _getChainDeployment("KintoAppRegistry");
if (appAddr != address(0)) {
console.log("KintoAppRegistry already deployed", appAddr);
return;
}
address walletFactoryAddr = _getChainDeployment("KintoWalletFactory");
IKintoWalletFactory _walletFactory = IKintoWalletFactory(walletFactoryAddr);
_kintoApp = KintoAppRegistry(
_walletFactory.deployContract(
msg.sender, 0, abi.encodePacked(type(KintoAppRegistry).creationCode), bytes32(0)
IOldWalletFactory _walletFactory = IOldWalletFactory(walletFactoryAddr);

bytes memory bytecode = abi.encodePacked(
abi.encodePacked(type(KintoAppRegistry).creationCode),
abi.encode(
address(_walletFactory)
)
);
_kintoAppImpl = KintoAppRegistry(
_walletFactory.deployContract{value: 0}(
0, bytecode, bytes32(0)
)
);
address credits = _getChainDeployment("EngenCredits");
// Fund in the paymaster
SponsorPaymaster _paymaster = SponsorPaymaster(payable(_getChainDeployment("SponsorPaymaster")));
_paymaster.addDepositFor{value: 1e17}(credits);
vm.stopBroadcast();

// Writes the addresses to a file
console.log("Add these new addresses to the artifacts file");
console.log(string.concat('"KintoAppRegistry": "', vm.toString(address(_kintoApp)), '"'));
console.log(string.concat('"KintoAppRegistry-impl": "', vm.toString(address(_kintoAppImpl)), '"'));
}
}

interface IOldWalletFactory {

function deployContract(uint256 amount, bytes calldata bytecode, bytes32 salt) external payable returns (address);
}
75 changes: 75 additions & 0 deletions script/migrations/08-deploy_registry_proxy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;

import "forge-std/Script.sol";
import "../../src/apps/KintoAppRegistry.sol";
import "../../src/paymasters/SponsorPaymaster.sol";
import "../../src/interfaces/IKintoWalletFactory.sol";
import {Create2Helper} from "../../test/helpers/Create2Helper.sol";
import {ArtifactsReader} from "../../test/helpers/ArtifactsReader.sol";
import {UUPSProxy} from "../../test/helpers/UUPSProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import "forge-std/console.sol";

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

KintoAppRegistry _kintoApp;
KintoAppRegistry _kintoAppImpl;

function setUp() public {}

// solhint-disable code-complexity
function run() public {
console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid));
// Execute this script with the hot wallet
uint256 deployerPrivateKey = vm.envUint('PRIVATE_KEY');
vm.startBroadcast(deployerPrivateKey);
console.log("Executing with address", msg.sender);
address ledgerAdmin = vm.envAddress('LEDGER_ADMIN');
console.log("Executing with ledger admin as", ledgerAdmin);

address appAddr = _getChainDeployment("KintoAppRegistry");
if (appAddr != address(0)) {
console.log("KintoAppRegistry already deployed", appAddr);
return;
}
address walletFactoryAddr = _getChainDeployment("KintoWalletFactory");
IOldWalletFactory _walletFactory = IOldWalletFactory(walletFactoryAddr);
address kintoAppRegistryImpl = _getChainDeployment("KintoAppRegistry-impl");

if (kintoAppRegistryImpl == address(0)) {
console.log("kintoAppRegistryImpl not deployed", appAddr);
return;
}
console.log("kintoAppRegistryImpl", kintoAppRegistryImpl);
bytes memory bytecode = abi.encodePacked(
abi.encodePacked(type(UUPSProxy).creationCode),
abi.encode(
address(kintoAppRegistryImpl),
bytes("")
)
);
// deploy _proxy contract and point it to _implementation

_kintoApp = KintoAppRegistry(
_walletFactory.deployContract{value: 0}(
0, bytecode, bytes32("")
)
);
_kintoApp.initialize();
vm.stopBroadcast();

// Writes the addresses to a file
console.log("Add these new addresses to the artifacts file");
console.log(string.concat('"KintoAppRegistry": "', vm.toString(address(_kintoApp)), '"'));

}
}

interface IOldWalletFactory {

function deployContract(uint256 amount, bytes calldata bytecode, bytes32 salt) external payable returns (address);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
pragma solidity ^0.8.23;

import "forge-std/Script.sol";
import "../../src/wallet/KintoWalletFactory.sol";
import "../../src/wallet/KintoWallet.sol";
import "../../src/paymasters/SponsorPaymaster.sol";
import {Create2Helper} from "../../test/helpers/Create2Helper.sol";
import {ArtifactsReader} from "../../test/helpers/ArtifactsReader.sol";
import {UUPSProxy} from "../../test/helpers/UUPSProxy.sol";
Expand Down Expand Up @@ -52,6 +53,10 @@ contract KintoMigration8DeployScript is Create2Helper, ArtifactsReader {
_kintoWalletImpl = KintoWalletV3(payable(_walletFactory.deployContract(msg.sender, 0, bytecode, bytes32(0))));
// Upgrade all implementations
_walletFactory.upgradeAllWalletImplementations(_kintoWalletImpl);
address credits = _getChainDeployment("EngenCredits");
// Fund in the paymaster
SponsorPaymaster _paymaster = SponsorPaymaster(payable(_getChainDeployment("SponsorPaymaster")));
_paymaster.addDepositFor{value: 1e17}(credits);
vm.stopBroadcast();
// Writes the addresses to a file
console.log("Add these new addresses to the artifacts file");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
pragma solidity ^0.8.23;

import "forge-std/Script.sol";
import "../../src/wallet/KintoWalletFactory.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
pragma solidity ^0.8.23;

import "forge-std/Script.sol";
import "../../src/wallet/KintoWalletFactory.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
pragma solidity ^0.8.23;

import "forge-std/Script.sol";
import "../../src/wallet/KintoWalletFactory.sol";
Expand Down Expand Up @@ -40,6 +40,7 @@ contract KintoMigration11DeployScript is Create2Helper, ArtifactsReader {
IKintoAppRegistry _kintoApp = IKintoAppRegistry(_getChainDeployment("KintoAppRegistry"));

// TODO: This needs to go through the entry point and the wallet we created in 4
// transfer ownership of kinto app proxy to admin
// Create Engen App
_kintoApp.registerApp("Engen", credits, new address[](0), [uint256(0), uint256(0), uint256(0), uint256(0)]);

Expand Down
3 changes: 2 additions & 1 deletion test/artifacts/7887/addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"EngenCredits": "0xb2F2BF932105A192566b56643BCa738eec06b3f1",
"KintoWallet-admin": "0x2e2B1c42E38f5af81771e65D87729E57ABD1337a",
"Faucet": "0xa62Bf9b53044885CddFcbC4cA52f51f8ae39eCFE",
"Counter": "0xdb791AF345A21588957E4e45596411b2Be2BD4cd"
"Counter": "0xdb791AF345A21588957E4e45596411b2Be2BD4cd",
"KintoAppRegistry-impl": "0x0e0e7c6e5e5b5b4b0b4b4b4b4b4b4b4b4b4b4b4b"
}

0 comments on commit 299cfde

Please sign in to comment.