From d74539d11e3336a28de9c9db34a38d54497fc9d1 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 10 Apr 2024 10:00:58 +0100 Subject: [PATCH 1/4] remove constellations factories, tokens and tests --- scripts/core/ConstellationFactory.s.sol | 50 ----- scripts/tokens/ERC20Constellation.s.sol | 29 --- src/factories/Constellation.sol | 96 --------- src/factories/IConstellation.sol | 11 -- src/tokens/ERC20/ERC20Constellation.sol | 204 -------------------- src/tokens/ERC20/ERC20ConstellationMock.sol | 10 - test/Constellation/Constellation.t.sol | 106 ---------- 7 files changed, 506 deletions(-) delete mode 100644 scripts/core/ConstellationFactory.s.sol delete mode 100644 scripts/tokens/ERC20Constellation.s.sol delete mode 100644 src/factories/Constellation.sol delete mode 100644 src/factories/IConstellation.sol delete mode 100644 src/tokens/ERC20/ERC20Constellation.sol delete mode 100644 src/tokens/ERC20/ERC20ConstellationMock.sol delete mode 100644 test/Constellation/Constellation.t.sol diff --git a/scripts/core/ConstellationFactory.s.sol b/scripts/core/ConstellationFactory.s.sol deleted file mode 100644 index bd6c144..0000000 --- a/scripts/core/ConstellationFactory.s.sol +++ /dev/null @@ -1,50 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.16; - -import "forge-std/Script.sol"; -import "forge-std/console.sol"; -import {Utils} from "scripts/utils/Utils.sol"; -import {ConstellationFactory} from "src/factories/Constellation.sol"; - -string constant CONTRACT_NAME = "ConstellationFactory"; - -contract Deploy is Script, Utils { - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - - address erc20Base = getContractDeploymentAddress("ERC20Base"); - address globals = getContractDeploymentAddress("Globals"); - - if (globals == address(0)) { - revert("cannot find deployments, make sure to deploy ERC20Base and Globals first"); - } - - ConstellationFactory factory = new ConstellationFactory(erc20Base, globals); - - vm.stopBroadcast(); - - exportContractDeployment(CONTRACT_NAME, address(factory), block.number); - } -} - -contract CreateConstellation is Script, Utils { - function run(string memory appName) external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - - bytes32 appNameBytes32 = vm.parseBytes32(appName); - - if (appNameBytes32.length == 0) { - revert("please provide an app name, make CreateApp args=appName"); - } - - address appAddress = - ConstellationFactory(getContractDeploymentAddress(CONTRACT_NAME)).create("constellation_A", "CA", 18, 1000); - - console.log("App:", appName); - console.log("Deployed:", appAddress); - - vm.stopBroadcast(); - } -} diff --git a/scripts/tokens/ERC20Constellation.s.sol b/scripts/tokens/ERC20Constellation.s.sol deleted file mode 100644 index 36b702b..0000000 --- a/scripts/tokens/ERC20Constellation.s.sol +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.16; - -import "forge-std/Script.sol"; -import {Utils} from "scripts/utils/Utils.sol"; -import {ERC20Constellation} from "src/tokens/ERC20/ERC20Constellation.sol"; -import {Globals} from "src/globals/Globals.sol"; - -string constant CONTRACT_NAME = "ERC20Constellation"; -bytes32 constant implementationId = "Constellation"; - -contract Deploy is Script, Utils { - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - - // deploy - ERC20Constellation erc20Constellation = new ERC20Constellation(); - - // add to globals - Globals(getContractDeploymentAddress("Globals")).setERC20Implementation( - implementationId, address(erc20Constellation) - ); - - vm.stopBroadcast(); - - exportContractDeployment(CONTRACT_NAME, address(erc20Constellation), block.number); - } -} diff --git a/src/factories/Constellation.sol b/src/factories/Constellation.sol deleted file mode 100644 index 186213d..0000000 --- a/src/factories/Constellation.sol +++ /dev/null @@ -1,96 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.16; - -import {Ownable} from "@solidstate/contracts/access/ownable/Ownable.sol"; -import {MinimalProxyFactory} from "@solidstate/contracts/factory/MinimalProxyFactory.sol"; - -import {IConstellation} from "./IConstellation.sol"; -import {ERC20Base} from "../tokens/ERC20/ERC20Base.sol"; -import {IERC20} from "@solidstate/contracts/interfaces/IERC20.sol"; -import {IERC165} from "@solidstate/contracts/interfaces/IERC165.sol"; - -/** - * @title "Constellation Factory" - * @notice A contract for creating ERC20 (constellation) contracts. - * This contract deploys minimal proxies that point to a Proxy implementation/template - * and is designed to be deployed separately from the registry and managed by Open Format. - */ -contract ConstellationFactory is IConstellation, MinimalProxyFactory, Ownable { - address public globals; - address public template; - - // store created constellations - mapping(bytes32 => address) public constellations; // salt => deployment address - - constructor(address _template, address _globals) { - _setOwner(msg.sender); - template = _template; - globals = _globals; - } - - /** - * @dev _salt param can be thought as the constellation id - */ - function create(bytes32 _name, string memory _symbol, uint8 _decimals, uint256 _supply) - external - returns (address id) - { - bytes32 salt = keccak256(abi.encode(msg.sender, _name)); - - // check constellation not already deployed - if (constellations[salt] != address(0)) { - revert Constellation_NameAlreadyUsed(); - } - - // deploy new constellation using CREATE2 - id = _deployMinimalProxy(template, salt); - constellations[salt] = id; - - ERC20Base(payable(id)).initialize( - msg.sender, string(abi.encodePacked(bytes32(_name))), _symbol, _decimals, _supply, "" - ); - - emit Created(id, msg.sender, string(abi.encodePacked(bytes32(_name)))); - } - - function updateToken(bytes32 _name, address _oldTokenAddress, address _newTokenAddress) external { - bytes32 salt = keccak256(abi.encode(msg.sender, _name)); - address oldTokenAddress = constellations[salt]; - - if (oldTokenAddress == address(0)) { - revert Constellation_NotFoundOrNotOwner(); - } - - // check _newTokenAddress address is a valid ERC20 - if (!IERC165(_newTokenAddress).supportsInterface(type(IERC20).interfaceId)) { - revert Constellation_InvalidToken(); - } - - constellations[salt] = _newTokenAddress; - - emit UpdatedToken(_oldTokenAddress, _newTokenAddress); - } - - /** - * @notice returns the deterministic deployment address for constellation - * @dev The contract deployed is a minimal proxy pointing to the constellation template - * @return deploymentAddress the address of the constellation - */ - function calculateDeploymentAddress(address _account, bytes32 _name) external view returns (address) { - bytes32 salt = keccak256(abi.encode(_account, _name)); - // check constellation not already deployed - if (constellations[salt] != address(0)) { - revert Constellation_NameAlreadyUsed(); - } - - return _calculateMinimalProxyDeploymentAddress(template, salt); - } - - function setTemplate(address _template) public onlyOwner { - template = _template; - } - - function setGlobals(address _globals) public onlyOwner { - globals = _globals; - } -} diff --git a/src/factories/IConstellation.sol b/src/factories/IConstellation.sol deleted file mode 100644 index 4a18f95..0000000 --- a/src/factories/IConstellation.sol +++ /dev/null @@ -1,11 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.16; - -interface IConstellation { - error Constellation_NameAlreadyUsed(); - error Constellation_InvalidToken(); - error Constellation_NotFoundOrNotOwner(); - - event Created(address id, address owner, string name); - event UpdatedToken(address oldTokenAddress, address newTokenAddress); -} diff --git a/src/tokens/ERC20/ERC20Constellation.sol b/src/tokens/ERC20/ERC20Constellation.sol deleted file mode 100644 index 2791d1e..0000000 --- a/src/tokens/ERC20/ERC20Constellation.sol +++ /dev/null @@ -1,204 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.16; - -import {IERC20} from "@solidstate/contracts/interfaces/IERC20.sol"; -import {SolidStateERC20} from "@solidstate/contracts/token/ERC20/SolidStateERC20.sol"; -import {IERC2612} from "@solidstate/contracts/token/ERC20/permit/IERC2612.sol"; -import {ERC165Base} from "@solidstate/contracts/introspection/ERC165/base/ERC165Base.sol"; -import {IERC165} from "@solidstate/contracts/interfaces/IERC165.sol"; -import {AccessControl} from "@solidstate/contracts/access/access_control/AccessControl.sol"; -import {Multicall} from "@solidstate/contracts/utils/Multicall.sol"; -import {ReentrancyGuard} from "@solidstate/contracts/utils/ReentrancyGuard.sol"; - -import {ContractMetadata, IContractMetadata} from "@extensions/contractMetadata/ContractMetadata.sol"; -import {Initializable} from "@extensions/initializable/Initializable.sol"; -import {Global} from "@extensions/global/Global.sol"; -import {PlatformFee} from "@extensions/platformFee/PlatformFee.sol"; - -import {CurrencyTransferLib} from "src/lib/CurrencyTransferLib.sol"; - -/** - * @dev Thirdweb inspired ERC20Constellation contract using solidstates ERC20 contract and diamond storage throughout. - * has the edition of ERC165 - * - * The `ERC20Constellation` smart contract implements the ERC20 standard. - * It includes the following additions to standard ERC20 logic: - * - * - Ability to mint & burn tokens via the provided `mintTo` & `burn` functions. - * - * - Ownership of the contract, with the ability to restrict certain functions to - * only be called by the contract's owner. - * - * - Multicall capability to perform multiple actions atomically - * - * - EIP 2612 compliance: See {ERC20-permit} method, which can be used to change an account's ERC20 allowance by - * presenting a message signed by the account. - */ - -bytes32 constant ADMIN_ROLE = bytes32(uint256(0)); -bytes32 constant MINTER_ROLE = bytes32(uint256(1)); - -contract ERC20Constellation is - SolidStateERC20, - AccessControl, - Multicall, - ContractMetadata, - Initializable, - ERC165Base, - Global, - PlatformFee, - ReentrancyGuard -{ - error ERC20Constellation_notAuthorized(); - error ERC20Constellation_zeroAmount(); - error ERC20Constellation_insufficientBalance(); - - function initialize( - address _owner, - string memory _name, - string memory _symbol, - uint8 _decimals, - uint256 _supply, - bytes memory _data - ) public initializer { - _grantRole(ADMIN_ROLE, _owner); - - _setName(_name); - _setSymbol(_symbol); - _setDecimals(_decimals); - - _mint(_owner, _supply); - - _setSupportsInterface(type(IERC165).interfaceId, true); - _setSupportsInterface(type(IERC20).interfaceId, true); - _setSupportsInterface(type(IERC2612).interfaceId, true); - _setSupportsInterface(type(IContractMetadata).interfaceId, true); - - if (_data.length == 0) { - return; - } - - // decode data to app address and globals address - (address app, address globals) = abi.decode(_data, (address, address)); - - if (app != address(0)) { - _grantRole(MINTER_ROLE, app); - } - - if (globals != address(0)) { - _setGlobals(globals); - } - } - - function validConstellation(bytes32 _implementationId) public view returns (bool) { - return _getGlobals().getERC20Implementation(_implementationId) == address(this); - } - - /*////////////////////////////////////////////////////////////// - Minting logic - //////////////////////////////////////////////////////////////*/ - - /** - * @notice Lets an authorized address mint tokens to a recipient. - * @dev The logic in the `_canMint` function determines whether the caller is authorized to mint tokens. - * - * @param _to The recipient of the tokens to mint. - * @param _amount Quantity of tokens to mint. - */ - function mintTo(address _to, uint256 _amount) public payable virtual nonReentrant { - if (!_canMint()) { - revert ERC20Constellation_notAuthorized(); - } - - if (_amount < 1) { - revert ERC20Constellation_zeroAmount(); - } - - (address platformFeeRecipient, uint256 platformFeeAmount) = _checkPlatformFee(); - - _mint(_to, _amount); - - _payPlatformFee(platformFeeRecipient, platformFeeAmount); - } - - /** - * @notice Lets an owner a given amount of their tokens. - * @dev Caller should own the `_amount` of tokens. - * - * @param _amount The number of tokens to burn. - */ - function burn(uint256 _amount) external virtual { - if (_balanceOf(msg.sender) < _amount) { - revert ERC20Constellation_insufficientBalance(); - } - - _burn(msg.sender, _amount); - } - - /*////////////////////////////////////////////////////////////// - Internal (overrideable) functions - //////////////////////////////////////////////////////////////*/ - - /// @dev Returns whether tokens can be minted in the given execution context. - function _canMint() internal view virtual returns (bool) { - return _hasRole(ADMIN_ROLE, msg.sender) || _hasRole(MINTER_ROLE, msg.sender); - } - - /// @dev Returns whether owner can be set in the given execution context. - function _canSetContractURI() internal view virtual override returns (bool) { - return _hasRole(ADMIN_ROLE, msg.sender); - } - - /// @dev grants minter role if data is just an address - function _grantMinterRoleFromData(bytes memory _data) internal virtual { - if (_data.length == 0) { - return; - } - - (address account) = abi.decode(_data, (address)); - if (account != address(0)) { - _grantRole(MINTER_ROLE, account); - } - } - - /*////////////////////////////////////////////////////////////// - Internal (platform fee) functions - //////////////////////////////////////////////////////////////*/ - - function _checkPlatformFee() internal view returns (address recipient, uint256 amount) { - // don't charge platform fee if sender is a contract or globals address is not set - if (_isContract(msg.sender) || _getGlobalsAddress() == address(0)) { - return (address(0), 0); - } - - (recipient, amount) = _platformFeeInfo(0); - - // ensure the ether being sent was included in the transaction - if (amount > msg.value) { - revert CurrencyTransferLib.CurrencyTransferLib_insufficientValue(); - } - } - - function _payPlatformFee(address recipient, uint256 amount) internal { - if (amount == 0) { - return; - } - - CurrencyTransferLib.safeTransferNativeToken(recipient, amount); - - emit PaidPlatformFee(address(0), amount); - } - - /** - * @dev derived from Openzepplin's address utils - * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.2/contracts/utils/Address.sol - */ - - function _isContract(address _account) internal view returns (bool) { - // This method relies on extcodesize/address.code.length, which returns 0 - // for contracts in construction, since the code is only stored at the end - // of the constructor execution. - - return _account.code.length > 0; - } -} diff --git a/src/tokens/ERC20/ERC20ConstellationMock.sol b/src/tokens/ERC20/ERC20ConstellationMock.sol deleted file mode 100644 index 30622a5..0000000 --- a/src/tokens/ERC20/ERC20ConstellationMock.sol +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.16; - -import {ERC20Constellation} from "./ERC20Constellation.sol"; - -contract ERC20ConstellationMock is ERC20Constellation { - constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _supply) payable initializer { - initialize(msg.sender, _name, _symbol, _decimals, _supply, ""); - } -} diff --git a/test/Constellation/Constellation.t.sol b/test/Constellation/Constellation.t.sol deleted file mode 100644 index 9f08c14..0000000 --- a/test/Constellation/Constellation.t.sol +++ /dev/null @@ -1,106 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.16; - -// The following tests that proxy and registry contracts work together as intended - -import "forge-std/Test.sol"; -import {ConstellationFactory, IConstellation} from "../../src/factories/Constellation.sol"; -import {ERC20Base} from "../../src/tokens/ERC20/ERC20Base.sol"; -import {IERC20} from "@solidstate/contracts/interfaces/IERC20.sol"; - -contract Setup is Test { - address creator; - - ConstellationFactory factory; - ERC20Base erc20Implementation; - address constellation; - - function setUp() public { - creator = address(0x10); - - erc20Implementation = new ERC20Base(); - factory = new ConstellationFactory(address(erc20Implementation), address(0)); - constellation = factory.create("Constellation", "CSTN", 18, 1000); - } -} - -contract Factory__create is Setup, IConstellation { - function test_creates_minmal_proxy_of_implementation() public { - address minimalProxy = factory.create("constellation_A", "CA", 18, 1000); - assertEq(IERC20(minimalProxy).totalSupply(), 1000); - } - - function test_can_create_with_the_same_name_from_different_accounts() public { - factory.create("constellation_A", "CA", 18, 1000); - - vm.prank(creator); - factory.create("constellation_A", "CA", 18, 1000); - } - - function test_emits_created_event() public { - // get deployment address by calling `calculateDeploymentAddress` from creators wallet - vm.prank(creator); - address id = factory.calculateDeploymentAddress(creator, "constellation_A"); - - string memory zeroPaddedAppName = string(abi.encodePacked(bytes32("constellation_A"))); - - vm.expectEmit(true, true, true, true); - emit Created(id, creator, zeroPaddedAppName); - - vm.prank(creator); - factory.create("constellation_A", "CA", 18, 1000); - } - - function test_reverts_if_name_already_used_by_same_account() public { - factory.create("constellation_A", "CA", 18, 1000); - - vm.expectRevert(IConstellation.Constellation_NameAlreadyUsed.selector); - factory.create("constellation_A", "CA", 18, 1000); - } -} - -contract Factory__apps is Setup { - function test_can_get_address_via_hash_of_address_and_name() public { - vm.prank(creator); - address minimalProxy = factory.create("constellation_A", "CA", 18, 1000); - - bytes32 id = keccak256(abi.encode(creator, bytes32("constellation_A"))); - assertEq(factory.constellations(id), minimalProxy); - } - - function test_returns_zero_address_if_name_is_free() public { - assertEq(factory.constellations(keccak256(abi.encode(creator, bytes32("constellation_A")))), address(0)); - } -} - -contract Factory__calculateDeploymentAddress is Setup { - function test_can_get_address_of_deployment() public { - vm.prank(creator); - address expectedAddress = factory.calculateDeploymentAddress(creator, "constellation_A"); - - vm.prank(creator); - address minimalProxy = factory.create("constellation_A", "CA", 18, 1000); - assertEq(expectedAddress, minimalProxy); - } - - function test_reverts_when_name_is_already_used() public { - vm.prank(creator); - factory.create("constellation_A", "CA", 18, 1000); - - vm.expectRevert(IConstellation.Constellation_NameAlreadyUsed.selector); - vm.prank(creator); - factory.calculateDeploymentAddress(creator, "constellation_A"); - } -} - -contract Factory__update is Setup, IConstellation { - function test_update_constellation_token() public { - factory.updateToken("Constellation", constellation, constellation); - } - - function test_update_constellation_token_not_owner() public { - vm.prank(creator); - vm.expectRevert(IConstellation.Constellation_NotFoundOrNotOwner.selector); - factory.updateToken("Constellation", constellation, constellation); - } -} From 65aca1fc3e97aa649bea3e5da3c1b784b17e5995 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 10 Apr 2024 10:04:55 +0100 Subject: [PATCH 2/4] update tests and naming app convention --- test/{Star/Star.t.sol => App/App.t.sol} | 47 +++++++------------ test/integration/{Star.sol => App.sol} | 19 +++----- test/integration/TransactionLayer.t.sol | 15 ++---- test/integration/extensions/PlatformFee.t.sol | 14 ++---- .../integration/facet/ERC20FactoryFacet.t.sol | 16 ++----- .../facet/ERC721FactoryFacet.t.sol | 15 ++---- test/integration/facet/ERC721LazyDrop.t.sol | 15 ++---- test/integration/facet/RewardsFacet.t.sol | 15 ++---- test/integration/facet/SettingsFacet.t.sol | 18 ++----- test/integration/tokens/ERC20Base.t.sol | 16 ++----- test/integration/tokens/ERC721Base.t.sol | 17 ++----- test/integration/tokens/ERC721LazyMint.t.sol | 15 ++---- 12 files changed, 65 insertions(+), 157 deletions(-) rename test/{Star/Star.t.sol => App/App.t.sol} (59%) rename test/integration/{Star.sol => App.sol} (78%) diff --git a/test/Star/Star.t.sol b/test/App/App.t.sol similarity index 59% rename from test/Star/Star.t.sol rename to test/App/App.t.sol index 8a61fb9..1bb3f67 100644 --- a/test/Star/Star.t.sol +++ b/test/App/App.t.sol @@ -4,8 +4,7 @@ pragma solidity ^0.8.16; // The following tests that proxy and registry contracts work together as intended import "forge-std/Test.sol"; -import {StarFactory, IStar} from "../../src/factories/Star.sol"; -import {ConstellationFactory} from "src/factories/Constellation.sol"; +import {AppFactory, IApp} from "../../src/factories/App.sol"; import {ERC20Base} from "src/tokens/ERC20/ERC20Base.sol"; import {Globals} from "src/globals/Globals.sol"; @@ -24,14 +23,11 @@ contract DummyImplementation { contract Setup is Test { address creator; - StarFactory factory; + AppFactory factory; Globals globals; - ConstellationFactory constellationFactory; ERC20Base erc20Implementation; DummyImplementation implementation; - address constellation; - address constellationB; function setUp() public { creator = address(0x10); @@ -39,30 +35,23 @@ contract Setup is Test { globals = new Globals(); erc20Implementation = new ERC20Base(); - constellationFactory = new ConstellationFactory(address(erc20Implementation), address(globals)); - - // create constellations - constellation = constellationFactory.create("Constellation", "CSN", 18, 1000); - - vm.prank(creator); - constellationB = constellationFactory.create("ConstellationB", "CSN", 18, 1000); implementation = new DummyImplementation(); - factory = new StarFactory(address(implementation), address(0), address(0)); + factory = new AppFactory(address(implementation), address(0), address(0)); } } -contract Factory__create is Setup, IStar { +contract Factory__create is Setup, IApp { function test_creates_minmal_proxy_of_implementation() public { - address minimalProxy = factory.create("app_name", constellation, address(0)); + address minimalProxy = factory.create("app_name", address(0)); assertEq(DummyImplementation(minimalProxy).boop(), "boop"); } function test_can_create_with_the_same_name_from_different_accounts() public { - factory.create("app_name", constellation, address(0)); + factory.create("app_name", address(0)); vm.prank(creator); - factory.create("app_name", constellationB, creator); + factory.create("app_name", creator); } function test_emits_created_event() public { @@ -73,32 +62,32 @@ contract Factory__create is Setup, IStar { string memory zeroPaddedAppName = string(abi.encodePacked(bytes32("app_name"))); vm.expectEmit(true, true, true, true); - emit Created(id, constellationB, creator, zeroPaddedAppName); + emit Created(id, creator, zeroPaddedAppName); vm.startPrank(creator); - factory.create("app_name", constellationB, creator); + factory.create("app_name", creator); vm.stopPrank(); } function test_reverts_if_name_already_used_by_same_account() public { - factory.create("app_name", constellation, address(0)); + factory.create("app_name", address(0)); - vm.expectRevert(IStar.Factory_nameAlreadyUsed.selector); - factory.create("app_name", constellation, address(0)); + vm.expectRevert(IApp.Factory_nameAlreadyUsed.selector); + factory.create("app_name", address(0)); } } contract Factory__apps is Setup { function test_can_get_address_via_hash_of_address_and_name() public { vm.prank(creator); - address minimalProxy = factory.create("app_name", constellationB, creator); + address minimalProxy = factory.create("app_name", creator); bytes32 id = keccak256(abi.encode(creator, bytes32("app_name"))); - assertEq(factory.stars(id), minimalProxy); + assertEq(factory.apps(id), minimalProxy); } function test_returns_zero_address_if_name_is_free() public { - assertEq(factory.stars(keccak256(abi.encode(creator, bytes32("app_name")))), address(0)); + assertEq(factory.apps(keccak256(abi.encode(creator, bytes32("app_name")))), address(0)); } } @@ -106,7 +95,7 @@ contract Factory__calculateDeploymentAddress is Setup { function test_can_get_address_of_deployment() public { vm.startPrank(creator); address expectedAddress = factory.calculateDeploymentAddress(creator, "app_name"); - address minimalProxy = factory.create("app_name", constellationB, creator); + address minimalProxy = factory.create("app_name", creator); vm.stopPrank(); assertEq(expectedAddress, minimalProxy); @@ -114,9 +103,9 @@ contract Factory__calculateDeploymentAddress is Setup { function test_reverts_when_name_is_already_used() public { vm.startPrank(creator); - address minimalProxy = factory.create("app_name", constellationB, creator); + factory.create("app_name", creator); - vm.expectRevert(IStar.Factory_nameAlreadyUsed.selector); + vm.expectRevert(IApp.Factory_nameAlreadyUsed.selector); factory.calculateDeploymentAddress(creator, "app_name"); vm.stopPrank(); } diff --git a/test/integration/Star.sol b/test/integration/App.sol similarity index 78% rename from test/integration/Star.sol rename to test/integration/App.sol index 6c7661b..9adf0cd 100644 --- a/test/integration/Star.sol +++ b/test/integration/App.sol @@ -13,8 +13,7 @@ import { import {Proxy} from "../../src/proxy/Proxy.sol"; import {Upgradable} from "../../src/proxy/upgradable/Upgradable.sol"; import {RegistryMock} from "../../src/registry/RegistryMock.sol"; -import {StarFactory} from "../../src/factories/Star.sol"; -import {ConstellationFactory} from "src/factories/Constellation.sol"; +import {AppFactory} from "../../src/factories/App.sol"; import {ERC20Base} from "src/tokens/ERC20/ERC20Base.sol"; contract MessageFacet { @@ -42,8 +41,7 @@ abstract contract Helpers { } contract Factory__intergration is Test, Helpers { - StarFactory starFactory; - ConstellationFactory constellationFactory; + AppFactory appFactory; ERC20Base erc20Implementation; Proxy template; RegistryMock registry; @@ -56,9 +54,8 @@ contract Factory__intergration is Test, Helpers { address globals = address(0); // TODO: add globals contract registry = new RegistryMock(); template = new Proxy(true); - starFactory = new StarFactory(address(template), address(registry), globals); + appFactory = new AppFactory(address(template), address(registry), globals); erc20Implementation = new ERC20Base(); - constellationFactory = new ConstellationFactory(address(erc20Implementation), address(globals)); message = new MessageFacet(); // add hello facet to registry @@ -73,18 +70,16 @@ contract Factory__intergration is Test, Helpers { } function test_factory_registry_is_correct() public { - assertEq(starFactory.registry(), address(registry)); + assertEq(appFactory.registry(), address(registry)); } function test_factory_template_is_correct() public { - assertEq(starFactory.template(), address(template)); + assertEq(appFactory.template(), address(template)); } function test_proxys_sketch() public { - address constellation = constellationFactory.create("Constellation", "CSN", 18, 1000); - - address cloneAddress1 = starFactory.create(bytes32("saltyA"), address(constellation), address(0)); - address cloneAddress2 = starFactory.create(bytes32("saltyB"), address(constellation), address(0)); + address cloneAddress1 = appFactory.create(bytes32("saltyA"), address(0)); + address cloneAddress2 = appFactory.create(bytes32("saltyB"), address(0)); // create instances Proxy clone1 = Proxy(payable(cloneAddress1)); diff --git a/test/integration/TransactionLayer.t.sol b/test/integration/TransactionLayer.t.sol index 9cd3537..bb002ef 100644 --- a/test/integration/TransactionLayer.t.sol +++ b/test/integration/TransactionLayer.t.sol @@ -20,8 +20,7 @@ import {IERC20, SafeERC20} from "@solidstate/contracts/utils/SafeERC20.sol"; import {Proxy} from "src/proxy/Proxy.sol"; import {Upgradable} from "src/proxy/upgradable/Upgradable.sol"; import {RegistryMock} from "src/registry/RegistryMock.sol"; -import {StarFactory} from "src/factories/Star.sol"; -import {ConstellationFactory} from "src/factories/Constellation.sol"; +import {AppFactory} from "src/factories/App.sol"; import {Globals} from "src/globals/Globals.sol"; import {SettingsFacet} from "src/facet/SettingsFacet.sol"; import {ERC20BaseMock} from "src/tokens/ERC20/ERC20BaseMock.sol"; @@ -96,8 +95,7 @@ contract Setup is Test, Helpers { address other; address socialConscious; - StarFactory starFactory; - ConstellationFactory constellationFactory; + AppFactory appFactory; Proxy template; Proxy app; RegistryMock registry; @@ -118,11 +116,10 @@ contract Setup is Test, Helpers { globals = new Globals(); registry = new RegistryMock(); template = new Proxy(true); - starFactory = new StarFactory(address(template), address(registry), address(globals)); + appFactory = new AppFactory(address(template), address(registry), address(globals)); erc20 = new ERC20BaseMock("Dummy", "D", 18, 1000); erc20Implementation = new ERC20Base(); - constellationFactory = new ConstellationFactory(address(erc20Implementation), address(globals)); // Add Facets { @@ -150,13 +147,9 @@ contract Setup is Test, Helpers { // setup platform fee to be base 0.01 ether and receiver to be social Conscious globals.setPlatformFee(0.1 ether, 0, socialConscious); - // create constellation - vm.prank(appOwner); - address constellation = constellationFactory.create("Constellation", "CSN", 18, 1000); - // create app vm.prank(appOwner); - app = Proxy(payable(starFactory.create("ERC721LazyMintTest", constellation, appOwner))); + app = Proxy(payable(appFactory.create("ERC721LazyMintTest", appOwner))); // set application fee vm.prank(appOwner); diff --git a/test/integration/extensions/PlatformFee.t.sol b/test/integration/extensions/PlatformFee.t.sol index 55f35ec..4826a6e 100644 --- a/test/integration/extensions/PlatformFee.t.sol +++ b/test/integration/extensions/PlatformFee.t.sol @@ -15,8 +15,7 @@ import {CurrencyTransferLib} from "src/lib/CurrencyTransferLib.sol"; import {Proxy} from "src/proxy/Proxy.sol"; import {Upgradable} from "src/proxy/upgradable/Upgradable.sol"; import {RegistryMock} from "src/registry/RegistryMock.sol"; -import {StarFactory} from "src/factories/Star.sol"; -import {ConstellationFactory} from "src/factories/Constellation.sol"; +import {AppFactory} from "src/factories/App.sol"; import {Globals} from "src/globals/Globals.sol"; import {ERC20Base} from "src/tokens/ERC20/ERC20Base.sol"; @@ -73,8 +72,7 @@ contract Setup is Test, Helpers { address creator; address socialConscious; - StarFactory starFactory; - ConstellationFactory constellationFactory; + AppFactory appFactory; Proxy template; Proxy app; RegistryMock registry; @@ -89,11 +87,10 @@ contract Setup is Test, Helpers { globals = new Globals(); registry = new RegistryMock(); template = new Proxy(true); - starFactory = new StarFactory(address(template), address(registry), address(globals)); + appFactory = new AppFactory(address(template), address(registry), address(globals)); facet = new DummyFacet(); erc20Implementation = new ERC20Base(); - constellationFactory = new ConstellationFactory(address(erc20Implementation), address(globals)); // add facet to registry bytes4[] memory selectors = new bytes4[](2); @@ -108,11 +105,8 @@ contract Setup is Test, Helpers { // setup platform fee to be base 0.01 ether and reciever to be social Conscious globals.setPlatformFee(0.1 ether, 0, socialConscious); - // create constellation - address constellation = constellationFactory.create("Constellation", "CSN", 18, 1000); - // create app - app = Proxy(payable(starFactory.create("platformFeeTest", constellation, address(0)))); + app = Proxy(payable(appFactory.create("platformFeeTest", address(0)))); } } diff --git a/test/integration/facet/ERC20FactoryFacet.t.sol b/test/integration/facet/ERC20FactoryFacet.t.sol index 55f6b7a..53f25f9 100644 --- a/test/integration/facet/ERC20FactoryFacet.t.sol +++ b/test/integration/facet/ERC20FactoryFacet.t.sol @@ -13,8 +13,7 @@ import { import {Proxy} from "src/proxy/Proxy.sol"; import {Upgradable} from "src/proxy/upgradable/Upgradable.sol"; import {RegistryMock} from "src/registry/RegistryMock.sol"; -import {StarFactory} from "src/factories/Star.sol"; -import {ConstellationFactory} from "src/factories/Constellation.sol"; +import {AppFactory} from "src/factories/App.sol"; import {Globals} from "src/globals/Globals.sol"; import {IERC20Factory} from "@extensions/ERC20Factory/IERC20Factory.sol"; @@ -43,8 +42,7 @@ contract Setup is Test, Helpers { address other; address socialConscious; - StarFactory starFactory; - ConstellationFactory constellationFactory; + AppFactory appFactory; Proxy appImplementation; Proxy app; RegistryMock registry; @@ -68,21 +66,15 @@ contract Setup is Test, Helpers { globals = new Globals(); registry = new RegistryMock(); appImplementation = new Proxy(true); - starFactory = new StarFactory(address(appImplementation), address(registry), address(globals)); + appFactory = new AppFactory(address(appImplementation), address(registry), address(globals)); erc20Implementation = new ERC20Base(); erc20ImplementationId = bytes32("base"); erc20FactoryFacet = new ERC20FactoryFacet(); - constellationFactory = new ConstellationFactory(address(erc20Implementation), address(globals)); - - // create constellation - vm.prank(creator); - address constellation = constellationFactory.create("Constellation", "CSN", 18, 1000); - // create app vm.prank(creator); - app = Proxy(payable(starFactory.create("ERC721LazyMintTest", constellation, creator))); + app = Proxy(payable(appFactory.create("ERC721LazyMintTest", creator))); // setup globals globals.setPlatformFee(0, 0, socialConscious); diff --git a/test/integration/facet/ERC721FactoryFacet.t.sol b/test/integration/facet/ERC721FactoryFacet.t.sol index 5b5aca2..6a53b2b 100644 --- a/test/integration/facet/ERC721FactoryFacet.t.sol +++ b/test/integration/facet/ERC721FactoryFacet.t.sol @@ -13,8 +13,7 @@ import { import {Proxy} from "src/proxy/Proxy.sol"; import {Upgradable} from "src/proxy/upgradable/Upgradable.sol"; import {RegistryMock} from "src/registry/RegistryMock.sol"; -import {StarFactory} from "src/factories/Star.sol"; -import {ConstellationFactory} from "src/factories/Constellation.sol"; +import {AppFactory} from "src/factories/App.sol"; import {Globals} from "src/globals/Globals.sol"; import {ERC20Base} from "src/tokens/ERC20/ERC20Base.sol"; @@ -45,8 +44,7 @@ contract Setup is Test, Helpers { address other; address socialConscious; - StarFactory starFactory; - ConstellationFactory constellationFactory; + AppFactory appFactory; Proxy appImplementation; Proxy app; RegistryMock registry; @@ -71,22 +69,17 @@ contract Setup is Test, Helpers { globals = new Globals(); registry = new RegistryMock(); appImplementation = new Proxy(true); - starFactory = new StarFactory(address(appImplementation), address(registry), address(globals)); + appFactory = new AppFactory(address(appImplementation), address(registry), address(globals)); erc20Implementation = new ERC20Base(); - constellationFactory = new ConstellationFactory(address(erc20Implementation), address(globals)); erc721Implementation = new ERC721Base(); erc721ImplementationId = bytes32("Base"); erc721FactoryFacet = new ERC721FactoryFacet(); - // create constellation - vm.prank(creator); - address constellation = constellationFactory.create("Constellation", "CSN", 18, 1000); - // create app vm.prank(creator); - app = Proxy(payable(starFactory.create("ERC721LazyMintTest", constellation, creator))); + app = Proxy(payable(appFactory.create("ERC721LazyMintTest", creator))); // setup globals globals.setPlatformFee(0, 0, socialConscious); diff --git a/test/integration/facet/ERC721LazyDrop.t.sol b/test/integration/facet/ERC721LazyDrop.t.sol index 3d063b9..4ffbc03 100644 --- a/test/integration/facet/ERC721LazyDrop.t.sol +++ b/test/integration/facet/ERC721LazyDrop.t.sol @@ -13,8 +13,7 @@ import { import {Proxy} from "src/proxy/Proxy.sol"; import {Upgradable} from "src/proxy/upgradable/Upgradable.sol"; import {RegistryMock} from "src/registry/RegistryMock.sol"; -import {StarFactory} from "src/factories/Star.sol"; -import {ConstellationFactory} from "src/factories/Constellation.sol"; +import {AppFactory} from "src/factories/App.sol"; import {Globals} from "src/globals/Globals.sol"; import {ERC20BaseMock} from "src/tokens/ERC20/ERC20BaseMock.sol"; @@ -59,8 +58,7 @@ contract Setup is Test, Helpers { uint16 tenPercentBPS = 1000; - StarFactory starFactory; - ConstellationFactory constellationFactory; + AppFactory appFactory; Proxy appImplementation; Proxy app; RegistryMock registry; @@ -86,10 +84,9 @@ contract Setup is Test, Helpers { globals = new Globals(); registry = new RegistryMock(); appImplementation = new Proxy(true); - starFactory = new StarFactory(address(appImplementation), address(registry), address(globals)); + appFactory = new AppFactory(address(appImplementation), address(registry), address(globals)); erc20Implementation = new ERC20Base(); - constellationFactory = new ConstellationFactory(address(erc20Implementation), address(globals)); { settingsFacet = new SettingsFacet(); @@ -128,13 +125,9 @@ contract Setup is Test, Helpers { erc20 = new ERC20BaseMock("name", "symbol", 18, 100 ether); erc20.transfer(other, 1 ether); - // create constellation - vm.prank(appOwner); - address constellation = constellationFactory.create("Constellation", "CSN", 18, 1000); - // create app vm.prank(appOwner); - app = Proxy(payable(starFactory.create("ERC721LazyMintTest", constellation, appOwner))); + app = Proxy(payable(appFactory.create("ERC721LazyMintTest", appOwner))); // Add NATIVE_TOKEN and ERC20 to accepted currencies { address[] memory currencies = new address[](2); diff --git a/test/integration/facet/RewardsFacet.t.sol b/test/integration/facet/RewardsFacet.t.sol index 25ec202..467e6c9 100644 --- a/test/integration/facet/RewardsFacet.t.sol +++ b/test/integration/facet/RewardsFacet.t.sol @@ -15,7 +15,7 @@ import {IERC20} from "@solidstate/contracts/interfaces/IERC20.sol"; import {Proxy} from "src/proxy/Proxy.sol"; import {Upgradable} from "src/proxy/upgradable/Upgradable.sol"; import {RegistryMock} from "src/registry/RegistryMock.sol"; -import {StarFactory} from "src/factories/Star.sol"; +import {AppFactory} from "src/factories/App.sol"; import {Globals} from "src/globals/Globals.sol"; import {ERC20Base, ADMIN_ROLE, MINTER_ROLE} from "src/tokens/ERC20/ERC20Base.sol"; @@ -23,7 +23,6 @@ import {IERC20Factory} from "@extensions/ERC20Factory/IERC20Factory.sol"; import {ERC20FactoryFacet} from "src/facet/ERC20FactoryFacet.sol"; import {RewardsFacet} from "src/facet/RewardsFacet.sol"; import {SettingsFacet, IApplicationAccess} from "src/facet/SettingsFacet.sol"; -import {ConstellationFactory} from "src/factories/Constellation.sol"; import {Deploy} from "scripts/core/Globals.s.sol"; @@ -55,8 +54,7 @@ contract Setup is Test, Helpers { address other; address socialConscious; - StarFactory starFactory; - ConstellationFactory constellationFactory; + AppFactory appFactory; Proxy appImplementation; Proxy app; RegistryMock registry; @@ -81,20 +79,15 @@ contract Setup is Test, Helpers { globals = new Globals(); registry = new RegistryMock(); appImplementation = new Proxy(true); - starFactory = new StarFactory(address(appImplementation), address(registry), address(globals)); + appFactory = new AppFactory(address(appImplementation), address(registry), address(globals)); erc20Implementation = new ERC20Base(); erc20ImplementationId = bytes32("Base"); erc20FactoryFacet = new ERC20FactoryFacet(); - constellationFactory = new ConstellationFactory(address(erc20Implementation), address(globals)); - - vm.prank(creator); - address constellation = constellationFactory.create("Constellation", "CSN", 18, 1000); - // create app vm.prank(creator); - app = Proxy(payable(starFactory.create("RewardFacetTest", address(constellation), creator))); + app = Proxy(payable(appFactory.create("RewardFacetTest", creator))); // setup globals globals.setPlatformFee(0, 0, socialConscious); diff --git a/test/integration/facet/SettingsFacet.t.sol b/test/integration/facet/SettingsFacet.t.sol index 8f30877..c3de95c 100644 --- a/test/integration/facet/SettingsFacet.t.sol +++ b/test/integration/facet/SettingsFacet.t.sol @@ -14,8 +14,7 @@ import {IOwnableInternal} from "@solidstate/contracts/access/ownable/IOwnableInt import {Proxy} from "src/proxy/Proxy.sol"; import {Upgradable} from "src/proxy/upgradable/Upgradable.sol"; import {RegistryMock} from "src/registry/RegistryMock.sol"; -import {StarFactory} from "src/factories/Star.sol"; -import {ConstellationFactory} from "src/factories/Constellation.sol"; +import {AppFactory} from "src/factories/App.sol"; import {Globals} from "src/globals/Globals.sol"; import {ERC20Base} from "src/tokens/ERC20/ERC20Base.sol"; @@ -39,9 +38,7 @@ contract Setup is Test, Helpers { uint16 tenPercentBPS = 1000; - StarFactory starFactory; - ConstellationFactory constellationFactory; - ERC20Base erc20Implementation; + AppFactory appFactory; Proxy appImplementation; Proxy app; RegistryMock registry; @@ -58,10 +55,7 @@ contract Setup is Test, Helpers { globals = new Globals(); registry = new RegistryMock(); appImplementation = new Proxy(true); - starFactory = new StarFactory(address(appImplementation), address(registry), address(globals)); - - erc20Implementation = new ERC20Base(); - constellationFactory = new ConstellationFactory(address(erc20Implementation), address(globals)); + appFactory = new AppFactory(address(appImplementation), address(registry), address(globals)); settingsFacet = new SettingsFacet(); @@ -81,13 +75,9 @@ contract Setup is Test, Helpers { "" ); - // create constellation - vm.prank(appOwner); - address constellation = constellationFactory.create("Constellation", "CSN", 18, 1000); - // create app vm.prank(appOwner); - app = Proxy(payable(starFactory.create("SettingsTest", constellation, appOwner))); + app = Proxy(payable(appFactory.create("SettingsTest", appOwner))); _afterSetUp(); } diff --git a/test/integration/tokens/ERC20Base.t.sol b/test/integration/tokens/ERC20Base.t.sol index 9228d3f..3e9cc98 100644 --- a/test/integration/tokens/ERC20Base.t.sol +++ b/test/integration/tokens/ERC20Base.t.sol @@ -13,8 +13,7 @@ import { import {Proxy} from "src/proxy/Proxy.sol"; import {Upgradable} from "src/proxy/upgradable/Upgradable.sol"; import {RegistryMock} from "src/registry/RegistryMock.sol"; -import {StarFactory} from "src/factories/Star.sol"; -import {ConstellationFactory} from "src/factories/Constellation.sol"; +import {AppFactory} from "src/factories/App.sol"; import {Globals} from "src/globals/Globals.sol"; import {ERC20Base, ADMIN_ROLE, MINTER_ROLE} from "src/tokens/ERC20/ERC20Base.sol"; @@ -52,8 +51,7 @@ contract Setup is Test, Helpers { address other; address socialConscious; - StarFactory starFactory; - ConstellationFactory constellationFactory; + AppFactory appFactory; Proxy appImplementation; Proxy app; RegistryMock registry; @@ -77,21 +75,15 @@ contract Setup is Test, Helpers { globals = new Globals(); registry = new RegistryMock(); appImplementation = new Proxy(true); - starFactory = new StarFactory(address(appImplementation), address(registry), address(globals)); + appFactory = new AppFactory(address(appImplementation), address(registry), address(globals)); erc20Implementation = new ERC20Base(); erc20ImplementationId = bytes32("Base"); erc20FactoryFacet = new ERC20FactoryFacet(); - constellationFactory = new ConstellationFactory(address(erc20Implementation), address(globals)); - - // create constellation - vm.prank(creator); - address constellation = constellationFactory.create("Constellation", "CSN", 18, 1000); - // create app vm.prank(creator); - app = Proxy(payable(starFactory.create("platformFeeTest", constellation, creator))); + app = Proxy(payable(appFactory.create("platformFeeTest", creator))); // setup globals globals.setPlatformFee(0, 0, socialConscious); diff --git a/test/integration/tokens/ERC721Base.t.sol b/test/integration/tokens/ERC721Base.t.sol index d0a5962..0b1e67a 100644 --- a/test/integration/tokens/ERC721Base.t.sol +++ b/test/integration/tokens/ERC721Base.t.sol @@ -13,8 +13,7 @@ import { import {Proxy} from "src/proxy/Proxy.sol"; import {Upgradable} from "src/proxy/upgradable/Upgradable.sol"; import {RegistryMock} from "src/registry/RegistryMock.sol"; -import {StarFactory} from "src/factories/Star.sol"; -import {ConstellationFactory} from "src/factories/Constellation.sol"; +import {AppFactory} from "src/factories/App.sol"; import {Globals} from "src/globals/Globals.sol"; import {ERC20Base} from "src/tokens/ERC20/ERC20Base.sol"; @@ -57,8 +56,7 @@ contract Setup is Test, Helpers { address other; address socialConscious; - StarFactory starFactory; - ConstellationFactory constellationFactory; + AppFactory appFactory; Proxy appImplementation; Proxy app; RegistryMock registry; @@ -83,22 +81,15 @@ contract Setup is Test, Helpers { globals = new Globals(); registry = new RegistryMock(); appImplementation = new Proxy(true); - starFactory = new StarFactory(address(appImplementation), address(registry), address(globals)); - - erc20Implementation = new ERC20Base(); - constellationFactory = new ConstellationFactory(address(erc20Implementation), address(globals)); + appFactory = new AppFactory(address(appImplementation), address(registry), address(globals)); erc721Implementation = new ERC721Base(); erc721ImplementationId = bytes32("Base"); erc721FactoryFacet = new ERC721FactoryFacet(); - // create constellation - vm.prank(creator); - address constellation = constellationFactory.create("Constellation", "CSN", 18, 1000); - // create app vm.prank(creator); - app = Proxy(payable(starFactory.create("platformFeeTest", constellation, creator))); + app = Proxy(payable(appFactory.create("platformFeeTest", creator))); // setup globals globals.setPlatformFee(0, 0, socialConscious); diff --git a/test/integration/tokens/ERC721LazyMint.t.sol b/test/integration/tokens/ERC721LazyMint.t.sol index 62fbea3..65b1ac8 100644 --- a/test/integration/tokens/ERC721LazyMint.t.sol +++ b/test/integration/tokens/ERC721LazyMint.t.sol @@ -13,8 +13,7 @@ import { import {Proxy} from "src/proxy/Proxy.sol"; import {Upgradable} from "src/proxy/upgradable/Upgradable.sol"; import {RegistryMock} from "src/registry/RegistryMock.sol"; -import {StarFactory} from "src/factories/Star.sol"; -import {ConstellationFactory} from "src/factories/Constellation.sol"; +import {AppFactory} from "src/factories/App.sol"; import {Globals} from "src/globals/Globals.sol"; import {ERC20Base} from "src/tokens/ERC20/ERC20Base.sol"; @@ -62,8 +61,7 @@ contract Setup is Test, Helpers { address other; address socialConscious; - StarFactory starFactory; - ConstellationFactory constellationFactory; + AppFactory appFactory; Proxy appImplementation; Proxy app; RegistryMock registry; @@ -88,22 +86,17 @@ contract Setup is Test, Helpers { globals = new Globals(); registry = new RegistryMock(); appImplementation = new Proxy(true); - starFactory = new StarFactory(address(appImplementation), address(registry), address(globals)); + appFactory = new AppFactory(address(appImplementation), address(registry), address(globals)); erc20Implementation = new ERC20Base(); - constellationFactory = new ConstellationFactory(address(erc20Implementation), address(globals)); erc721Implementation = new ERC721Base(); erc721ImplementationId = bytes32("Base"); erc721FactoryFacet = new ERC721FactoryFacet(); - // create constellation - vm.prank(creator); - address constellation = constellationFactory.create("Constellation", "CSN", 18, 1000); - // create app vm.prank(creator); - app = Proxy(payable(starFactory.create("ERC721LazyMintTest", constellation, creator))); + app = Proxy(payable(appFactory.create("ERC721LazyMintTest", creator))); // setup globals globals.setPlatformFee(0, 0, socialConscious); From e4ac8b539ea0ccc9220b8132b49c1ce87c632a4e Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 10 Apr 2024 10:09:17 +0100 Subject: [PATCH 3/4] change Star to App, remove constellation requirement from App setup --- .../{StarFactory.s.sol => AppFactory.s.sol} | 9 ++-- src/factories/{Star.sol => App.sol} | 41 ++++++++----------- src/factories/IApp.sol | 8 ++++ src/factories/IStar.sol | 10 ----- test/App/App.t.sol | 4 +- 5 files changed, 30 insertions(+), 42 deletions(-) rename scripts/core/{StarFactory.s.sol => AppFactory.s.sol} (81%) rename src/factories/{Star.sol => App.sol} (63%) create mode 100644 src/factories/IApp.sol delete mode 100644 src/factories/IStar.sol diff --git a/scripts/core/StarFactory.s.sol b/scripts/core/AppFactory.s.sol similarity index 81% rename from scripts/core/StarFactory.s.sol rename to scripts/core/AppFactory.s.sol index a39ef67..c363c24 100644 --- a/scripts/core/StarFactory.s.sol +++ b/scripts/core/AppFactory.s.sol @@ -4,9 +4,9 @@ pragma solidity ^0.8.16; import "forge-std/Script.sol"; import "forge-std/console.sol"; import {Utils} from "scripts/utils/Utils.sol"; -import {StarFactory} from "src/factories/Star.sol"; +import {AppFactory} from "src/factories/App.sol"; -string constant CONTRACT_NAME = "StarFactory"; +string constant CONTRACT_NAME = "AppFactory"; contract Deploy is Script, Utils { function run() external { @@ -21,7 +21,7 @@ contract Deploy is Script, Utils { revert("cannot find deployments, make sure to deploy Proxy, Registry, Globals first"); } - StarFactory factory = new StarFactory(proxy, registry, globals); + AppFactory factory = new AppFactory(proxy, registry, globals); vm.stopBroadcast(); @@ -40,8 +40,7 @@ contract CreateApp is Script, Utils { revert("please provide an app name, make CreateApp args=appName"); } - address appAddress = - StarFactory(getContractDeploymentAddress(CONTRACT_NAME)).create(appNameBytes32, address(0), address(0)); + address appAddress = AppFactory(getContractDeploymentAddress(CONTRACT_NAME)).create(appNameBytes32, address(0)); console.log("App:", appName); console.log("Deployed:", appAddress); diff --git a/src/factories/Star.sol b/src/factories/App.sol similarity index 63% rename from src/factories/Star.sol rename to src/factories/App.sol index ac4b0b9..da3b86e 100644 --- a/src/factories/Star.sol +++ b/src/factories/App.sol @@ -4,25 +4,25 @@ pragma solidity ^0.8.16; import {Ownable} from "@solidstate/contracts/access/ownable/Ownable.sol"; import {MinimalProxyFactory} from "@solidstate/contracts/factory/MinimalProxyFactory.sol"; -import {IStar} from "./IStar.sol"; +import {IApp} from "./IApp.sol"; import {Proxy} from "../proxy/Proxy.sol"; import {IERC20} from "@solidstate/contracts/interfaces/IERC20.sol"; import {IERC165} from "@solidstate/contracts/interfaces/IERC165.sol"; import {ERC20Base} from "../tokens/ERC20/ERC20Base.sol"; /** - * @title "Star Factory" - * @notice A contract for creating proxy (star) contracts. + * @title "App Factory" + * @notice A contract for creating proxy (app) contracts. * This contract deploys minimal proxies that point to a Proxy implementation/template * and is designed to be deployed separately from the registry and managed by Open Format. */ -contract StarFactory is IStar, MinimalProxyFactory, Ownable { +contract AppFactory is IApp, MinimalProxyFactory, Ownable { address public template; address public registry; address public globals; - // store created stars - mapping(bytes32 => address) public stars; // salt => deployment address + // store created apps + mapping(bytes32 => address) public apps; // salt => deployment address constructor(address _template, address _registry, address _globals) { _setOwner(msg.sender); @@ -32,44 +32,35 @@ contract StarFactory is IStar, MinimalProxyFactory, Ownable { } /** - * @dev _salt param can be thought as the star id + * @dev _salt param can be thought as the app id */ - function create(bytes32 _name, address _constellation, address _owner) external returns (address id) { + function create(bytes32 _name, address _owner) external returns (address id) { bytes32 salt = keccak256(abi.encode(_owner, _name)); // check proxy not already deployed - if (stars[salt] != address(0)) { - revert Factory_nameAlreadyUsed(); - } - - // check _constellation address is a valid ERC20 - if (!IERC165(_constellation).supportsInterface(type(IERC20).interfaceId)) { - revert Factory_invalidConstellation(); - } - - if (!ERC20Base(_constellation).hasRole(bytes32(uint256(0)), msg.sender)) { - revert Factory_notConstellationOwner(); + if (apps[salt] != address(0)) { + revert App_nameAlreadyUsed(); } // deploy new proxy using CREATE2 id = _deployMinimalProxy(template, salt); - stars[salt] = id; + apps[salt] = id; Proxy(payable(id)).init(_owner, registry, globals); - emit Created(id, _constellation, _owner, string(abi.encodePacked(_name))); + emit Created(id, _owner, string(abi.encodePacked(_name))); } /** * @notice returns the deterministic deployment address for a stsar - * @dev The contract deployed is a minimal proxy pointing to the star template - * @return deploymentAddress the address of the star + * @dev The contract deployed is a minimal proxy pointing to the app template + * @return deploymentAddress the address of the app */ function calculateDeploymentAddress(address _account, bytes32 _name) external view returns (address) { bytes32 salt = keccak256(abi.encode(_account, _name)); // check proxy not already deployed - if (stars[salt] != address(0)) { - revert Factory_nameAlreadyUsed(); + if (apps[salt] != address(0)) { + revert App_nameAlreadyUsed(); } return _calculateMinimalProxyDeploymentAddress(template, salt); diff --git a/src/factories/IApp.sol b/src/factories/IApp.sol new file mode 100644 index 0000000..6b9459e --- /dev/null +++ b/src/factories/IApp.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.16; + +interface IApp { + error App_nameAlreadyUsed(); + + event Created(address id, address owner, string name); +} diff --git a/src/factories/IStar.sol b/src/factories/IStar.sol deleted file mode 100644 index 32afd37..0000000 --- a/src/factories/IStar.sol +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.16; - -interface IStar { - error Factory_nameAlreadyUsed(); - error Factory_invalidConstellation(); - error Factory_notConstellationOwner(); - - event Created(address id, address constellation, address owner, string name); -} diff --git a/test/App/App.t.sol b/test/App/App.t.sol index 1bb3f67..00dba52 100644 --- a/test/App/App.t.sol +++ b/test/App/App.t.sol @@ -72,7 +72,7 @@ contract Factory__create is Setup, IApp { function test_reverts_if_name_already_used_by_same_account() public { factory.create("app_name", address(0)); - vm.expectRevert(IApp.Factory_nameAlreadyUsed.selector); + vm.expectRevert(IApp.App_nameAlreadyUsed.selector); factory.create("app_name", address(0)); } } @@ -105,7 +105,7 @@ contract Factory__calculateDeploymentAddress is Setup { vm.startPrank(creator); factory.create("app_name", creator); - vm.expectRevert(IApp.Factory_nameAlreadyUsed.selector); + vm.expectRevert(IApp.App_nameAlreadyUsed.selector); factory.calculateDeploymentAddress(creator, "app_name"); vm.stopPrank(); } From abbfc897a33e45afcf94bb33468d9ef6600f9240 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 11 Apr 2024 08:35:04 +0100 Subject: [PATCH 4/4] docs(changeset): - Remove ConstellationFactory and ERC20Constellation - Renames Star to App --- .changeset/lemon-readers-hug.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/lemon-readers-hug.md diff --git a/.changeset/lemon-readers-hug.md b/.changeset/lemon-readers-hug.md new file mode 100644 index 0000000..de42fa1 --- /dev/null +++ b/.changeset/lemon-readers-hug.md @@ -0,0 +1,6 @@ +--- +"@openformat/contracts": minor +--- + +- Remove ConstellationFactory and ERC20Constellation +- Renames Star to App