diff --git a/.changeset/tame-keys-mix.md b/.changeset/tame-keys-mix.md new file mode 100644 index 000000000..5744e3c9a --- /dev/null +++ b/.changeset/tame-keys-mix.md @@ -0,0 +1,5 @@ +--- +"@zoralabs/zora-1155-contracts": patch +--- + +Deployed determinstic proxies and latest versions to mainnet, goerli, base, base goerli, optimism, optimism goerli diff --git a/DEVELOPING.md b/DEVELOPING.md index 7830544d5..28dec4b85 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -3,12 +3,29 @@ ## Deploying to a new chain 1. Setup new `chainConfigs` file setting 1. fee recipient, and 2. owner for factory contracts -2. Run forge/foundry deploy script -3. Update deployed addresses file `yarn run update-new-deployment-addresses` -4. Verify `addresses/CHAINID.json` exists. -5. Ensure contracts are verified on block explorer. -7. Add a changeset with `npx changeset` -6. Make PR with new addresses json files and changeset. +2. Generate signatures for deploying upgrade gate at a deterministic address and trasfering ownership to the factory owner: + + npx tsx script/signDeploymentTransactions.ts + +3. Deploy upgrade gate and implementation contracts: + + forge script script/DeployMintersAndImplementations.s.sol $(chains {CHAINNAME} --deploy) --interactives 1 --broadcast --verify + +4. Copy deployed addresses to `addresses/{CHAINID}.json`: + + npx tsx script/copy-deployed-contracts.ts + +5. Generate signatures to deploy proxy contracts at determinstic address: + + npx tsx script/signDeploymentTransactions.ts + +6. Deploy proxy contracts: + + forge script script/DeployProxiesToNewChain.s.sol $(chains {CHAINNAME} --deploy) --interactives 1 --broadcast --verify + +7. Ensure contracts are verified on block explorer. +8. Add a changeset with `npx changeset` +9. Make PR with new addresses json files and changeset. # Whats bundled in the published package diff --git a/addresses/1.json b/addresses/1.json index a7915c571..1266e8c7c 100644 --- a/addresses/1.json +++ b/addresses/1.json @@ -1,9 +1,13 @@ { - "FIXED_PRICE_SALE_STRATEGY": "0x8A1DBE9b1CeB1d17f92Bebf10216FCFAb5C3fbA7", - "MERKLE_MINT_SALE_STRATEGY": "0x5c895Cc296e334CA11DF751aA72135807D4057d4", - "REDEEM_MINTER_FACTORY": "0xdA48f625903547Dc7B70Ad8E019e7dFc55d0aA96", - "CONTRACT_1155_IMPL": "0xF62b0d56BA617F803DF1C464C519FF7D29451B2f", - "CONTRACT_1155_IMPL_VERSION": "1.4.0", - "FACTORY_IMPL": "0x2810D376AC3b80C443ddD3F4e84E036F2e90622A", - "FACTORY_PROXY": "0xA6C5f2DE915240270DaC655152C3f6A91748cb85" -} + "CONTRACT_1155_IMPL": "0x8e90D8cfc0CA66EA143930E4c5F7E31Bf16F722b", + "CONTRACT_1155_IMPL_VERSION": "2.0.0", + "FACTORY_IMPL": "0x55B53DBE22859d538E3b44DD06C9FAE292409E3c", + "FACTORY_PROXY": "0x777777C338d93e2C7adf08D102d45CA7CC4Ed021", + "FIXED_PRICE_SALE_STRATEGY": "0x04E2516A2c207E84a1839755675dfd8eF6302F0a", + "MERKLE_MINT_SALE_STRATEGY": "0xf48172CA3B6068B20eE4917Eb27b5472f1f272C7", + "PREMINTER_IMPL": "0x6E2AbBcd82935bFC68A1d5d2c96372b13b65eD9C", + "PREMINTER_PROXY": "0x7777773606e7e46C8Ba8B98C08f5cD218e31d340", + "REDEEM_MINTER_FACTORY": "0x78964965cF77850224513a367f899435C5B69174", + "timestamp": 1696362785, + "commit": "5e4c96a" +} \ No newline at end of file diff --git a/addresses/10.json b/addresses/10.json index ee97d03a7..9c145a19a 100644 --- a/addresses/10.json +++ b/addresses/10.json @@ -1,11 +1,13 @@ { - "CONTRACT_1155_IMPL": "0xeB29A4e5b84fef428c072debA2444e93c080CE87", - "CONTRACT_1155_IMPL_VERSION": "1.4.0", - "FACTORY_IMPL": "0x8Ca5e648C5dFEfcdDa06d627F4b490B719ccFD98", - "FACTORY_PROXY": "0x78b524931e9d847c40BcBf225c25e154a7B05fDA", + "CONTRACT_1155_IMPL": "0xF3a46845548bE811Ce37e65153563f4a0AaEbe31", + "CONTRACT_1155_IMPL_VERSION": "2.0.0", + "FACTORY_IMPL": "0xF7e49F97E82cc38ACd82E303F37Fe046f5a190B5", + "FACTORY_PROXY": "0x777777C338d93e2C7adf08D102d45CA7CC4Ed021", "FIXED_PRICE_SALE_STRATEGY": "0x3678862f04290E565cCA2EF163BAeb92Bb76790C", "MERKLE_MINT_SALE_STRATEGY": "0x899ce31dF6C6Af81203AcAaD285bF539234eF4b8", + "PREMINTER_IMPL": "0x6E2AbBcd82935bFC68A1d5d2c96372b13b65eD9C", + "PREMINTER_PROXY": "0x7777773606e7e46C8Ba8B98C08f5cD218e31d340", "REDEEM_MINTER_FACTORY": "0x1B28A04b7eB7b93f920ddF2021aa3fAE065395f2", - "timestamp": 1683685200, - "commit": "3e8799e" + "timestamp": 1696355077, + "commit": "dbb5d57" } \ No newline at end of file diff --git a/addresses/420.json b/addresses/420.json index 44d25e0d1..acd6caebf 100644 --- a/addresses/420.json +++ b/addresses/420.json @@ -1,11 +1,13 @@ { - "CONTRACT_1155_IMPL": "0x34c976E09EEcA565E208b0860Ea83F3cB881d205", - "CONTRACT_1155_IMPL_VERSION": "1.4.0", - "FACTORY_IMPL": "0x39Bcc1e15b8ec15684F17fEf298151F4A544B591", - "FACTORY_PROXY": "0xb0C56317E9cEBc6E0f7A59458a83D0A9ccC3e955", - "FIXED_PRICE_SALE_STRATEGY": "0x5b31082c269e1e575b371e14dec2594ebc6a4c5a", - "MERKLE_MINT_SALE_STRATEGY": "0xC126d0C412bE68809827c0522Eba05910936e46b", - "REDEEM_MINTER_FACTORY": "0x06E71de8A63c5392a15d06665C36184dbE78C85B", - "timestamp": 1686277138, - "commit": "563e0ff" + "CONTRACT_1155_IMPL": "0xAF5A4F6F6640734d7D000321Bb27De40D4Ae91f6", + "CONTRACT_1155_IMPL_VERSION": "2.0.0", + "FACTORY_IMPL": "0x7B59c0378F540c0356A5DAEF7574255A7C74EC76", + "FACTORY_PROXY": "0x777777C338d93e2C7adf08D102d45CA7CC4Ed021", + "FIXED_PRICE_SALE_STRATEGY": "0x04E2516A2c207E84a1839755675dfd8eF6302F0a", + "MERKLE_MINT_SALE_STRATEGY": "0xf48172CA3B6068B20eE4917Eb27b5472f1f272C7", + "PREMINTER_IMPL": "0x6E2AbBcd82935bFC68A1d5d2c96372b13b65eD9C", + "PREMINTER_PROXY": "0x7777773606e7e46C8Ba8B98C08f5cD218e31d340", + "REDEEM_MINTER_FACTORY": "0x78964965cF77850224513a367f899435C5B69174", + "timestamp": 1696354853, + "commit": "0656a4c" } \ No newline at end of file diff --git a/addresses/5.json b/addresses/5.json index 8cac8b801..509a8bcfe 100644 --- a/addresses/5.json +++ b/addresses/5.json @@ -1,11 +1,13 @@ { - "CONTRACT_1155_IMPL": "0x89a53404d3e29c6e5431d73e04F44045d37D01FE", - "CONTRACT_1155_IMPL_VERSION": "1.4.0", - "FACTORY_IMPL": "0xA06262157905913f855573f53AD48DE2D4ba1F4A", - "FACTORY_PROXY": "0x8732b4bCa198509bB9c40f9a24638Be1eaB7D30c", - "FIXED_PRICE_SALE_STRATEGY": "0xD8EB23E82f0795427F27D7F20CAb56e7630D1166", - "MERKLE_MINT_SALE_STRATEGY": "0x91724462892148fb0bAcD300d7503A80baB32aA5", - "REDEEM_MINTER_FACTORY": "0xD507589779D7a4ec85FF9041dB2C2dc19e4B0554", - "timestamp": 1688510153, - "commit": "f60dd5f" + "CONTRACT_1155_IMPL": "0x455c9D3188A3Cd94aCDE8E5Ec90cA92FC10805EA", + "CONTRACT_1155_IMPL_VERSION": "2.0.0", + "FACTORY_IMPL": "0x9074Ae399235d26B56e3aF1331b033366E4FE072", + "FACTORY_PROXY": "0x777777C338d93e2C7adf08D102d45CA7CC4Ed021", + "FIXED_PRICE_SALE_STRATEGY": "0x04E2516A2c207E84a1839755675dfd8eF6302F0a", + "MERKLE_MINT_SALE_STRATEGY": "0xf48172CA3B6068B20eE4917Eb27b5472f1f272C7", + "PREMINTER_IMPL": "0x6E2AbBcd82935bFC68A1d5d2c96372b13b65eD9C", + "PREMINTER_PROXY": "0x7777773606e7e46C8Ba8B98C08f5cD218e31d340", + "REDEEM_MINTER_FACTORY": "0x78964965cF77850224513a367f899435C5B69174", + "timestamp": 1696361976, + "commit": "a8eeef3" } \ No newline at end of file diff --git a/addresses/8453.json b/addresses/8453.json index 625c2a4e4..4bd17fb19 100644 --- a/addresses/8453.json +++ b/addresses/8453.json @@ -1,11 +1,13 @@ { - "CONTRACT_1155_IMPL": "0x805E0a08dE70f85C01F7848370d5e3fc08aAd0ea", - "CONTRACT_1155_IMPL_VERSION": "1.4.0", - "FACTORY_IMPL": "0xeB29A4e5b84fef428c072debA2444e93c080CE87", - "FACTORY_PROXY": "0x9b24FD165a371042e5CA81e8d066d25CAD11EDE7", - "FIXED_PRICE_SALE_STRATEGY": "0xFF8B0f870ff56870Dc5aBd6cB3E6E89c8ba2e062", - "MERKLE_MINT_SALE_STRATEGY": "0xbC98b527433266910fcc0ae56E17DDbd41846bCB", - "REDEEM_MINTER_FACTORY": "0x56Ab0bc1971f5fE6A263cA34050896f4B0fcF88E", - "timestamp": 1689781747, - "commit": "1854b5d" + "CONTRACT_1155_IMPL": "0x314E552b55DFbDfD4d76623E1D45E5056723998B", + "CONTRACT_1155_IMPL_VERSION": "2.0.0", + "FACTORY_IMPL": "0xC6899816663891D7493939d74d83cb7f2BBcBB16", + "FACTORY_PROXY": "0x777777C338d93e2C7adf08D102d45CA7CC4Ed021", + "FIXED_PRICE_SALE_STRATEGY": "0x04E2516A2c207E84a1839755675dfd8eF6302F0a", + "MERKLE_MINT_SALE_STRATEGY": "0xf48172CA3B6068B20eE4917Eb27b5472f1f272C7", + "PREMINTER_IMPL": "0x6E2AbBcd82935bFC68A1d5d2c96372b13b65eD9C", + "PREMINTER_PROXY": "0x7777773606e7e46C8Ba8B98C08f5cD218e31d340", + "REDEEM_MINTER_FACTORY": "0x78964965cF77850224513a367f899435C5B69174", + "timestamp": 1696357595, + "commit": "804ad45" } \ No newline at end of file diff --git a/addresses/84531.json b/addresses/84531.json index ca25f386f..b7effc731 100644 --- a/addresses/84531.json +++ b/addresses/84531.json @@ -1,11 +1,13 @@ { - "CONTRACT_1155_IMPL": "0x669c0E36c7C3b7Ba984F746c43C5b7C073db7197", - "CONTRACT_1155_IMPL_VERSION": "1.4.0", - "FACTORY_IMPL": "0x2bB7D8226575AEB76597A50134088BaA8AaA48De", - "FACTORY_PROXY": "0x9168C5ba5a0a76db8A1BF5b2eE5557f2A0ECA4f4", - "FIXED_PRICE_SALE_STRATEGY": "0x66e7bE0b5A7dD9eb7999AAbE7AbdFa40381b6d5E", - "MERKLE_MINT_SALE_STRATEGY": "0xFFc886a0C539e2AB50211D7C55f01408507a3c65", - "REDEEM_MINTER_FACTORY": "0x13dAA8E9e3f68deDE7b1386ACdc12eA98F2FB688", - "timestamp": 1689090854, - "commit": "4cfd3cc" + "CONTRACT_1155_IMPL": "0xD66B730aA3B4921356Fc56907D22e65CA9F4ff58", + "CONTRACT_1155_IMPL_VERSION": "2.0.0", + "FACTORY_IMPL": "0xF482C51346f3c77673dc619F243Eb8B09E9A954E", + "FACTORY_PROXY": "0x777777C338d93e2C7adf08D102d45CA7CC4Ed021", + "FIXED_PRICE_SALE_STRATEGY": "0x04E2516A2c207E84a1839755675dfd8eF6302F0a", + "MERKLE_MINT_SALE_STRATEGY": "0xf48172CA3B6068B20eE4917Eb27b5472f1f272C7", + "PREMINTER_IMPL": "0x6E2AbBcd82935bFC68A1d5d2c96372b13b65eD9C", + "PREMINTER_PROXY": "0x7777773606e7e46C8Ba8B98C08f5cD218e31d340", + "REDEEM_MINTER_FACTORY": "0x78964965cF77850224513a367f899435C5B69174", + "timestamp": 1696355958, + "commit": "9a9df5f" } \ No newline at end of file diff --git a/deterministicConfig/factoryProxy/signatures.json b/deterministicConfig/factoryProxy/signatures.json index 23d1b4f1f..64da0382f 100644 --- a/deterministicConfig/factoryProxy/signatures.json +++ b/deterministicConfig/factoryProxy/signatures.json @@ -1,13 +1,13 @@ { - "1": "0xbc9e925ad723c48a9a52fcfe42e21440ceb3dac3865d1cfc5fd5afd5e83575cd38fe281dea73e4f04b39281bf9237427a069df50a313913d189afe7ca1fc611f1b", - "5": "0x9864c37cbb0684ccbe21a8295a45e52947d2baf171b197b3c86216e8731bbd4245a1814964a3b34034d03982a56aac731b41f67eaf8bfa29a5bd532dcafd411d1c", - "10": "0xa1d757624927c176ff756177cb6d9da085e1d2d0a6e58f62fdc3d5f0b1528da81e15207c66a868d9f6412bcddf532e983d88b01c52343228b2f1e908b26f5a921b", - "420": "0x63a19226346eac1a22816e51d22bcde3daaa4fd5b0c0e032ac339ae0c4526fa611000d9d86ce9ec24432f6730872a885686424a050545eac19381ecf175ebc931b", + "1": "0xcd4c9970be747e8789231d2caf25299f1a5398220722bf415f146b510aad968d6aeec91da8a564e03a383ea162c54ac7cce794ccd39c1561e08ecbe8a7ac39791c", + "5": "0xabbaa6951c41abd10a624ee695a6e5c35038df0e933478cef339ce54b072483d3e7ee5736d1c71833c25a3e852c5c2bf910b7663f4d56569da977ad9e14ad9231c", + "10": "0xf748deeb047a535753c9f751904958ad446b6c93eae089ce62f045f9a7fb525250e946095b9534e649b9b1efd6eb3e7264ad7bf65711866569205604315d237e1b", + "420": "0x64e0922bd08e7256d5622a692ef8a015ca2ed421d19813495e9e1056ff537a30361917fd0c4cff183bc54b75098d9b3b087393b2be52c8c9ee5105001edd0e6c1b", "424": "0xcc4a742f435b66a75c054f18b8b1bd92d46e92a3bf0d02ad0ab9e9b5e66095be19721f3123c5754de5067ec8a1cdfbed18e4e99e66c433034f74d62373b5cd221b", "999": "0x560ec794208401df7446777c93ae50cb202be28e80a06700101ddb526d0541b33fedaf949e931bf8ce01b4648cf89b4b29c45c6f4125584e9c368b34079849cf1b", - "8453": "0xebba1e596cdad038f08ba902230ef61b0dde8e6451e23871e698597a984243af3596efeaf82ab56af6c14cea05b9dcb3f738949b80f1866c25d59368dc46fbd71b", + "8453": "0x4c26816c8b9f4cdd8f56d789b77d943b2f1676abc3d4af90c18a3a6aec9595bd3f7ff530867885969bafa3cc43f6098d7c867e8ea0fd190ffd03a1071aae92481b", "58008": "0xae84314a335c1faca4472d2fede2a730b3bc444cb371c20e0ccff1507bc6918478ac088668371101a39a2a0ecdf6161c5a2a66eeaa12f32d92ea53ffd25665ad1c", - "84531": "0xde44b0d71687ae81424fc8ae0af0c7f572406021f6f9f1577195e6aba1ca2dcc33da2a1fe7bf3982be87a92955c7f041823eb9d2f1e2daacad17079c522e1f201c", + "84531": "0x0575f344bd610c1206335dcb5b5041b84b8f93e5f12b733d9c85a875e037744e751f431fb65e4822af8f6bc4444be6be96ffb16a8d9ab6b196ba1d961e7e75921b", "7777777": "0x8ccdbb2700e9fe53111443c4d2262a2a9ae7edc2e550d270c632bd3516b6c86974d81bb2b6c49d5ee751dbbf6ad0d5296f9a8e8213ff58a9a2cb7e6bb1b3a6f81c", "11155111": "0x13840cf936c6c07dc185b7f1023072bd91d4494786b2f356b1510e32e4e8b50e5e954c60d895c4be500c071d937a786952a8ed514028dacaf75cdf15222140ca1c" } \ No newline at end of file diff --git a/deterministicConfig/premintExecutorProxy/signatures.json b/deterministicConfig/premintExecutorProxy/signatures.json index f45f13694..6cd0903f0 100644 --- a/deterministicConfig/premintExecutorProxy/signatures.json +++ b/deterministicConfig/premintExecutorProxy/signatures.json @@ -1,6 +1,10 @@ { + "1": "0xeb5417ad05bb90e252937c3258e9843730d0224f0a5f38f43d48a4ce6f23673a5c6da3f17e5aec99346d6bcab86def782bdc65a57942a4f90950b8e8bdc022ca1c", + "5": "0x1293214f6aa6f1016fa73045d854bea14337eb9a08cdee739666da3f8b2e9f510a173df48f017eb0c7985c256ac2a18ce429636bb79ca993c03800e0d295a80a1c", "10": "0xe35889f0aa5eb832fc6f992b128ed6203cf46273cb968d6ab2c14acb870f7c775c68b563af3d7b0d5be3fe2aec00aa0b2610390e59ecc55897cb2db914f939ef1b", "420": "0x910e52eb373a23b9a1cdead2e1741a9b22367708909594ab363eab4fc118165c5f9e4ed44ee65edd40a477d81a4b62959b10611b96ac54ecc3177a8f725bc8091b", "999": "0x0104248b75845b2f24e7988ace4b7057275a4fbe58781be6080ed59b335c8eb263bac72ecd5d42809641b47c630f42e22f72aa5676337f7959caef122f32f2141b", + "8453": "0x6c1ff489ce4abc4ed4e66368b926ed1414a54b6685e483e90e8495895a525c273e7f10342d02fbad07ed59da35366e610917a120562ab36b3eb2dfacecc484eb1c", + "84531": "0xb489fca7545641f1066e0f04bebe7cf680f7a45c89ab12911cb2ba411e49e26f00a5c799ca5070c2f059ae46371fe612ff4efc3deaf77fe2793a562ed660af0a1c", "7777777": "0xbfb5d8fad289d2792f2e9f31fb175029ec257e1705bb1c16db805d3ce391466f62f7b3c40941848451c414aecc6197f455496637bb6c895d086fbbf0b6a5a8071c" } \ No newline at end of file diff --git a/deterministicConfig/upgradeGate/signatures.json b/deterministicConfig/upgradeGate/signatures.json index cb413e997..19f1e0ce0 100644 --- a/deterministicConfig/upgradeGate/signatures.json +++ b/deterministicConfig/upgradeGate/signatures.json @@ -1,6 +1,13 @@ { + "1": "0x2f1655640cec59018cf3df3333698ec56255d79217baaecc3d5111e245487a7d24f92dcb5e92545dedb6618bc44cf920b2af246a8307259fd47ccacf1e89d9ec1c", + "5": "0xcb64e94035539d5864038d4687a835ebb068d5ab620610d36aff5906e274d8eb28d983d663151142f220534afca73035d3f0e30e234da31b4264afb74bff25ed1b", "10": "0x2c2772daabef01fc8de3e57702e002490783c9262cd3a9e9874e024afc8caf706fc8a733cc6eb92f1381c64fb9b74d986c4315ac6de0512c54d2190dd4e8a1a61c", "420": "0x7076721a5716503f8875429bd9357beff99f8c44ccc2c6d769b33cbc04ba00bb6a33599d29fe263d759b434f6146086aab5f878ab54d09fd6229b23b619f9deb1c", + "424": "0x10c79903001e2f7530266631e2b695e0cba1e655004dfc7448059fb4b979704b3f835679f1a85787918f48ffad1cfd28544d69d693d3ce2d3b52f19c409a519d1b", "999": "0x4c82704c3dcb8a7e12489f706f8b776c5d4e6095167dd60c007ad997c56adc1a355c9f1994faa7699643571cf5b10b644192c7a1610dba04555cb092f9af61251c", - "7777777": "0x520fe50fcbd9749ae74af7f75e6eb1b825bc1c17a8f50238e7f92d210cc4620422f2aeddb7ead68bcfffba6b16965003371b275c88a15161aa3e59809d7d3f4b1b" + "8453": "0xddc5f96dc6552a5475f5aab46573701ae51446f6da7168318d26e87d4e434f1c6892b0f640a752bae2717f1688c1e02b0eac28708cfad160eb581e7b8179b7501c", + "58008": "0xd1f1e7dcae636306c3b4d20091b930f67feb0a2f7366d254f919bf262d9a309939648eeb313e35f5b6bff64e3fb13e361d5cbb3cc052c59a911a0b2de1c3f0691b", + "84531": "0x31afd94b98e5e9de1e449bf8872209b17132b54d5dbdcf533aab88164044969759f1aa349b4c0184c194c4ddcf62f9e1c740e17016f9da89b89e83d5135b34641b", + "7777777": "0x520fe50fcbd9749ae74af7f75e6eb1b825bc1c17a8f50238e7f92d210cc4620422f2aeddb7ead68bcfffba6b16965003371b275c88a15161aa3e59809d7d3f4b1b", + "11155111": "0x81240ffa1480e231635c6cd8e9d5af3e7fe4c069022918ba8d431ddcd7d75ea72e3951d7a3c2f73f1c675105091b12d9350c07518207398b7606bf88a9ee03371c" } \ No newline at end of file diff --git a/package.json b/package.json index a56a7ade4..7f0fa5162 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "test": "forge test", "test-gas": "forge test --gas-report", "prettier:check": "prettier --check 'src/**/*.sol' 'test/**/*.sol' 'package/**/*.ts' 'wagmi.config.ts'", - "prettier": "prettier --write 'src/**/*.sol' 'test/**/*.sol' 'package/**/*.ts' 'wagmi.config.ts'", + "prettier": "prettier --write 'src/**/*.sol' 'test/**/*.sol' 'package/**/*.ts' 'script/**/*.ts' 'wagmi.config.ts'", "coverage": "forge coverage --report lcov", "write-gas-report": "forge test --gas-report > gasreport.ansi", "prepack": "yarn wagmi && yarn bundle-configs && yarn build", diff --git a/script/CalculateDeterministicParams.s.sol b/script/CalculateDeterministicParams.s.sol index bd05c3ceb..cdab57dfb 100644 --- a/script/CalculateDeterministicParams.s.sol +++ b/script/CalculateDeterministicParams.s.sol @@ -20,7 +20,7 @@ import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; /// @dev Example usage: DEPLOYER=0xf69fEc6d858c77e969509843852178bd24CAd2B6 forge script script/GetDeterminsticParam.s.sol --rpc-url https://testnet.rpc.zora.energy --ffi /// @author doved /// @notice Ensure to set env variable for DEPLOYER -contract FactoryProxyDeterministicParams is ZoraDeployerBase, DeterministicDeployerScript { +contract FactoryProxyDeterministicParams is ZoraDeployerBase { address deployerAddress; // Set in step 2 address proxyDeployerAddress; diff --git a/script/DeployMintersAndImplementations.s.sol b/script/DeployMintersAndImplementations.s.sol index 08b3f96e2..98cb5f065 100644 --- a/script/DeployMintersAndImplementations.s.sol +++ b/script/DeployMintersAndImplementations.s.sol @@ -6,62 +6,26 @@ import "forge-std/console2.sol"; import {ZoraDeployerBase} from "./ZoraDeployerBase.sol"; import {ZoraDeployerUtils} from "../src/deployment/ZoraDeployerUtils.sol"; -import {ChainConfig, Deployment} from "../src/deployment/DeploymentConfig.sol"; +import {Deployment} from "../src/deployment/DeploymentConfig.sol"; -import {ZoraCreator1155FactoryImpl} from "../src/factory/ZoraCreator1155FactoryImpl.sol"; -import {Zora1155Factory} from "../src/proxies/Zora1155Factory.sol"; -import {ZoraCreator1155Impl} from "../src/nft/ZoraCreator1155Impl.sol"; -import {IZoraCreator1155Factory} from "../src/interfaces/IZoraCreator1155Factory.sol"; -import {IZoraCreator1155} from "../src/interfaces/IZoraCreator1155.sol"; -import {DeterministicDeployerScript} from "../src/deployment/DeterministicDeployerScript.sol"; -import {IMinter1155} from "../src/interfaces/IMinter1155.sol"; -import {DeploymentTestingUtils} from "../src/deployment/DeploymentTestingUtils.sol"; - -contract DeployMintersAndImplementations is ZoraDeployerBase, DeterministicDeployerScript, DeploymentTestingUtils { +contract DeployMintersAndImplementations is ZoraDeployerBase { function run() public returns (string memory) { Deployment memory deployment = getDeployment(); - ChainConfig memory chainConfig = getChainConfig(); address deployer = vm.envAddress("DEPLOYER"); - // Sanity check to make sure that the factory owner is a smart contract. - // This may catch cross-chain data copy mistakes where there is no safe at the desired admin address. - if (address(chainConfig.factoryOwner).code.length == 0) { - revert("FactoryOwner should be a contract. See DeployNewProxies:31."); - } - - uint256 chain = chainId(); - vm.startBroadcast(deployer); - (address fixedPriceMinter, address merkleMinter, address redeemMinterFactory) = ZoraDeployerUtils.deployMinters(); + deployUpgradeGateDeterminstic(deployment); - console.log("deploy upgrade gate"); + deployMinters(deployment); - address upgradeGateAddress = deployUpgradeGate({chain: chainId(), upgradeGateOwner: chainConfig.factoryOwner}); + deployNew1155AndFactoryImpl(deployment); - console.log("impl contracts"); - - (address factoryImplAddress, address contract1155ImplAddress) = ZoraDeployerUtils.deployNew1155AndFactoryImpl( - upgradeGateAddress, - chainConfig.mintFeeRecipient, - chainConfig.protocolRewards, - IMinter1155(merkleMinter), - IMinter1155(redeemMinterFactory), - IMinter1155(fixedPriceMinter) - ); - - deployment.fixedPriceSaleStrategy = address(fixedPriceMinter); - deployment.merkleMintSaleStrategy = address(merkleMinter); - deployment.redeemMinterFactory = address(redeemMinterFactory); - deployment.upgradeGate = upgradeGateAddress; - deployment.factoryImpl = factoryImplAddress; - deployment.contract1155Impl = contract1155ImplAddress; + deployNewPreminterImplementationDeterminstic(deployment); vm.stopBroadcast(); - // now test signing and executing premint - return getDeploymentJSON(deployment); } } diff --git a/script/DeployNewImplementation.s.sol b/script/DeployNewImplementation.s.sol index 785c3ff93..87833b6ee 100644 --- a/script/DeployNewImplementation.s.sol +++ b/script/DeployNewImplementation.s.sol @@ -5,19 +5,9 @@ import "forge-std/Script.sol"; import "forge-std/console2.sol"; import {ZoraDeployerBase} from "./ZoraDeployerBase.sol"; -import {ChainConfig, Deployment} from "../src/deployment/DeploymentConfig.sol"; - -import {ZoraCreator1155FactoryImpl} from "../src/factory/ZoraCreator1155FactoryImpl.sol"; -import {Zora1155Factory} from "../src/proxies/Zora1155Factory.sol"; -import {ZoraCreator1155Impl} from "../src/nft/ZoraCreator1155Impl.sol"; -import {ICreatorRoyaltiesControl} from "../src/interfaces/ICreatorRoyaltiesControl.sol"; -import {IZoraCreator1155Factory} from "../src/interfaces/IZoraCreator1155Factory.sol"; -import {IZoraCreator1155} from "../src/interfaces/IZoraCreator1155.sol"; -import {IMinter1155} from "../src/interfaces/IMinter1155.sol"; -import {ZoraCreatorFixedPriceSaleStrategy} from "../src/minters/fixed-price/ZoraCreatorFixedPriceSaleStrategy.sol"; -import {ZoraCreatorMerkleMinterStrategy} from "../src/minters/merkle/ZoraCreatorMerkleMinterStrategy.sol"; -import {ZoraCreatorRedeemMinterFactory} from "../src/minters/redeem/ZoraCreatorRedeemMinterFactory.sol"; -import {ZoraDeployerUtils} from "../src/deployment/ZoraDeployerUtils.sol"; +import {Deployment} from "../src/deployment/DeploymentConfig.sol"; + +import {DeterministicDeployerScript} from "../src/deployment/DeterministicDeployerScript.sol"; /// @dev Deploys implementation contracts for 1155 contracts. /// @notice Run after deploying the minters @@ -25,30 +15,12 @@ import {ZoraDeployerUtils} from "../src/deployment/ZoraDeployerUtils.sol"; contract DeployNewImplementations is ZoraDeployerBase { function run() public returns (string memory) { Deployment memory deployment = getDeployment(); - ChainConfig memory chainConfig = getChainConfig(); - - console2.log("zoraFeeRecipient", chainConfig.mintFeeRecipient); - console2.log("factoryOwner", chainConfig.factoryOwner); - console2.log("protocolRewards", chainConfig.protocolRewards); - - deployment.upgradeGate = vm.parseJsonAddress(vm.readFile("./deterministicConfig/upgradeGate/params.json"), ".upgradeGateAddress"); - - console2.log("upgradeGateAddress", deployment.upgradeGate); vm.startBroadcast(); - (address factoryImplAddress, address contract1155ImplAddress) = ZoraDeployerUtils.deployNew1155AndFactoryImpl( - address(deployment.upgradeGate), - chainConfig.mintFeeRecipient, - chainConfig.protocolRewards, - IMinter1155(deployment.merkleMintSaleStrategy), - IMinter1155(deployment.redeemMinterFactory), - IMinter1155(deployment.fixedPriceSaleStrategy) - ); - - deployment.factoryImpl = factoryImplAddress; - deployment.contract1155Impl = contract1155ImplAddress; - deployment.preminterImpl = ZoraDeployerUtils.deployNewPreminterImplementationDeterminstic(address(deployment.factoryProxy)); + deployNew1155AndFactoryImpl(deployment); + + deployNewPreminterImplementationDeterminstic(deployment); return getDeploymentJSON(deployment); } diff --git a/script/DeployPreminterImpl.s.sol b/script/DeployPreminterImpl.s.sol new file mode 100644 index 000000000..5e5f192b0 --- /dev/null +++ b/script/DeployPreminterImpl.s.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "forge-std/Script.sol"; +import "forge-std/console2.sol"; + +import {ZoraDeployerBase} from "./ZoraDeployerBase.sol"; +import {Deployment} from "../src/deployment/DeploymentConfig.sol"; + +import {DeterministicDeployerScript} from "../src/deployment/DeterministicDeployerScript.sol"; + +/// @dev Deploys preminter implementation contract. +/// @notice Run after deploying the minters +contract DeployPreminterImpl is ZoraDeployerBase { + function run() public returns (string memory) { + Deployment memory deployment = getDeployment(); + + vm.startBroadcast(); + + deployNewPreminterImplementationDeterminstic(deployment); + + return getDeploymentJSON(deployment); + } +} diff --git a/script/DeployProxiesToNewChain.s.sol b/script/DeployProxiesToNewChain.s.sol index 508e04a69..79cdf993d 100644 --- a/script/DeployProxiesToNewChain.s.sol +++ b/script/DeployProxiesToNewChain.s.sol @@ -6,87 +6,33 @@ import "forge-std/console2.sol"; import {ZoraDeployerBase} from "./ZoraDeployerBase.sol"; import {ZoraDeployerUtils} from "../src/deployment/ZoraDeployerUtils.sol"; -import {ChainConfig, Deployment} from "../src/deployment/DeploymentConfig.sol"; - -import {ZoraCreator1155FactoryImpl} from "../src/factory/ZoraCreator1155FactoryImpl.sol"; -import {Zora1155Factory} from "../src/proxies/Zora1155Factory.sol"; -import {ZoraCreator1155Impl} from "../src/nft/ZoraCreator1155Impl.sol"; -import {IZoraCreator1155Factory} from "../src/interfaces/IZoraCreator1155Factory.sol"; -import {IZoraCreator1155} from "../src/interfaces/IZoraCreator1155.sol"; -import {DeterministicDeployerScript} from "../src/deployment/DeterministicDeployerScript.sol"; -import {IMinter1155} from "../src/interfaces/IMinter1155.sol"; +import {Deployment} from "../src/deployment/DeploymentConfig.sol"; + import {DeploymentTestingUtils} from "../src/deployment/DeploymentTestingUtils.sol"; -contract DeployProxiesToNewChain is ZoraDeployerBase, DeterministicDeployerScript, DeploymentTestingUtils { +contract DeployProxiesToNewChain is ZoraDeployerBase, DeploymentTestingUtils { function run() public returns (string memory) { Deployment memory deployment = getDeployment(); - ChainConfig memory chainConfig = getChainConfig(); - - address deployer = vm.envAddress("DEPLOYER"); - - // Sanity check to make sure that the factory owner is a smart contract. - // This may catch cross-chain data copy mistakes where there is no safe at the desired admin address. - if (address(chainConfig.factoryOwner).code.length == 0) { - revert("FactoryOwner should be a contract. See DeployNewProxies:31."); - } - uint256 chain = chainId(); - - vm.startBroadcast(deployer); + vm.startBroadcast(); console.log("deploy factory proxy"); - address factoryProxyAddress = deployDeterministicProxy({ - proxyName: "factoryProxy", - implementation: deployment.factoryImpl, - owner: chainConfig.factoryOwner, - chain: chain - }); - - console2.log("factory proxy address:", factoryProxyAddress); - - require( - keccak256(abi.encodePacked(ZoraCreator1155FactoryImpl(factoryProxyAddress).contractName())) == - keccak256(abi.encodePacked("ZORA 1155 Contract Factory")) - ); + deployFactoryProxyDeterminstic(deployment); - console2.log("implementation", ZoraCreator1155FactoryImpl(factoryProxyAddress).implementation()); - - address hi = makeAddr("hi"); - address adsdfasd = makeAddr("admin"); - console2.log( - "get da contract address", - ZoraCreator1155FactoryImpl(factoryProxyAddress).deterministicContractAddress(hi, "asdfasf", "asdfasdf", adsdfasd) - ); + console2.log("factory proxy address:", deployment.factoryProxy); console2.log("create test contract for verification"); - ZoraDeployerUtils.deployTestContractForVerification(factoryProxyAddress, makeAddr("admin")); - - console2.log("Deployed new contract for verification purposes"); - - console2.log("deploy preminter and proxy"); - - address preminterImpl = ZoraDeployerUtils.deployNewPreminterImplementationDeterminstic(address(factoryProxyAddress)); - - console2.log("preminter impl", preminterImpl); - - address preminterProxyAddress = deployDeterministicProxy({ - proxyName: "premintExecutorProxy", - implementation: preminterImpl, - owner: chainConfig.factoryOwner, - chain: chain - }); + ZoraDeployerUtils.deployTestContractForVerification(deployment.factoryProxy, makeAddr("admin")); - console2.log("preminter proxy", preminterProxyAddress); + deployPreminterProxyDeterminstic(deployment); - deployment.factoryProxy = factoryProxyAddress; - deployment.preminterImpl = preminterImpl; - deployment.preminterProxy = preminterProxyAddress; + console2.log("preminter proxy", deployment.preminterProxy); console2.log("testing premint"); - signAndExecutePremint(preminterProxyAddress); + signAndExecutePremint(deployment.preminterProxy); vm.stopBroadcast(); diff --git a/script/DeployUpgradeGate.s.sol b/script/DeployUpgradeGate.s.sol new file mode 100644 index 000000000..b10d429d0 --- /dev/null +++ b/script/DeployUpgradeGate.s.sol @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "forge-std/Script.sol"; +import "forge-std/console2.sol"; + +import {ZoraDeployerBase} from "./ZoraDeployerBase.sol"; +import {ZoraDeployerUtils} from "../src/deployment/ZoraDeployerUtils.sol"; +import {ChainConfig, Deployment} from "../src/deployment/DeploymentConfig.sol"; + +import {DeterministicDeployerScript} from "../src/deployment/DeterministicDeployerScript.sol"; + +contract DeployUpgradeGate is ZoraDeployerBase { + function run() public returns (string memory) { + Deployment memory deployment = getDeployment(); + + vm.startBroadcast(); + + deployUpgradeGateDeterminstic(deployment); + + vm.stopBroadcast(); + + // now test signing and executing premint + + return getDeploymentJSON(deployment); + } +} diff --git a/script/ZoraDeployerBase.sol b/script/ZoraDeployerBase.sol index 324761c10..1354eab6f 100644 --- a/script/ZoraDeployerBase.sol +++ b/script/ZoraDeployerBase.sol @@ -11,9 +11,11 @@ import {ICreatorRoyaltiesControl} from "../src/interfaces/ICreatorRoyaltiesContr import {ScriptDeploymentConfig, Deployment, ChainConfig} from "../src/deployment/DeploymentConfig.sol"; import {ZoraDeployerUtils} from "../src/deployment/ZoraDeployerUtils.sol"; import {IMinter1155} from "../src/interfaces/IMinter1155.sol"; +import {DeterministicDeployerScript} from "../src/deployment/DeterministicDeployerScript.sol"; +import {ZoraCreator1155FactoryImpl} from "../src/factory/ZoraCreator1155FactoryImpl.sol"; /// @notice Deployment drops for base where -abstract contract ZoraDeployerBase is ScriptDeploymentConfig { +abstract contract ZoraDeployerBase is ScriptDeploymentConfig, DeterministicDeployerScript { using stdJson for string; /// @notice File used for demo metadata on verification test mint @@ -36,25 +38,106 @@ abstract contract ZoraDeployerBase is ScriptDeploymentConfig { console2.log(deploymentJson); } - function deployNew1155AndFactoryImpl(Deployment memory deployment, Zora1155Factory factoryProxy) internal { + function deployMinters(Deployment memory deployment) internal { + (address fixedPriceMinter, address merkleMinter, address redeemMinterFactory) = ZoraDeployerUtils.deployMinters(); + deployment.fixedPriceSaleStrategy = address(fixedPriceMinter); + deployment.merkleMintSaleStrategy = address(merkleMinter); + deployment.redeemMinterFactory = address(redeemMinterFactory); + } + + function deployNew1155AndFactoryImpl(Deployment memory deployment) internal { + ChainConfig memory chainConfig = getChainConfig(); + + ensureCanOwn(chainConfig.factoryOwner); + + (address factoryImplDeployment, address contract1155ImplDeployment, string memory contract1155ImplVersion) = ZoraDeployerUtils + .deployNew1155AndFactoryImpl({ + upgradeGateAddress: determinsticUpgradeGateAddress(), + mintFeeRecipient: chainConfig.mintFeeRecipient, + protocolRewards: chainConfig.protocolRewards, + merkleMinter: IMinter1155(deployment.merkleMintSaleStrategy), + redeemMinterFactory: IMinter1155(deployment.redeemMinterFactory), + fixedPriceMinter: IMinter1155(deployment.fixedPriceSaleStrategy) + }); + + deployment.factoryImpl = factoryImplDeployment; + deployment.contract1155Impl = contract1155ImplDeployment; + deployment.contract1155ImplVersion = contract1155ImplVersion; + } + + function deployNewPreminterImplementationDeterminstic(Deployment memory deployment) internal { + address factoryProxyAddress = determinticFactoryProxyAddress(); + deployment.preminterImpl = ZoraDeployerUtils.deployNewPreminterImplementationDeterminstic(factoryProxyAddress); + } + + function determinticFactoryProxyAddress() internal view returns (address) { + return readFactoryProxyDeterminsticParams().deterministicProxyAddress; + } + + function determinsticPreminterProxyAddress() internal view returns (address) { + return readPreminterProxyDeterminsticParams().deterministicProxyAddress; + } + + function deployFactoryProxyDeterminstic(Deployment memory deployment) internal { + ChainConfig memory chainConfig = getChainConfig(); + + ensureCanOwn(chainConfig.factoryOwner); + + address factoryProxyAddress = deployDeterministicProxy({ + proxyName: "factoryProxy", + implementation: deployment.factoryImpl, + owner: chainConfig.factoryOwner, + chain: chainId() + }); + + require(factoryProxyAddress == determinticFactoryProxyAddress(), "address not expected deterministic address"); + + require( + keccak256(abi.encodePacked(ZoraCreator1155FactoryImpl(factoryProxyAddress).contractName())) == + keccak256(abi.encodePacked("ZORA 1155 Contract Factory")) + ); + + deployment.factoryProxy = factoryProxyAddress; + } + + function deployPreminterProxyDeterminstic(Deployment memory deployment) internal { ChainConfig memory chainConfig = getChainConfig(); - (address factoryImplAddress, address contract1155ImplAddress) = ZoraDeployerUtils.deployNew1155AndFactoryImpl({ - factoryProxyAddress: address(factoryProxy), - mintFeeRecipient: chainConfig.mintFeeRecipient, - protocolRewards: chainConfig.protocolRewards, - merkleMinter: IMinter1155(deployment.merkleMintSaleStrategy), - redeemMinterFactory: IMinter1155(deployment.redeemMinterFactory), - fixedPriceMinter: IMinter1155(deployment.fixedPriceSaleStrategy) + ensureCanOwn(chainConfig.factoryOwner); + + address preminterProxyAddress = deployDeterministicProxy({ + proxyName: "premintExecutorProxy", + implementation: deployment.preminterImpl, + owner: chainConfig.factoryOwner, + chain: chainId() }); - deployment.contract1155Impl = contract1155ImplAddress; - deployment.factoryImpl = factoryImplAddress; + require(preminterProxyAddress == determinsticPreminterProxyAddress(), "address not expected deterministic address"); + + deployment.preminterProxy = preminterProxyAddress; } - // function deployNewPreminterProxy(Deployment memory deployment) internal { - // address proxyOwner = getChainConfig().factoryOwner; + function deployUpgradeGateDeterminstic(Deployment memory deployment) internal { + ChainConfig memory chainConfig = getChainConfig(); - // deployment.preminter = ZoraDeployerUtils.deployNewPreminterProxy(deployment.factoryProxy, proxyOwner); - // } + ensureCanOwn(chainConfig.factoryOwner); + + address upgradeGateAddress = deployUpgradeGate({chain: chainId(), upgradeGateOwner: chainConfig.factoryOwner}); + + require(upgradeGateAddress == determinsticUpgradeGateAddress(), "address not expected deterministic address"); + + deployment.upgradeGate = upgradeGateAddress; + } + + function ensureCanOwn(address account) internal view { + // Sanity check to make sure that the factory owner is a smart contract. + // This may catch cross-chain data copy mistakes where there is no safe at the desired admin address. + if (account.code.length == 0) { + revert("FactoryOwner should be a contract. See DeployNewProxies:31."); + } + } + + function determinsticUpgradeGateAddress() internal view returns (address) { + return vm.parseJsonAddress(vm.readFile("./deterministicConfig/upgradeGate/params.json"), ".upgradeGateAddress"); + } } diff --git a/script/copy-deployed-contracts.mjs b/script/copy-deployed-contracts.mjs deleted file mode 100644 index 480a2bbe9..000000000 --- a/script/copy-deployed-contracts.mjs +++ /dev/null @@ -1,51 +0,0 @@ -import { writeFile, readFile } from "fs/promises"; -import esMain from "es-main"; -import { glob } from "glob"; - -async function copyEnvironmentRunFiles(scriptName) { - const latestFiles = await glob( - `broadcast/${scriptName}/*/run-latest.json` - ); - - for (const file of latestFiles) { - const latestDeploy = JSON.parse(await readFile(file)); - const { timestamp, commit, returns, chain } = latestDeploy; - console.log({ timestamp, commit, returns, chain }); - const filePath = `addresses/${chain}.json`; - const lastTimestamp = null; - - try { - JSON.parse(await readFile(filePath)).timestamp || null; - } catch {} - - if (!lastTimestamp || lastTimestamp < timestamp) { - await writeFile( - filePath, - JSON.stringify( - { - ...JSON.parse(returns["0"].value), - timestamp, - commit, - }, - null, - 2 - ) - ); - } else { - console.log("old run-latest file, skipping"); - } - } -} - -if (esMain(import.meta)) { - const command = process.argv[2]; - let scriptName = 'DeployAllToNewChain.s.sol'; - - if (command === "upgrade"){ - scriptName = 'Upgrade.s.sol'; - } else if (command === 'deploy-premint') { - scriptName = 'DeployNewPreminterAndFactoryProxy.s.sol' - } - - await copyEnvironmentRunFiles(scriptName); -} diff --git a/script/copy-deployed-contracts.ts b/script/copy-deployed-contracts.ts new file mode 100644 index 000000000..5b1b79e49 --- /dev/null +++ b/script/copy-deployed-contracts.ts @@ -0,0 +1,66 @@ +import { writeFile, readFile } from "fs/promises"; +import esMain from "es-main"; +import { glob } from "glob"; + +type Deploy = { + timestamp: number; + commit: string; + returns: { value: string }[]; + chain: number; +}; +async function copyEnvironmentRunFiles() { + const latestFiles = await glob(`broadcast/**/*run-latest.json`); + + const allFileContents = await Promise.all( + latestFiles.map(async (file) => { + const fileParts = file.split("/"); + const chainId = fileParts[fileParts.length - 2]; + return { + chainId, + contents: JSON.parse(await readFile(file, "utf-8")) as Deploy, + }; + }) + ); + + const groupedByChainId = allFileContents.reduce((acc, file) => { + const chainId = file.chainId!; + if (isNaN(Number(chainId))) return acc; + + if (!acc[chainId]) { + acc[chainId] = []; + } + acc[chainId]!.push(file.contents); + return acc; + }, {} as Record); + + const withLatest = Object.entries(groupedByChainId).map( + ([chainId, files]) => { + const latest = files.sort((a, b) => b.timestamp! - a.timestamp!)[0]; + return { + chainId, + latest, + }; + } + ); + + withLatest.forEach(async ({ chainId, latest }) => { + const filePath = `addresses/${chainId}.json`; + + await writeFile( + filePath, + JSON.stringify( + { + ...JSON.parse(latest!.returns["0"]!.value), + timestamp: latest!.timestamp, + commit: latest!.commit, + }, + null, + 2 + ) + ); + }); +} + +if (esMain(import.meta)) { + await copyEnvironmentRunFiles(); +} diff --git a/script/signDeploymentTransactions.ts b/script/signDeploymentTransactions.ts index 095076cc1..80f8ad626 100644 --- a/script/signDeploymentTransactions.ts +++ b/script/signDeploymentTransactions.ts @@ -241,7 +241,7 @@ async function main() { await signAndSaveGenericSignatures({ turnkeyAccount, - chainConfigs: await getPreminterImplConfigs(), + chainConfigs: await getFactoryImplConfigs(), proxyName: "upgradeGate", }); } diff --git a/script/verifyContracts.sh b/script/verifyContracts.sh deleted file mode 100755 index 2acdd0f1a..000000000 --- a/script/verifyContracts.sh +++ /dev/null @@ -1,12 +0,0 @@ -# forge script on 999 failed with error: -# We haven't found any matching bytecode for the following contracts: -# [0x49e85797dc499b9132433a62f63ef80e76c07865, 0x71524d1d958f9014848c69511c685008e0caef60, 0x561798076ab88b3c760614fdcb948fff4584a9ff] -# 0x49e is the -# - -# verify factory proxy Zora1155Factory -forge verify-contract 0x777777267FA8D1C26EF7A2dffb33A290464D1b4B --chain 777777 --verifier-url $VERIFIER_URL --verifier blockscout --etherscan-api-key asdfasdf Zora1155Factory -# forge verify-contract 0x49e85797dc499b9132433a62f63ef80e76c07865 --chain 777777 --verifier-url $VERIFIER_URL --verifier blockscout --etherscan-api-key asdfasdf ZoraCreator1155Impl -#forge verify-contract 0x6E2AbBcd82935bFC68A1d5d2c96372b13b65eD9C --chain 777777 --verifier-url $VERIFIER_URL --verifier blockscout --etherscan-api-key asdfasdf Zora1155PremintExecutorImpl -#forge verify-contract 0x6E2AbBcd82935bFC68A1d5d2c96372b13b65eD9C --chain 777777 --verifier-url $VERIFIER_URL --verifier blockscout --etherscan-api-key asdfasdf ZoraCreator1155PremintExecutorImpl -# forge verify-contract 0x8E024a6e8E9c1cbC5BfcC73e87409a6D98b3425d --chain 777777 --verifier-url $VERIFIER_URL --verifier blockscout --etherscan-api-key asdfasdf Zora1155 \ No newline at end of file diff --git a/src/deployment/DeterministicDeployerScript.sol b/src/deployment/DeterministicDeployerScript.sol index 1d470f0b6..e4a15d847 100644 --- a/src/deployment/DeterministicDeployerScript.sol +++ b/src/deployment/DeterministicDeployerScript.sol @@ -185,8 +185,16 @@ contract DeterministicDeployerScript is Script { error MismatchedAddress(address expected, address actual); + function readFactoryProxyDeterminsticParams() internal view returns (DeterministicParams memory) { + return readDeterministicParams("factoryProxy"); + } + + function readPreminterProxyDeterminsticParams() internal view returns (DeterministicParams memory) { + return readDeterministicParams("premintExecutorProxy"); + } + function getOrCreateProxyDeployer() internal returns (DeterministicProxyDeployer factoryDeployer) { - DeterministicParams memory params = readDeterministicParams("factoryProxy"); + DeterministicParams memory params = readFactoryProxyDeterminsticParams(); address proxyDeployerAddress = params.proxyDeployerAddress; bytes32 proxyDeployerSalt = params.proxyDeployerSalt; bytes memory proxyDeployerCreationCode = params.proxyDeployerCreationCode; diff --git a/src/deployment/ZoraDeployerUtils.sol b/src/deployment/ZoraDeployerUtils.sol index 5ec067c7c..6b923e007 100644 --- a/src/deployment/ZoraDeployerUtils.sol +++ b/src/deployment/ZoraDeployerUtils.sol @@ -16,44 +16,89 @@ import {ZoraCreatorMerkleMinterStrategy} from "../minters/merkle/ZoraCreatorMerk import {ZoraCreatorRedeemMinterFactory} from "../minters/redeem/ZoraCreatorRedeemMinterFactory.sol"; import {Create2} from "@openzeppelin/contracts/utils/Create2.sol"; import {ICreatorRoyaltiesControl} from "../interfaces/ICreatorRoyaltiesControl.sol"; +import {UpgradeGate} from "../upgrades/UpgradeGate.sol"; + +struct Create2Deployment { + address deployerAddress; + bytes32 salt; + bytes constructorArguments; + address deployedAddress; +} library ZoraDeployerUtils { IImmutableCreate2Factory constant IMMUTABLE_CREATE2_FACTORY = IImmutableCreate2Factory(0x0000000000FFe8B47B3e2130213B802212439497); + bytes32 constant IMMUTABLE_CREATE_2_FRIENDLY_SALT = bytes32(0x0000000000000000000000000000000000000000000000000000000000000001); + + function deployWithImmutableCreate2( + bytes32 salt, + bytes memory creationCode, + bytes memory constructorArguments + ) internal returns (Create2Deployment memory) { + address deployedAddress = IMMUTABLE_CREATE2_FACTORY.safeCreate2(salt, abi.encodePacked(creationCode, constructorArguments)); + + return + Create2Deployment({ + deployerAddress: address(IMMUTABLE_CREATE2_FACTORY), + salt: salt, + constructorArguments: constructorArguments, + deployedAddress: deployedAddress + }); + } + + function ensureValidUpgradeGate(address upgradeGateAddress) internal pure { + require( + keccak256(abi.encodePacked(UpgradeGate(upgradeGateAddress).contractName())) == keccak256(abi.encodePacked("ZORA 1155 Upgrade Gate")), + "INVALID_UPGRADE_GATE" + ); + } + function deployNew1155AndFactoryImpl( - address factoryProxyAddress, + address upgradeGateAddress, address mintFeeRecipient, address protocolRewards, IMinter1155 merkleMinter, IMinter1155 redeemMinterFactory, IMinter1155 fixedPriceMinter - ) internal returns (address factoryImplAddress, address contract1155ImplAddress) { - ZoraCreator1155Impl creatorImpl = new ZoraCreator1155Impl(mintFeeRecipient, factoryProxyAddress, protocolRewards); + ) internal returns (address factoryImplAddress, address contract1155ImplAddress, string memory contract1155ImplVersion) { + ensureValidUpgradeGate(upgradeGateAddress); - contract1155ImplAddress = address(creatorImpl); + ZoraCreator1155Impl zoraCreator1155Impl = new ZoraCreator1155Impl(mintFeeRecipient, upgradeGateAddress, protocolRewards); - ZoraCreator1155FactoryImpl factoryImpl = new ZoraCreator1155FactoryImpl({ - _zora1155Impl: creatorImpl, - _merkleMinter: merkleMinter, - _redeemMinterFactory: redeemMinterFactory, - _fixedPriceMinter: fixedPriceMinter - }); + contract1155ImplVersion = zoraCreator1155Impl.contractVersion(); - factoryImplAddress = address(factoryImpl); + contract1155ImplAddress = address(zoraCreator1155Impl); + factoryImplAddress = address( + new ZoraCreator1155FactoryImpl({ + _zora1155Impl: zoraCreator1155Impl, + _merkleMinter: merkleMinter, + _redeemMinterFactory: redeemMinterFactory, + _fixedPriceMinter: fixedPriceMinter + }) + ); + } + + function deployImmutableOrGetAddress(bytes32 salt, bytes memory creationCode) internal returns (address) { + address deployedAddress = Create2.computeAddress(salt, keccak256(creationCode), address(IMMUTABLE_CREATE2_FACTORY)); + if (IMMUTABLE_CREATE2_FACTORY.hasBeenDeployed(deployedAddress)) { + return deployedAddress; + } + + return IMMUTABLE_CREATE2_FACTORY.safeCreate2(salt, creationCode); } function deployMinters() internal returns (address fixedPriceMinter, address merkleMinter, address redeemMinterFactory) { - fixedPriceMinter = IMMUTABLE_CREATE2_FACTORY.safeCreate2( + fixedPriceMinter = deployImmutableOrGetAddress( bytes32(0x0000000000000000000000000000000000000000000000000000000000000001), type(ZoraCreatorFixedPriceSaleStrategy).creationCode ); - merkleMinter = IMMUTABLE_CREATE2_FACTORY.safeCreate2( + merkleMinter = deployImmutableOrGetAddress( bytes32(0x0000000000000000000000000000000000000000000000000000000000000001), type(ZoraCreatorMerkleMinterStrategy).creationCode ); - redeemMinterFactory = IMMUTABLE_CREATE2_FACTORY.safeCreate2( + redeemMinterFactory = deployImmutableOrGetAddress( bytes32(0x0000000000000000000000000000000000000000000000000000000000000001), type(ZoraCreatorRedeemMinterFactory).creationCode ); @@ -86,17 +131,23 @@ library ZoraDeployerUtils { return IMMUTABLE_CREATE2_FACTORY.findCreate2Address(FACTORY_DEPLOYER_DEPLOYMENT_SALT, type(DeterministicProxyDeployer).creationCode); } - function deterministicFactoryProxyAddress(bytes32 proxyShimSalt, bytes32 factoryProxySalt, address proxyDeployerAddress) internal pure returns (address) { + function factoryProxyConstructorArguments(bytes32 proxyShimSalt, address proxyDeployerAddress) internal pure returns (bytes memory) { address proxyShimAddress = Create2.computeAddress( proxyShimSalt, keccak256(abi.encodePacked(type(ProxyShim).creationCode, abi.encode(proxyDeployerAddress))), proxyDeployerAddress ); + return abi.encode(proxyShimAddress, ""); + } + + function deterministicFactoryProxyAddress(bytes32 proxyShimSalt, bytes32 factoryProxySalt, address proxyDeployerAddress) internal pure returns (address) { + bytes memory constructorArguments = factoryProxyConstructorArguments(proxyShimSalt, proxyDeployerAddress); + return Create2.computeAddress( factoryProxySalt, - keccak256(abi.encodePacked(type(Zora1155Factory).creationCode, abi.encode(proxyShimAddress, ""))), + keccak256(abi.encodePacked(type(Zora1155Factory).creationCode, constructorArguments)), proxyDeployerAddress ); } @@ -122,6 +173,4 @@ library ZoraDeployerUtils { ) ); } - - function testPremintSigningAndExecution(address preminterProxyAddress, address creatorAddress, uint256 creatorPrivateKey) internal {} } diff --git a/test/deployer/NewFactoryProxyDeployer.t.sol b/test/deployer/NewFactoryProxyDeployer.t.sol index 70fb4e18e..d48b03e96 100644 --- a/test/deployer/NewFactoryProxyDeployer.t.sol +++ b/test/deployer/NewFactoryProxyDeployer.t.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.17; import "forge-std/Test.sol"; import {Zora1155Factory} from "../../src/proxies/Zora1155Factory.sol"; -import {ZoraDeployerUtils} from "../../src/deployment/ZoraDeployerUtils.sol"; +import {ZoraDeployerUtils, Create2Deployment} from "../../src/deployment/ZoraDeployerUtils.sol"; import {DeterministicProxyDeployer} from "../../src/deployment/DeterministicProxyDeployer.sol"; import {ProxyShim} from "../../src/utils/ProxyShim.sol"; import {UpgradeGate} from "../../src/upgrades/UpgradeGate.sol"; @@ -26,8 +26,8 @@ contract DeterministicProxyDeployerTest is DeterministicDeployerScript, Test { address mintFeeRecipient = makeAddr("mintFeeRecipient"); address protocolRewards = makeAddr("protocolRewards"); - (address factoryImplAddress, ) = ZoraDeployerUtils.deployNew1155AndFactoryImpl({ - factoryProxyAddress: address(0), + (address factoryImplDeployment, , ) = ZoraDeployerUtils.deployNew1155AndFactoryImpl({ + upgradeGateAddress: address(new UpgradeGate()), mintFeeRecipient: mintFeeRecipient, protocolRewards: protocolRewards, merkleMinter: IMinter1155(address(0)), @@ -35,7 +35,7 @@ contract DeterministicProxyDeployerTest is DeterministicDeployerScript, Test { fixedPriceMinter: IMinter1155(address(0)) }); - return factoryImplAddress; + return factoryImplDeployment; } function test_proxyCanByDeployedAtDesiredAddress(bytes32 proxySalt) external {