@zoralabs/protocol-deployments 0.0.12 → 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.
- package/.turbo/turbo-build.log +24 -25
- package/CHANGELOG.md +10 -0
- package/README.md +2 -8
- package/dist/{package/chainConfigs.d.ts → chainConfigs.d.ts} +4 -3
- package/dist/chainConfigs.d.ts.map +1 -0
- package/dist/deployment.d.ts.map +1 -0
- package/dist/index.cjs +88 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +84 -53
- package/dist/index.js.map +1 -1
- package/dist/{package/wagmiGenerated.d.ts → wagmiGenerated.d.ts} +118 -44
- package/dist/{package/wagmiGenerated.d.ts.map → wagmiGenerated.d.ts.map} +1 -1
- package/package.json +9 -21
- package/{script → scripts}/bundle-chainConfigs.mjs +9 -7
- package/tsconfig.json +1 -1
- package/tsup.config.ts +5 -5
- package/wagmi.config.ts +31 -9
- package/.env.anvil +0 -2
- package/addresses/1.json +0 -13
- package/addresses/10.json +0 -13
- package/addresses/11155111.json +0 -13
- package/addresses/420.json +0 -13
- package/addresses/424.json +0 -11
- package/addresses/5.json +0 -14
- package/addresses/58008.json +0 -11
- package/addresses/7777777.json +0 -13
- package/addresses/8453.json +0 -13
- package/addresses/84531.json +0 -14
- package/addresses/999.json +0 -13
- package/addresses/999999999.json +0 -14
- package/chainConfigs/1.json +0 -5
- package/chainConfigs/10.json +0 -5
- package/chainConfigs/11155111.json +0 -5
- package/chainConfigs/420.json +0 -5
- package/chainConfigs/424.json +0 -5
- package/chainConfigs/5.json +0 -5
- package/chainConfigs/58008.json +0 -4
- package/chainConfigs/7777777.json +0 -5
- package/chainConfigs/8453.json +0 -5
- package/chainConfigs/84531.json +0 -5
- package/chainConfigs/999.json +0 -5
- package/chainConfigs/999999999.json +0 -5
- package/deterministicConfig/factoryProxy/params.json +0 -10
- package/deterministicConfig/factoryProxy/signatures.json +0 -14
- package/deterministicConfig/premintExecutorProxy/params.json +0 -10
- package/deterministicConfig/premintExecutorProxy/signatures.json +0 -12
- package/deterministicConfig/upgradeGate/params.json +0 -7
- package/deterministicConfig/upgradeGate/signatures.json +0 -14
- package/dist/package/batchPublish.test.d.ts +0 -452
- package/dist/package/batchPublish.test.d.ts.map +0 -1
- package/dist/package/chainConfigs.d.ts.map +0 -1
- package/dist/package/deployment.d.ts.map +0 -1
- package/dist/package/index.d.ts.map +0 -1
- package/dist/script/copy-deployed-contracts.d.ts +0 -2
- package/dist/script/copy-deployed-contracts.d.ts.map +0 -1
- package/dist/script/signDeploymentTransactions.d.ts +0 -2
- package/dist/script/signDeploymentTransactions.d.ts.map +0 -1
- package/foundry.toml +0 -41
- package/package/batchPublish.test.ts +0 -327
- package/package/wagmiGenerated.ts +0 -3657
- package/remappings.txt +0 -9
- package/script/CalculateDeterministicParams.s.sol +0 -84
- package/script/DeployMintersAndImplementations.s.sol +0 -29
- package/script/DeployNew1155Impl.s.sol +0 -24
- package/script/DeployNewImplementation.s.sol +0 -26
- package/script/DeployPreminterImpl.s.sol +0 -23
- package/script/DeployProxiesToNewChain.s.sol +0 -50
- package/script/DeployTestContracts.s.sol +0 -35
- package/script/DeployUpgradeGate.s.sol +0 -27
- package/script/Upgrade.s.sol +0 -83
- package/script/UpgradePreminter.s.sol +0 -34
- package/script/copy-deployed-contracts.ts +0 -86
- package/script/signDeploymentTransactions.ts +0 -302
- package/src/DeploymentConfig.sol +0 -124
- package/src/DeploymentTestingUtils.sol +0 -166
- package/src/DeterministicDeployerScript.sol +0 -249
- package/src/DeterministicProxyDeployer.sol +0 -139
- package/src/IImmutableCreate2Factory.sol +0 -59
- package/src/Zora1155PremintFixtures.sol +0 -75
- package/src/ZoraDeployerBase.sol +0 -144
- package/src/ZoraDeployerUtils.sol +0 -212
- package/test/NewFactoryProxyDeployer.t.sol +0 -127
- package/test/UpgradesTest.t.sol +0 -222
- package/test/ZoraCreator1155Factory_Fork.t.sol +0 -149
- package/test/ZoraCreator1155PremintExecutorForkTest.t.sol +0 -205
- /package/dist/{package/deployment.d.ts → deployment.d.ts} +0 -0
- /package/dist/{package/index.d.ts → index.d.ts} +0 -0
- /package/{package → src}/deployment.ts +0 -0
- /package/{package → src}/index.ts +0 -0
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
// spdx-license-identifier: mit
|
|
2
|
-
pragma solidity ^0.8.17;
|
|
3
|
-
|
|
4
|
-
import {Zora1155Factory} from "@zoralabs/zora-1155-contracts/src/proxies/Zora1155Factory.sol";
|
|
5
|
-
import {ZoraCreator1155Impl} from "@zoralabs/zora-1155-contracts/src/nft/ZoraCreator1155Impl.sol";
|
|
6
|
-
import {IZoraCreator1155Factory} from "@zoralabs/zora-1155-contracts/src/interfaces/IZoraCreator1155Factory.sol";
|
|
7
|
-
import {ZoraCreator1155FactoryImpl} from "@zoralabs/zora-1155-contracts/src/factory/ZoraCreator1155FactoryImpl.sol";
|
|
8
|
-
import {IMinter1155} from "@zoralabs/zora-1155-contracts/src/interfaces/IMinter1155.sol";
|
|
9
|
-
import {Deployment, ChainConfig} from "./DeploymentConfig.sol";
|
|
10
|
-
import {ProxyShim} from "@zoralabs/zora-1155-contracts/src/utils/ProxyShim.sol";
|
|
11
|
-
import {ZoraCreator1155PremintExecutorImpl} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImpl.sol";
|
|
12
|
-
import {IImmutableCreate2Factory} from "./IImmutableCreate2Factory.sol";
|
|
13
|
-
import {DeterministicProxyDeployer} from "./DeterministicProxyDeployer.sol";
|
|
14
|
-
import {ZoraCreatorFixedPriceSaleStrategy} from "@zoralabs/zora-1155-contracts/src/minters/fixed-price/ZoraCreatorFixedPriceSaleStrategy.sol";
|
|
15
|
-
import {ZoraCreatorMerkleMinterStrategy} from "@zoralabs/zora-1155-contracts/src/minters/merkle/ZoraCreatorMerkleMinterStrategy.sol";
|
|
16
|
-
import {ZoraCreatorRedeemMinterFactory} from "@zoralabs/zora-1155-contracts/src/minters/redeem/ZoraCreatorRedeemMinterFactory.sol";
|
|
17
|
-
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
|
|
18
|
-
import {ICreatorRoyaltiesControl} from "@zoralabs/zora-1155-contracts/src/interfaces/ICreatorRoyaltiesControl.sol";
|
|
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";
|
|
21
|
-
|
|
22
|
-
struct Create2Deployment {
|
|
23
|
-
address deployerAddress;
|
|
24
|
-
bytes32 salt;
|
|
25
|
-
bytes constructorArguments;
|
|
26
|
-
address deployedAddress;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
library ZoraDeployerUtils {
|
|
30
|
-
IImmutableCreate2Factory constant IMMUTABLE_CREATE2_FACTORY = IImmutableCreate2Factory(0x0000000000FFe8B47B3e2130213B802212439497);
|
|
31
|
-
|
|
32
|
-
bytes32 constant IMMUTABLE_CREATE_2_FRIENDLY_SALT = bytes32(0x0000000000000000000000000000000000000000000000000000000000000001);
|
|
33
|
-
|
|
34
|
-
function deployWithImmutableCreate2(
|
|
35
|
-
bytes32 salt,
|
|
36
|
-
bytes memory creationCode,
|
|
37
|
-
bytes memory constructorArguments
|
|
38
|
-
) internal returns (Create2Deployment memory) {
|
|
39
|
-
address deployedAddress = IMMUTABLE_CREATE2_FACTORY.safeCreate2(salt, abi.encodePacked(creationCode, constructorArguments));
|
|
40
|
-
|
|
41
|
-
return
|
|
42
|
-
Create2Deployment({
|
|
43
|
-
deployerAddress: address(IMMUTABLE_CREATE2_FACTORY),
|
|
44
|
-
salt: salt,
|
|
45
|
-
constructorArguments: constructorArguments,
|
|
46
|
-
deployedAddress: deployedAddress
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function ensureValidUpgradeGate(address upgradeGateAddress) internal pure {
|
|
51
|
-
require(
|
|
52
|
-
keccak256(abi.encodePacked(UpgradeGate(upgradeGateAddress).contractName())) == keccak256(abi.encodePacked("ZORA 1155 Upgrade Gate")),
|
|
53
|
-
"INVALID_UPGRADE_GATE"
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function deployNew1155AndFactoryImpl(
|
|
58
|
-
address upgradeGateAddress,
|
|
59
|
-
address mintFeeRecipient,
|
|
60
|
-
address protocolRewards,
|
|
61
|
-
IMinter1155 merkleMinter,
|
|
62
|
-
IMinter1155 redeemMinterFactory,
|
|
63
|
-
IMinter1155 fixedPriceMinter
|
|
64
|
-
) internal returns (address factoryImplAddress, address contract1155ImplAddress, string memory contract1155ImplVersion) {
|
|
65
|
-
ensureValidUpgradeGate(upgradeGateAddress);
|
|
66
|
-
|
|
67
|
-
ZoraCreator1155Impl zoraCreator1155Impl = new ZoraCreator1155Impl(mintFeeRecipient, upgradeGateAddress, protocolRewards);
|
|
68
|
-
|
|
69
|
-
contract1155ImplVersion = zoraCreator1155Impl.contractVersion();
|
|
70
|
-
|
|
71
|
-
contract1155ImplAddress = address(zoraCreator1155Impl);
|
|
72
|
-
factoryImplAddress = address(
|
|
73
|
-
new ZoraCreator1155FactoryImpl({
|
|
74
|
-
_zora1155Impl: zoraCreator1155Impl,
|
|
75
|
-
_merkleMinter: merkleMinter,
|
|
76
|
-
_redeemMinterFactory: redeemMinterFactory,
|
|
77
|
-
_fixedPriceMinter: fixedPriceMinter
|
|
78
|
-
})
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function deployImmutableOrGetAddress(bytes32 salt, bytes memory creationCode) internal returns (address) {
|
|
83
|
-
address deployedAddress = Create2.computeAddress(salt, keccak256(creationCode), address(IMMUTABLE_CREATE2_FACTORY));
|
|
84
|
-
if (IMMUTABLE_CREATE2_FACTORY.hasBeenDeployed(deployedAddress)) {
|
|
85
|
-
return deployedAddress;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return IMMUTABLE_CREATE2_FACTORY.safeCreate2(salt, creationCode);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function deployMinters() internal returns (address fixedPriceMinter, address merkleMinter, address redeemMinterFactory) {
|
|
92
|
-
fixedPriceMinter = deployImmutableOrGetAddress(
|
|
93
|
-
bytes32(0x0000000000000000000000000000000000000000000000000000000000000001),
|
|
94
|
-
type(ZoraCreatorFixedPriceSaleStrategy).creationCode
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
merkleMinter = deployImmutableOrGetAddress(
|
|
98
|
-
bytes32(0x0000000000000000000000000000000000000000000000000000000000000001),
|
|
99
|
-
type(ZoraCreatorMerkleMinterStrategy).creationCode
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
redeemMinterFactory = deployImmutableOrGetAddress(
|
|
103
|
-
bytes32(0x0000000000000000000000000000000000000000000000000000000000000001),
|
|
104
|
-
type(ZoraCreatorRedeemMinterFactory).creationCode
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// we dont care what this salt is, as long as it's the same for all deployments and it has first 20 bytes of 0
|
|
109
|
-
// so that anyone can deploy it
|
|
110
|
-
bytes32 constant FACTORY_DEPLOYER_DEPLOYMENT_SALT = bytes32(0x0000000000000000000000000000000000000000668d7f9ed18e35000dbaba0f);
|
|
111
|
-
|
|
112
|
-
function createDeterministicFactoryProxyDeployer() internal returns (DeterministicProxyDeployer) {
|
|
113
|
-
return
|
|
114
|
-
DeterministicProxyDeployer(IMMUTABLE_CREATE2_FACTORY.safeCreate2(FACTORY_DEPLOYER_DEPLOYMENT_SALT, type(DeterministicProxyDeployer).creationCode));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function deployNewPreminterImplementationDeterminstic(address factoryProxyAddress) internal returns (address) {
|
|
118
|
-
// create preminter implementation
|
|
119
|
-
bytes memory creationCode = abi.encodePacked(type(ZoraCreator1155PremintExecutorImpl).creationCode, abi.encode(factoryProxyAddress));
|
|
120
|
-
|
|
121
|
-
bytes32 salt = bytes32(0x0000000000000000000000000000000000000000668d7f9ec18e35000dbaba0e);
|
|
122
|
-
|
|
123
|
-
address determinsticAddress = ZoraDeployerUtils.getImmutableCreate2Address(salt, creationCode);
|
|
124
|
-
|
|
125
|
-
ZoraDeployerUtils.getOrImmutable2Create(determinsticAddress, salt, creationCode);
|
|
126
|
-
|
|
127
|
-
return determinsticAddress;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function deterministicFactoryDeployerAddress() internal view returns (address) {
|
|
131
|
-
// 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,
|
|
132
|
-
// from the ImmutableCreate2Factory
|
|
133
|
-
return IMMUTABLE_CREATE2_FACTORY.findCreate2Address(FACTORY_DEPLOYER_DEPLOYMENT_SALT, type(DeterministicProxyDeployer).creationCode);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function factoryProxyConstructorArguments(bytes32 proxyShimSalt, address proxyDeployerAddress) internal pure returns (bytes memory) {
|
|
137
|
-
address proxyShimAddress = Create2.computeAddress(
|
|
138
|
-
proxyShimSalt,
|
|
139
|
-
keccak256(abi.encodePacked(type(ProxyShim).creationCode, abi.encode(proxyDeployerAddress))),
|
|
140
|
-
proxyDeployerAddress
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
return abi.encode(proxyShimAddress, "");
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function deterministicFactoryProxyAddress(bytes32 proxyShimSalt, bytes32 factoryProxySalt, address proxyDeployerAddress) internal pure returns (address) {
|
|
147
|
-
bytes memory constructorArguments = factoryProxyConstructorArguments(proxyShimSalt, proxyDeployerAddress);
|
|
148
|
-
|
|
149
|
-
return
|
|
150
|
-
Create2.computeAddress(
|
|
151
|
-
factoryProxySalt,
|
|
152
|
-
keccak256(abi.encodePacked(type(Zora1155Factory).creationCode, constructorArguments)),
|
|
153
|
-
proxyDeployerAddress
|
|
154
|
-
);
|
|
155
|
-
}
|
|
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
|
-
|
|
175
|
-
/// @notice Deploy a test contract for etherscan auto-verification
|
|
176
|
-
/// @param factoryProxy Factory address to use
|
|
177
|
-
/// @param admin Admin owner address to use
|
|
178
|
-
function deployTestContractForVerification(address factoryProxy, address admin) internal returns (address) {
|
|
179
|
-
bytes[] memory initUpdate = new bytes[](1);
|
|
180
|
-
initUpdate[0] = abi.encodeWithSelector(
|
|
181
|
-
ZoraCreator1155Impl.setupNewToken.selector,
|
|
182
|
-
"ipfs://bafkreigu544g6wjvqcysurpzy5pcskbt45a5f33m6wgythpgb3rfqi3lzi",
|
|
183
|
-
100
|
|
184
|
-
);
|
|
185
|
-
return
|
|
186
|
-
address(
|
|
187
|
-
IZoraCreator1155Factory(factoryProxy).createContract(
|
|
188
|
-
"ipfs://bafybeicgolwqpozsc7iwgytavete56a2nnytzix2nb2rxefdvbtwwtnnoe/metadata",
|
|
189
|
-
unicode"🪄",
|
|
190
|
-
ICreatorRoyaltiesControl.RoyaltyConfiguration({royaltyBPS: 0, royaltyRecipient: address(0), royaltyMintSchedule: 0}),
|
|
191
|
-
payable(admin),
|
|
192
|
-
initUpdate
|
|
193
|
-
)
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function getUpgradeCalldata(address targetImpl) internal pure returns (bytes memory upgradeCalldata) {
|
|
198
|
-
// simulate upgrade call
|
|
199
|
-
upgradeCalldata = abi.encodeWithSelector(UUPSUpgradeable.upgradeTo.selector, targetImpl);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function simulateUpgrade(address targetProxy, address targetImpl) internal returns (bytes memory upgradeCalldata) {
|
|
203
|
-
// console log update information
|
|
204
|
-
|
|
205
|
-
upgradeCalldata = getUpgradeCalldata(targetImpl);
|
|
206
|
-
|
|
207
|
-
// upgrade the factory proxy to the new implementation
|
|
208
|
-
(bool success, ) = targetProxy.call(upgradeCalldata);
|
|
209
|
-
|
|
210
|
-
require(success, "upgrade failed");
|
|
211
|
-
}
|
|
212
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.17;
|
|
3
|
-
|
|
4
|
-
import "forge-std/Test.sol";
|
|
5
|
-
import {Zora1155Factory} from "@zoralabs/zora-1155-contracts/src/proxies/Zora1155Factory.sol";
|
|
6
|
-
import {ZoraDeployerUtils, Create2Deployment} from "../src/ZoraDeployerUtils.sol";
|
|
7
|
-
import {DeterministicProxyDeployer} from "../src/DeterministicProxyDeployer.sol";
|
|
8
|
-
import {ProxyShim} from "@zoralabs/zora-1155-contracts/src/utils/ProxyShim.sol";
|
|
9
|
-
import {UpgradeGate} from "@zoralabs/zora-1155-contracts/src/upgrades/UpgradeGate.sol";
|
|
10
|
-
import {Deployment, ChainConfig} from "../src/DeploymentConfig.sol";
|
|
11
|
-
import {IMinter1155} from "@zoralabs/zora-1155-contracts/src/interfaces/IMinter1155.sol";
|
|
12
|
-
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
|
|
13
|
-
import {DeterministicDeployerScript, DeterministicParams} from "../src/DeterministicDeployerScript.sol";
|
|
14
|
-
|
|
15
|
-
contract DeterministicProxyDeployerTest is DeterministicDeployerScript, Test {
|
|
16
|
-
using stdJson for string;
|
|
17
|
-
|
|
18
|
-
// the values in this test can be determined by running the script GetDeterministicParam.s.sol,
|
|
19
|
-
// and copying the output values here.
|
|
20
|
-
function _deployKnownZoraFactoryProxy(bytes32 salt) internal returns (DeterministicProxyDeployer) {
|
|
21
|
-
// create new factory deployer using ImmutableCreate2Factory
|
|
22
|
-
return DeterministicProxyDeployer(ZoraDeployerUtils.IMMUTABLE_CREATE2_FACTORY.safeCreate2(salt, type(DeterministicProxyDeployer).creationCode));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function create1155FactoryImpl() internal returns (address) {
|
|
26
|
-
address mintFeeRecipient = makeAddr("mintFeeRecipient");
|
|
27
|
-
address protocolRewards = makeAddr("protocolRewards");
|
|
28
|
-
|
|
29
|
-
(address factoryImplDeployment, , ) = ZoraDeployerUtils.deployNew1155AndFactoryImpl({
|
|
30
|
-
upgradeGateAddress: address(new UpgradeGate()),
|
|
31
|
-
mintFeeRecipient: mintFeeRecipient,
|
|
32
|
-
protocolRewards: protocolRewards,
|
|
33
|
-
merkleMinter: IMinter1155(address(0)),
|
|
34
|
-
redeemMinterFactory: IMinter1155(address(0)),
|
|
35
|
-
fixedPriceMinter: IMinter1155(address(0))
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return factoryImplDeployment;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function test_proxyCanByDeployedAtDesiredAddress(bytes32 proxySalt) external {
|
|
42
|
-
vm.createSelectFork("zora_goerli", 1252119);
|
|
43
|
-
// ensure nonce is greater than current account's nonce
|
|
44
|
-
|
|
45
|
-
(address deployerAddress, uint256 deployerPrivateKey) = makeAddrAndKey("deployer");
|
|
46
|
-
bytes32 proxyDeployerSalt = ZoraDeployerUtils.FACTORY_DEPLOYER_DEPLOYMENT_SALT;
|
|
47
|
-
|
|
48
|
-
// now we can create the implementation, pointing it to the expected deterministic address:
|
|
49
|
-
bytes32 proxyShimSalt = saltWithAddressInFirst20Bytes(deployerAddress, 10);
|
|
50
|
-
|
|
51
|
-
// 1. Create implementation contracts based on deterministic factory proxy address
|
|
52
|
-
|
|
53
|
-
// create 1155 and factory impl, we can know the deterministic factor proxy address ahead of time:
|
|
54
|
-
address factoryImplAddress = create1155FactoryImpl();
|
|
55
|
-
|
|
56
|
-
// 2. Create factory deployer at deterministic address
|
|
57
|
-
DeterministicProxyDeployer factoryProxyDeployer = _deployKnownZoraFactoryProxy(proxyDeployerSalt);
|
|
58
|
-
|
|
59
|
-
bytes memory factoryProxyCreationCode = type(Zora1155Factory).creationCode;
|
|
60
|
-
address mintFeeRecipient = makeAddr("mintFeeRecipient ");
|
|
61
|
-
|
|
62
|
-
bytes32 digest = factoryProxyDeployer.hashedDigestFactoryProxy(
|
|
63
|
-
proxyShimSalt,
|
|
64
|
-
proxySalt,
|
|
65
|
-
factoryProxyCreationCode,
|
|
66
|
-
factoryImplAddress,
|
|
67
|
-
mintFeeRecipient
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
// sign the message
|
|
71
|
-
bytes memory signature = signAndMakeBytes(digest, deployerPrivateKey);
|
|
72
|
-
|
|
73
|
-
address expectedFactoryProxyAddress = ZoraDeployerUtils.deterministicFactoryProxyAddress(proxyShimSalt, proxySalt, address(factoryProxyDeployer));
|
|
74
|
-
|
|
75
|
-
// now do it as original deployer, it should succeed:
|
|
76
|
-
address factoryProxyAddress = factoryProxyDeployer.createFactoryProxyDeterministic(
|
|
77
|
-
proxyShimSalt,
|
|
78
|
-
proxySalt,
|
|
79
|
-
factoryProxyCreationCode,
|
|
80
|
-
expectedFactoryProxyAddress,
|
|
81
|
-
factoryImplAddress,
|
|
82
|
-
mintFeeRecipient,
|
|
83
|
-
signature
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
// we know this salt from a script we ran that will generated
|
|
87
|
-
// create factory proxy, using deterministic address and known salt to get proper expected address:
|
|
88
|
-
assertEq(factoryProxyAddress, expectedFactoryProxyAddress, "factory proxy address wrong");
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function signAndMakeBytes(bytes32 digest, uint256 privateKey) internal pure returns (bytes memory) {
|
|
92
|
-
(uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest);
|
|
93
|
-
|
|
94
|
-
// combine into a single bytes array
|
|
95
|
-
return abi.encodePacked(r, s, v);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function test_genericContractCanByDeployedAtDesiredAddress(uint32 nonce) external {
|
|
99
|
-
vm.createSelectFork("zora_goerli", 1252119);
|
|
100
|
-
|
|
101
|
-
(address deployerAddress, uint256 deployerPrivateKey) = makeAddrAndKey("deployer");
|
|
102
|
-
|
|
103
|
-
vm.assume(nonce > vm.getNonce(deployerAddress));
|
|
104
|
-
// we set the nonce to a random value, to prove this doesn't affect the deterministic addrss
|
|
105
|
-
vm.setNonce(deployerAddress, nonce);
|
|
106
|
-
|
|
107
|
-
DeterministicProxyDeployer factoryProxyDeployer = _deployKnownZoraFactoryProxy(bytes32(0));
|
|
108
|
-
|
|
109
|
-
address gateAdmin = makeAddr("gateAdmin");
|
|
110
|
-
|
|
111
|
-
bytes memory upgradeGateDeployCode = type(UpgradeGate).creationCode;
|
|
112
|
-
|
|
113
|
-
bytes memory initCall = abi.encodeWithSignature("initialize(address)", gateAdmin);
|
|
114
|
-
|
|
115
|
-
bytes32 genericTestDeploySalt = saltWithAddressInFirst20Bytes(deployerAddress, 20);
|
|
116
|
-
|
|
117
|
-
bytes32 digest = factoryProxyDeployer.hashedDigestGenericCreation(genericTestDeploySalt, upgradeGateDeployCode, initCall);
|
|
118
|
-
|
|
119
|
-
// sign the message
|
|
120
|
-
(uint8 v, bytes32 r, bytes32 s) = vm.sign(deployerPrivateKey, digest);
|
|
121
|
-
|
|
122
|
-
// combine into a single bytes array
|
|
123
|
-
bytes memory signature = abi.encodePacked(r, s, v);
|
|
124
|
-
|
|
125
|
-
factoryProxyDeployer.createAndInitGenericContractDeterministic(genericTestDeploySalt, upgradeGateDeployCode, initCall, signature);
|
|
126
|
-
}
|
|
127
|
-
}
|
package/test/UpgradesTest.t.sol
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.17;
|
|
3
|
-
|
|
4
|
-
import "forge-std/Test.sol";
|
|
5
|
-
import {ZoraCreator1155FactoryImpl} from "@zoralabs/zora-1155-contracts/src/factory/ZoraCreator1155FactoryImpl.sol";
|
|
6
|
-
import {ZoraCreator1155PremintExecutorImpl} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImpl.sol";
|
|
7
|
-
import {ForkDeploymentConfig, Deployment, ChainConfig} from "../src/DeploymentConfig.sol";
|
|
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";
|
|
11
|
-
|
|
12
|
-
contract UpgradesTest is ForkDeploymentConfig, DeploymentTestingUtils, Test {
|
|
13
|
-
/// @notice gets the chains to do fork tests on, by reading environment var FORK_TEST_CHAINS.
|
|
14
|
-
/// Chains are by name, and must match whats under `rpc_endpoints` in the foundry.toml
|
|
15
|
-
function getForkTestChains() private view returns (string[] memory result) {
|
|
16
|
-
try vm.envString("FORK_TEST_CHAINS", ",") returns (string[] memory forkTestChains) {
|
|
17
|
-
result = forkTestChains;
|
|
18
|
-
} catch {
|
|
19
|
-
console.log("could not get fork test chains - make sure the environment variable FORK_TEST_CHAINS is set");
|
|
20
|
-
result = new string[](0);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
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
|
-
|
|
55
|
-
function _buildSafeUrl(address safe, address target, bytes memory cd) internal view returns (string memory) {
|
|
56
|
-
address[] memory targets = new address[](1);
|
|
57
|
-
targets[0] = target;
|
|
58
|
-
|
|
59
|
-
bytes[] memory calldatas = new bytes[](1);
|
|
60
|
-
calldatas[0] = cd;
|
|
61
|
-
|
|
62
|
-
return _buildBatchSafeUrl(safe, targets, calldatas);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// pipe delimiter is url encoded | which is %7C
|
|
66
|
-
string constant PIPE_DELIMITER = "%7C";
|
|
67
|
-
|
|
68
|
-
function _buildBatchSafeUrl(address safe, address[] memory targets, bytes[] memory cd) internal view returns (string memory) {
|
|
69
|
-
string memory targetsString = "";
|
|
70
|
-
|
|
71
|
-
for (uint256 i = 0; i < targets.length; i++) {
|
|
72
|
-
targetsString = string.concat(targetsString, vm.toString(targets[i]));
|
|
73
|
-
|
|
74
|
-
if (i < targets.length - 1) {
|
|
75
|
-
targetsString = string.concat(targetsString, PIPE_DELIMITER);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
string memory calldataString = "";
|
|
80
|
-
|
|
81
|
-
for (uint256 i = 0; i < cd.length; i++) {
|
|
82
|
-
calldataString = string.concat(calldataString, vm.toString(cd[i]));
|
|
83
|
-
|
|
84
|
-
if (i < cd.length - 1) {
|
|
85
|
-
calldataString = string.concat(calldataString, PIPE_DELIMITER);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
string memory valuesString = "";
|
|
90
|
-
|
|
91
|
-
for (uint256 i = 0; i < cd.length; i++) {
|
|
92
|
-
valuesString = string.concat(valuesString, "0");
|
|
93
|
-
|
|
94
|
-
if (i < cd.length - 1) {
|
|
95
|
-
valuesString = string.concat(valuesString, PIPE_DELIMITER);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// sample url: https://ourzora.github.io/smol-safe/${chainId}/${safeAddress}&target={pipeDelimitedTargets}&calldata={pipeDelimitedCalldata}&value={pipeDelimitedValues}
|
|
100
|
-
string memory targetUrl = "https://ourzora.github.io/smol-safe/#safe/";
|
|
101
|
-
targetUrl = string.concat(targetUrl, vm.toString(block.chainid));
|
|
102
|
-
targetUrl = string.concat(targetUrl, "/");
|
|
103
|
-
targetUrl = string.concat(targetUrl, vm.toString(safe));
|
|
104
|
-
targetUrl = string.concat(targetUrl, "/new");
|
|
105
|
-
targetUrl = string.concat(targetUrl, "?");
|
|
106
|
-
targetUrl = string.concat(targetUrl, "targets=");
|
|
107
|
-
targetUrl = string.concat(targetUrl, targetsString);
|
|
108
|
-
targetUrl = string.concat(targetUrl, "&calldatas=");
|
|
109
|
-
targetUrl = string.concat(targetUrl, calldataString);
|
|
110
|
-
targetUrl = string.concat(targetUrl, "&values=");
|
|
111
|
-
targetUrl = string.concat(targetUrl, valuesString);
|
|
112
|
-
|
|
113
|
-
return targetUrl;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/// @notice checks which chains need an upgrade, simulated the upgrade, and gets the upgrade calldata
|
|
117
|
-
function simulateUpgradeOnFork(string memory chainName) private {
|
|
118
|
-
// create and select the fork, which will be used for all subsequent calls
|
|
119
|
-
vm.createSelectFork(vm.rpcUrl(chainName));
|
|
120
|
-
|
|
121
|
-
Deployment memory deployment = getDeployment();
|
|
122
|
-
|
|
123
|
-
ChainConfig memory chainConfig = getChainConfig();
|
|
124
|
-
|
|
125
|
-
address creator = makeAddr("creator");
|
|
126
|
-
|
|
127
|
-
(bool is1155UpgradeNeeded, address targetProxy1155, address targetImpl1155) = determine1155Upgrade(deployment);
|
|
128
|
-
(bool preminterUpgradeNeeded, address targetPreminterProxy, address targetPremintImpl) = determinePreminterUpgrade(deployment);
|
|
129
|
-
|
|
130
|
-
if (!is1155UpgradeNeeded && !preminterUpgradeNeeded) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
console2.log("====== upgrade needed ======");
|
|
135
|
-
console2.log("chain:", chainName);
|
|
136
|
-
console2.log("upgrade owner:", chainConfig.factoryOwner);
|
|
137
|
-
|
|
138
|
-
bytes memory factory1155UpgradeCalldata;
|
|
139
|
-
|
|
140
|
-
if (is1155UpgradeNeeded) {
|
|
141
|
-
console2.log("-- 1155 upgrade needed --");
|
|
142
|
-
vm.prank(chainConfig.factoryOwner);
|
|
143
|
-
factory1155UpgradeCalldata = ZoraDeployerUtils.simulateUpgrade(targetProxy1155, targetImpl1155);
|
|
144
|
-
vm.prank(creator);
|
|
145
|
-
ZoraDeployerUtils.deployTestContractForVerification(targetProxy1155, creator);
|
|
146
|
-
|
|
147
|
-
console2.log("1155 upgrade target:", targetProxy1155);
|
|
148
|
-
console2.log("upgrade calldata:");
|
|
149
|
-
console.logBytes(factory1155UpgradeCalldata);
|
|
150
|
-
{
|
|
151
|
-
console2.log("upgrade to address:", targetImpl1155);
|
|
152
|
-
console2.log("upgrade to version:", ZoraCreator1155FactoryImpl(targetImpl1155).contractVersion());
|
|
153
|
-
if (!preminterUpgradeNeeded) {
|
|
154
|
-
console2.log("smol safe upgrade url: ", _buildSafeUrl(chainConfig.factoryOwner, targetProxy1155, factory1155UpgradeCalldata));
|
|
155
|
-
}
|
|
156
|
-
console2.log("------------------------");
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
address factoryOwner = chainConfig.factoryOwner;
|
|
161
|
-
bytes memory preminterUpgradeCalldata;
|
|
162
|
-
|
|
163
|
-
// hack - for now, only check on zora sepolia or goerli
|
|
164
|
-
if (preminterUpgradeNeeded) {
|
|
165
|
-
console2.log("-- preminter upgrade needed --");
|
|
166
|
-
console2.log("preminter upgrade target:", targetPreminterProxy);
|
|
167
|
-
vm.prank(factoryOwner);
|
|
168
|
-
preminterUpgradeCalldata = ZoraDeployerUtils.simulateUpgrade(deployment.preminterProxy, deployment.preminterImpl);
|
|
169
|
-
|
|
170
|
-
address collector = makeAddr("collector");
|
|
171
|
-
address mintReferral = makeAddr("referral");
|
|
172
|
-
vm.deal(collector, 10 ether);
|
|
173
|
-
|
|
174
|
-
address[] memory mintRewardsRecipients = new address[](1);
|
|
175
|
-
mintRewardsRecipients[0] = mintReferral;
|
|
176
|
-
|
|
177
|
-
IZoraCreator1155PremintExecutor.MintArguments memory mintArguments = IZoraCreator1155PremintExecutor.MintArguments({
|
|
178
|
-
mintRecipient: collector,
|
|
179
|
-
mintComment: "",
|
|
180
|
-
mintRewardsRecipients: mintRewardsRecipients
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
vm.startPrank(collector);
|
|
184
|
-
signAndExecutePremintV1(targetPreminterProxy, makeAddr("payoutRecipientA"), mintArguments);
|
|
185
|
-
signAndExecutePremintV2(targetPreminterProxy, makeAddr("payoutRecipientB"), mintArguments);
|
|
186
|
-
|
|
187
|
-
vm.stopPrank();
|
|
188
|
-
|
|
189
|
-
{
|
|
190
|
-
console2.log("upgrade calldata:");
|
|
191
|
-
console.logBytes(preminterUpgradeCalldata);
|
|
192
|
-
console2.log("upgrade to address:", targetPremintImpl);
|
|
193
|
-
if (!is1155UpgradeNeeded) {
|
|
194
|
-
console2.log("smol safe upgrade url: ", _buildSafeUrl(factoryOwner, targetPreminterProxy, preminterUpgradeCalldata));
|
|
195
|
-
}
|
|
196
|
-
console2.log("------------------------");
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// if both needed:
|
|
201
|
-
if (is1155UpgradeNeeded && preminterUpgradeNeeded) {
|
|
202
|
-
address[] memory targets = new address[](2);
|
|
203
|
-
targets[0] = targetProxy1155;
|
|
204
|
-
targets[1] = targetPreminterProxy;
|
|
205
|
-
|
|
206
|
-
bytes[] memory calldatas = new bytes[](2);
|
|
207
|
-
calldatas[0] = factory1155UpgradeCalldata;
|
|
208
|
-
calldatas[1] = preminterUpgradeCalldata;
|
|
209
|
-
|
|
210
|
-
console2.log("multi-upgrade smol safe upgrade url: ", _buildBatchSafeUrl(factoryOwner, targets, calldatas));
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
console2.log("=================\n");
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
function test_fork_simulateUpgrades() external {
|
|
217
|
-
string[] memory forkTestChains = getForkTestChains();
|
|
218
|
-
for (uint256 i = 0; i < forkTestChains.length; i++) {
|
|
219
|
-
simulateUpgradeOnFork(forkTestChains[i]);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|