Skip to content

Commit

Permalink
chore: update deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
gnkz committed Nov 14, 2024
1 parent 44b4e53 commit edb5957
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
22 changes: 22 additions & 0 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -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();
}
}
16 changes: 15 additions & 1 deletion test/TokenFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit edb5957

Please sign in to comment.