diff --git a/.changeset/lazy-experts-battle.md b/.changeset/lazy-experts-battle.md new file mode 100644 index 000000000..757560dba --- /dev/null +++ b/.changeset/lazy-experts-battle.md @@ -0,0 +1,9 @@ +--- +"@zoralabs/protocol-deployments": patch +"@zoralabs/premint-sdk": patch +--- + +created new package `protocol-deployments` that includes the deployed contract addresses. + +* 1155-contracts js no longer exports deployed addresses, just the abis +* premint-sdk imports deployed addresses from `protocol-deployments \ No newline at end of file diff --git a/.gitignore b/.gitignore index ae6e5aa50..65692c2f5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ abis/ # /broadcast/**/dry-run/ # Remove broadcast logs -/broadcast/ +**/*/broadcast # Docs docs/ diff --git a/README.md b/README.md index e9899aa14..dfb5c6ab9 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ In it you will find: - [Zora 1155 Contracts](./packages/1155-contracts) - [Protocol Rewards](./packages/protocol-rewards) +- [Procotol Deployments](./packages/protocol-deployments) ## Official docs diff --git a/packages/1155-contracts/package.json b/packages/1155-contracts/package.json index 7119bdc09..3ec1b5e73 100644 --- a/packages/1155-contracts/package.json +++ b/packages/1155-contracts/package.json @@ -14,23 +14,17 @@ "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' 'script/**/*.ts' 'wagmi.config.ts'", + "copy-abis": "tsx script/bundle-abis.ts", "lint": "yarn run prettier:check", "coverage": "forge coverage --report lcov", "write-gas-report": "forge test --gas-report > gasreport.ansi", - "copy-abis": "tsx script/bundle-abis.ts", - "update-new-deployment-addresses": "node script/copy-deployed-contracts.mjs deploy", - "update-contract-version": "node script/update-contract-version.mjs", "build:contracts": "forge build", - "build": "yarn wagmi && yarn copy-abis && yarn bundle-configs && tsup", - "build:sizes": "forge build --sizes", - "bundle-configs": "node script/bundle-chainConfigs.mjs && yarn prettier", + "build": "yarn wagmi && yarn copy-abis && tsup", "wagmi": "FOUNDRY_PROFILE=dev forge build && wagmi generate", + "build:sizes": "forge build --sizes", "storage-inspect:check": "./script/storage-check.sh check ZoraCreator1155Impl ZoraCreator1155FactoryImpl", "storage-inspect:generate": "./script/storage-check.sh generate ZoraCreator1155Impl ZoraCreator1155FactoryImpl", - "js-test:watch": "vitest dev", - "anvil": "source .env.anvil && anvil --fork-url $FORK_RPC_URL --fork-block-number $FORK_BLOCK_NUMBER --chain-id 31337", - "unlink-contracts": "rm -rf ./node_modules/@zoralabs/protocol-rewards && cp -r ../protocol-rewards ./node_modules/@zoralabs/protocol-rewards", - "link-contracts": "rm -rf ./node_modules && cd .. && yarn" + "update-contract-version": "node script/update-contract-version.mjs" }, "files": [ "dist/", @@ -57,10 +51,7 @@ "glob": "^10.2.2", "prettier": "^2.8.8", "es-main": "^1.2.0", - "@turnkey/api-key-stamper": "^0.1.1", "prettier-plugin-solidity": "^1.1.3", - "@turnkey/http": "^1.2.0", - "@turnkey/viem": "^0.2.4", "@types/node": "^20.1.2", "tsup": "^7.2.0", "typescript": "^5.0.4" diff --git a/packages/1155-contracts/package/index.ts b/packages/1155-contracts/package/index.ts index 061b80576..06da3c8bd 100644 --- a/packages/1155-contracts/package/index.ts +++ b/packages/1155-contracts/package/index.ts @@ -2,4 +2,3 @@ // built at build time. They are not checked in to git. // The can be generated by running `yarn prepack` in the root export * from "./wagmiGenerated"; -export { chainConfigs } from "./chainConfigs"; diff --git a/packages/1155-contracts/script/DeployUpgradeGate.s.sol b/packages/1155-contracts/script/DeployUpgradeGate.s.sol deleted file mode 100644 index b10d429d0..000000000 --- a/packages/1155-contracts/script/DeployUpgradeGate.s.sol +++ /dev/null @@ -1,27 +0,0 @@ -// 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/packages/1155-contracts/script/TestCreateDeterministic.sol b/packages/1155-contracts/script/TestCreateDeterministic.sol deleted file mode 100644 index 7ce5349e3..000000000 --- a/packages/1155-contracts/script/TestCreateDeterministic.sol +++ /dev/null @@ -1,67 +0,0 @@ -// 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 {ProtocolRewards} from "@zoralabs/protocol-rewards/src/ProtocolRewards.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 {IMinter1155} from "../src/interfaces/IMinter1155.sol"; -import {IZoraCreator1155} from "../src/interfaces/IZoraCreator1155.sol"; -import {ProxyShim} from "../src/utils/ProxyShim.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"; - -contract DeployScript is ZoraDeployerBase { - function run() public { - // ChainConfig memory chainConfig = getChainConfig(); - - // console2.log("zoraFeeRecipient", chainConfig.mintFeeRecipient); - // console2.log("factoryOwner", chainConfig.factoryOwner); - - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - address deployer = vm.addr(deployerPrivateKey); - - ICreatorRoyaltiesControl.RoyaltyConfiguration memory royaltyConfig = ICreatorRoyaltiesControl.RoyaltyConfiguration({ - royaltyBPS: 10, - royaltyRecipient: vm.addr(5), - royaltyMintSchedule: 100 - }); - bytes[] memory initSetup = new bytes[](1); - initSetup[0] = abi.encodeWithSelector(IZoraCreator1155.setupNewToken.selector, "ipfs://asdfadsf", 100); - string memory uri = "ipfs://asdfadsf"; - string memory nameA = "nameA"; - - vm.startBroadcast(deployerPrivateKey); - - ZoraCreator1155Impl zoraCreator1155Impl = new ZoraCreator1155Impl(address(0), address(0), address(new ProtocolRewards())); - // get above constructor args encoded for verification later: - ZoraCreator1155FactoryImpl factory = new ZoraCreator1155FactoryImpl( - zoraCreator1155Impl, - IMinter1155(address(1)), - IMinter1155(address(2)), - IMinter1155(address(3)) - ); - - address factoryOwner = deployer; - - // 1. create the proxy, pointing it to the factory implementation and setting the owner - ZoraCreator1155FactoryImpl proxy = ZoraCreator1155FactoryImpl( - payable(new Zora1155Factory(address(factory), abi.encodeWithSelector(ZoraCreator1155FactoryImpl.initialize.selector, factoryOwner))) - ); - - address createdErc1155 = proxy.createContractDeterministic(uri, nameA, royaltyConfig, payable(deployer), initSetup); - - console.log("deployed erc1155 at", createdErc1155); - console.log("constructor args", string(abi.encode(0, address(0), address(0)))); - vm.stopBroadcast(); - } -} diff --git a/packages/1155-contracts/script/TestUpgrade.s.sol b/packages/1155-contracts/script/TestUpgrade.s.sol deleted file mode 100644 index 7c732b9c5..000000000 --- a/packages/1155-contracts/script/TestUpgrade.s.sol +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.17; - -import "forge-std/Script.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 {IMinter1155} from "../src/interfaces/IMinter1155.sol"; -import {IZoraCreator1155} from "../src/interfaces/IZoraCreator1155.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 {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; - -contract UpgradeScript is Script { - using Strings for uint256; - using stdJson for string; - - string configFile; - - function setUp() public { - uint256 chainID = vm.envUint("CHAIN_ID"); - console.log("CHAIN_ID", chainID); - - console2.log("Starting ---"); - - configFile = vm.readFile(string.concat("./addresses/", Strings.toString(chainID), ".json")); - } - - function run() public { - ZoraCreator1155FactoryImpl factory = ZoraCreator1155FactoryImpl(payable(configFile.readAddress(".FACTORY_PROXY"))); - vm.prank(factory.owner()); - factory.upgradeTo(address(0xfca4587FAf3a32eBE2F05c9D044aEF072031A796)); - vm.expectRevert(); - factory.upgradeTo(address(0xfca4587FAf3a32eBE2F05c9D044aEF072031A796)); - vm.prank(factory.owner()); - factory.upgradeTo(address(0xfca4587FAf3a32eBE2F05c9D044aEF072031A796)); - console2.log(factory.owner()); - } -} diff --git a/packages/1155-contracts/script/storage-check.sh b/packages/1155-contracts/script/storage-check.sh index ca57b0c33..a38fb5e81 100755 --- a/packages/1155-contracts/script/storage-check.sh +++ b/packages/1155-contracts/script/storage-check.sh @@ -16,7 +16,7 @@ generate() { for contract in ${contracts[@]} do { echo -e "\n======================="; echo "➡ $contract" ; echo -e "=======================\n"; } >> "$file" - forge inspect --pretty "$contract" storage-layout >> "$file" + FOUNDRY_PROFILE=dev forge inspect --pretty "$contract" storage-layout >> "$file" done if [[ $func == "generate" ]]; then echo "Storage layout snapshot stored at $file" diff --git a/packages/1155-contracts/script/ZoraDeployerBase.sol b/packages/1155-contracts/src/deployment/ZoraDeployerBase.sol similarity index 90% rename from packages/1155-contracts/script/ZoraDeployerBase.sol rename to packages/1155-contracts/src/deployment/ZoraDeployerBase.sol index f50b59852..57ec401c3 100644 --- a/packages/1155-contracts/script/ZoraDeployerBase.sol +++ b/packages/1155-contracts/src/deployment/ZoraDeployerBase.sol @@ -4,15 +4,15 @@ pragma solidity ^0.8.13; import "forge-std/Script.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; -import {IZoraCreator1155Factory} from "../src/interfaces/IZoraCreator1155Factory.sol"; -import {ZoraCreator1155Impl} from "../src/nft/ZoraCreator1155Impl.sol"; -import {Zora1155Factory} from "../src/proxies/Zora1155Factory.sol"; -import {ICreatorRoyaltiesControl} from "../src/interfaces/ICreatorRoyaltiesControl.sol"; -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"; +import {IZoraCreator1155Factory} from "../interfaces/IZoraCreator1155Factory.sol"; +import {ZoraCreator1155Impl} from "../nft/ZoraCreator1155Impl.sol"; +import {Zora1155Factory} from "../proxies/Zora1155Factory.sol"; +import {ICreatorRoyaltiesControl} from "../interfaces/ICreatorRoyaltiesControl.sol"; +import {ScriptDeploymentConfig, Deployment, ChainConfig} from "../deployment/DeploymentConfig.sol"; +import {ZoraDeployerUtils} from "../deployment/ZoraDeployerUtils.sol"; +import {IMinter1155} from "../interfaces/IMinter1155.sol"; +import {DeterministicDeployerScript} from "../deployment/DeterministicDeployerScript.sol"; +import {ZoraCreator1155FactoryImpl} from "../factory/ZoraCreator1155FactoryImpl.sol"; /// @notice Deployment drops for base where abstract contract ZoraDeployerBase is ScriptDeploymentConfig, DeterministicDeployerScript { diff --git a/packages/1155-contracts/wagmi.config.ts b/packages/1155-contracts/wagmi.config.ts index 321a69a31..41fca6c4f 100644 --- a/packages/1155-contracts/wagmi.config.ts +++ b/packages/1155-contracts/wagmi.config.ts @@ -1,118 +1,24 @@ import { defineConfig } from "@wagmi/cli"; import { foundry } from "@wagmi/cli/plugins"; -import { readdirSync, readFileSync } from "fs"; -import { publishAbisJson } from "./publishAbisPlugin"; - -type ContractNames = - | "ZoraCreator1155FactoryImpl" - | "ZoraCreator1155Impl" - | "ZoraCreatorFixedPriceSaleStrategy" - | "ZoraCreatorMerkleMinterStrategy" - | "ZoraCreatorRedeemMinterFactory" - | "ZoraCreatorRedeemMinterStrategy" - | "ZoraCreator1155PremintExecutorImpl" - | "DeterministicProxyDeployer" - | "IImmutableCreate2Factory"; - -type Address = `0x${string}`; - -const contractFilesToInclude: ContractNames[] = [ - "ZoraCreator1155FactoryImpl", - "ZoraCreator1155Impl", - "ZoraCreatorFixedPriceSaleStrategy", - "ZoraCreatorMerkleMinterStrategy", - "ZoraCreatorRedeemMinterFactory", - "ZoraCreatorRedeemMinterStrategy", - "ZoraCreator1155PremintExecutorImpl", - "DeterministicProxyDeployer", - "IImmutableCreate2Factory", -]; - -type Addresses = { - [key in ContractNames]?: { - [chainId: number]: Address; - }; -}; - -const getAddresses = () => { - const addresses: Addresses = {}; - - const addressesFiles = readdirSync("./addresses"); - - const addAddress = ( - contractName: ContractNames, - chainId: number, - address?: Address - ) => { - if (!address) return; - if (!addresses[contractName]) { - addresses[contractName] = {}; - } - - addresses[contractName]![chainId] = address; - }; - - for (const addressesFile of addressesFiles) { - const jsonAddress = JSON.parse( - readFileSync(`./addresses/${addressesFile}`, "utf-8") - ) as { - FIXED_PRICE_SALE_STRATEGY: Address; - MERKLE_MINT_SALE_STRATEGY: Address; - REDEEM_MINTER_FACTORY: Address; - "1155_IMPL": Address; - FACTORY_IMPL: Address; - FACTORY_PROXY: Address; - PREMINTER_PROXY?: Address; - }; - - const chainId = parseInt(addressesFile.split(".")[0]); - - addAddress( - "ZoraCreatorFixedPriceSaleStrategy", - chainId, - jsonAddress.FIXED_PRICE_SALE_STRATEGY - ); - addAddress( - "ZoraCreatorMerkleMinterStrategy", - chainId, - jsonAddress.MERKLE_MINT_SALE_STRATEGY - ); - addAddress( - "ZoraCreator1155FactoryImpl", - chainId, - jsonAddress.FACTORY_PROXY - ); - addAddress( - "ZoraCreatorRedeemMinterFactory", - chainId, - jsonAddress.REDEEM_MINTER_FACTORY - ); - addAddress( - "ZoraCreator1155PremintExecutorImpl", - chainId, - jsonAddress.PREMINTER_PROXY - ), - addAddress( - "IImmutableCreate2Factory", - chainId, - "0x0000000000FFe8B47B3e2130213B802212439497" - ); - } - - return addresses; -}; export default defineConfig({ out: "package/wagmiGenerated.ts", plugins: [ foundry({ - deployments: getAddresses(), forge: { build: false, }, - include: contractFilesToInclude.map( - (contractName) => `${contractName}.json` - ), + include: [ + "ZoraCreator1155FactoryImpl", + "ZoraCreator1155Impl", + "ZoraCreatorFixedPriceSaleStrategy", + "ZoraCreatorMerkleMinterStrategy", + "ZoraCreatorRedeemMinterFactory", + "ZoraCreatorRedeemMinterStrategy", + "ZoraCreator1155PremintExecutorImpl", + "DeterministicProxyDeployer", + "IImmutableCreate2Factory", + ].map((contractName) => `${contractName}.json`), }), ], }); diff --git a/packages/premint-sdk/package.json b/packages/premint-sdk/package.json index 8ffc6e6a9..eb8e2e3eb 100644 --- a/packages/premint-sdk/package.json +++ b/packages/premint-sdk/package.json @@ -14,10 +14,9 @@ "anvil": "source .env.anvil && anvil --fork-url $FORK_RPC_URL --fork-block-number $FORK_BLOCK_NUMBER --chain-id 31337" }, "dependencies": { - "@zoralabs/zora-1155-contracts": "*", + "@zoralabs/protocol-deployments": "*", "abitype": "^0.8.7", - "vite": "4.5.0", - "vitest": "0.34.6" + "vite": "4.5.0" }, "peerDependencies": { "viem": "^1.16.6" diff --git a/packages/premint-sdk/src/premint-client.ts b/packages/premint-sdk/src/premint-client.ts index f9798df35..ca97746ec 100644 --- a/packages/premint-sdk/src/premint-client.ts +++ b/packages/premint-sdk/src/premint-client.ts @@ -12,7 +12,7 @@ import { zoraCreator1155PremintExecutorImplABI, zoraCreator1155PremintExecutorImplAddress, zoraCreatorFixedPriceSaleStrategyAddress, -} from "@zoralabs/zora-1155-contracts"; +} from "@zoralabs/protocol-deployments"; import { foundry, zora, zoraTestnet } from "viem/chains"; import { PremintConfig, preminterTypedDataDefinition } from "./preminter"; import type { diff --git a/packages/premint-sdk/src/preminter.test.ts b/packages/premint-sdk/src/preminter.test.ts index bb2c1dd2f..5065842af 100644 --- a/packages/premint-sdk/src/preminter.test.ts +++ b/packages/premint-sdk/src/preminter.test.ts @@ -18,7 +18,7 @@ import { zoraCreator1155ImplABI, zoraCreator1155FactoryImplAddress, zoraCreator1155FactoryImplConfig, -} from "@zoralabs/zora-1155-contracts"; +} from "@zoralabs/protocol-deployments"; import { ContractCreationConfig, diff --git a/packages/premint-sdk/src/preminter.ts b/packages/premint-sdk/src/preminter.ts index beeea8ebb..dd9a93b0a 100644 --- a/packages/premint-sdk/src/preminter.ts +++ b/packages/premint-sdk/src/preminter.ts @@ -1,6 +1,6 @@ import { Address } from "abitype"; import { ExtractAbiFunction, AbiParametersToPrimitiveTypes } from "abitype"; -import { zoraCreator1155PremintExecutorImplABI as preminterAbi } from "@zoralabs/zora-1155-contracts/package/wagmiGenerated"; +import { zoraCreator1155PremintExecutorImplABI as preminterAbi } from "@zoralabs/protocol-deployments"; import { TypedDataDefinition } from "viem"; type PremintInputs = ExtractAbiFunction< diff --git a/packages/protocol-deployments/.env.anvil b/packages/protocol-deployments/.env.anvil new file mode 100644 index 000000000..ce8d9a6d7 --- /dev/null +++ b/packages/protocol-deployments/.env.anvil @@ -0,0 +1,2 @@ +FORK_RPC_URL="https://rpc.zora.co/" +FORK_BLOCK_NUMBER=5141442 \ No newline at end of file diff --git a/packages/protocol-deployments/.gitignore b/packages/protocol-deployments/.gitignore new file mode 100644 index 000000000..8491ab9e8 --- /dev/null +++ b/packages/protocol-deployments/.gitignore @@ -0,0 +1 @@ +broadcast diff --git a/packages/protocol-deployments/CHANGELOG.md b/packages/protocol-deployments/CHANGELOG.md new file mode 100644 index 000000000..fc9d782fa --- /dev/null +++ b/packages/protocol-deployments/CHANGELOG.md @@ -0,0 +1,22 @@ +# @zoralabs/premint-sdk + +## 0.0.2-premint-api.2 + +### Patch Changes + +- c29e080: Update retry and error reporting + +## 0.0.2-premint-api.1 + +### Patch Changes + +- 6eaf7bb: add retries + +## 0.0.2-premint-api.0 + +### Patch Changes + +- Updated dependencies [8395b8e] +- Updated dependencies [aae756b] +- Updated dependencies [cf184b3] + - @zoralabs/zora-1155-contracts@2.1.1-premint-api.0 diff --git a/packages/protocol-deployments/README.md b/packages/protocol-deployments/README.md new file mode 100644 index 000000000..db418d2c8 --- /dev/null +++ b/packages/protocol-deployments/README.md @@ -0,0 +1,20 @@ +# Zora Protocol Deployments + +Contains deployment scripts, deployed addresses and versions for the Zora Protocol. + +## Package contents + +* [Deployment scripts](./scripts/) for deployment Zora Protocol Contracts +* [Deployed addresses](./addresses/) containing deployed addresses and contract versions by chain. +* [Published npm package](https://www.npmjs.com/package/@zoralabs/protocol-deployments) containing [wagmi cli](https://wagmi.sh/cli/getting-started) generated typescript bundle of deployed contract abis and addresses. + +## Npm package usage + +Import abis and addresses for a contract from the package: + +```typescript +import { zoraCreator1155FactoryImplConfig } from "@zoralabs/protocol-deployments"; + +// get addresses and abi for zora creator 1155 factory: +const { addresses, abi } = zoraCreator1155FactoryImplConfig; +``` diff --git a/packages/1155-contracts/addresses/1.json b/packages/protocol-deployments/addresses/1.json similarity index 100% rename from packages/1155-contracts/addresses/1.json rename to packages/protocol-deployments/addresses/1.json diff --git a/packages/1155-contracts/addresses/10.json b/packages/protocol-deployments/addresses/10.json similarity index 100% rename from packages/1155-contracts/addresses/10.json rename to packages/protocol-deployments/addresses/10.json diff --git a/packages/1155-contracts/addresses/11155111.json b/packages/protocol-deployments/addresses/11155111.json similarity index 100% rename from packages/1155-contracts/addresses/11155111.json rename to packages/protocol-deployments/addresses/11155111.json diff --git a/packages/1155-contracts/addresses/420.json b/packages/protocol-deployments/addresses/420.json similarity index 100% rename from packages/1155-contracts/addresses/420.json rename to packages/protocol-deployments/addresses/420.json diff --git a/packages/1155-contracts/addresses/424.json b/packages/protocol-deployments/addresses/424.json similarity index 100% rename from packages/1155-contracts/addresses/424.json rename to packages/protocol-deployments/addresses/424.json diff --git a/packages/1155-contracts/addresses/5.json b/packages/protocol-deployments/addresses/5.json similarity index 100% rename from packages/1155-contracts/addresses/5.json rename to packages/protocol-deployments/addresses/5.json diff --git a/packages/1155-contracts/addresses/58008.json b/packages/protocol-deployments/addresses/58008.json similarity index 100% rename from packages/1155-contracts/addresses/58008.json rename to packages/protocol-deployments/addresses/58008.json diff --git a/packages/1155-contracts/addresses/7777777.json b/packages/protocol-deployments/addresses/7777777.json similarity index 100% rename from packages/1155-contracts/addresses/7777777.json rename to packages/protocol-deployments/addresses/7777777.json diff --git a/packages/1155-contracts/addresses/8453.json b/packages/protocol-deployments/addresses/8453.json similarity index 100% rename from packages/1155-contracts/addresses/8453.json rename to packages/protocol-deployments/addresses/8453.json diff --git a/packages/1155-contracts/addresses/84531.json b/packages/protocol-deployments/addresses/84531.json similarity index 100% rename from packages/1155-contracts/addresses/84531.json rename to packages/protocol-deployments/addresses/84531.json diff --git a/packages/1155-contracts/addresses/999.json b/packages/protocol-deployments/addresses/999.json similarity index 100% rename from packages/1155-contracts/addresses/999.json rename to packages/protocol-deployments/addresses/999.json diff --git a/packages/1155-contracts/chainConfigs/1.json b/packages/protocol-deployments/chainConfigs/1.json similarity index 100% rename from packages/1155-contracts/chainConfigs/1.json rename to packages/protocol-deployments/chainConfigs/1.json diff --git a/packages/1155-contracts/chainConfigs/10.json b/packages/protocol-deployments/chainConfigs/10.json similarity index 100% rename from packages/1155-contracts/chainConfigs/10.json rename to packages/protocol-deployments/chainConfigs/10.json diff --git a/packages/1155-contracts/chainConfigs/11155111.json b/packages/protocol-deployments/chainConfigs/11155111.json similarity index 100% rename from packages/1155-contracts/chainConfigs/11155111.json rename to packages/protocol-deployments/chainConfigs/11155111.json diff --git a/packages/1155-contracts/chainConfigs/420.json b/packages/protocol-deployments/chainConfigs/420.json similarity index 100% rename from packages/1155-contracts/chainConfigs/420.json rename to packages/protocol-deployments/chainConfigs/420.json diff --git a/packages/1155-contracts/chainConfigs/424.json b/packages/protocol-deployments/chainConfigs/424.json similarity index 100% rename from packages/1155-contracts/chainConfigs/424.json rename to packages/protocol-deployments/chainConfigs/424.json diff --git a/packages/1155-contracts/chainConfigs/5.json b/packages/protocol-deployments/chainConfigs/5.json similarity index 100% rename from packages/1155-contracts/chainConfigs/5.json rename to packages/protocol-deployments/chainConfigs/5.json diff --git a/packages/1155-contracts/chainConfigs/58008.json b/packages/protocol-deployments/chainConfigs/58008.json similarity index 100% rename from packages/1155-contracts/chainConfigs/58008.json rename to packages/protocol-deployments/chainConfigs/58008.json diff --git a/packages/1155-contracts/chainConfigs/7777777.json b/packages/protocol-deployments/chainConfigs/7777777.json similarity index 100% rename from packages/1155-contracts/chainConfigs/7777777.json rename to packages/protocol-deployments/chainConfigs/7777777.json diff --git a/packages/1155-contracts/chainConfigs/8453.json b/packages/protocol-deployments/chainConfigs/8453.json similarity index 100% rename from packages/1155-contracts/chainConfigs/8453.json rename to packages/protocol-deployments/chainConfigs/8453.json diff --git a/packages/1155-contracts/chainConfigs/84531.json b/packages/protocol-deployments/chainConfigs/84531.json similarity index 100% rename from packages/1155-contracts/chainConfigs/84531.json rename to packages/protocol-deployments/chainConfigs/84531.json diff --git a/packages/1155-contracts/chainConfigs/999.json b/packages/protocol-deployments/chainConfigs/999.json similarity index 100% rename from packages/1155-contracts/chainConfigs/999.json rename to packages/protocol-deployments/chainConfigs/999.json diff --git a/packages/1155-contracts/deterministicConfig/factoryProxy/params.json b/packages/protocol-deployments/deterministicConfig/factoryProxy/params.json similarity index 100% rename from packages/1155-contracts/deterministicConfig/factoryProxy/params.json rename to packages/protocol-deployments/deterministicConfig/factoryProxy/params.json diff --git a/packages/1155-contracts/deterministicConfig/factoryProxy/signatures.json b/packages/protocol-deployments/deterministicConfig/factoryProxy/signatures.json similarity index 100% rename from packages/1155-contracts/deterministicConfig/factoryProxy/signatures.json rename to packages/protocol-deployments/deterministicConfig/factoryProxy/signatures.json diff --git a/packages/1155-contracts/deterministicConfig/premintExecutorProxy/params.json b/packages/protocol-deployments/deterministicConfig/premintExecutorProxy/params.json similarity index 100% rename from packages/1155-contracts/deterministicConfig/premintExecutorProxy/params.json rename to packages/protocol-deployments/deterministicConfig/premintExecutorProxy/params.json diff --git a/packages/1155-contracts/deterministicConfig/premintExecutorProxy/signatures.json b/packages/protocol-deployments/deterministicConfig/premintExecutorProxy/signatures.json similarity index 100% rename from packages/1155-contracts/deterministicConfig/premintExecutorProxy/signatures.json rename to packages/protocol-deployments/deterministicConfig/premintExecutorProxy/signatures.json diff --git a/packages/1155-contracts/deterministicConfig/upgradeGate/params.json b/packages/protocol-deployments/deterministicConfig/upgradeGate/params.json similarity index 100% rename from packages/1155-contracts/deterministicConfig/upgradeGate/params.json rename to packages/protocol-deployments/deterministicConfig/upgradeGate/params.json diff --git a/packages/1155-contracts/deterministicConfig/upgradeGate/signatures.json b/packages/protocol-deployments/deterministicConfig/upgradeGate/signatures.json similarity index 100% rename from packages/1155-contracts/deterministicConfig/upgradeGate/signatures.json rename to packages/protocol-deployments/deterministicConfig/upgradeGate/signatures.json diff --git a/packages/protocol-deployments/foundry.toml b/packages/protocol-deployments/foundry.toml new file mode 100644 index 000000000..744269902 --- /dev/null +++ b/packages/protocol-deployments/foundry.toml @@ -0,0 +1,39 @@ +[profile.default] +fs_permissions = [ + { access = "read", path = "./addresses" }, + { access = "read", path = "./chainConfigs" }, + { access = "read", path = "./package.json" }, + { access = "readwrite", path = "./deterministicConfig" }, +] +libs = ['_imagine', 'node_modules', 'script'] +allow_paths = [ + "node_modules/@zoralabs/protocol-rewards", + "node_modules/@zoralabs/zora-1155-contracts", +] +optimizer = true +optimizer_runs = 50 +via_ir = true +solc_version = '0.8.17' +out = 'out' +src = 'src' + +[profile.dev] +optimizer = false +optimizer_runs = 0 +via_ir = false + +[rpc_endpoints] +goerli = "https://eth-goerli.g.alchemy.com/v2/${ALCHEMY_KEY}" +mainnet = "https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}" +# for optimism, since we are just using this for deployment/fork testing, +# we can use these since they're lower volume. +base = "https://base-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}" +base_goerli = "https://base-goerli.g.alchemy.com/v2/${ALCHEMY_KEY}" +optimism = "https://opt-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}" +optimism_goerli = "https://opt-goerli.g.alchemy.com/v2/${ALCHEMY_KEY}" +pgn = "https://rpc.publicgoods.network" +pgn_sepolia = "https://sepolia.publicgoods.network" +zora = "https://rpc.zora.energy" +zora_goerli = "https://testnet.rpc.zora.energy" + +# See more config options https://github.com/foundry-rs/foundry/tree/master/config diff --git a/packages/protocol-deployments/package.json b/packages/protocol-deployments/package.json new file mode 100644 index 000000000..608b610ac --- /dev/null +++ b/packages/protocol-deployments/package.json @@ -0,0 +1,42 @@ +{ + "name": "@zoralabs/protocol-deployments", + "version": "0.0.1", + "repository": "https://github.com/ourzora/zora-protocol", + "license": "MIT", + "main": "./dist/index.js", + "types": "./dist/package/index.d.ts", + "type": "module", + "scripts": { + "build": "yarn wagmi && yarn bundle-configs && tsup", + "bundle-configs": "node script/bundle-chainConfigs.mjs && yarn prettier", + "prettier": "prettier --write 'package/**/*.ts' 'script/**/*.ts' 'wagmi.config.ts'", + "update-new-deployment-addresses": "node script/copy-deployed-contracts.mjs deploy", + "update-contract-version": "node script/update-contract-version.mjs", + "wagmi": "wagmi generate", + "unlink-protocol-rewards": "rm -rf ./node_modules/@zoralabs/protocol-rewards && cp -r ../protocol-rewards ./node_modules/@zoralabs/protocol-rewards", + "unlink-1155": "rm -rf ./node_modules/@zoralabs/zora-1155-contracts && cp -r ../1155-contracts ./node_modules/@zoralabs/zora-1155-contracts", + "unlink-contracts": "yarn unlink-protocol-rewards && yarn unlink-1155", + "link-contracts": "rm -rf ./node_modules && cd .. && yarn" + }, + "dependencies": { + "@zoralabs/zora-1155-contracts": "*", + "ds-test": "https://github.com/dapphub/ds-test#cd98eff28324bfac652e63a239a60632a761790b", + "forge-std": "https://github.com/foundry-rs/forge-std#705263c95892a906d7af65f0f73ce8a4a0c80b80", + "solmate": "^6.1.0" + }, + "devDependencies": { + "@turnkey/api-key-stamper": "^0.1.1", + "@turnkey/http": "^1.2.0", + "@turnkey/viem": "^0.2.4", + "@types/node": "^20.1.2", + "@wagmi/cli": "^1.0.1", + "es-main": "^1.2.0", + "glob": "^10.2.2", + "prettier": "^2.8.8", + "prettier-plugin-solidity": "^1.1.3", + "solady": "^0.0.132", + "tsup": "^7.2.0", + "tsx": "^3.13.0", + "typescript": "^5.2.2" + } +} diff --git a/packages/1155-contracts/package/batchPublish.test.ts b/packages/protocol-deployments/package/batchPublish.test.ts similarity index 99% rename from packages/1155-contracts/package/batchPublish.test.ts rename to packages/protocol-deployments/package/batchPublish.test.ts index c9131e96b..fc3325a64 100644 --- a/packages/1155-contracts/package/batchPublish.test.ts +++ b/packages/protocol-deployments/package/batchPublish.test.ts @@ -13,9 +13,9 @@ import { foundry, zora } from "viem/chains"; import { describe, it, expect } from "vitest"; import { zoraCreator1155FactoryImplConfig, - zoraCreator1155ImplABI, zoraCreatorFixedPriceSaleStrategyABI, } from "./wagmiGenerated"; +import { zoraCreator1155ImplABI } from "@zoralabs/zora-1155-contracts"; const walletClient = createWalletClient({ chain: foundry, diff --git a/packages/1155-contracts/package/chainConfigs.ts b/packages/protocol-deployments/package/chainConfigs.ts similarity index 100% rename from packages/1155-contracts/package/chainConfigs.ts rename to packages/protocol-deployments/package/chainConfigs.ts diff --git a/packages/1155-contracts/package/deployment.ts b/packages/protocol-deployments/package/deployment.ts similarity index 100% rename from packages/1155-contracts/package/deployment.ts rename to packages/protocol-deployments/package/deployment.ts diff --git a/packages/protocol-deployments/package/index.ts b/packages/protocol-deployments/package/index.ts new file mode 100644 index 000000000..061b80576 --- /dev/null +++ b/packages/protocol-deployments/package/index.ts @@ -0,0 +1,5 @@ +// the below files are auto-generated and will be +// built at build time. They are not checked in to git. +// The can be generated by running `yarn prepack` in the root +export * from "./wagmiGenerated"; +export { chainConfigs } from "./chainConfigs"; diff --git a/packages/protocol-deployments/remappings.txt b/packages/protocol-deployments/remappings.txt new file mode 100644 index 000000000..9e89d8c48 --- /dev/null +++ b/packages/protocol-deployments/remappings.txt @@ -0,0 +1,9 @@ +ds-test/=node_modules/ds-test/src/ +forge-std/=node_modules/forge-std/src/ +@zoralabs/openzeppelin-contracts-upgradeable/=node_modules/@zoralabs/openzeppelin-contracts-upgradeable/ +@zoralabs/protocol-rewards/src/=node_modules/@zoralabs/protocol-rewards/src/ +@zoralabs/zora-1155-contracts/src/=node_modules/@zoralabs/zora-1155-contracts/src/ +@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/ +_imagine=node_modules/@zoralabs/zora-1155-contracts/_imagine +solemate/=/node_modules/solemate/src/ +solady/=node_modules/solady/src/ \ No newline at end of file diff --git a/packages/1155-contracts/script/CalculateDeterministicParams.s.sol b/packages/protocol-deployments/script/CalculateDeterministicParams.s.sol similarity index 80% rename from packages/1155-contracts/script/CalculateDeterministicParams.s.sol rename to packages/protocol-deployments/script/CalculateDeterministicParams.s.sol index cecbe8b3f..504616233 100644 --- a/packages/1155-contracts/script/CalculateDeterministicParams.s.sol +++ b/packages/protocol-deployments/script/CalculateDeterministicParams.s.sol @@ -4,16 +4,16 @@ pragma solidity ^0.8.17; import "forge-std/Script.sol"; import "forge-std/console2.sol"; -import {ZoraDeployerBase} from "./ZoraDeployerBase.sol"; -import {Zora1155Factory} from "../src/proxies/Zora1155Factory.sol"; -import {ProxyShim} from "../src/utils/ProxyShim.sol"; -import {UpgradeGate} from "../src/upgrades/UpgradeGate.sol"; +import {ZoraDeployerBase} from "@zoralabs/zora-1155-contracts/src/deployment/ZoraDeployerBase.sol"; +import {Zora1155Factory} from "@zoralabs/zora-1155-contracts/src/proxies/Zora1155Factory.sol"; +import {ProxyShim} from "@zoralabs/zora-1155-contracts/src/utils/ProxyShim.sol"; +import {UpgradeGate} from "@zoralabs/zora-1155-contracts/src/upgrades/UpgradeGate.sol"; import {LibString} from "solady/utils/LibString.sol"; import {Create2} from "@openzeppelin/contracts/utils/Create2.sol"; -import {ZoraDeployerUtils} from "../src/deployment/ZoraDeployerUtils.sol"; -import {Zora1155PremintExecutor} from "../src/proxies/Zora1155PremintExecutor.sol"; -import {DeterministicDeployerScript, DeterministicParams} from "../src/deployment/DeterministicDeployerScript.sol"; -import {DeterministicProxyDeployer} from "../src/deployment/DeterministicProxyDeployer.sol"; +import {ZoraDeployerUtils} from "@zoralabs/zora-1155-contracts/src/deployment/ZoraDeployerUtils.sol"; +import {Zora1155PremintExecutor} from "@zoralabs/zora-1155-contracts/src/proxies/Zora1155PremintExecutor.sol"; +import {DeterministicDeployerScript, DeterministicParams} from "@zoralabs/zora-1155-contracts/src/deployment/DeterministicDeployerScript.sol"; +import {DeterministicProxyDeployer} from "@zoralabs/zora-1155-contracts/src/deployment/DeterministicProxyDeployer.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; /// @title Gets parameters for deterministically deploying a new 1155 factory proxy at an address starting with 0x777777, regardless of the chain. diff --git a/packages/1155-contracts/script/DeployMintersAndImplementations.s.sol b/packages/protocol-deployments/script/DeployMintersAndImplementations.s.sol similarity index 69% rename from packages/1155-contracts/script/DeployMintersAndImplementations.s.sol rename to packages/protocol-deployments/script/DeployMintersAndImplementations.s.sol index 98cb5f065..32a20295a 100644 --- a/packages/1155-contracts/script/DeployMintersAndImplementations.s.sol +++ b/packages/protocol-deployments/script/DeployMintersAndImplementations.s.sol @@ -4,9 +4,9 @@ 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 {Deployment} from "../src/deployment/DeploymentConfig.sol"; +import {ZoraDeployerBase} from "@zoralabs/zora-1155-contracts/src/deployment/ZoraDeployerBase.sol"; +import {ZoraDeployerUtils} from "@zoralabs/zora-1155-contracts/src/deployment/ZoraDeployerUtils.sol"; +import {Deployment} from "@zoralabs/zora-1155-contracts/src/deployment/DeploymentConfig.sol"; contract DeployMintersAndImplementations is ZoraDeployerBase { function run() public returns (string memory) { diff --git a/packages/1155-contracts/script/DeployNewImplementation.s.sol b/packages/protocol-deployments/script/DeployNewImplementation.s.sol similarity index 65% rename from packages/1155-contracts/script/DeployNewImplementation.s.sol rename to packages/protocol-deployments/script/DeployNewImplementation.s.sol index 87833b6ee..1b4929234 100644 --- a/packages/1155-contracts/script/DeployNewImplementation.s.sol +++ b/packages/protocol-deployments/script/DeployNewImplementation.s.sol @@ -4,10 +4,9 @@ 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"; +import {ZoraDeployerBase} from "@zoralabs/zora-1155-contracts/src/deployment/ZoraDeployerBase.sol"; +import {Deployment} from "@zoralabs/zora-1155-contracts/src/deployment/DeploymentConfig.sol"; +import {DeterministicDeployerScript} from "@zoralabs/zora-1155-contracts/src/deployment/DeterministicDeployerScript.sol"; /// @dev Deploys implementation contracts for 1155 contracts. /// @notice Run after deploying the minters diff --git a/packages/1155-contracts/script/DeployPreminterImpl.s.sol b/packages/protocol-deployments/script/DeployPreminterImpl.s.sol similarity index 62% rename from packages/1155-contracts/script/DeployPreminterImpl.s.sol rename to packages/protocol-deployments/script/DeployPreminterImpl.s.sol index 5e5f192b0..f4463385e 100644 --- a/packages/1155-contracts/script/DeployPreminterImpl.s.sol +++ b/packages/protocol-deployments/script/DeployPreminterImpl.s.sol @@ -4,10 +4,9 @@ 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"; +import {ZoraDeployerBase} from "@zoralabs/zora-1155-contracts/src/deployment/ZoraDeployerBase.sol"; +import {Deployment} from "@zoralabs/zora-1155-contracts/src/deployment/DeploymentConfig.sol"; +import {DeterministicDeployerScript} from "@zoralabs/zora-1155-contracts/src/deployment/DeterministicDeployerScript.sol"; /// @dev Deploys preminter implementation contract. /// @notice Run after deploying the minters diff --git a/packages/1155-contracts/script/DeployProxiesToNewChain.s.sol b/packages/protocol-deployments/script/DeployProxiesToNewChain.s.sol similarity index 71% rename from packages/1155-contracts/script/DeployProxiesToNewChain.s.sol rename to packages/protocol-deployments/script/DeployProxiesToNewChain.s.sol index 79cdf993d..6bba5cf1a 100644 --- a/packages/1155-contracts/script/DeployProxiesToNewChain.s.sol +++ b/packages/protocol-deployments/script/DeployProxiesToNewChain.s.sol @@ -4,11 +4,10 @@ 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 {Deployment} from "../src/deployment/DeploymentConfig.sol"; - -import {DeploymentTestingUtils} from "../src/deployment/DeploymentTestingUtils.sol"; +import {ZoraDeployerBase} from "@zoralabs/zora-1155-contracts/src/deployment/ZoraDeployerBase.sol"; +import {Deployment} from "@zoralabs/zora-1155-contracts/src/deployment/DeploymentConfig.sol"; +import {ZoraDeployerUtils} from "@zoralabs/zora-1155-contracts/src/deployment/ZoraDeployerUtils.sol"; +import {DeploymentTestingUtils} from "@zoralabs/zora-1155-contracts/src/deployment/DeploymentTestingUtils.sol"; contract DeployProxiesToNewChain is ZoraDeployerBase, DeploymentTestingUtils { function run() public returns (string memory) { diff --git a/packages/protocol-deployments/script/DeployUpgradeGate.s.sol b/packages/protocol-deployments/script/DeployUpgradeGate.s.sol new file mode 100644 index 000000000..00a784e2c --- /dev/null +++ b/packages/protocol-deployments/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 "@zoralabs/zora-1155-contracts/src/deployment/ZoraDeployerBase.sol"; +import {Deployment} from "@zoralabs/zora-1155-contracts/src/deployment/DeploymentConfig.sol"; +import {ZoraDeployerUtils} from "@zoralabs/zora-1155-contracts/src/deployment/ZoraDeployerUtils.sol"; +import {DeploymentTestingUtils} from "@zoralabs/zora-1155-contracts/src/deployment/DeploymentTestingUtils.sol"; +import {DeterministicDeployerScript} from "@zoralabs/zora-1155-contracts/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/packages/1155-contracts/script/Upgrade.s.sol b/packages/protocol-deployments/script/Upgrade.s.sol similarity index 67% rename from packages/1155-contracts/script/Upgrade.s.sol rename to packages/protocol-deployments/script/Upgrade.s.sol index eaee57231..06b938fc7 100644 --- a/packages/1155-contracts/script/Upgrade.s.sol +++ b/packages/protocol-deployments/script/Upgrade.s.sol @@ -3,20 +3,20 @@ pragma solidity ^0.8.17; import "forge-std/Script.sol"; -import {ZoraDeployerBase} from "./ZoraDeployerBase.sol"; -import {ChainConfig, Deployment} from "../src/deployment/DeploymentConfig.sol"; +import {ZoraDeployerBase} from "@zoralabs/zora-1155-contracts/src/deployment/ZoraDeployerBase.sol"; +import {ChainConfig, Deployment} from "@zoralabs/zora-1155-contracts/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 {IMinter1155} from "../src/interfaces/IMinter1155.sol"; -import {IZoraCreator1155} from "../src/interfaces/IZoraCreator1155.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 {ZoraCreator1155FactoryImpl} from "@zoralabs/zora-1155-contracts/src/factory/ZoraCreator1155FactoryImpl.sol"; +import {Zora1155Factory} from "@zoralabs/zora-1155-contracts/src/proxies/Zora1155Factory.sol"; +import {ZoraCreator1155Impl} from "@zoralabs/zora-1155-contracts/src/nft/ZoraCreator1155Impl.sol"; +import {ICreatorRoyaltiesControl} from "@zoralabs/zora-1155-contracts/src/interfaces/ICreatorRoyaltiesControl.sol"; +import {IZoraCreator1155Factory} from "@zoralabs/zora-1155-contracts/src/interfaces/IZoraCreator1155Factory.sol"; +import {IMinter1155} from "@zoralabs/zora-1155-contracts/src/interfaces/IMinter1155.sol"; +import {IZoraCreator1155} from "@zoralabs/zora-1155-contracts/src/interfaces/IZoraCreator1155.sol"; +import {ZoraCreatorFixedPriceSaleStrategy} from "@zoralabs/zora-1155-contracts/src/minters/fixed-price/ZoraCreatorFixedPriceSaleStrategy.sol"; +import {ZoraCreatorMerkleMinterStrategy} from "@zoralabs/zora-1155-contracts/src/minters/merkle/ZoraCreatorMerkleMinterStrategy.sol"; +import {ZoraCreatorRedeemMinterFactory} from "@zoralabs/zora-1155-contracts/src/minters/redeem/ZoraCreatorRedeemMinterFactory.sol"; +import {ZoraDeployerUtils} from "@zoralabs/zora-1155-contracts/src/deployment/ZoraDeployerUtils.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; contract UpgradeScript is ZoraDeployerBase { diff --git a/packages/1155-contracts/script/UpgradePreminter.s.sol b/packages/protocol-deployments/script/UpgradePreminter.s.sol similarity index 79% rename from packages/1155-contracts/script/UpgradePreminter.s.sol rename to packages/protocol-deployments/script/UpgradePreminter.s.sol index 9c487c0d4..ff01ae27d 100644 --- a/packages/1155-contracts/script/UpgradePreminter.s.sol +++ b/packages/protocol-deployments/script/UpgradePreminter.s.sol @@ -4,10 +4,10 @@ pragma solidity ^0.8.17; import "forge-std/Script.sol"; import "forge-std/console2.sol"; -import {ZoraDeployerBase} from "./ZoraDeployerBase.sol"; -import {ChainConfig, Deployment} from "../src/deployment/DeploymentConfig.sol"; +import {ZoraDeployerBase} from "@zoralabs/zora-1155-contracts/src/deployment/ZoraDeployerBase.sol"; +import {ChainConfig, Deployment} from "@zoralabs/zora-1155-contracts/src/deployment/DeploymentConfig.sol"; import {UUPSUpgradeable} from "@zoralabs/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol"; -import {ZoraDeployerUtils} from "../src/deployment/ZoraDeployerUtils.sol"; +import {ZoraDeployerUtils} from "@zoralabs/zora-1155-contracts/src/deployment/ZoraDeployerUtils.sol"; contract UpgradePreminter is ZoraDeployerBase { function run() public returns (string memory, bytes memory upgradeCalldata, address upgradeTarget) { diff --git a/packages/1155-contracts/script/bundle-chainConfigs.mjs b/packages/protocol-deployments/script/bundle-chainConfigs.mjs similarity index 100% rename from packages/1155-contracts/script/bundle-chainConfigs.mjs rename to packages/protocol-deployments/script/bundle-chainConfigs.mjs diff --git a/packages/1155-contracts/script/copy-deployed-contracts.ts b/packages/protocol-deployments/script/copy-deployed-contracts.ts similarity index 100% rename from packages/1155-contracts/script/copy-deployed-contracts.ts rename to packages/protocol-deployments/script/copy-deployed-contracts.ts diff --git a/packages/1155-contracts/script/signDeploymentTransactions.ts b/packages/protocol-deployments/script/signDeploymentTransactions.ts similarity index 91% rename from packages/1155-contracts/script/signDeploymentTransactions.ts rename to packages/protocol-deployments/script/signDeploymentTransactions.ts index 80f8ad626..2e5cac57a 100644 --- a/packages/1155-contracts/script/signDeploymentTransactions.ts +++ b/packages/protocol-deployments/script/signDeploymentTransactions.ts @@ -82,13 +82,15 @@ async function signAndSaveSignatures({ ); } -async function signAndSaveGenericSignatures({ +async function signAndSaveUpgradeGate({ turnkeyAccount, chainConfigs, proxyName, }: { turnkeyAccount: LocalAccount; - chainConfigs: ChainConfig[]; + chainConfigs: { + chainId: number; owner: Address + }[]; proxyName: "upgradeGate"; }) { const configFolder = path.resolve( @@ -148,6 +150,28 @@ async function signAndSaveGenericSignatures({ ); } +const getChainConfigs = async () => { + const chainConfigsFiles = await glob( + path.resolve(__dirname, "../chainConfigs/*.json") + ); + + const chainConfigs = await Promise.all( + chainConfigsFiles.map(async (chainConfigFile) => { + const chainId = parseInt(path.basename(chainConfigFile).split(".")[0]!); + + // read file and process JSON contents: + const fileContents = await import(chainConfigFile); + + return { + chainId, + owner: fileContents["FACTORY_OWNER"]! as Address, + }; + }) + ); + + return chainConfigs; +}; + const getFactoryImplConfigs = async () => { const addresseFiles = await glob( path.resolve(__dirname, "../addresses/*.json") @@ -239,9 +263,9 @@ async function main() { proxyName: "premintExecutorProxy", }); - await signAndSaveGenericSignatures({ + await signAndSaveUpgradeGate({ turnkeyAccount, - chainConfigs: await getFactoryImplConfigs(), + chainConfigs: await getChainConfigs(), proxyName: "upgradeGate", }); } diff --git a/packages/1155-contracts/script/update-contract-version.mjs b/packages/protocol-deployments/script/update-contract-version.mjs similarity index 100% rename from packages/1155-contracts/script/update-contract-version.mjs rename to packages/protocol-deployments/script/update-contract-version.mjs diff --git a/packages/protocol-deployments/tsconfig.json b/packages/protocol-deployments/tsconfig.json new file mode 100644 index 000000000..7a2947026 --- /dev/null +++ b/packages/protocol-deployments/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "allowJs": true, + "baseUrl": ".", + "downlevelIteration": true, + "esModuleInterop": true, + "isolatedModules": true, + "lib": ["es2021"], + "module": "esnext", + "moduleResolution": "node", + "noImplicitAny": true, + "noUncheckedIndexedAccess": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "strict": true, + "strictNullChecks": true, + "target": "es2021", + "types": ["node"], + "outDir": "dist" + }, + "exclude": ["node_modules/**", "dist/**"], + "include": ["package/**/*.ts", "script/*.ts"] +} diff --git a/packages/protocol-deployments/tsup.config.ts b/packages/protocol-deployments/tsup.config.ts new file mode 100644 index 000000000..1f0e7d5a4 --- /dev/null +++ b/packages/protocol-deployments/tsup.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from 'tsup' + +export default defineConfig({ + entry: ['package/index.ts'], + sourcemap: true, + clean: true, + dts: false, + format: ['cjs', 'esm'], + onSuccess: 'tsc --emitDeclarationOnly --declaration --declarationMap' +}) \ No newline at end of file diff --git a/packages/protocol-deployments/wagmi.config.ts b/packages/protocol-deployments/wagmi.config.ts new file mode 100644 index 000000000..2bdff79b3 --- /dev/null +++ b/packages/protocol-deployments/wagmi.config.ts @@ -0,0 +1,113 @@ +import { defineConfig } from "@wagmi/cli"; +import { Abi } from "viem"; +import { readdirSync, readFileSync } from "fs"; +import * as abis from "@zoralabs/zora-1155-contracts"; + +type Address = `0x${string}`; + +type Addresses = { + [contractName: string]: { + address: { + [chainId: number]: Address; + }; + abi: Abi; + }; +}; + +const getAddresses = () => { + const addresses: Addresses = {}; + + const addressesFiles = readdirSync("./addresses"); + + const addAddress = ({ + contractName, + chainId, + address, + abi, + }: { + contractName: string; + chainId: number; + address?: Address; + abi: Abi; + }) => { + if (!address) return; + if (!addresses[contractName]) { + addresses[contractName] = { + address: {}, + abi, + }; + } + + addresses[contractName]!.address[chainId] = address; + }; + + for (const addressesFile of addressesFiles) { + const jsonAddress = JSON.parse( + readFileSync(`./addresses/${addressesFile}`, "utf-8") + ) as { + FIXED_PRICE_SALE_STRATEGY: Address; + MERKLE_MINT_SALE_STRATEGY: Address; + REDEEM_MINTER_FACTORY: Address; + "1155_IMPL": Address; + FACTORY_IMPL: Address; + FACTORY_PROXY: Address; + PREMINTER_PROXY?: Address; + }; + + const chainId = parseInt(addressesFile.split(".")[0]); + + addAddress({ + contractName: "ZoraCreatorFixedPriceSaleStrategy", + chainId, + address: jsonAddress.FIXED_PRICE_SALE_STRATEGY, + abi: abis.zoraCreatorFixedPriceSaleStrategyABI, + }); + addAddress({ + contractName: "ZoraCreatorMerkleMinterStrategy", + chainId, + address: jsonAddress.MERKLE_MINT_SALE_STRATEGY, + abi: abis.zoraCreatorMerkleMinterStrategyABI, + }); + addAddress({ + contractName: "ZoraCreator1155FactoryImpl", + chainId, + address: jsonAddress.FACTORY_PROXY, + abi: abis.zoraCreator1155FactoryImplABI, + }); + addAddress({ + contractName: "ZoraCreatorRedeemMinterFactory", + chainId, + address: jsonAddress.REDEEM_MINTER_FACTORY, + abi: abis.zoraCreatorRedeemMinterFactoryABI, + }); + addAddress({ + contractName: "ZoraCreator1155PremintExecutorImpl", + chainId, + address: jsonAddress.PREMINTER_PROXY, + abi: abis.zoraCreator1155PremintExecutorImplABI, + }), + addAddress({ + contractName: "IImmutableCreate2Factory", + chainId, + address: "0x0000000000FFe8B47B3e2130213B802212439497", + abi: abis.iImmutableCreate2FactoryABI, + }); + } + + return addresses; +}; + +export default defineConfig({ + out: "package/wagmiGenerated.ts", + contracts: [ + ...Object.entries(getAddresses()).map(([contractName, addressConfig]) => ({ + abi: addressConfig.abi, + address: addressConfig.address, + name: contractName, + })), + { + abi: abis.zoraCreator1155ImplABI, + name: "ZoraCreator1155Impl", + }, + ], +}); diff --git a/packages/protocol-rewards/package.json b/packages/protocol-rewards/package.json index f377b19dd..176088da9 100644 --- a/packages/protocol-rewards/package.json +++ b/packages/protocol-rewards/package.json @@ -8,7 +8,6 @@ "_imagine" ], "scripts": { - "build": "forge build", "build:sizes": "forge build --sizes", "dev": "FOUNDRY_PROFILE=dev forge test --watch -vvv", "test": "forge test", diff --git a/yarn.lock b/yarn.lock index edd286f4f..453419b39 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3497,6 +3497,11 @@ solady@^0.0.123: resolved "https://registry.yarnpkg.com/solady/-/solady-0.0.123.tgz#7ef95767c1570e3efde7550da2a8b439b2f413d2" integrity sha512-F/B8OMCplGsS4FrdPrnEG0xdg8HKede5PwC+Rum8soj/LWxfKckA0p+Uwnlbgey2iI82IHvmSOCNhsdbA+lUrw== +solady@^0.0.132: + version "0.0.132" + resolved "https://registry.yarnpkg.com/solady/-/solady-0.0.132.tgz#5e81ec342990f334055db8e8f319786fcedb6b1a" + integrity sha512-qMdj/Y5fgPmxcis3eTs1Z03Qt/DVt1VJmlugRNjw7DySkrMOW/rHNyUVqqvevsYaGXgbPT54z68chDNesFnH+Q== + solidity-comments-extractor@^0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.7.tgz#99d8f1361438f84019795d928b931f4e5c39ca19"