From 0b2432da4395413768456ff8403e6a6f14242988 Mon Sep 17 00:00:00 2001 From: KONFeature Date: Mon, 23 Oct 2023 11:16:52 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Add=20a=20script=20to=20perform?= =?UTF-8?q?=20the=20version=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/UpdateToEip712Diamond.s.sol | 78 ++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 script/UpdateToEip712Diamond.s.sol diff --git a/script/UpdateToEip712Diamond.s.sol b/script/UpdateToEip712Diamond.s.sol new file mode 100644 index 0000000..b198f52 --- /dev/null +++ b/script/UpdateToEip712Diamond.s.sol @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GNU GPLv3 +pragma solidity 0.8.21; + +import "forge-std/console.sol"; +import "forge-std/Script.sol"; +import { UpgradeScript } from "./utils/UpgradeScript.s.sol"; +import { FrakToken } from "@frak/tokens/FrakToken.sol"; +import { FraktionTokens } from "@frak/fraktions/FraktionTokens.sol"; +import { MultiVestingWallets } from "@frak/wallets/MultiVestingWallets.sol"; +import { VestingWalletFactory } from "@frak/wallets/VestingWalletFactory.sol"; +import { FrakTreasuryWallet } from "@frak/wallets/FrakTreasuryWallet.sol"; +import { ReferralPool } from "@frak/reward/referralPool/ReferralPool.sol"; +import { Minter } from "@frak/minter/Minter.sol"; +import { ContentPool } from "@frak/reward/contentPool/ContentPool.sol"; +import { Rewarder } from "@frak/reward/Rewarder.sol"; +import { FrakRoles } from "@frak/roles/FrakRoles.sol"; +import { WalletMigrator } from "@frak/wallets/WalletMigrator.sol"; + +contract UpdateToEip712Diamond is UpgradeScript { + function run() external { + // Get the current treasury wallet address + UpgradeScript.ContractProxyAddresses memory addresses = _currentProxyAddresses(); + + // Update all the tokens contracts + _updateToDiamondEip712(addresses); + + // Update the reward pools contracts + _updateRewardPoolsContracts(addresses); + + // Deploy the migrator contract + WalletMigrator walletMigrator = _deployMigrator(addresses); + console.log("Migrator deployed to %s", address(walletMigrator)); + } + + /// @dev Update every contracts + function _updateToDiamondEip712(UpgradeScript.ContractProxyAddresses memory addresses) internal deployerBroadcast { + // Deploy every contract + FrakToken frakToken = new FrakToken(); + FraktionTokens fraktionTokens = new FraktionTokens(); + + // Update frk proxy + bytes memory updateData = bytes.concat(FrakToken.updateToDiamondEip712.selector); + _upgradeToAndCall(addresses.frakToken, address(frakToken), updateData); + + // Update fraktion proxy + updateData = bytes.concat(FraktionTokens.updateToDiamondEip712.selector); + _upgradeToAndCall(addresses.fraktionTokens, address(fraktionTokens), updateData); + } + + function _updateRewardPoolsContracts(UpgradeScript.ContractProxyAddresses memory addresses) + internal + deployerBroadcast + { + ReferralPool referralPool = new ReferralPool(); + ContentPool contentPool = new ContentPool(); + Rewarder rewarder = new Rewarder(); + + _upgradeTo(addresses.contentPool, address(contentPool)); + _upgradeTo(addresses.rewarder, address(rewarder)); + _upgradeTo(addresses.referralPool, address(referralPool)); + } + + /// @dev Deploy the migrator contract + function _deployMigrator(UpgradeScript.ContractProxyAddresses memory addresses) + internal + deployerBroadcast + returns (WalletMigrator) + { + // Build the wallet migrator we will test + return new WalletMigrator( + addresses.frakToken, + addresses.fraktionTokens, + addresses.rewarder, + addresses.contentPool, + addresses.referralPool + ); + } +}