From 401cbdb9cb72fa16f6cb856f57984b678ad6ed54 Mon Sep 17 00:00:00 2001 From: Dan Oved Date: Mon, 17 Jul 2023 17:39:56 -0700 Subject: [PATCH] Added fork test for creating an edition Updated to use foundry version from npm --- .github/workflows/test_fork.yml | 10 +-- .gitmodules | 4 - addresses/1.json | 4 +- chainConfigs/1.json | 2 +- chainConfigs/420.json | 2 +- foundry.toml | 2 +- lib/forge-std | 1 - package.json | 4 +- remappings.txt | 3 +- script/Deploy.s.sol | 3 +- script/DeployFeeRegistry.s.sol | 3 +- script/UpgradeERC721DropFactory.s.sol | 3 +- script/ZoraDropsDeployBase.sol | 100 +--------------------- src/DeploymentConfig.sol | 119 ++++++++++++++++++++++++++ test/ZoraNFTCreatorV1.t.sol | 59 ++++++++++++- test/utils/ForkHelper.sol | 16 ++++ yarn.lock | 8 ++ 17 files changed, 221 insertions(+), 122 deletions(-) delete mode 160000 lib/forge-std create mode 100644 src/DeploymentConfig.sol create mode 100644 test/utils/ForkHelper.sol diff --git a/.github/workflows/test_fork.yml b/.github/workflows/test_fork.yml index 21610d6..0cc19ca 100644 --- a/.github/workflows/test_fork.yml +++ b/.github/workflows/test_fork.yml @@ -1,12 +1,6 @@ name: fork tests -on: - push: - branches: - - main - - fork-tests - - changeset - - adding_base_testnet +on: push env: FOUNDRY_PROFILE: ci @@ -27,7 +21,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16 - cache: "yarn" + cache: 'yarn' - name: Install project dependencies run: yarn diff --git a/.gitmodules b/.gitmodules index b3c5b03..259f8cf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,7 +7,3 @@ [submodule "lib/ERC721A-Upgradeable"] path = lib/ERC721A-Upgradeable url = https://github.com/chiru-labs/ERC721A-Upgradeable -[submodule "lib/forge-std"] - path = lib/forge-std - url = https://github.com/foundry-rs/forge-std - branch = v1.4.0 diff --git a/addresses/1.json b/addresses/1.json index f0d0b81..28c6196 100644 --- a/addresses/1.json +++ b/addresses/1.json @@ -1,6 +1,6 @@ { - "DROP_METADATA_RENDERER": "0x5914d9a241008B9F02f22811bF3A77e02B84D226", - "EDITION_METADATA_RENDERER": "0x192ce8267CbaB9C3C477D61e85D7f0c5fE3B46Af", + "DROP_METADATA_RENDERER": "0x5914d9a241008b9f02f22811bf3a77e02b84d226", + "EDITION_METADATA_RENDERER": "0x192ce8267cbab9c3c477d61e85d7f0c5fe3b46af", "ERC721DROP_IMPL": "0x419074d73Cf0852e46b8531b430B1230C348C291", "FACTORY_UPGRADE_GATE": "0x8Da5aC3A39D3B8BCaA1FC15A01506cf4F5e79830", "ZORA_NFT_CREATOR_PROXY": "0xF74B146ce44CC162b601deC3BE331784DB111DC1", diff --git a/chainConfigs/1.json b/chainConfigs/1.json index 24b6e53..4e1eef1 100644 --- a/chainConfigs/1.json +++ b/chainConfigs/1.json @@ -1,5 +1,5 @@ { - "FACTORY_OWNER": "0xd1d1D4e36117aB794ec5d4c78cBD3a8904E691D0", + "FACTORY_OWNER": "0xdb392f4391462d60b8b4413ef72018ab595af9d0", "FACTORY_UPGRADE_GATE_OWNER": "0xd1d1D4e36117aB794ec5d4c78cBD3a8904E691D0", "MINT_FEE_AMOUNT": 777000000000000, "MINT_FEE_RECIPIENT": "0xd1d1D4e36117aB794ec5d4c78cBD3a8904E691D0", diff --git a/chainConfigs/420.json b/chainConfigs/420.json index 00dcfe6..6af76c2 100644 --- a/chainConfigs/420.json +++ b/chainConfigs/420.json @@ -1,5 +1,5 @@ { - "FACTORY_OWNER": "0x11cf5F667dC6AD4dEE58CB07e4AAc6a3fc7E1DCb", + "FACTORY_OWNER": "0x5dee21327cd7cd6725c2578da1c3e5bb2d2d34b2", "FACTORY_UPGRADE_GATE_OWNER": "0x11cf5F667dC6AD4dEE58CB07e4AAc6a3fc7E1DCb", "MINT_FEE_AMOUNT": 777000000000000, "MINT_FEE_RECIPIENT": "0x11cf5F667dC6AD4dEE58CB07e4AAc6a3fc7E1DCb", diff --git a/foundry.toml b/foundry.toml index 99e8112..43b582a 100644 --- a/foundry.toml +++ b/foundry.toml @@ -6,7 +6,7 @@ via_ir = true out = 'out' test = 'test' src = 'src' -libs = ['lib'] +libs = ['lib', 'node_modules'] gas_reports = ['*'] fs_permissions = [{ access = "read", path = "./addresses"}, { access = "read", path = "./chainConfigs"}, { access = "read", path = "./package.json" }] diff --git a/lib/forge-std b/lib/forge-std deleted file mode 160000 index a2edd39..0000000 --- a/lib/forge-std +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a2edd39db95df7e9dd3f9ef9edc8c55fefddb6df diff --git a/package.json b/package.json index c0710d6..98a68f1 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,8 @@ "typescript": "^5.0.4" }, "dependencies": { - "@dotenv/cli": "^2.2.2" + "@dotenv/cli": "^2.2.2", + "ds-test": "https://github.com/dapphub/ds-test#cd98eff28324bfac652e63a239a60632a761790b", + "forge-std": "https://github.com/foundry-rs/forge-std#cd7d533f9a0ee0ec02ad81e0a8f262bc4203c653" } } diff --git a/remappings.txt b/remappings.txt index a8d15e8..3a80d29 100644 --- a/remappings.txt +++ b/remappings.txt @@ -2,4 +2,5 @@ @openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ erc721a-upgradeable=lib/ERC721A-Upgradeable/contracts/ base64/=lib/base64/ -forge-std/=lib/forge-std/src/ +ds-test/=node_modules/ds-test/src/ +forge-std/=node_modules/forge-std/src/ diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol index c935fdc..1e55946 100644 --- a/script/Deploy.s.sol +++ b/script/Deploy.s.sol @@ -14,7 +14,8 @@ import {DropMetadataRenderer} from "../src/metadata/DropMetadataRenderer.sol"; import {EditionMetadataRenderer} from "../src/metadata/EditionMetadataRenderer.sol"; import {IERC721Drop} from "../src//interfaces/IERC721Drop.sol"; -import {ZoraDropsDeployBase, ChainConfig, DropDeployment} from "./ZoraDropsDeployBase.sol"; +import {ZoraDropsDeployBase} from "./ZoraDropsDeployBase.sol"; +import {ChainConfig, DropDeployment} from '../src/DeploymentConfig.sol'; contract Deploy is ZoraDropsDeployBase { function run() public returns (string memory) { diff --git a/script/DeployFeeRegistry.s.sol b/script/DeployFeeRegistry.s.sol index 19831db..7b042af 100644 --- a/script/DeployFeeRegistry.s.sol +++ b/script/DeployFeeRegistry.s.sol @@ -3,9 +3,10 @@ pragma solidity ^0.8.13; import "forge-std/console2.sol"; -import {ZoraDropsDeployBase, ChainConfig} from "./ZoraDropsDeployBase.sol"; +import {ZoraDropsDeployBase} from "./ZoraDropsDeployBase.sol"; import {IOperatorFilterRegistry} from "../src/interfaces/IOperatorFilterRegistry.sol"; import {OwnedSubscriptionManager} from "../src/filter/OwnedSubscriptionManager.sol"; +import {ChainConfig} from '../src/DeploymentConfig.sol'; contract DeployFeeRegistry is ZoraDropsDeployBase { address constant IMMUTABLE_OPENSEA_FEE_REGISTRY = address(0x000000000000AAeB6D7670E522A718067333cd4E); diff --git a/script/UpgradeERC721DropFactory.s.sol b/script/UpgradeERC721DropFactory.s.sol index a252356..28d3f18 100644 --- a/script/UpgradeERC721DropFactory.s.sol +++ b/script/UpgradeERC721DropFactory.s.sol @@ -2,7 +2,8 @@ pragma solidity ^0.8.13; import "forge-std/console2.sol"; -import {ZoraDropsDeployBase, ChainConfig, DropDeployment} from "./ZoraDropsDeployBase.sol"; +import {ZoraDropsDeployBase} from "./ZoraDropsDeployBase.sol"; +import {ChainConfig, DropDeployment} from '../src/DeploymentConfig.sol'; import {ERC721Drop} from "../src/ERC721Drop.sol"; import {ERC721DropProxy} from "../src/ERC721DropProxy.sol"; diff --git a/script/ZoraDropsDeployBase.sol b/script/ZoraDropsDeployBase.sol index 743736e..e10c6b5 100644 --- a/script/ZoraDropsDeployBase.sol +++ b/script/ZoraDropsDeployBase.sol @@ -2,109 +2,13 @@ pragma solidity ^0.8.13; import "forge-std/Script.sol"; +import {ScriptDeploymentConfig, DropDeployment} from '../src/DeploymentConfig.sol'; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; import {ZoraNFTCreatorV1} from "../src/ZoraNFTCreatorV1.sol"; import {IERC721Drop} from "../src/interfaces/IERC721Drop.sol"; -/// @notice Chain configuration for constants set manually during deploy. Does not get written to after deploys. -struct ChainConfig { - /// @notice The user that owns the factory proxy. Allows ability to upgrade for new implementations deployed. - address factoryOwner; - /// @notice The user that owns the factory upgrade gate. This contract gates what existing deployed impls can upgrade to. - address factoryUpgradeGateOwner; - /// @notice Mint fee amount in WEI charged for each mint - uint256 mintFeeAmount; - /// @notice Mint fee recipient user - address mintFeeRecipient; - /// @notice Subscription address for operator-filterer-registry (opensea / cori) - address subscriptionMarketFilterAddress; - /// @notice Owner for subscription of operator-filterer-registry (opensea / cori) - address subscriptionMarketFilterOwner; - /// @notice Auto-approved hyperstructure on mainnet for enabling ZORA v3 with less gas. Deprecated – safe to set to address(0x) - address zoraERC721TransferHelper; -} - -/// @notice Deployment addresses – set to new deployed addresses by the scripts. -struct DropDeployment { - /// @notice Metadata renderer for drop style contracts - address dropMetadata; - /// @notice Metadata renderer for edition style contracts - address editionMetadata; - /// @notice Implementation contract for the drop contract - address dropImplementation; - /// @notice Factory upgrade gate immutable registry for allowing upgrades - address factoryUpgradeGate; - /// @notice Factory proxy contract that creates zora drops style NFT contracts - address factory; - /// @notice Factory implementation contract that is the impl for the above proxy. - address factoryImpl; -} - /// @notice Deployment drops for base where -abstract contract ZoraDropsDeployBase is Script { - using stdJson for string; - - /// @notice ChainID convenience getter - /// @return id chainId - function chainId() internal view returns (uint256 id) { - assembly { - id := chainid() - } - } - - /// @notice File used for demo metadata on verification test mint - string constant DEMO_IPFS_METADATA_FILE = "ipfs://bafkreigu544g6wjvqcysurpzy5pcskbt45a5f33m6wgythpgb3rfqi3lzi"; - - /// - // These are the JSON key constants to standardize writing and reading configuration - /// - - string constant FACTORY_OWNER = "FACTORY_OWNER"; - string constant FACTORY_UPGRADE_GATE_OWNER = "FACTORY_OWNER"; - string constant MINT_FEE_AMOUNT = "MINT_FEE_AMOUNT"; - string constant MINT_FEE_RECIPIENT = "MINT_FEE_RECIPIENT"; - string constant SUBSCRIPTION_MARKET_FILTER_ADDRESS = "SUBSCRIPTION_MARKET_FILTER_ADDRESS"; - string constant SUBSCRIPTION_MARKET_FILTER_OWNER = "SUBSCRIPTION_MARKET_FILTER_OWNER"; - string constant ZORA_ERC721_TRANSFER_HELPER = "ZORA_ERC721_TRANSFER_HELPER"; - - string constant DROP_METADATA_RENDERER = "DROP_METADATA_RENDERER"; - string constant EDITION_METADATA_RENDERER = "EDITION_METADATA_RENDERER"; - string constant ERC721DROP_IMPL = "ERC721DROP_IMPL"; - string constant FACTORY_UPGRADE_GATE = "FACTORY_UPGRADE_GATE"; - string constant ZORA_NFT_CREATOR_PROXY = "ZORA_NFT_CREATOR_PROXY"; - string constant ZORA_NFT_CREATOR_V1_IMPL = "ZORA_NFT_CREATOR_V1_IMPL"; - - /// @notice Return a prefixed key for reading with a ".". - /// @param key key to prefix - /// @return prefixed key - function getKeyPrefix(string memory key) internal pure returns (string memory) { - return string.concat(".", key); - } - - /// @notice Returns the chain configuration struct from the JSON configuration file - /// @return chainConfig structure - function getChainConfig() internal returns (ChainConfig memory chainConfig) { - string memory json = vm.readFile(string.concat("chainConfigs/", Strings.toString(chainId()), ".json")); - chainConfig.factoryOwner = json.readAddress(getKeyPrefix(FACTORY_OWNER)); - chainConfig.factoryUpgradeGateOwner = json.readAddress(getKeyPrefix(FACTORY_UPGRADE_GATE_OWNER)); - chainConfig.mintFeeAmount = json.readUint(getKeyPrefix(MINT_FEE_AMOUNT)); - chainConfig.mintFeeRecipient = json.readAddress(getKeyPrefix(MINT_FEE_RECIPIENT)); - chainConfig.subscriptionMarketFilterAddress = json.readAddress(getKeyPrefix(SUBSCRIPTION_MARKET_FILTER_ADDRESS)); - chainConfig.subscriptionMarketFilterOwner = json.readAddress(getKeyPrefix(SUBSCRIPTION_MARKET_FILTER_OWNER)); - chainConfig.zoraERC721TransferHelper = json.readAddress(getKeyPrefix(ZORA_ERC721_TRANSFER_HELPER)); - } - - /// @notice Get the deployment configuration struct from the JSON configuration file - /// @return dropDeployment deployment configuration structure - function getDeployment() internal returns (DropDeployment memory dropDeployment) { - string memory json = vm.readFile(string.concat("addresses/", Strings.toString(chainId()), ".json")); - dropDeployment.dropMetadata = json.readAddress(getKeyPrefix(DROP_METADATA_RENDERER)); - dropDeployment.editionMetadata = json.readAddress(getKeyPrefix(EDITION_METADATA_RENDERER)); - dropDeployment.dropImplementation = json.readAddress(getKeyPrefix(ERC721DROP_IMPL)); - dropDeployment.factoryUpgradeGate = json.readAddress(getKeyPrefix(FACTORY_UPGRADE_GATE)); - dropDeployment.factory = json.readAddress(getKeyPrefix(ZORA_NFT_CREATOR_PROXY)); - dropDeployment.factoryImpl = json.readAddress(getKeyPrefix(ZORA_NFT_CREATOR_V1_IMPL)); - } +abstract contract ZoraDropsDeployBase is ScriptDeploymentConfig { /// @notice Get deployment configuration struct as JSON /// @param deployment deploymet struct diff --git a/src/DeploymentConfig.sol b/src/DeploymentConfig.sol new file mode 100644 index 0000000..d627ee9 --- /dev/null +++ b/src/DeploymentConfig.sol @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.13; + +import "forge-std/Script.sol"; +import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; +import {ZoraNFTCreatorV1} from "../src/ZoraNFTCreatorV1.sol"; +import {IERC721Drop} from "../src/interfaces/IERC721Drop.sol"; + +/// @notice Chain configuration for constants set manually during deploy. Does not get written to after deploys. +struct ChainConfig { + /// @notice The user that owns the factory proxy. Allows ability to upgrade for new implementations deployed. + address factoryOwner; + /// @notice The user that owns the factory upgrade gate. This contract gates what existing deployed impls can upgrade to. + address factoryUpgradeGateOwner; + /// @notice Mint fee amount in WEI charged for each mint + uint256 mintFeeAmount; + /// @notice Mint fee recipient user + address mintFeeRecipient; + /// @notice Subscription address for operator-filterer-registry (opensea / cori) + address subscriptionMarketFilterAddress; + /// @notice Owner for subscription of operator-filterer-registry (opensea / cori) + address subscriptionMarketFilterOwner; + /// @notice Auto-approved hyperstructure on mainnet for enabling ZORA v3 with less gas. Deprecated – safe to set to address(0x) + address zoraERC721TransferHelper; +} + +/// @notice Deployment addresses – set to new deployed addresses by the scripts. +struct DropDeployment { + /// @notice Metadata renderer for drop style contracts + address dropMetadata; + /// @notice Metadata renderer for edition style contracts + address editionMetadata; + /// @notice Implementation contract for the drop contract + address dropImplementation; + /// @notice Factory upgrade gate immutable registry for allowing upgrades + address factoryUpgradeGate; + /// @notice Factory proxy contract that creates zora drops style NFT contracts + address factory; + /// @notice Factory implementation contract that is the impl for the above proxy. + address factoryImpl; +} + +/// @notice Deployment drops for base where +abstract contract DeploymentConfig is StdChains, StdCheatsSafe, StdUtils, ScriptBase { + using stdJson for string; + + /// @notice ChainID convenience getter + /// @return id chainId + function chainId() internal view virtual returns (uint256 id); + + /// @notice File used for demo metadata on verification test mint + string constant DEMO_IPFS_METADATA_FILE = "ipfs://bafkreigu544g6wjvqcysurpzy5pcskbt45a5f33m6wgythpgb3rfqi3lzi"; + + /// + // These are the JSON key constants to standardize writing and reading configuration + /// + + string constant FACTORY_OWNER = "FACTORY_OWNER"; + string constant FACTORY_UPGRADE_GATE_OWNER = "FACTORY_OWNER"; + string constant MINT_FEE_AMOUNT = "MINT_FEE_AMOUNT"; + string constant MINT_FEE_RECIPIENT = "MINT_FEE_RECIPIENT"; + string constant SUBSCRIPTION_MARKET_FILTER_ADDRESS = "SUBSCRIPTION_MARKET_FILTER_ADDRESS"; + string constant SUBSCRIPTION_MARKET_FILTER_OWNER = "SUBSCRIPTION_MARKET_FILTER_OWNER"; + string constant ZORA_ERC721_TRANSFER_HELPER = "ZORA_ERC721_TRANSFER_HELPER"; + + string constant DROP_METADATA_RENDERER = "DROP_METADATA_RENDERER"; + string constant EDITION_METADATA_RENDERER = "EDITION_METADATA_RENDERER"; + string constant ERC721DROP_IMPL = "ERC721DROP_IMPL"; + string constant FACTORY_UPGRADE_GATE = "FACTORY_UPGRADE_GATE"; + string constant ZORA_NFT_CREATOR_PROXY = "ZORA_NFT_CREATOR_PROXY"; + string constant ZORA_NFT_CREATOR_V1_IMPL = "ZORA_NFT_CREATOR_V1_IMPL"; + + /// @notice Return a prefixed key for reading with a ".". + /// @param key key to prefix + /// @return prefixed key + function getKeyPrefix(string memory key) internal pure returns (string memory) { + return string.concat(".", key); + } + + /// @notice Returns the chain configuration struct from the JSON configuration file + /// @return chainConfig structure + function getChainConfig() internal view returns (ChainConfig memory chainConfig) { + string memory json = vm.readFile(string.concat("chainConfigs/", Strings.toString(chainId()), ".json")); + chainConfig.factoryOwner = json.readAddress(getKeyPrefix(FACTORY_OWNER)); + chainConfig.factoryUpgradeGateOwner = json.readAddress(getKeyPrefix(FACTORY_UPGRADE_GATE_OWNER)); + chainConfig.mintFeeAmount = json.readUint(getKeyPrefix(MINT_FEE_AMOUNT)); + chainConfig.mintFeeRecipient = json.readAddress(getKeyPrefix(MINT_FEE_RECIPIENT)); + chainConfig.subscriptionMarketFilterAddress = json.readAddress(getKeyPrefix(SUBSCRIPTION_MARKET_FILTER_ADDRESS)); + chainConfig.subscriptionMarketFilterOwner = json.readAddress(getKeyPrefix(SUBSCRIPTION_MARKET_FILTER_OWNER)); + chainConfig.zoraERC721TransferHelper = json.readAddress(getKeyPrefix(ZORA_ERC721_TRANSFER_HELPER)); + } + + /// @notice Get the deployment configuration struct from the JSON configuration file + /// @return dropDeployment deployment configuration structure + function getDeployment() internal view returns (DropDeployment memory dropDeployment) { + string memory json = vm.readFile(string.concat("addresses/", Strings.toString(chainId()), ".json")); + dropDeployment.dropMetadata = json.readAddress(getKeyPrefix(DROP_METADATA_RENDERER)); + dropDeployment.editionMetadata = json.readAddress(getKeyPrefix(EDITION_METADATA_RENDERER)); + dropDeployment.dropImplementation = json.readAddress(getKeyPrefix(ERC721DROP_IMPL)); + dropDeployment.factoryUpgradeGate = json.readAddress(getKeyPrefix(FACTORY_UPGRADE_GATE)); + dropDeployment.factory = json.readAddress(getKeyPrefix(ZORA_NFT_CREATOR_PROXY)); + dropDeployment.factoryImpl = json.readAddress(getKeyPrefix(ZORA_NFT_CREATOR_V1_IMPL)); + } + +} + +contract ForkDeploymentConfig is DeploymentConfig { + function chainId() internal view override returns (uint256 id) { + return block.chainid; + } +} + +contract ScriptDeploymentConfig is DeploymentConfig { + function chainId() internal view override returns (uint256 id) { + assembly { + id := chainid() + } + } +} diff --git a/test/ZoraNFTCreatorV1.t.sol b/test/ZoraNFTCreatorV1.t.sol index cf38341..38323b2 100644 --- a/test/ZoraNFTCreatorV1.t.sol +++ b/test/ZoraNFTCreatorV1.t.sol @@ -8,8 +8,10 @@ import "../src/ZoraNFTCreatorProxy.sol"; import {MockMetadataRenderer} from "./metadata/MockMetadataRenderer.sol"; import {FactoryUpgradeGate} from "../src/FactoryUpgradeGate.sol"; import {IERC721AUpgradeable} from "erc721a-upgradeable/IERC721AUpgradeable.sol"; +import {ForkHelper} from "./utils/ForkHelper.sol"; +import {DropDeployment , ChainConfig} from "../src/DeploymentConfig.sol"; -contract ZoraNFTCreatorV1Test is Test { +contract ZoraNFTCreatorV1Test is Test, ForkHelper { address public constant DEFAULT_OWNER_ADDRESS = address(0x23499); address payable public constant DEFAULT_FUNDS_RECIPIENT_ADDRESS = payable(address(0x21303)); @@ -85,6 +87,59 @@ contract ZoraNFTCreatorV1Test is Test { assertEq(drop.totalSupply(), 10); } + function test_fork_CreateEdition() external { + string[] memory forkTestChains = getForkTestChains(); + + DropDeployment memory deployment; + ChainConfig memory chainConfig; + + for (uint256 i = 0; i < forkTestChains.length; i++) { + string memory chainName = forkTestChains[i]; + + vm.createSelectFork(vm.rpcUrl(chainName )); + + // get the deployment for the current chain id. + deployment = getDeployment(); + chainConfig = getChainConfig(); + + address factoryAddress = deployment.factory; + ZoraNFTCreatorV1 factory = ZoraNFTCreatorV1(factoryAddress); + + assertEq(chainConfig.factoryOwner, OwnableUpgradeable(factoryAddress).owner(), string.concat("configured owner incorrect on: ", chainName)); + assertEq(deployment.dropMetadata, address(factory.dropMetadataRenderer()), string.concat("configured drop metadata renderer incorrect on: ", chainName)); + assertEq(deployment.editionMetadata, address(factory.editionMetadataRenderer()), string.concat("configured edition metadata renderer incorrect on: ", chainName)); + // assertEq(deployment.dropImplementation, address(factory.editionMetadataRenderer()), string.concat("configured metadata renderer incorrect on: ", chainName)); + + address deployedEdition = factory.createEdition( + "name", + "symbol", + 100, + 500, + DEFAULT_FUNDS_RECIPIENT_ADDRESS, + DEFAULT_FUNDS_RECIPIENT_ADDRESS, + IERC721Drop.SalesConfiguration({ + publicSaleStart: 0, + publicSaleEnd: type(uint64).max, + presaleStart: 0, + presaleEnd: 0, + publicSalePrice: 0.1 ether, + maxSalePurchasePerAddress: 0, + presaleMerkleRoot: bytes32(0) + }), + "desc", + "animation", + "image" + ); + ERC721Drop drop = ERC721Drop(payable(deployedEdition)); + (, uint256 fee) = drop.zoraFeeForAmount(10); + vm.startPrank(DEFAULT_FUNDS_RECIPIENT_ADDRESS); + vm.deal(DEFAULT_FUNDS_RECIPIENT_ADDRESS, 10 ether + fee); + drop.purchase{value: 1 ether + fee}(10); + assertEq(drop.totalSupply(), 10); + + } + } + function test_CreateDrop() public { address deployedDrop = creator.createDrop( "name", @@ -146,4 +201,6 @@ contract ZoraNFTCreatorV1Test is Test { drop.purchase{value: fee}(1); assertEq(drop.tokenURI(1), "DEMO"); } + + } diff --git a/test/utils/ForkHelper.sol b/test/utils/ForkHelper.sol new file mode 100644 index 0000000..7a173c4 --- /dev/null +++ b/test/utils/ForkHelper.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import {ForkDeploymentConfig} from "../../src/DeploymentConfig.sol"; + +contract ForkHelper is ForkDeploymentConfig { + /// @notice gets the chains to do fork tests on, by reading environment var FORK_TEST_CHAINS. + /// Chains are by name, and must match whats under `rpc_endpoints` in the foundry.toml + function getForkTestChains() internal view returns (string[] memory result) { + try vm.envString("FORK_TEST_CHAINS", ",") returns (string[] memory forkTestChains) { + result = forkTestChains; + } catch { + result = new string[](0); + } + } +} diff --git a/yarn.lock b/yarn.lock index e69431b..7ed0686 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1428,6 +1428,10 @@ dotenv@^9.0.0: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-9.0.2.tgz#dacc20160935a37dea6364aa1bef819fb9b6ab05" integrity sha512-I9OvvrHp4pIARv4+x9iuewrWycX6CcZtoAu1XrzPxc5UygMJXJZYmBsynku8IkrJwgypE5DGNjDPmPRhDCptUg== +"ds-test@https://github.com/dapphub/ds-test#cd98eff28324bfac652e63a239a60632a761790b": + version "1.0.0" + resolved "https://github.com/dapphub/ds-test#cd98eff28324bfac652e63a239a60632a761790b" + eastasianwidth@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" @@ -1878,6 +1882,10 @@ foreground-child@^3.1.0: cross-spawn "^7.0.0" signal-exit "^4.0.1" +"forge-std@https://github.com/foundry-rs/forge-std#cd7d533f9a0ee0ec02ad81e0a8f262bc4203c653": + version "1.1.1" + resolved "https://github.com/foundry-rs/forge-std#cd7d533f9a0ee0ec02ad81e0a8f262bc4203c653" + formdata-polyfill@^4.0.10: version "4.0.10" resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz#24807c31c9d402e002ab3d8c720144ceb8848423"