From edb595743793738ac5d8f040656e4b942a401fb8 Mon Sep 17 00:00:00 2001 From: gnkz Date: Thu, 14 Nov 2024 11:47:34 -0300 Subject: [PATCH] chore: update deployment script --- script/Deploy.s.sol | 22 ++++++++++++++++++++++ test/TokenFactory.t.sol | 16 +++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 script/Deploy.s.sol diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol new file mode 100644 index 0000000..0dd10dc --- /dev/null +++ b/script/Deploy.s.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.4; + +import {Script} from "forge-std/Script.sol"; + +import {ERC20TokenUpgradeable} from "../src/ERC20TokenUpgradeable.sol"; +import {ERC20TokenUpgradeableProxy} from "../src/ERC20TokenUpgradeableProxy.sol"; +import {TokenFactory} from "../src/TokenFactory.sol"; +import {WrappedNativeToken} from "../src/WrappedNativeToken.sol"; + +contract DeployFactory is Script { + function run() external { + vm.startBroadcast(); + + ERC20TokenUpgradeableProxy proxy = new ERC20TokenUpgradeableProxy(); + ERC20TokenUpgradeable token = new ERC20TokenUpgradeable(); + + new TokenFactory(address(proxy), address(token)); + + vm.stopBroadcast(); + } +} diff --git a/test/TokenFactory.t.sol b/test/TokenFactory.t.sol index 21cc557..d003555 100644 --- a/test/TokenFactory.t.sol +++ b/test/TokenFactory.t.sol @@ -3,11 +3,12 @@ pragma solidity ^0.8.4; import {Test} from "forge-std/Test.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; +import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +import {Brick} from "../src/Brick.sol"; import {TokenFactory} from "../src/TokenFactory.sol"; import {ERC20TokenUpgradeable} from "../src/ERC20TokenUpgradeable.sol"; import {ERC20TokenUpgradeableProxy} from "../src/ERC20TokenUpgradeableProxy.sol"; -import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract TokenFactoryTest is Test { TokenFactory factory; @@ -40,6 +41,19 @@ contract TokenFactoryTest is Test { vm.assertEq(token.owner(), owner); } + function testDeployedTokenCanBeUpgraded() public { + string memory tokenName = "Upgradeable Token"; + string memory tokenSymbol = "uToken"; + uint256 initialSupply = 1_000_000 ether; + + ERC20TokenUpgradeable token = + ERC20TokenUpgradeable(factory.deployERC20Upgradeable(tokenName, tokenSymbol, initialSupply, owner, owner)); + + vm.startPrank(owner); + token.upgradeToAndCall(address(new Brick()), ""); + vm.stopPrank(); + } + function testDeployedProxyCannotBeInitializedAgain() public { string memory tokenName = "Upgradeable Token"; string memory tokenSymbol = "uToken";