Skip to content

Commit

Permalink
Add upgrade contract for core
Browse files Browse the repository at this point in the history
  • Loading branch information
SoraSuegami committed Sep 5, 2024
1 parent 4a79b70 commit c10b443
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
42 changes: 42 additions & 0 deletions packages/contracts/script/UpgradeCore.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import "forge-std/Script.sol";
import "forge-std/console.sol";
import "../src/EmailWalletCore.sol";

contract Upgrade is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
if (deployerPrivateKey == 0) {
console.log("PRIVATE_KEY env var not set");
return;
}

address core = vm.envAddress("CORE");
if (core == address(0)) {
console.log("CORE env var not set. Deploy EmailWalletCore and set env var");
return;
}

vm.startBroadcast(deployerPrivateKey);

// FIXME Set new TokenRegistry implementation
// e.g. TokenRegistryV2 tokenRegistryImpl = new TokenRegistryV2();
EmailWalletCore coreImpl = new EmailWalletCore();

EmailWalletCore coreProxy = EmailWalletCore(payable(core));
coreProxy.upgradeTo(address(coreImpl));

// If you want to call some v2 function, refer to the following steps
//
// TokenRegistryV2 tokenRegistryV2 = TokenRegistryV2(address(tokenRegistry));
// address usdc = tokenRegistry.getTokenAddress(0, "USDC");

vm.stopBroadcast();

console.log("Core implementation deployed at: %s", address(coreImpl));
console.log("---- DONE ----");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import "forge-std/Script.sol";
import "forge-std/console.sol";
import "../src/utils/TokenRegistry.sol";

contract Deploy is Script {
contract Upgrade is Script {
function run() external {

uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
if (deployerPrivateKey == 0) {
console.log("PRIVATE_KEY env var not set");
Expand All @@ -34,7 +33,7 @@ contract Deploy is Script {
//
// TokenRegistryV2 tokenRegistryV2 = TokenRegistryV2(address(tokenRegistry));
// address usdc = tokenRegistry.getTokenAddress(0, "USDC");

vm.stopBroadcast();

console.log("TokenRegistry implementation deployed at: %s", address(tokenRegistryImpl));
Expand Down

0 comments on commit c10b443

Please sign in to comment.