@zoralabs/protocol-deployments 0.0.11 → 0.0.14-MINT.0
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 +18 -20
- package/CHANGELOG.md +26 -0
- package/README.md +3 -9
- package/dist/{package/chainConfigs.d.ts → chainConfigs.d.ts} +5 -3
- package/dist/chainConfigs.d.ts.map +1 -0
- package/dist/deployment.d.ts.map +1 -0
- package/dist/index.cjs +68 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +64 -57
- package/dist/index.js.map +1 -1
- package/dist/{package/wagmiGenerated.d.ts → wagmiGenerated.d.ts} +158 -68
- package/dist/{package/wagmiGenerated.d.ts.map → wagmiGenerated.d.ts.map} +1 -1
- package/package.json +18 -30
- package/{script → scripts}/bundle-chainConfigs.mjs +9 -7
- package/{package → src}/chainConfigs.ts +12 -10
- package/{package → src}/wagmiGenerated.ts +107 -54
- 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 -14
- package/addresses/10.json +0 -14
- package/addresses/11155111.json +0 -9
- package/addresses/420.json +0 -14
- package/addresses/424.json +0 -11
- package/addresses/5.json +0 -14
- package/addresses/58008.json +0 -11
- package/addresses/7777777.json +0 -15
- package/addresses/8453.json +0 -14
- package/addresses/84531.json +0 -14
- package/addresses/999.json +0 -15
- package/addresses/999999999.json +0 -14
- package/chainConfigs/1.json +0 -5
- package/chainConfigs/10.json +0 -5
- package/chainConfigs/11155111.json +0 -4
- 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 -11
- package/deterministicConfig/upgradeGate/params.json +0 -7
- package/deterministicConfig/upgradeGate/signatures.json +0 -14
- package/dist/package/batchPublish.test.d.ts +0 -451
- 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/remappings.txt +0 -9
- package/script/CalculateDeterministicParams.s.sol +0 -84
- package/script/DeployMintersAndImplementations.s.sol +0 -31
- 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 -66
- package/script/signDeploymentTransactions.ts +0 -277
- 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 -145
- 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,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
|
-
}
|
package/src/ZoraDeployerBase.sol
DELETED
|
@@ -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
|
-
}
|
|
@@ -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
|
-
}
|