@zoralabs/protocol-deployments 0.0.6 → 0.0.7
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +10 -0
- package/addresses/999.json +6 -6
- package/addresses/999999999.json +6 -6
- package/dist/index.cjs +1574 -1574
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1574 -1574
- package/dist/index.js.map +1 -1
- package/dist/package/batchPublish.test.d.ts +8 -8
- package/dist/package/wagmiGenerated.d.ts +3516 -3516
- package/package/wagmiGenerated.ts +1338 -1338
- package/package.json +1 -1
- package/script/DeployProxiesToNewChain.s.sol +10 -2
- package/script/DeployTestContracts.s.sol +35 -0
- package/src/DeploymentTestingUtils.sol +118 -22
- package/src/DeterministicDeployerScript.sol +2 -6
- package/src/ZoraDeployerBase.sol +2 -1
- package/src/ZoraDeployerUtils.sol +30 -17
- package/test/UpgradesTest.t.sol +87 -17
package/package.json
CHANGED
|
@@ -8,8 +8,9 @@ import {ZoraDeployerBase} from "../src/ZoraDeployerBase.sol";
|
|
|
8
8
|
import {Deployment} from "../src/DeploymentConfig.sol";
|
|
9
9
|
import {ZoraDeployerUtils} from "../src/ZoraDeployerUtils.sol";
|
|
10
10
|
import {DeploymentTestingUtils} from "../src/DeploymentTestingUtils.sol";
|
|
11
|
+
import {IZoraCreator1155PremintExecutor} from "@zoralabs/zora-1155-contracts/src/interfaces/IZoraCreator1155PremintExecutor.sol";
|
|
11
12
|
|
|
12
|
-
contract DeployProxiesToNewChain is ZoraDeployerBase
|
|
13
|
+
contract DeployProxiesToNewChain is ZoraDeployerBase {
|
|
13
14
|
function run() public returns (string memory) {
|
|
14
15
|
Deployment memory deployment = getDeployment();
|
|
15
16
|
|
|
@@ -31,7 +32,14 @@ contract DeployProxiesToNewChain is ZoraDeployerBase, DeploymentTestingUtils {
|
|
|
31
32
|
|
|
32
33
|
console2.log("testing premint");
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
address fundsRecipient = vm.envAddress("TEST_PREMINT_FUNDS_RECIPIENT");
|
|
36
|
+
IZoraCreator1155PremintExecutor.MintArguments memory mintArguments = IZoraCreator1155PremintExecutor.MintArguments({
|
|
37
|
+
mintRecipient: fundsRecipient,
|
|
38
|
+
mintComment: "",
|
|
39
|
+
mintReferral: fundsRecipient
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
signAndExecutePremintV2(deployment.preminterProxy, vm.envAddress("TEST_PREMINT_FUNDS_RECIPIENT"), mintArguments);
|
|
35
43
|
|
|
36
44
|
vm.stopBroadcast();
|
|
37
45
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
|
+
|
|
4
|
+
import "forge-std/Script.sol";
|
|
5
|
+
import "forge-std/console2.sol";
|
|
6
|
+
|
|
7
|
+
import {ZoraDeployerBase} from "../src/ZoraDeployerBase.sol";
|
|
8
|
+
import {Deployment} from "../src/DeploymentConfig.sol";
|
|
9
|
+
import {ZoraDeployerUtils} from "../src/ZoraDeployerUtils.sol";
|
|
10
|
+
import {IZoraCreator1155PremintExecutor} from "@zoralabs/zora-1155-contracts/src/interfaces/IZoraCreator1155PremintExecutor.sol";
|
|
11
|
+
|
|
12
|
+
contract DeployTestContracts is ZoraDeployerBase {
|
|
13
|
+
function run() public returns (string memory) {
|
|
14
|
+
Deployment memory deployment = getDeployment();
|
|
15
|
+
|
|
16
|
+
vm.startBroadcast();
|
|
17
|
+
|
|
18
|
+
ZoraDeployerUtils.deployTestContractForVerification(deployment.factoryProxy, makeAddr("admin"));
|
|
19
|
+
|
|
20
|
+
address fundsRecipient = vm.envAddress("DEPLOYER");
|
|
21
|
+
IZoraCreator1155PremintExecutor.MintArguments memory mintArguments = IZoraCreator1155PremintExecutor.MintArguments({
|
|
22
|
+
mintRecipient: fundsRecipient,
|
|
23
|
+
mintComment: "",
|
|
24
|
+
mintReferral: fundsRecipient
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
signAndExecutePremintV2(deployment.preminterProxy, fundsRecipient, mintArguments);
|
|
28
|
+
|
|
29
|
+
vm.stopBroadcast();
|
|
30
|
+
|
|
31
|
+
// now test signing and executing premint
|
|
32
|
+
|
|
33
|
+
return getDeploymentJSON(deployment);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -6,56 +6,138 @@ import {IMinter1155} from "@zoralabs/zora-1155-contracts/src/interfaces/IMinter1
|
|
|
6
6
|
import {IZoraCreator1155PremintExecutor} from "@zoralabs/zora-1155-contracts/src/interfaces/IZoraCreator1155PremintExecutor.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 {ZoraCreator1155Attribution, ContractCreationConfig, PremintConfigV2, TokenCreationConfigV2} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155Attribution.sol";
|
|
9
|
+
import {ZoraCreator1155Attribution, ContractCreationConfig, PremintConfigV2, TokenCreationConfigV2, PremintConfig, TokenCreationConfig} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155Attribution.sol";
|
|
10
|
+
import {ScriptDeploymentConfig} from "./DeploymentConfig.sol";
|
|
10
11
|
import {ZoraCreator1155Impl} from "@zoralabs/zora-1155-contracts/src/nft/ZoraCreator1155Impl.sol";
|
|
11
12
|
|
|
12
13
|
contract DeploymentTestingUtils is Script {
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
function createAndSignPremintV1(
|
|
15
|
+
address premintExecutorProxyAddress,
|
|
16
|
+
address payoutRecipient
|
|
17
|
+
)
|
|
18
|
+
internal
|
|
19
|
+
returns (
|
|
20
|
+
ContractCreationConfig memory contractConfig,
|
|
21
|
+
IZoraCreator1155PremintExecutor preminterAtProxy,
|
|
22
|
+
PremintConfig memory premintConfig,
|
|
23
|
+
bytes memory signature
|
|
24
|
+
)
|
|
25
|
+
{
|
|
16
26
|
(address creator, uint256 creatorPrivateKey) = makeAddrAndKey("creator");
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
IMinter1155 fixedPriceMinter = ZoraCreator1155FactoryImpl(address(preminterAtProxy.zora1155Factory())).fixedPriceMinter();
|
|
27
|
+
preminterAtProxy = IZoraCreator1155PremintExecutor(premintExecutorProxyAddress);
|
|
20
28
|
|
|
21
|
-
|
|
22
|
-
tokenConfig:
|
|
29
|
+
premintConfig = PremintConfig({
|
|
30
|
+
tokenConfig: TokenCreationConfig({
|
|
23
31
|
tokenURI: "blah.token",
|
|
24
32
|
maxSupply: 10,
|
|
25
33
|
maxTokensPerAddress: 5,
|
|
26
34
|
pricePerToken: 0,
|
|
27
35
|
mintStart: 0,
|
|
28
36
|
mintDuration: 0,
|
|
37
|
+
royaltyMintSchedule: 0,
|
|
29
38
|
royaltyBPS: 100,
|
|
30
|
-
|
|
31
|
-
fixedPriceMinter: address(fixedPriceMinter)
|
|
32
|
-
createReferral: address(0)
|
|
39
|
+
royaltyRecipient: payoutRecipient,
|
|
40
|
+
fixedPriceMinter: address(ZoraCreator1155FactoryImpl(address(preminterAtProxy.zora1155Factory())).fixedPriceMinter())
|
|
33
41
|
}),
|
|
34
|
-
uid:
|
|
42
|
+
uid: 101,
|
|
35
43
|
version: 0,
|
|
36
44
|
deleted: false
|
|
37
45
|
});
|
|
38
46
|
|
|
39
47
|
// now interface with proxy preminter - sign and execute the premint
|
|
40
|
-
|
|
48
|
+
contractConfig = ContractCreationConfig({contractAdmin: creator, contractName: "blahb", contractURI: "blah.contract"});
|
|
41
49
|
address deterministicAddress = preminterAtProxy.getContractAddress(contractConfig);
|
|
42
50
|
|
|
51
|
+
signature = signPremint(premintConfig, deterministicAddress, creatorPrivateKey);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function signAndExecutePremintV1(
|
|
55
|
+
address premintExecutorProxyAddress,
|
|
56
|
+
address payoutRecipient,
|
|
57
|
+
IZoraCreator1155PremintExecutor.MintArguments memory mintArguments
|
|
58
|
+
) internal {
|
|
59
|
+
(
|
|
60
|
+
ContractCreationConfig memory contractConfig,
|
|
61
|
+
IZoraCreator1155PremintExecutor preminterAtProxy,
|
|
62
|
+
PremintConfig memory premintConfig,
|
|
63
|
+
bytes memory signature
|
|
64
|
+
) = createAndSignPremintV1(premintExecutorProxyAddress, payoutRecipient);
|
|
65
|
+
|
|
43
66
|
uint256 quantityToMint = 1;
|
|
44
67
|
|
|
45
|
-
|
|
68
|
+
// execute the premint
|
|
69
|
+
IZoraCreator1155PremintExecutor.PremintResult memory premintResult = preminterAtProxy.premintV1{value: mintFee(quantityToMint)}(
|
|
70
|
+
contractConfig,
|
|
71
|
+
premintConfig,
|
|
72
|
+
signature,
|
|
73
|
+
quantityToMint,
|
|
74
|
+
mintArguments
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
require(ZoraCreator1155Impl(premintResult.contractAddress).delegatedTokenId(premintConfig.uid) == premintResult.tokenId, "token id mismatch");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function createAndSignPremintV2(
|
|
81
|
+
address premintExecutorProxyAddress,
|
|
82
|
+
address payoutRecipient
|
|
83
|
+
)
|
|
84
|
+
internal
|
|
85
|
+
returns (
|
|
86
|
+
ContractCreationConfig memory contractConfig,
|
|
87
|
+
IZoraCreator1155PremintExecutor preminterAtProxy,
|
|
88
|
+
PremintConfigV2 memory premintConfig,
|
|
89
|
+
bytes memory signature
|
|
90
|
+
)
|
|
91
|
+
{
|
|
92
|
+
(address creator, uint256 creatorPrivateKey) = makeAddrAndKey("creator");
|
|
93
|
+
preminterAtProxy = IZoraCreator1155PremintExecutor(premintExecutorProxyAddress);
|
|
46
94
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
95
|
+
premintConfig = PremintConfigV2({
|
|
96
|
+
tokenConfig: TokenCreationConfigV2({
|
|
97
|
+
tokenURI: "blah.token",
|
|
98
|
+
maxSupply: 100,
|
|
99
|
+
maxTokensPerAddress: 50,
|
|
100
|
+
pricePerToken: 0,
|
|
101
|
+
mintStart: 0,
|
|
102
|
+
mintDuration: 0,
|
|
103
|
+
royaltyBPS: 100,
|
|
104
|
+
payoutRecipient: payoutRecipient,
|
|
105
|
+
fixedPriceMinter: address(ZoraCreator1155FactoryImpl(address(preminterAtProxy.zora1155Factory())).fixedPriceMinter()),
|
|
106
|
+
createReferral: creator
|
|
107
|
+
}),
|
|
108
|
+
uid: 100,
|
|
109
|
+
version: 0,
|
|
110
|
+
deleted: false
|
|
51
111
|
});
|
|
52
112
|
|
|
53
|
-
|
|
113
|
+
// now interface with proxy preminter - sign and execute the premint
|
|
114
|
+
contractConfig = ContractCreationConfig({contractAdmin: creator, contractName: "blahb", contractURI: "blah.contract"});
|
|
115
|
+
address deterministicAddress = preminterAtProxy.getContractAddress(contractConfig);
|
|
116
|
+
|
|
117
|
+
signature = signPremint(premintConfig, deterministicAddress, creatorPrivateKey);
|
|
118
|
+
}
|
|
54
119
|
|
|
120
|
+
function signAndExecutePremintV2(
|
|
121
|
+
address premintExecutorProxyAddress,
|
|
122
|
+
address payoutRecipient,
|
|
123
|
+
IZoraCreator1155PremintExecutor.MintArguments memory mintArguments
|
|
124
|
+
) internal {
|
|
125
|
+
(
|
|
126
|
+
ContractCreationConfig memory contractConfig,
|
|
127
|
+
IZoraCreator1155PremintExecutor preminterAtProxy,
|
|
128
|
+
PremintConfigV2 memory premintConfig,
|
|
129
|
+
bytes memory signature
|
|
130
|
+
) = createAndSignPremintV2(premintExecutorProxyAddress, payoutRecipient);
|
|
131
|
+
|
|
132
|
+
uint256 quantityToMint = 1;
|
|
55
133
|
// execute the premint
|
|
56
|
-
uint256 tokenId = preminterAtProxy
|
|
134
|
+
uint256 tokenId = preminterAtProxy
|
|
135
|
+
.premintV2{value: mintFee(quantityToMint)}(contractConfig, premintConfig, signature, quantityToMint, mintArguments).tokenId;
|
|
57
136
|
|
|
58
|
-
require(
|
|
137
|
+
require(
|
|
138
|
+
ZoraCreator1155Impl(preminterAtProxy.getContractAddress(contractConfig)).delegatedTokenId(premintConfig.uid) == tokenId,
|
|
139
|
+
"token id not created for uid"
|
|
140
|
+
);
|
|
59
141
|
}
|
|
60
142
|
|
|
61
143
|
function signPremint(PremintConfigV2 memory premintConfig, address deterministicAddress, uint256 privateKey) private view returns (bytes memory signature) {
|
|
@@ -67,4 +149,18 @@ contract DeploymentTestingUtils is Script {
|
|
|
67
149
|
(uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest);
|
|
68
150
|
return abi.encodePacked(r, s, v);
|
|
69
151
|
}
|
|
152
|
+
|
|
153
|
+
function mintFee(uint256 quantityToMint) internal pure returns (uint256) {
|
|
154
|
+
return quantityToMint * 0.000777 ether;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function signPremint(PremintConfig memory premintConfig, address deterministicAddress, uint256 privateKey) private view returns (bytes memory signature) {
|
|
158
|
+
bytes32 signatureVersion = ZoraCreator1155Attribution.HASHED_VERSION_1;
|
|
159
|
+
bytes32 structHash = ZoraCreator1155Attribution.hashPremint(premintConfig);
|
|
160
|
+
// sign the premint
|
|
161
|
+
bytes32 digest = ZoraCreator1155Attribution.premintHashedTypeDataV4(structHash, deterministicAddress, signatureVersion, block.chainid);
|
|
162
|
+
|
|
163
|
+
(uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest);
|
|
164
|
+
return abi.encodePacked(r, s, v);
|
|
165
|
+
}
|
|
70
166
|
}
|
|
@@ -199,13 +199,9 @@ contract DeterministicDeployerScript is Script {
|
|
|
199
199
|
bytes32 proxyDeployerSalt = params.proxyDeployerSalt;
|
|
200
200
|
bytes memory proxyDeployerCreationCode = params.proxyDeployerCreationCode;
|
|
201
201
|
|
|
202
|
-
|
|
203
|
-
factoryDeployer = DeterministicProxyDeployer(proxyDeployerAddress);
|
|
204
|
-
} else {
|
|
205
|
-
factoryDeployer = DeterministicProxyDeployer(ZoraDeployerUtils.IMMUTABLE_CREATE2_FACTORY.safeCreate2(proxyDeployerSalt, proxyDeployerCreationCode));
|
|
206
|
-
}
|
|
202
|
+
ZoraDeployerUtils.getOrImmutable2Create(proxyDeployerAddress, proxyDeployerSalt, proxyDeployerCreationCode);
|
|
207
203
|
|
|
208
|
-
|
|
204
|
+
factoryDeployer = DeterministicProxyDeployer(proxyDeployerAddress);
|
|
209
205
|
}
|
|
210
206
|
|
|
211
207
|
function deployDeterministicProxy(string memory proxyName, address implementation, address owner, uint256 chain) internal returns (address) {
|
package/src/ZoraDeployerBase.sol
CHANGED
|
@@ -13,9 +13,10 @@ import {ZoraDeployerUtils} from "./ZoraDeployerUtils.sol";
|
|
|
13
13
|
import {IMinter1155} from "@zoralabs/zora-1155-contracts/src/interfaces/IMinter1155.sol";
|
|
14
14
|
import {DeterministicDeployerScript} from "./DeterministicDeployerScript.sol";
|
|
15
15
|
import {ZoraCreator1155FactoryImpl} from "@zoralabs/zora-1155-contracts/src/factory/ZoraCreator1155FactoryImpl.sol";
|
|
16
|
+
import {DeploymentTestingUtils} from "./DeploymentTestingUtils.sol";
|
|
16
17
|
|
|
17
18
|
/// @notice Deployment drops for base where
|
|
18
|
-
abstract contract ZoraDeployerBase is ScriptDeploymentConfig, DeterministicDeployerScript {
|
|
19
|
+
abstract contract ZoraDeployerBase is DeploymentTestingUtils, ScriptDeploymentConfig, DeterministicDeployerScript {
|
|
19
20
|
using stdJson for string;
|
|
20
21
|
|
|
21
22
|
/// @notice File used for demo metadata on verification test mint
|
|
@@ -17,6 +17,7 @@ import {ZoraCreatorRedeemMinterFactory} from "@zoralabs/zora-1155-contracts/src/
|
|
|
17
17
|
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
|
|
18
18
|
import {ICreatorRoyaltiesControl} from "@zoralabs/zora-1155-contracts/src/interfaces/ICreatorRoyaltiesControl.sol";
|
|
19
19
|
import {UpgradeGate} from "@zoralabs/zora-1155-contracts/src/upgrades/UpgradeGate.sol";
|
|
20
|
+
import {UUPSUpgradeable} from "@zoralabs/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
20
21
|
|
|
21
22
|
struct Create2Deployment {
|
|
22
23
|
address deployerAddress;
|
|
@@ -117,12 +118,13 @@ library ZoraDeployerUtils {
|
|
|
117
118
|
// create preminter implementation
|
|
118
119
|
bytes memory creationCode = abi.encodePacked(type(ZoraCreator1155PremintExecutorImpl).creationCode, abi.encode(factoryProxyAddress));
|
|
119
120
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
);
|
|
121
|
+
bytes32 salt = bytes32(0x0000000000000000000000000000000000000000668d7f9ec18e35000dbaba0e);
|
|
122
|
+
|
|
123
|
+
address determinsticAddress = ZoraDeployerUtils.getImmutableCreate2Address(salt, creationCode);
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
ZoraDeployerUtils.getOrImmutable2Create(determinsticAddress, salt, creationCode);
|
|
126
|
+
|
|
127
|
+
return determinsticAddress;
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
function deterministicFactoryDeployerAddress() internal view returns (address) {
|
|
@@ -152,6 +154,24 @@ library ZoraDeployerUtils {
|
|
|
152
154
|
);
|
|
153
155
|
}
|
|
154
156
|
|
|
157
|
+
error MismatchedAddress(address expected, address actual);
|
|
158
|
+
|
|
159
|
+
function getImmutableCreate2Address(bytes32 salt, bytes memory creationCode) internal pure returns (address) {
|
|
160
|
+
return Create2.computeAddress(salt, keccak256(creationCode), address(IMMUTABLE_CREATE2_FACTORY));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function getOrImmutable2Create(address expectedAddress, bytes32 salt, bytes memory creationCode) internal returns (bool contractWasCreated) {
|
|
164
|
+
if (IMMUTABLE_CREATE2_FACTORY.hasBeenDeployed(expectedAddress)) {
|
|
165
|
+
return false;
|
|
166
|
+
} else {
|
|
167
|
+
address result = ZoraDeployerUtils.IMMUTABLE_CREATE2_FACTORY.safeCreate2(salt, creationCode);
|
|
168
|
+
|
|
169
|
+
if (result != expectedAddress) revert MismatchedAddress(expectedAddress, result);
|
|
170
|
+
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
155
175
|
/// @notice Deploy a test contract for etherscan auto-verification
|
|
156
176
|
/// @param factoryProxy Factory address to use
|
|
157
177
|
/// @param admin Admin owner address to use
|
|
@@ -174,25 +194,18 @@ library ZoraDeployerUtils {
|
|
|
174
194
|
);
|
|
175
195
|
}
|
|
176
196
|
|
|
177
|
-
function getUpgradeCalldata(
|
|
178
|
-
// create 1155 proxy from deployment factory proxy address
|
|
179
|
-
ZoraCreator1155FactoryImpl factory = ZoraCreator1155FactoryImpl(deployment.factoryProxy);
|
|
180
|
-
|
|
181
|
-
address owner = factory.owner();
|
|
182
|
-
|
|
197
|
+
function getUpgradeCalldata(address targetImpl) internal pure returns (bytes memory upgradeCalldata) {
|
|
183
198
|
// simulate upgrade call
|
|
184
|
-
upgradeCalldata = abi.encodeWithSelector(
|
|
199
|
+
upgradeCalldata = abi.encodeWithSelector(UUPSUpgradeable.upgradeTo.selector, targetImpl);
|
|
185
200
|
}
|
|
186
201
|
|
|
187
|
-
function simulateUpgrade(
|
|
202
|
+
function simulateUpgrade(address targetProxy, address targetImpl) internal returns (bytes memory upgradeCalldata) {
|
|
188
203
|
// console log update information
|
|
189
204
|
|
|
190
|
-
upgradeCalldata = getUpgradeCalldata(
|
|
205
|
+
upgradeCalldata = getUpgradeCalldata(targetImpl);
|
|
191
206
|
|
|
192
|
-
target = deployment.factoryProxy;
|
|
193
207
|
// upgrade the factory proxy to the new implementation
|
|
194
|
-
|
|
195
|
-
(bool success, ) = target.call(upgradeCalldata);
|
|
208
|
+
(bool success, ) = targetProxy.call(upgradeCalldata);
|
|
196
209
|
|
|
197
210
|
require(success, "upgrade failed");
|
|
198
211
|
}
|
package/test/UpgradesTest.t.sol
CHANGED
|
@@ -3,10 +3,13 @@ pragma solidity 0.8.17;
|
|
|
3
3
|
|
|
4
4
|
import "forge-std/Test.sol";
|
|
5
5
|
import {ZoraCreator1155FactoryImpl} from "@zoralabs/zora-1155-contracts/src/factory/ZoraCreator1155FactoryImpl.sol";
|
|
6
|
+
import {ZoraCreator1155PremintExecutorImpl} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImpl.sol";
|
|
6
7
|
import {ForkDeploymentConfig, Deployment, ChainConfig} from "../src/DeploymentConfig.sol";
|
|
7
8
|
import {ZoraDeployerUtils} from "../src/ZoraDeployerUtils.sol";
|
|
9
|
+
import {DeploymentTestingUtils} from "../src/DeploymentTestingUtils.sol";
|
|
10
|
+
import {IZoraCreator1155PremintExecutor} from "@zoralabs/zora-1155-contracts/src/interfaces/IZoraCreator1155PremintExecutor.sol";
|
|
8
11
|
|
|
9
|
-
contract UpgradesTest is ForkDeploymentConfig, Test {
|
|
12
|
+
contract UpgradesTest is ForkDeploymentConfig, DeploymentTestingUtils, Test {
|
|
10
13
|
/// @notice gets the chains to do fork tests on, by reading environment var FORK_TEST_CHAINS.
|
|
11
14
|
/// Chains are by name, and must match whats under `rpc_endpoints` in the foundry.toml
|
|
12
15
|
function getForkTestChains() private view returns (string[] memory result) {
|
|
@@ -18,8 +21,39 @@ contract UpgradesTest is ForkDeploymentConfig, Test {
|
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
|
|
24
|
+
function determine1155Upgrade(Deployment memory deployment) private view returns (bool upgradeNeeded, address targetProxy, address targetImpl) {
|
|
25
|
+
targetProxy = deployment.factoryProxy;
|
|
26
|
+
targetImpl = deployment.factoryImpl;
|
|
27
|
+
address currentImplementation = ZoraCreator1155FactoryImpl(targetProxy).implementation();
|
|
28
|
+
|
|
29
|
+
upgradeNeeded = targetImpl != currentImplementation;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function determinePreminterUpgrade(Deployment memory deployment) private returns (bool upgradeNeeded, address targetProxy, address targetImpl) {
|
|
33
|
+
targetProxy = deployment.preminterProxy;
|
|
34
|
+
targetImpl = deployment.preminterImpl;
|
|
35
|
+
|
|
36
|
+
// right now we cannot call "implementation" on contract since it doesn't exist yet, so we check if deployed impl meets the v1 impl we know
|
|
37
|
+
address preminterV1ImplAddress = 0x6E2AbBcd82935bFC68A1d5d2c96372b13b65eD9C;
|
|
38
|
+
|
|
39
|
+
// if the target impl is still the v1 impl, it didnt have a method to check impl so we can't call it, also we know its still v1 impl so we don't need to upgrade
|
|
40
|
+
if (targetImpl == preminterV1ImplAddress) {
|
|
41
|
+
upgradeNeeded = false;
|
|
42
|
+
} else {
|
|
43
|
+
// if doesnt have implementation method, then we know upgrade is needed
|
|
44
|
+
(bool success, bytes memory data) = deployment.preminterProxy.call(abi.encodePacked(ZoraCreator1155PremintExecutorImpl.implementation.selector));
|
|
45
|
+
|
|
46
|
+
if (!success) {
|
|
47
|
+
upgradeNeeded = true;
|
|
48
|
+
} else {
|
|
49
|
+
address currentImplementation = abi.decode(data, (address));
|
|
50
|
+
upgradeNeeded = currentImplementation != targetImpl;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
21
55
|
/// @notice checks which chains need an upgrade, simulated the upgrade, and gets the upgrade calldata
|
|
22
|
-
function
|
|
56
|
+
function simulateUpgradeOnFork(string memory chainName) private {
|
|
23
57
|
// create and select the fork, which will be used for all subsequent calls
|
|
24
58
|
vm.createSelectFork(vm.rpcUrl(chainName));
|
|
25
59
|
|
|
@@ -29,32 +63,68 @@ contract UpgradesTest is ForkDeploymentConfig, Test {
|
|
|
29
63
|
|
|
30
64
|
address creator = makeAddr("creator");
|
|
31
65
|
|
|
32
|
-
|
|
66
|
+
(bool is1155UpgradeNeeded, address targetProxy1155, address targetImpl1155) = determine1155Upgrade(deployment);
|
|
67
|
+
(bool preminterUpgradeNeeded, address targetPreminterProxy, address targetPremintImpl) = determinePreminterUpgrade(deployment);
|
|
33
68
|
|
|
34
|
-
|
|
69
|
+
if (!is1155UpgradeNeeded && !preminterUpgradeNeeded) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
35
72
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
73
|
+
console2.log("====== upgrade needed ======");
|
|
74
|
+
console2.log("chain:", chainName);
|
|
75
|
+
console2.log("upgrade owner:", chainConfig.factoryOwner);
|
|
39
76
|
|
|
40
|
-
|
|
77
|
+
if (is1155UpgradeNeeded) {
|
|
78
|
+
console2.log("-- 1155 upgrade needed --");
|
|
79
|
+
vm.prank(chainConfig.factoryOwner);
|
|
80
|
+
bytes memory factory1155UpgradeCalldata = ZoraDeployerUtils.simulateUpgrade(targetProxy1155, targetImpl1155);
|
|
81
|
+
vm.prank(creator);
|
|
82
|
+
ZoraDeployerUtils.deployTestContractForVerification(targetProxy1155, creator);
|
|
41
83
|
|
|
42
|
-
console2.log("
|
|
43
|
-
console2.log("chain:", chainName);
|
|
44
|
-
console2.log("upgrade owner:", chainConfig.factoryOwner);
|
|
45
|
-
console2.log("upgrade target:", target);
|
|
84
|
+
console2.log("1155 upgrade target:", targetProxy1155);
|
|
46
85
|
console2.log("upgrade calldata:");
|
|
47
|
-
console.logBytes(
|
|
48
|
-
console2.log("upgrade to address:",
|
|
49
|
-
console2.log("upgrade to version:", ZoraCreator1155FactoryImpl(
|
|
50
|
-
console2.log("
|
|
86
|
+
console.logBytes(factory1155UpgradeCalldata);
|
|
87
|
+
console2.log("upgrade to address:", targetImpl1155);
|
|
88
|
+
console2.log("upgrade to version:", ZoraCreator1155FactoryImpl(targetImpl1155).contractVersion());
|
|
89
|
+
console2.log("------------------------");
|
|
51
90
|
}
|
|
91
|
+
|
|
92
|
+
// hack - for now, only check on zora sepolia or goerli
|
|
93
|
+
if (preminterUpgradeNeeded) {
|
|
94
|
+
console2.log("-- preminter upgrade needed --");
|
|
95
|
+
console2.log("preminter upgrade target:", targetPreminterProxy);
|
|
96
|
+
vm.prank(chainConfig.factoryOwner);
|
|
97
|
+
bytes memory preminterUpgradeCalldata = ZoraDeployerUtils.simulateUpgrade(deployment.preminterProxy, deployment.preminterImpl);
|
|
98
|
+
|
|
99
|
+
address collector = makeAddr("collector");
|
|
100
|
+
address mintReferral = makeAddr("referral");
|
|
101
|
+
vm.deal(collector, 10 ether);
|
|
102
|
+
|
|
103
|
+
IZoraCreator1155PremintExecutor.MintArguments memory mintArguments = IZoraCreator1155PremintExecutor.MintArguments({
|
|
104
|
+
mintRecipient: collector,
|
|
105
|
+
mintComment: "",
|
|
106
|
+
mintReferral: mintReferral
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
vm.startPrank(collector);
|
|
110
|
+
signAndExecutePremintV1(targetPreminterProxy, makeAddr("payoutRecipientA"), mintArguments);
|
|
111
|
+
signAndExecutePremintV2(targetPreminterProxy, makeAddr("payoutRecipientB"), mintArguments);
|
|
112
|
+
|
|
113
|
+
vm.stopPrank();
|
|
114
|
+
|
|
115
|
+
console2.log("upgrade calldata:");
|
|
116
|
+
console.logBytes(preminterUpgradeCalldata);
|
|
117
|
+
console2.log("upgrade to address:", targetPremintImpl);
|
|
118
|
+
console2.log("------------------------");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
console2.log("=================\n");
|
|
52
122
|
}
|
|
53
123
|
|
|
54
124
|
function test_fork_simulateUpgrades() external {
|
|
55
125
|
string[] memory forkTestChains = getForkTestChains();
|
|
56
126
|
for (uint256 i = 0; i < forkTestChains.length; i++) {
|
|
57
|
-
|
|
127
|
+
simulateUpgradeOnFork(forkTestChains[i]);
|
|
58
128
|
}
|
|
59
129
|
}
|
|
60
130
|
}
|