@zoralabs/protocol-deployments 0.0.7-prerelease.0 → 0.0.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zoralabs/protocol-deployments",
3
- "version": "0.0.7-prerelease.0",
3
+ "version": "0.0.8",
4
4
  "repository": "https://github.com/ourzora/zora-protocol",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -39,6 +39,7 @@
39
39
  "solady": "^0.0.132",
40
40
  "tsup": "^7.2.0",
41
41
  "tsx": "^3.13.0",
42
+ "zoralabs-tsconfig": "*",
42
43
  "typescript": "^5.2.2"
43
44
  }
44
45
  }
@@ -0,0 +1,75 @@
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
+ }
@@ -49,11 +49,28 @@ contract UpgradesTest is ForkDeploymentConfig, DeploymentTestingUtils, Test {
49
49
  address currentImplementation = abi.decode(data, (address));
50
50
  upgradeNeeded = currentImplementation != targetImpl;
51
51
  }
52
-
53
- console2.log(upgradeNeeded);
54
52
  }
55
53
  }
56
54
 
55
+ function _buildSafeUrl(address safe, address target, bytes memory cd) internal view returns (string memory) {
56
+ // sample url: https://ourzora.github.io/smol-safe/?value=0&safe={safeAddress}&to={target}&data={calldata}&network={chainId}
57
+ // https://ourzora.github.io/smol-safe/?safe={safe}&to={to}&data={data}&value=0&network={network}
58
+ string memory safeQueryString = string.concat("safe=", vm.toString(safe));
59
+ string memory toQueryString = string.concat("&to=", vm.toString(target));
60
+ string memory dataQueryString = string.concat("&data=", vm.toString(cd));
61
+ string memory valueQueryString = "&value=0";
62
+ string memory chainIdQueryString = string.concat("&network=", vm.toString(block.chainid));
63
+ string memory targetUrl = string.concat(
64
+ string.concat(
65
+ string.concat(string.concat(string.concat("https://ourzora.github.io/smol-safe/?", safeQueryString), toQueryString), dataQueryString),
66
+ valueQueryString
67
+ ),
68
+ chainIdQueryString
69
+ );
70
+
71
+ return targetUrl;
72
+ }
73
+
57
74
  /// @notice checks which chains need an upgrade, simulated the upgrade, and gets the upgrade calldata
58
75
  function simulateUpgradeOnFork(string memory chainName) private {
59
76
  // create and select the fork, which will be used for all subsequent calls
@@ -88,6 +105,7 @@ contract UpgradesTest is ForkDeploymentConfig, DeploymentTestingUtils, Test {
88
105
  console.logBytes(factory1155UpgradeCalldata);
89
106
  console2.log("upgrade to address:", targetImpl1155);
90
107
  console2.log("upgrade to version:", ZoraCreator1155FactoryImpl(targetImpl1155).contractVersion());
108
+ console2.log("smol safe upgrade url: ", _buildSafeUrl(chainConfig.factoryOwner, targetProxy1155, factory1155UpgradeCalldata));
91
109
  console2.log("------------------------");
92
110
  }
93
111
 
@@ -117,6 +135,7 @@ contract UpgradesTest is ForkDeploymentConfig, DeploymentTestingUtils, Test {
117
135
  console2.log("upgrade calldata:");
118
136
  console.logBytes(preminterUpgradeCalldata);
119
137
  console2.log("upgrade to address:", targetPremintImpl);
138
+ console2.log("smol safe upgrade url: ", _buildSafeUrl(chainConfig.factoryOwner, targetPreminterProxy, preminterUpgradeCalldata));
120
139
  console2.log("------------------------");
121
140
  }
122
141
 
@@ -3,14 +3,25 @@ pragma solidity 0.8.17;
3
3
 
4
4
  import "forge-std/Test.sol";
5
5
  import {ForkDeploymentConfig} from "../src/DeploymentConfig.sol";
6
- import {ZoraCreator1155Attribution, ContractCreationConfig, PremintConfig, TokenCreationConfig} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155Attribution.sol";
6
+ import {ZoraCreator1155Attribution, ContractCreationConfig, PremintConfig, PremintConfigV2, TokenCreationConfig} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155Attribution.sol";
7
7
  import {ZoraCreator1155PremintExecutorImpl} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImpl.sol";
8
8
  import {ZoraCreator1155FactoryImpl} from "@zoralabs/zora-1155-contracts/src/factory/ZoraCreator1155FactoryImpl.sol";
9
+ import {IZoraCreator1155PremintExecutor} from "@zoralabs/zora-1155-contracts/src/interfaces/IZoraCreator1155PremintExecutor.sol";
10
+ import {Zora1155PremintFixtures} from "../src/Zora1155PremintFixtures.sol";
9
11
 
10
12
  contract ZoraCreator1155PreminterForkTest is ForkDeploymentConfig, Test {
11
13
  ZoraCreator1155FactoryImpl factory;
12
14
  ZoraCreator1155PremintExecutorImpl preminter;
13
15
  uint256 mintFeeAmount = 0.000777 ether;
16
+ address creator;
17
+ uint256 creatorPrivateKey;
18
+ address payoutRecipient = makeAddr("payoutRecipient");
19
+ address minter = makeAddr("minter");
20
+
21
+ ContractCreationConfig contractConfig;
22
+ PremintConfig premintConfig;
23
+ PremintConfigV2 premintConfigV2;
24
+ address createReferral = makeAddr("creatReferral");
14
25
 
15
26
  /// @notice gets the chains to do fork tests on, by reading environment var FORK_TEST_CHAINS.
16
27
  /// Chains are by name, and must match whats under `rpc_endpoints` in the foundry.toml
@@ -23,44 +34,98 @@ contract ZoraCreator1155PreminterForkTest is ForkDeploymentConfig, Test {
23
34
  }
24
35
  }
25
36
 
26
- function testTheForkPremint(string memory chainName) private {
27
- console.log("testing on fork: ", chainName);
28
-
29
- // create and select the fork, which will be used for all subsequent calls
30
- // it will also affect the current block chain id based on the rpc url returned
31
- vm.createSelectFork(vm.rpcUrl(chainName));
32
-
37
+ function setupPremint() private {
33
38
  // get contract hash, which is unique per contract creation config, and can be used
34
39
  // retrieve the address created for a contract
35
40
  address preminterAddress = getDeployment().preminterProxy;
36
41
 
37
- if (preminterAddress == address(0)) {
38
- console.log("preminter not configured for chain...skipping");
39
- return;
40
- }
41
-
42
42
  // override local preminter to use the addresses from the chain
43
43
  factory = ZoraCreator1155FactoryImpl(getDeployment().factoryProxy);
44
44
  preminter = ZoraCreator1155PremintExecutorImpl(preminterAddress);
45
+
46
+ (creator, creatorPrivateKey) = makeAddrAndKey("creator");
47
+
48
+ contractConfig = Zora1155PremintFixtures.makeDefaultContractCreationConfig(creator);
49
+
50
+ premintConfig = Zora1155PremintFixtures.makeDefaultV1PremintConfig(factory.fixedPriceMinter(), payoutRecipient);
51
+ premintConfigV2 = Zora1155PremintFixtures.makeDefaultV2PremintConfig(factory.fixedPriceMinter(), payoutRecipient, createReferral);
45
52
  }
46
53
 
47
- function test_fork_successfullyMintsTokens() external {
54
+ function equals(string memory str1, string memory str2) public pure returns (bool) {
55
+ return keccak256(abi.encodePacked(str1)) == keccak256(abi.encodePacked(str2));
56
+ }
57
+
58
+ function test_fork_legacyPremint_successfullyMintsPremintTokens() external {
48
59
  string[] memory forkTestChains = getForkTestChains();
49
60
  for (uint256 i = 0; i < forkTestChains.length; i++) {
50
- testTheForkPremint(forkTestChains[i]);
61
+ string memory chainName = forkTestChains[i];
62
+
63
+ console.log("testing on fork: ", chainName);
64
+
65
+ // create and select the fork, which will be used for all subsequent calls
66
+ // it will also affect the current block chain id based on the rpc url returned
67
+ vm.createSelectFork(vm.rpcUrl(chainName));
68
+
69
+ setupPremint();
70
+
71
+ _signAndExecutePremintLegacy(creatorPrivateKey, minter, 1, "test comment");
51
72
  }
52
73
  }
53
74
 
54
- function _signAndExecutePremint(
55
- ContractCreationConfig memory contractConfig,
56
- PremintConfig memory premintConfig,
75
+ function test_fork_premintV1_successfullyMintsPremintTokens() external {
76
+ string[] memory forkTestChains = getForkTestChains();
77
+ for (uint256 i = 0; i < forkTestChains.length; i++) {
78
+ string memory chainName = forkTestChains[i];
79
+
80
+ if (!_chainSupportsPremintV2(chainName)) {
81
+ console.log("skipping chain, does not support v1 premint: ", chainName);
82
+ continue;
83
+ }
84
+
85
+ console.log("testing on fork: ", chainName);
86
+
87
+ // it will also affect the current block chain id based on the rpc url returned
88
+ vm.createSelectFork(vm.rpcUrl(chainName));
89
+
90
+ setupPremint();
91
+
92
+ _signAndExecutePremintV1(creatorPrivateKey, minter, 1, "test comment");
93
+ }
94
+ }
95
+
96
+ function test_fork_premintV2_successfullyMintsPremintTokens() external {
97
+ string[] memory forkTestChains = getForkTestChains();
98
+ for (uint256 i = 0; i < forkTestChains.length; i++) {
99
+ string memory chainName = forkTestChains[i];
100
+
101
+ if (!_chainSupportsPremintV2(chainName)) {
102
+ console.log("skipping chain, does not support v2 premint: ", chainName);
103
+ continue;
104
+ }
105
+
106
+ console.log("testing on fork: ", chainName);
107
+
108
+ // it will also affect the current block chain id based on the rpc url returned
109
+ vm.createSelectFork(vm.rpcUrl(chainName));
110
+
111
+ setupPremint();
112
+
113
+ _signAndExecutePremintV2(creatorPrivateKey, minter, 0, "test comment");
114
+ }
115
+ }
116
+
117
+ function _chainSupportsPremintV2(string memory chainName) private pure returns (bool) {
118
+ // for now we know that only goerli and sepolia have v2 premint deployed
119
+ return (equals(chainName, "zora_sepolia") || equals(chainName, "zora_goerli"));
120
+ }
121
+
122
+ function _signAndExecutePremintLegacy(
57
123
  uint256 privateKey,
58
- uint256 chainId,
59
124
  address executor,
60
125
  uint256 quantityToMint,
61
126
  string memory comment
62
127
  ) private returns (uint256 newTokenId) {
63
- bytes memory signature = _signPremint(preminter.getContractAddress(contractConfig), premintConfig, privateKey, chainId);
128
+ bytes memory signature = _signPremintV1(preminter.getContractAddress(contractConfig), privateKey, block.chainid);
64
129
 
65
130
  uint256 mintCost = mintFeeAmount * quantityToMint;
66
131
  vm.deal(executor, mintCost);
@@ -70,12 +135,24 @@ contract ZoraCreator1155PreminterForkTest is ForkDeploymentConfig, Test {
70
135
  newTokenId = preminter.premint{value: mintCost}(contractConfig, premintConfig, signature, quantityToMint, comment);
71
136
  }
72
137
 
73
- function _signPremint(
74
- address contractAddress,
75
- PremintConfig memory premintConfig,
76
- uint256 privateKey,
77
- uint256 chainId
78
- ) private pure returns (bytes memory) {
138
+ function _signAndExecutePremintV1(uint256 privateKey, address executor, uint256 quantityToMint, string memory comment) private {
139
+ bytes memory signature = _signPremintV1(preminter.getContractAddress(contractConfig), privateKey, block.chainid);
140
+
141
+ uint256 mintCost = mintFeeAmount * quantityToMint;
142
+ vm.deal(executor, mintCost);
143
+
144
+ // now call the premint function, using the same config that was used to generate the digest, and the signature
145
+ vm.prank(executor);
146
+ preminter.premintV1{value: mintCost}(
147
+ contractConfig,
148
+ premintConfig,
149
+ signature,
150
+ quantityToMint,
151
+ IZoraCreator1155PremintExecutor.MintArguments({mintRecipient: executor, mintComment: comment, mintReferral: executor})
152
+ );
153
+ }
154
+
155
+ function _signPremintV1(address contractAddress, uint256 privateKey, uint256 chainId) private view returns (bytes memory) {
79
156
  bytes32 digest = ZoraCreator1155Attribution.premintHashedTypeDataV4(
80
157
  ZoraCreator1155Attribution.hashPremint(premintConfig),
81
158
  contractAddress,
@@ -88,6 +165,36 @@ contract ZoraCreator1155PreminterForkTest is ForkDeploymentConfig, Test {
88
165
  return _sign(privateKey, digest);
89
166
  }
90
167
 
168
+ function _signAndExecutePremintV2(uint256 privateKey, address executor, uint256 quantityToMint, string memory comment) private {
169
+ bytes memory signature = _signPremintV2(preminter.getContractAddress(contractConfig), privateKey, block.chainid);
170
+
171
+ uint256 mintCost = mintFeeAmount * quantityToMint;
172
+ vm.deal(executor, mintCost);
173
+
174
+ // now call the premint function, using the same config that was used to generate the digest, and the signature
175
+ vm.prank(executor);
176
+ preminter.premintV2{value: mintCost}(
177
+ contractConfig,
178
+ premintConfigV2,
179
+ signature,
180
+ quantityToMint,
181
+ IZoraCreator1155PremintExecutor.MintArguments({mintRecipient: executor, mintComment: comment, mintReferral: executor})
182
+ );
183
+ }
184
+
185
+ function _signPremintV2(address contractAddress, uint256 privateKey, uint256 chainId) private view returns (bytes memory) {
186
+ bytes32 digest = ZoraCreator1155Attribution.premintHashedTypeDataV4(
187
+ ZoraCreator1155Attribution.hashPremint(premintConfigV2),
188
+ contractAddress,
189
+ ZoraCreator1155Attribution.HASHED_VERSION_2,
190
+ chainId
191
+ );
192
+
193
+ // 3. Sign the digest
194
+ // create a signature with the digest for the params
195
+ return _sign(privateKey, digest);
196
+ }
197
+
91
198
  function _sign(uint256 privateKey, bytes32 digest) private pure returns (bytes memory) {
92
199
  // sign the message
93
200
  (uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest);
package/tsconfig.json CHANGED
@@ -1,23 +1,7 @@
1
1
  {
2
+ "extends": "zoralabs-tsconfig/tsconfig.json",
2
3
  "compilerOptions": {
3
- "allowJs": true,
4
4
  "baseUrl": ".",
5
- "downlevelIteration": true,
6
- "esModuleInterop": true,
7
- "isolatedModules": true,
8
- "lib": ["es2021"],
9
- "module": "esnext",
10
- "moduleResolution": "node",
11
- "noImplicitAny": true,
12
- "noUncheckedIndexedAccess": true,
13
- "noUnusedLocals": true,
14
- "noUnusedParameters": true,
15
- "resolveJsonModule": true,
16
- "skipLibCheck": true,
17
- "strict": true,
18
- "strictNullChecks": true,
19
- "target": "es2021",
20
- "types": ["node"],
21
5
  "outDir": "dist"
22
6
  },
23
7
  "exclude": ["node_modules/**", "dist/**"],