@zoralabs/protocol-deployments 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/.turbo/turbo-build.log +24 -26
  2. package/CHANGELOG.md +17 -0
  3. package/README.md +3 -9
  4. package/dist/{package/chainConfigs.d.ts → chainConfigs.d.ts} +5 -3
  5. package/dist/chainConfigs.d.ts.map +1 -0
  6. package/dist/deployment.d.ts.map +1 -0
  7. package/dist/index.cjs +68 -61
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +64 -57
  11. package/dist/index.js.map +1 -1
  12. package/dist/{package/wagmiGenerated.d.ts → wagmiGenerated.d.ts} +158 -68
  13. package/dist/{package/wagmiGenerated.d.ts.map → wagmiGenerated.d.ts.map} +1 -1
  14. package/package.json +18 -30
  15. package/{script → scripts}/bundle-chainConfigs.mjs +9 -7
  16. package/tsconfig.json +1 -1
  17. package/tsup.config.ts +5 -5
  18. package/wagmi.config.ts +31 -9
  19. package/.env.anvil +0 -2
  20. package/addresses/1.json +0 -14
  21. package/addresses/10.json +0 -14
  22. package/addresses/11155111.json +0 -9
  23. package/addresses/420.json +0 -14
  24. package/addresses/424.json +0 -11
  25. package/addresses/5.json +0 -14
  26. package/addresses/58008.json +0 -11
  27. package/addresses/7777777.json +0 -15
  28. package/addresses/8453.json +0 -14
  29. package/addresses/84531.json +0 -14
  30. package/addresses/999.json +0 -15
  31. package/addresses/999999999.json +0 -14
  32. package/chainConfigs/1.json +0 -5
  33. package/chainConfigs/10.json +0 -5
  34. package/chainConfigs/11155111.json +0 -4
  35. package/chainConfigs/420.json +0 -5
  36. package/chainConfigs/424.json +0 -5
  37. package/chainConfigs/5.json +0 -5
  38. package/chainConfigs/58008.json +0 -4
  39. package/chainConfigs/7777777.json +0 -5
  40. package/chainConfigs/8453.json +0 -5
  41. package/chainConfigs/84531.json +0 -5
  42. package/chainConfigs/999.json +0 -5
  43. package/chainConfigs/999999999.json +0 -5
  44. package/deterministicConfig/factoryProxy/params.json +0 -10
  45. package/deterministicConfig/factoryProxy/signatures.json +0 -14
  46. package/deterministicConfig/premintExecutorProxy/params.json +0 -10
  47. package/deterministicConfig/premintExecutorProxy/signatures.json +0 -11
  48. package/deterministicConfig/upgradeGate/params.json +0 -7
  49. package/deterministicConfig/upgradeGate/signatures.json +0 -14
  50. package/dist/package/batchPublish.test.d.ts +0 -451
  51. package/dist/package/batchPublish.test.d.ts.map +0 -1
  52. package/dist/package/chainConfigs.d.ts.map +0 -1
  53. package/dist/package/deployment.d.ts.map +0 -1
  54. package/dist/package/index.d.ts.map +0 -1
  55. package/dist/script/copy-deployed-contracts.d.ts +0 -2
  56. package/dist/script/copy-deployed-contracts.d.ts.map +0 -1
  57. package/dist/script/signDeploymentTransactions.d.ts +0 -2
  58. package/dist/script/signDeploymentTransactions.d.ts.map +0 -1
  59. package/foundry.toml +0 -41
  60. package/package/batchPublish.test.ts +0 -327
  61. package/package/chainConfigs.ts +0 -60
  62. package/package/wagmiGenerated.ts +0 -3640
  63. package/remappings.txt +0 -9
  64. package/script/CalculateDeterministicParams.s.sol +0 -84
  65. package/script/DeployMintersAndImplementations.s.sol +0 -31
  66. package/script/DeployNew1155Impl.s.sol +0 -24
  67. package/script/DeployNewImplementation.s.sol +0 -26
  68. package/script/DeployPreminterImpl.s.sol +0 -23
  69. package/script/DeployProxiesToNewChain.s.sol +0 -50
  70. package/script/DeployTestContracts.s.sol +0 -35
  71. package/script/DeployUpgradeGate.s.sol +0 -27
  72. package/script/Upgrade.s.sol +0 -83
  73. package/script/UpgradePreminter.s.sol +0 -34
  74. package/script/copy-deployed-contracts.ts +0 -66
  75. package/script/signDeploymentTransactions.ts +0 -277
  76. package/src/DeploymentConfig.sol +0 -124
  77. package/src/DeploymentTestingUtils.sol +0 -166
  78. package/src/DeterministicDeployerScript.sol +0 -249
  79. package/src/DeterministicProxyDeployer.sol +0 -139
  80. package/src/IImmutableCreate2Factory.sol +0 -59
  81. package/src/Zora1155PremintFixtures.sol +0 -75
  82. package/src/ZoraDeployerBase.sol +0 -145
  83. package/src/ZoraDeployerUtils.sol +0 -212
  84. package/test/NewFactoryProxyDeployer.t.sol +0 -127
  85. package/test/UpgradesTest.t.sol +0 -222
  86. package/test/ZoraCreator1155Factory_Fork.t.sol +0 -149
  87. package/test/ZoraCreator1155PremintExecutorForkTest.t.sol +0 -205
  88. /package/dist/{package/deployment.d.ts → deployment.d.ts} +0 -0
  89. /package/dist/{package/index.d.ts → index.d.ts} +0 -0
  90. /package/{package → src}/deployment.ts +0 -0
  91. /package/{package → src}/index.ts +0 -0
@@ -1,249 +0,0 @@
1
- // spdx-license-identifier: mit
2
- pragma solidity ^0.8.17;
3
-
4
- import "forge-std/Script.sol";
5
- import {Deployment, ChainConfig} from "./DeploymentConfig.sol";
6
- import {ProxyShim} from "@zoralabs/zora-1155-contracts/src/utils/ProxyShim.sol";
7
- import {DeterministicProxyDeployer} from "./DeterministicProxyDeployer.sol";
8
- import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
9
- import {UpgradeGate} from "@zoralabs/zora-1155-contracts/src/upgrades/UpgradeGate.sol";
10
- import {LibString} from "solady/utils/LibString.sol";
11
- import {ZoraDeployerUtils} from "./ZoraDeployerUtils.sol";
12
-
13
- struct DeterministicParams {
14
- bytes proxyDeployerCreationCode;
15
- bytes proxyCreationCode;
16
- address deployerAddress;
17
- address proxyDeployerAddress;
18
- bytes32 proxyDeployerSalt;
19
- bytes32 proxyShimSalt;
20
- bytes32 proxySalt;
21
- address deterministicProxyAddress;
22
- }
23
-
24
- contract DeterministicDeployerScript is Script {
25
- using stdJson for string;
26
-
27
- // copied from: https://github.com/karmacoma-eth/foundry-playground/blob/main/script/MineSaltScript.sol#L17C1-L36C9
28
- function mineSalt(address deployer, bytes32 initCodeHash, string memory startsWith) internal returns (bytes32 salt, address expectedAddress) {
29
- string[] memory args = new string[](8);
30
- args[0] = "cast";
31
- args[1] = "create2";
32
- args[2] = "--starts-with";
33
- args[3] = startsWith;
34
- args[4] = "--deployer";
35
- args[5] = LibString.toHexString(deployer);
36
- args[6] = "--init-code-hash";
37
- args[7] = LibString.toHexStringNoPrefix(uint256(initCodeHash), 32);
38
- string memory result = string(vm.ffi(args));
39
-
40
- uint256 addressIndex = LibString.indexOf(result, "Address: ");
41
- string memory addressStr = LibString.slice(result, addressIndex + 9, addressIndex + 9 + 42);
42
- expectedAddress = vm.parseAddress(addressStr);
43
-
44
- uint256 saltIndex = LibString.indexOf(result, "Salt: ");
45
- string memory saltStr = LibString.slice(result, saltIndex + 6, bytes(result).length);
46
-
47
- salt = bytes32(vm.parseUint(saltStr));
48
- }
49
-
50
- function saltWithAddressInFirst20Bytes(address addressToMakeSaltWith, uint256 suffix) internal pure returns (bytes32) {
51
- uint256 shifted = uint256(uint160(address(addressToMakeSaltWith))) << 96;
52
-
53
- // shifted on the left, suffix on the right:
54
-
55
- return bytes32(shifted | suffix);
56
- }
57
-
58
- function paramsFilePath(string memory proxyName) internal pure returns (string memory) {
59
- return string.concat("deterministicConfig/", proxyName, "/params.json");
60
- }
61
-
62
- function signaturesFilePath(string memory proxyName) internal pure returns (string memory) {
63
- return string.concat("deterministicConfig/", proxyName, "/signatures.json");
64
- }
65
-
66
- function serializeAndSaveOutput(DeterministicParams memory params, string memory proxyName) internal {
67
- string memory result = "deterministicKey";
68
-
69
- vm.serializeBytes(result, "proxyDeployerCreationCode", params.proxyDeployerCreationCode);
70
- vm.serializeBytes(result, "proxyCreationCode", params.proxyCreationCode);
71
- vm.serializeAddress(result, "deployerAddress", params.deployerAddress);
72
- vm.serializeAddress(result, "proxyDeployerAddress", params.proxyDeployerAddress);
73
- vm.serializeBytes32(result, "proxyDeployerSalt", params.proxyDeployerSalt);
74
- vm.serializeBytes32(result, "proxyShimSalt", params.proxyShimSalt);
75
- vm.serializeBytes32(result, "proxySalt", params.proxySalt);
76
-
77
- string memory finalOutput = vm.serializeAddress(result, "deterministicProxyAddress", params.deterministicProxyAddress);
78
-
79
- console2.log(finalOutput);
80
-
81
- vm.writeJson(finalOutput, paramsFilePath(proxyName));
82
- }
83
-
84
- function readDeterministicParams(string memory proxyName) internal view returns (DeterministicParams memory params) {
85
- string memory deployConfig = vm.readFile(paramsFilePath(proxyName));
86
-
87
- return
88
- DeterministicParams({
89
- proxyDeployerCreationCode: deployConfig.readBytes(".proxyDeployerCreationCode"),
90
- proxyCreationCode: deployConfig.readBytes(".proxyCreationCode"),
91
- deployerAddress: deployConfig.readAddress(".deployerAddress"),
92
- proxyDeployerAddress: deployConfig.readAddress(".proxyDeployerAddress"),
93
- proxyDeployerSalt: deployConfig.readBytes32(".proxyDeployerSalt"),
94
- proxyShimSalt: deployConfig.readBytes32(".proxyShimSalt"),
95
- proxySalt: deployConfig.readBytes32(".proxySalt"),
96
- deterministicProxyAddress: deployConfig.readAddress(".deterministicProxyAddress")
97
- });
98
- }
99
-
100
- function readDeterministicParamsAndSig(
101
- string memory proxyName,
102
- uint256 chain
103
- ) internal view returns (DeterministicParams memory params, bytes memory signature) {
104
- string memory signatures = vm.readFile(signaturesFilePath(proxyName));
105
-
106
- params = readDeterministicParams(proxyName);
107
-
108
- signature = signatures.readBytes(string.concat(".", string.concat(vm.toString(chain))));
109
- }
110
-
111
- function getProxyDeployerParams() internal view returns (bytes32 proxyDeployerSalt, bytes memory proxyDeployerCreationCode, address proxyDeployerAddress) {
112
- proxyDeployerSalt = ZoraDeployerUtils.FACTORY_DEPLOYER_DEPLOYMENT_SALT;
113
-
114
- proxyDeployerCreationCode = type(DeterministicProxyDeployer).creationCode;
115
-
116
- // we can know deterministically what the address of the new factory proxy deployer will be, given it's deployed from with the salt and init code,
117
- // from the ImmutableCreate2Factory
118
- proxyDeployerAddress = ZoraDeployerUtils.IMMUTABLE_CREATE2_FACTORY.findCreate2Address(proxyDeployerSalt, proxyDeployerCreationCode);
119
- }
120
-
121
- function getProxyShimParams(
122
- address proxyDeployerAddress,
123
- address deployerAddress,
124
- uint256 proxyShimSaltSuffix
125
- ) internal pure returns (bytes memory proxyShimInitCode, bytes32 proxyShimSalt, address proxyShimAddress) {
126
- proxyShimInitCode = abi.encodePacked(type(ProxyShim).creationCode, abi.encode(proxyDeployerAddress));
127
-
128
- // create any arbitrary salt for proxy shim (this can be anything, we just care about the resulting address)
129
- proxyShimSalt = saltWithAddressInFirst20Bytes(deployerAddress, proxyShimSaltSuffix);
130
-
131
- // now get deterministic proxy shim address based on salt, deployer address, which will be DeterministicProxyDeployer address and init code
132
- proxyShimAddress = Create2.computeAddress(proxyShimSalt, keccak256(proxyShimInitCode), proxyDeployerAddress);
133
- }
134
-
135
- function getProxyParams(
136
- bytes memory proxyCreationCode,
137
- address proxyShimAddress,
138
- address proxyDeployerAddress
139
- ) internal returns (bytes32 proxySalt, address deterministicProxyAddress) {
140
- bytes memory factoryProxyInitCode = abi.encodePacked(proxyCreationCode, abi.encode(proxyShimAddress, ""));
141
- bytes32 creationCodeHash = keccak256(factoryProxyInitCode);
142
-
143
- (proxySalt, deterministicProxyAddress) = mineSalt(proxyDeployerAddress, creationCodeHash, "777777");
144
- }
145
-
146
- function getDeterministicDeploymentParams(
147
- address deployerAddress,
148
- bytes memory proxyCreationCode,
149
- uint256 proxyShimSaltSuffix
150
- ) internal returns (DeterministicParams memory) {
151
- // 1. Get salt with first bytes that match address, and resulting determinisitic factory proxy deployer address
152
- (bytes32 proxyDeployerSalt, bytes memory proxyDeployerCreationCode, address proxyDeployerAddress) = getProxyDeployerParams();
153
- // replace first 20 characters of salt with deployer address, so that the salt can be used with
154
- // ImmutableCreate2Factory.safeCreate2 when called by this deployer's account:
155
-
156
- // 2. Get random proxy shim salt, and resulting deterministic address
157
- // Proxy shim will be initialized with the factory deployer address as the owner, allowing only the factory deployer to upgrade the proxy,
158
- // to the eventual factory implementation
159
- (, bytes32 proxyShimSalt, address proxyShimAddress) = getProxyShimParams({
160
- proxyDeployerAddress: proxyDeployerAddress,
161
- deployerAddress: deployerAddress,
162
- proxyShimSaltSuffix: proxyShimSaltSuffix
163
- });
164
-
165
- // 3. Mine for a salt that can be used to deterministically create the factory proxy, given the proxy shim address, which is passed as the
166
- // constructor argument, and the deployer, which is the new factory proxy deployer, which we know the address of deterministically
167
- (bytes32 proxySalt, address deterministicProxyAddress) = getProxyParams({
168
- proxyCreationCode: proxyCreationCode,
169
- proxyShimAddress: proxyShimAddress,
170
- proxyDeployerAddress: proxyDeployerAddress
171
- });
172
-
173
- return
174
- DeterministicParams({
175
- proxyDeployerCreationCode: proxyDeployerCreationCode,
176
- proxyCreationCode: proxyCreationCode,
177
- deployerAddress: deployerAddress,
178
- proxyDeployerAddress: proxyDeployerAddress,
179
- proxyDeployerSalt: proxyDeployerSalt,
180
- proxyShimSalt: proxyShimSalt,
181
- proxySalt: proxySalt,
182
- deterministicProxyAddress: deterministicProxyAddress
183
- });
184
- }
185
-
186
- error MismatchedAddress(address expected, address actual);
187
-
188
- function readFactoryProxyDeterminsticParams() internal view returns (DeterministicParams memory) {
189
- return readDeterministicParams("factoryProxy");
190
- }
191
-
192
- function readPreminterProxyDeterminsticParams() internal view returns (DeterministicParams memory) {
193
- return readDeterministicParams("premintExecutorProxy");
194
- }
195
-
196
- function getOrCreateProxyDeployer() internal returns (DeterministicProxyDeployer factoryDeployer) {
197
- DeterministicParams memory params = readFactoryProxyDeterminsticParams();
198
- address proxyDeployerAddress = params.proxyDeployerAddress;
199
- bytes32 proxyDeployerSalt = params.proxyDeployerSalt;
200
- bytes memory proxyDeployerCreationCode = params.proxyDeployerCreationCode;
201
-
202
- ZoraDeployerUtils.getOrImmutable2Create(proxyDeployerAddress, proxyDeployerSalt, proxyDeployerCreationCode);
203
-
204
- factoryDeployer = DeterministicProxyDeployer(proxyDeployerAddress);
205
- }
206
-
207
- function deployDeterministicProxy(string memory proxyName, address implementation, address owner, uint256 chain) internal returns (address) {
208
- (DeterministicParams memory params, bytes memory signature) = readDeterministicParamsAndSig(proxyName, chain);
209
-
210
- DeterministicProxyDeployer factoryDeployer = getOrCreateProxyDeployer();
211
-
212
- address resultAddress = factoryDeployer.createFactoryProxyDeterministic(
213
- params.proxyShimSalt,
214
- params.proxySalt,
215
- params.proxyCreationCode,
216
- params.deterministicProxyAddress,
217
- implementation,
218
- owner,
219
- signature
220
- );
221
-
222
- require(resultAddress == params.deterministicProxyAddress, "DeterministicDeployerScript: proxy address mismatch");
223
-
224
- return resultAddress;
225
- }
226
-
227
- function deployUpgradeGate(uint256 chain, address upgradeGateOwner) internal returns (address) {
228
- string memory signatures = vm.readFile(signaturesFilePath("upgradeGate"));
229
- bytes memory signature = signatures.readBytes(string.concat(".", string.concat(vm.toString(chain))));
230
-
231
- string memory upgradeGateParams = vm.readFile("./deterministicConfig/upgradeGate/params.json");
232
-
233
- bytes32 genericCreationSalt = vm.parseJsonBytes32(upgradeGateParams, ".salt");
234
- bytes memory creationCode = vm.parseJsonBytes(upgradeGateParams, ".creationCode");
235
-
236
- DeterministicProxyDeployer factoryDeployer = getOrCreateProxyDeployer();
237
-
238
- address resultAddress = factoryDeployer.createAndInitGenericContractDeterministic({
239
- genericCreationSalt: genericCreationSalt,
240
- creationCode: creationCode,
241
- initCall: abi.encodeWithSelector(UpgradeGate.initialize.selector, upgradeGateOwner),
242
- signature: signature
243
- });
244
-
245
- require(resultAddress == vm.parseJsonAddress(upgradeGateParams, ".upgradeGateAddress"), "DeterministicDeployerScript: upgrade gate address mismatch");
246
-
247
- return resultAddress;
248
- }
249
- }
@@ -1,139 +0,0 @@
1
- // spdx-license-identifier: mit
2
- pragma solidity ^0.8.17;
3
-
4
- import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
5
- import {ProxyShim} from "@zoralabs/zora-1155-contracts/src/utils/ProxyShim.sol";
6
- import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
7
- import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
8
-
9
- interface IUpgradeableProxy {
10
- function upgradeTo(address newImplementation) external;
11
-
12
- function initialize(address newOwner) external;
13
- }
14
-
15
- /// @notice Deterministic proxy deployer for deploying zora 1155 contract suite
16
- /// @dev Supports both generic contracts and the UUPS shim proxy pattern used for ZORA 1155
17
- /// @dev Requires approved signatures depending on the salt hashes (pattern from IMMUTABLE_CREATE2_FACTORY)
18
- contract DeterministicProxyDeployer is EIP712 {
19
- error FactoryProxyAddressMismatch(address expected, address actual);
20
- error FailedToInitGenericDeployedContract();
21
-
22
- constructor() EIP712("DeterministicProxyDeployer", "1") {}
23
-
24
- /// Creates a new factory proxy at a Deterministic address, with this address as the owner
25
- /// Upgrades the proxy to the factory implementation, and sets the new owner as the owner.
26
- /// @param proxyShimSalt Salt for deterministic proxy shim address
27
- /// @param factoryProxySalt Salt for deterministic factory proxy address
28
- function _createAndInitializeNewFactoryProxyDeterministic(
29
- bytes32 proxyShimSalt,
30
- bytes32 factoryProxySalt,
31
- bytes calldata proxyCreationCode,
32
- address expectedFactoryProxyAddress,
33
- address implementationAddress,
34
- address newOwner
35
- ) internal returns (address factoryProxyAddress) {
36
- // create proxy shim and factory proxy deterministically
37
- ProxyShim proxyShim = new ProxyShim{salt: proxyShimSalt}({_canUpgrade: address(this)});
38
-
39
- bytes memory creationCode = abi.encodePacked(proxyCreationCode, abi.encode(address(proxyShim), ""));
40
-
41
- address factoryProxy = Create2.deploy(0, factoryProxySalt, creationCode);
42
-
43
- if (factoryProxy != expectedFactoryProxyAddress) {
44
- revert FactoryProxyAddressMismatch(expectedFactoryProxyAddress, address(factoryProxy));
45
- }
46
-
47
- factoryProxyAddress = address(factoryProxy);
48
- IUpgradeableProxy proxy = IUpgradeableProxy(address(factoryProxy));
49
- proxy.upgradeTo(implementationAddress);
50
- proxy.initialize(newOwner);
51
-
52
- return factoryProxyAddress;
53
- }
54
-
55
- function _createAndInitGenericContractDeterministic(
56
- bytes32 genericCreationSalt,
57
- bytes calldata creationCode,
58
- bytes calldata initCall
59
- ) internal returns (address resultAddress) {
60
- resultAddress = Create2.deploy(0, genericCreationSalt, creationCode);
61
-
62
- (bool success, ) = resultAddress.call(initCall);
63
- if (!success) {
64
- revert FailedToInitGenericDeployedContract();
65
- }
66
- }
67
-
68
- bytes32 constant DOMAIN_UPGRADEABLE_PROXY =
69
- keccak256("createProxy(bytes32 proxyShimSalt,bytes32 proxySalt,bytes proxyCreationCode,address implementationAddress,address owner)");
70
- bytes32 constant DOMAIN_GENERIC_CREATION = keccak256("createGenericContract(bytes32 salt,bytes creationCode,bytes initCall)");
71
-
72
- function recoverSignature(bytes32 digest, bytes calldata signature) public pure returns (address) {
73
- return ECDSA.recover(digest, signature);
74
- }
75
-
76
- function hashedDigestFactoryProxy(
77
- bytes32 proxyShimSalt,
78
- bytes32 proxySalt,
79
- bytes calldata proxyCreationCode,
80
- address implementationAddress,
81
- address newOwner
82
- ) public view returns (bytes32) {
83
- return
84
- _hashTypedDataV4(
85
- keccak256(abi.encode(DOMAIN_UPGRADEABLE_PROXY, proxyShimSalt, proxySalt, keccak256(proxyCreationCode), implementationAddress, newOwner))
86
- );
87
- }
88
-
89
- function hashedDigestGenericCreation(bytes32 salt, bytes calldata creationCode, bytes calldata initCall) public view returns (bytes32) {
90
- return _hashTypedDataV4(keccak256(abi.encode(DOMAIN_GENERIC_CREATION, salt, keccak256(creationCode), keccak256(initCall))));
91
- }
92
-
93
- function requireContainsCaller(address caller, bytes32 salt) private pure {
94
- // prevent contract submissions from being stolen from tx.pool by requiring
95
- // that the first 20 bytes of the submitted salt match msg.sender.
96
- require((address(bytes20(salt)) == caller) || (bytes20(salt) == bytes20(0)), "Invalid salt - first 20 bytes of the salt must match calling address.");
97
- }
98
-
99
- /// Creates a new factory proxy at a Deterministic address, with this address as the owner
100
- /// Upgrades the proxy to the factory implementation, and sets the new owner as the owner.
101
- /// @param proxyShimSalt Salt for deterministic proxy shim address
102
- /// @param proxySalt Salt for deterministic factory proxy address
103
- function createFactoryProxyDeterministic(
104
- bytes32 proxyShimSalt,
105
- bytes32 proxySalt,
106
- bytes calldata proxyCreationCode,
107
- address expectedFactoryProxyAddress,
108
- address implementationAddress,
109
- address owner,
110
- bytes calldata signature
111
- ) external returns (address factoryProxyAddress) {
112
- address signer = recoverSignature(hashedDigestFactoryProxy(proxyShimSalt, proxySalt, proxyCreationCode, implementationAddress, owner), signature);
113
-
114
- requireContainsCaller(signer, proxyShimSalt);
115
-
116
- return
117
- _createAndInitializeNewFactoryProxyDeterministic(
118
- proxyShimSalt,
119
- proxySalt,
120
- proxyCreationCode,
121
- expectedFactoryProxyAddress,
122
- implementationAddress,
123
- owner
124
- );
125
- }
126
-
127
- function createAndInitGenericContractDeterministic(
128
- bytes32 genericCreationSalt,
129
- bytes calldata creationCode,
130
- bytes calldata initCall,
131
- bytes calldata signature
132
- ) external returns (address resultAddress) {
133
- address signer = recoverSignature(hashedDigestGenericCreation(genericCreationSalt, creationCode, initCall), signature);
134
-
135
- requireContainsCaller(signer, genericCreationSalt);
136
-
137
- return _createAndInitGenericContractDeterministic(genericCreationSalt, creationCode, initCall);
138
- }
139
- }
@@ -1,59 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.17;
3
-
4
- // Extracted interface of ImmutableCreate2Factory.sol, located at https://raw.githubusercontent.com/0age/metamorphic/master/contracts/ImmutableCreate2Factory.sol
5
-
6
- interface IImmutableCreate2Factory {
7
- /**
8
- * @dev Create a contract using CREATE2 by submitting a given salt or nonce
9
- * along with the initialization code for the contract. Note that the first 20
10
- * bytes of the salt must match those of the calling address, which prevents
11
- * contract creation events from being submitted by unintended parties.
12
- * @param salt bytes32 The nonce that will be passed into the CREATE2 call.
13
- * @param initializationCode bytes The initialization code that will be passed
14
- * into the CREATE2 call.
15
- * @return deploymentAddress Address of the contract that will be created, or the null address
16
- * if a contract already exists at that address.
17
- */
18
- function safeCreate2(bytes32 salt, bytes calldata initializationCode) external payable returns (address deploymentAddress);
19
-
20
- /**
21
- * @dev Compute the address of the contract that will be created when
22
- * submitting a given salt or nonce to the contract along with the contract's
23
- * initialization code. The CREATE2 address is computed in accordance with
24
- * EIP-1014, and adheres to the formula therein of
25
- * `keccak256( 0xff ++ address ++ salt ++ keccak256(init_code)))[12:]` when
26
- * performing the computation. The computed address is then checked for any
27
- * existing contract code - if so, the null address will be returned instead.
28
- * @param salt bytes32 The nonce passed into the CREATE2 address calculation.
29
- * @param initCode bytes The contract initialization code to be used.
30
- * that will be passed into the CREATE2 address calculation.
31
- * @return deploymentAddress Address of the contract that will be created, or the null address
32
- * if a contract has already been deployed to that address.
33
- */
34
- function findCreate2Address(bytes32 salt, bytes calldata initCode) external view returns (address deploymentAddress);
35
-
36
- /**
37
- * @dev Compute the address of the contract that will be created when
38
- * submitting a given salt or nonce to the contract along with the keccak256
39
- * hash of the contract's initialization code. The CREATE2 address is computed
40
- * in accordance with EIP-1014, and adheres to the formula therein of
41
- * `keccak256( 0xff ++ address ++ salt ++ keccak256(init_code)))[12:]` when
42
- * performing the computation. The computed address is then checked for any
43
- * existing contract code - if so, the null address will be returned instead.
44
- * @param salt bytes32 The nonce passed into the CREATE2 address calculation.
45
- * @param initCodeHash bytes32 The keccak256 hash of the initialization code
46
- * that will be passed into the CREATE2 address calculation.
47
- * @return deploymentAddress Address of the contract that will be created, or the null address
48
- * if a contract has already been deployed to that address.
49
- */
50
- function findCreate2AddressViaHash(bytes32 salt, bytes32 initCodeHash) external view returns (address deploymentAddress);
51
-
52
- /**
53
- * @dev Determine if a contract has already been deployed by the factory to a
54
- * given address.
55
- * @param deploymentAddress address The contract address to check.
56
- * @return True if the contract has been deployed, false otherwise.
57
- */
58
- function hasBeenDeployed(address deploymentAddress) external view returns (bool);
59
- }
@@ -1,75 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.17;
3
-
4
- import {ZoraCreator1155Impl} from "@zoralabs/zora-1155-contracts/src/nft/ZoraCreator1155Impl.sol";
5
- import {ZoraCreatorFixedPriceSaleStrategy} from "@zoralabs/zora-1155-contracts/src/minters/fixed-price/ZoraCreatorFixedPriceSaleStrategy.sol";
6
- import {IZoraCreator1155Errors} from "@zoralabs/zora-1155-contracts/src/interfaces/IZoraCreator1155Errors.sol";
7
- import {IMinter1155} from "@zoralabs/zora-1155-contracts/src/interfaces/IMinter1155.sol";
8
- import {Zora1155Factory} from "@zoralabs/zora-1155-contracts/src/proxies/Zora1155Factory.sol";
9
- import {ZoraCreator1155FactoryImpl} from "@zoralabs/zora-1155-contracts/src/factory/ZoraCreator1155FactoryImpl.sol";
10
- import {ProtocolRewards} from "@zoralabs/protocol-rewards/src/ProtocolRewards.sol";
11
- import {ProxyShim} from "@zoralabs/zora-1155-contracts/src/utils/ProxyShim.sol";
12
- import {PremintConfig, PremintConfigV2, ContractCreationConfig, TokenCreationConfigV2, TokenCreationConfig} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155Attribution.sol";
13
-
14
- library Zora1155PremintFixtures {
15
- function makeDefaultContractCreationConfig(address contractAdmin) internal pure returns (ContractCreationConfig memory) {
16
- return ContractCreationConfig({contractAdmin: contractAdmin, contractName: "blah_______blah", contractURI: "blah.contract"});
17
- }
18
-
19
- function makeTokenCreationConfigV2WithCreateReferral(
20
- IMinter1155 fixedPriceMinter,
21
- address payoutRecipient,
22
- address createReferral
23
- ) internal pure returns (TokenCreationConfigV2 memory) {
24
- return
25
- TokenCreationConfigV2({
26
- tokenURI: "blah.token",
27
- maxSupply: 10,
28
- maxTokensPerAddress: 5,
29
- pricePerToken: 0,
30
- mintStart: 0,
31
- mintDuration: 0,
32
- fixedPriceMinter: address(fixedPriceMinter),
33
- payoutRecipient: payoutRecipient,
34
- royaltyBPS: 10,
35
- createReferral: createReferral
36
- });
37
- }
38
-
39
- function makeDefaultV2PremintConfig(
40
- IMinter1155 fixedPriceMinter,
41
- address payoutRecipient,
42
- address createReferral
43
- ) internal pure returns (PremintConfigV2 memory) {
44
- // make a v2 premint config
45
- return
46
- PremintConfigV2({
47
- tokenConfig: makeTokenCreationConfigV2WithCreateReferral(fixedPriceMinter, payoutRecipient, createReferral),
48
- uid: 100,
49
- version: 0,
50
- deleted: false
51
- });
52
- }
53
-
54
- function makeDefaultV1PremintConfig(IMinter1155 fixedPriceMinter, address royaltyRecipient) internal pure returns (PremintConfig memory) {
55
- // make a v1 premint config
56
- return
57
- PremintConfig({
58
- tokenConfig: TokenCreationConfig({
59
- tokenURI: "blah.token",
60
- maxSupply: 10,
61
- maxTokensPerAddress: 5,
62
- pricePerToken: 0,
63
- mintStart: 0,
64
- mintDuration: 0,
65
- fixedPriceMinter: address(fixedPriceMinter),
66
- royaltyRecipient: royaltyRecipient,
67
- royaltyBPS: 10,
68
- royaltyMintSchedule: 0
69
- }),
70
- uid: 100,
71
- version: 0,
72
- deleted: false
73
- });
74
- }
75
- }
@@ -1,145 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.13;
3
-
4
- import "forge-std/Script.sol";
5
- import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
6
-
7
- import {IZoraCreator1155Factory} from "@zoralabs/zora-1155-contracts/src/interfaces/IZoraCreator1155Factory.sol";
8
- import {ZoraCreator1155Impl} from "@zoralabs/zora-1155-contracts/src/nft/ZoraCreator1155Impl.sol";
9
- import {Zora1155Factory} from "@zoralabs/zora-1155-contracts/src/proxies/Zora1155Factory.sol";
10
- import {ICreatorRoyaltiesControl} from "@zoralabs/zora-1155-contracts/src/interfaces/ICreatorRoyaltiesControl.sol";
11
- import {ScriptDeploymentConfig, Deployment, ChainConfig} from "./DeploymentConfig.sol";
12
- import {ZoraDeployerUtils} from "./ZoraDeployerUtils.sol";
13
- import {IMinter1155} from "@zoralabs/zora-1155-contracts/src/interfaces/IMinter1155.sol";
14
- import {DeterministicDeployerScript} from "./DeterministicDeployerScript.sol";
15
- import {ZoraCreator1155FactoryImpl} from "@zoralabs/zora-1155-contracts/src/factory/ZoraCreator1155FactoryImpl.sol";
16
- import {DeploymentTestingUtils} from "./DeploymentTestingUtils.sol";
17
-
18
- /// @notice Deployment drops for base where
19
- abstract contract ZoraDeployerBase is DeploymentTestingUtils, ScriptDeploymentConfig, DeterministicDeployerScript {
20
- using stdJson for string;
21
-
22
- /// @notice File used for demo metadata on verification test mint
23
- string constant DEMO_IPFS_METADATA_FILE = "ipfs://bafkreigu544g6wjvqcysurpzy5pcskbt45a5f33m6wgythpgb3rfqi3lzi";
24
-
25
- /// @notice Get deployment configuration struct as JSON
26
- /// @param deployment deployment struct
27
- /// @return deploymentJson string JSON of the deployment info
28
- function getDeploymentJSON(Deployment memory deployment) internal returns (string memory deploymentJson) {
29
- string memory deploymentJsonKey = "deployment_json_file_key";
30
- vm.serializeAddress(deploymentJsonKey, FIXED_PRICE_SALE_STRATEGY, deployment.fixedPriceSaleStrategy);
31
- vm.serializeAddress(deploymentJsonKey, MERKLE_MINT_SALE_STRATEGY, deployment.merkleMintSaleStrategy);
32
- vm.serializeAddress(deploymentJsonKey, REDEEM_MINTER_FACTORY, deployment.redeemMinterFactory);
33
- vm.serializeString(deploymentJsonKey, CONTRACT_1155_IMPL_VERSION, deployment.contract1155ImplVersion);
34
- vm.serializeAddress(deploymentJsonKey, CONTRACT_1155_IMPL, deployment.contract1155Impl);
35
- vm.serializeAddress(deploymentJsonKey, FACTORY_IMPL, deployment.factoryImpl);
36
- vm.serializeAddress(deploymentJsonKey, PREMINTER_PROXY, deployment.preminterProxy);
37
- vm.serializeAddress(deploymentJsonKey, PREMINTER_IMPL, deployment.preminterImpl);
38
- vm.serializeAddress(deploymentJsonKey, UPGRADE_GATE, deployment.upgradeGate);
39
- deploymentJson = vm.serializeAddress(deploymentJsonKey, FACTORY_PROXY, deployment.factoryProxy);
40
- console2.log(deploymentJson);
41
- }
42
-
43
- function deployMinters(Deployment memory deployment) internal {
44
- (address fixedPriceMinter, address merkleMinter, address redeemMinterFactory) = ZoraDeployerUtils.deployMinters();
45
- deployment.fixedPriceSaleStrategy = address(fixedPriceMinter);
46
- deployment.merkleMintSaleStrategy = address(merkleMinter);
47
- deployment.redeemMinterFactory = address(redeemMinterFactory);
48
- }
49
-
50
- function deployNew1155AndFactoryImpl(Deployment memory deployment) internal {
51
- ChainConfig memory chainConfig = getChainConfig();
52
-
53
- ensureCanOwn(chainConfig.factoryOwner);
54
-
55
- (address factoryImplDeployment, address contract1155ImplDeployment, string memory contract1155ImplVersion) = ZoraDeployerUtils
56
- .deployNew1155AndFactoryImpl({
57
- upgradeGateAddress: determinsticUpgradeGateAddress(),
58
- mintFeeRecipient: chainConfig.mintFeeRecipient,
59
- protocolRewards: chainConfig.protocolRewards,
60
- merkleMinter: IMinter1155(deployment.merkleMintSaleStrategy),
61
- redeemMinterFactory: IMinter1155(deployment.redeemMinterFactory),
62
- fixedPriceMinter: IMinter1155(deployment.fixedPriceSaleStrategy)
63
- });
64
-
65
- deployment.factoryImpl = factoryImplDeployment;
66
- deployment.contract1155Impl = contract1155ImplDeployment;
67
- deployment.contract1155ImplVersion = contract1155ImplVersion;
68
- }
69
-
70
- function deployNewPreminterImplementationDeterminstic(Deployment memory deployment) internal {
71
- address factoryProxyAddress = determinticFactoryProxyAddress();
72
- deployment.preminterImpl = ZoraDeployerUtils.deployNewPreminterImplementationDeterminstic(factoryProxyAddress);
73
- }
74
-
75
- function determinticFactoryProxyAddress() internal view returns (address) {
76
- return readFactoryProxyDeterminsticParams().deterministicProxyAddress;
77
- }
78
-
79
- function determinsticPreminterProxyAddress() internal view returns (address) {
80
- return readPreminterProxyDeterminsticParams().deterministicProxyAddress;
81
- }
82
-
83
- function deployFactoryProxyDeterminstic(Deployment memory deployment) internal {
84
- ChainConfig memory chainConfig = getChainConfig();
85
-
86
- ensureCanOwn(chainConfig.factoryOwner);
87
-
88
- address factoryProxyAddress = deployDeterministicProxy({
89
- proxyName: "factoryProxy",
90
- implementation: deployment.factoryImpl,
91
- owner: chainConfig.factoryOwner,
92
- chain: chainId()
93
- });
94
-
95
- require(factoryProxyAddress == determinticFactoryProxyAddress(), "address not expected deterministic address");
96
-
97
- require(
98
- keccak256(abi.encodePacked(ZoraCreator1155FactoryImpl(factoryProxyAddress).contractName())) ==
99
- keccak256(abi.encodePacked("ZORA 1155 Contract Factory"))
100
- );
101
-
102
- deployment.factoryProxy = factoryProxyAddress;
103
- }
104
-
105
- function deployPreminterProxyDeterminstic(Deployment memory deployment) internal {
106
- ChainConfig memory chainConfig = getChainConfig();
107
-
108
- ensureCanOwn(chainConfig.factoryOwner);
109
-
110
- address preminterProxyAddress = deployDeterministicProxy({
111
- proxyName: "premintExecutorProxy",
112
- implementation: deployment.preminterImpl,
113
- owner: chainConfig.factoryOwner,
114
- chain: chainId()
115
- });
116
-
117
- require(preminterProxyAddress == determinsticPreminterProxyAddress(), "address not expected deterministic address");
118
-
119
- deployment.preminterProxy = preminterProxyAddress;
120
- }
121
-
122
- function deployUpgradeGateDeterminstic(Deployment memory deployment) internal {
123
- ChainConfig memory chainConfig = getChainConfig();
124
-
125
- ensureCanOwn(chainConfig.factoryOwner);
126
-
127
- address upgradeGateAddress = deployUpgradeGate({chain: chainId(), upgradeGateOwner: chainConfig.factoryOwner});
128
-
129
- require(upgradeGateAddress == determinsticUpgradeGateAddress(), "address not expected deterministic address");
130
-
131
- deployment.upgradeGate = upgradeGateAddress;
132
- }
133
-
134
- function ensureCanOwn(address account) internal view {
135
- // Sanity check to make sure that the factory owner is a smart contract.
136
- // This may catch cross-chain data copy mistakes where there is no safe at the desired admin address.
137
- if (account.code.length == 0) {
138
- revert("FactoryOwner should be a contract. See DeployNewProxies:31.");
139
- }
140
- }
141
-
142
- function determinsticUpgradeGateAddress() internal view returns (address) {
143
- return vm.parseJsonAddress(vm.readFile("./deterministicConfig/upgradeGate/params.json"), ".upgradeGateAddress");
144
- }
145
- }