@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,166 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.13;
|
|
3
|
-
|
|
4
|
-
import "forge-std/Script.sol";
|
|
5
|
-
import {IMinter1155} from "@zoralabs/zora-1155-contracts/src/interfaces/IMinter1155.sol";
|
|
6
|
-
import {IZoraCreator1155PremintExecutor} from "@zoralabs/zora-1155-contracts/src/interfaces/IZoraCreator1155PremintExecutor.sol";
|
|
7
|
-
import {ZoraCreator1155PremintExecutorImpl} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImpl.sol";
|
|
8
|
-
import {ZoraCreator1155FactoryImpl} from "@zoralabs/zora-1155-contracts/src/factory/ZoraCreator1155FactoryImpl.sol";
|
|
9
|
-
import {ZoraCreator1155Attribution, ContractCreationConfig, PremintConfigV2, TokenCreationConfigV2, PremintConfig, TokenCreationConfig} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155Attribution.sol";
|
|
10
|
-
import {ScriptDeploymentConfig} from "./DeploymentConfig.sol";
|
|
11
|
-
import {ZoraCreator1155Impl} from "@zoralabs/zora-1155-contracts/src/nft/ZoraCreator1155Impl.sol";
|
|
12
|
-
|
|
13
|
-
contract DeploymentTestingUtils is Script {
|
|
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
|
-
{
|
|
26
|
-
(address creator, uint256 creatorPrivateKey) = makeAddrAndKey("creator");
|
|
27
|
-
preminterAtProxy = IZoraCreator1155PremintExecutor(premintExecutorProxyAddress);
|
|
28
|
-
|
|
29
|
-
premintConfig = PremintConfig({
|
|
30
|
-
tokenConfig: TokenCreationConfig({
|
|
31
|
-
tokenURI: "blah.token",
|
|
32
|
-
maxSupply: 10,
|
|
33
|
-
maxTokensPerAddress: 5,
|
|
34
|
-
pricePerToken: 0,
|
|
35
|
-
mintStart: 0,
|
|
36
|
-
mintDuration: 0,
|
|
37
|
-
royaltyMintSchedule: 0,
|
|
38
|
-
royaltyBPS: 100,
|
|
39
|
-
royaltyRecipient: payoutRecipient,
|
|
40
|
-
fixedPriceMinter: address(ZoraCreator1155FactoryImpl(address(preminterAtProxy.zora1155Factory())).fixedPriceMinter())
|
|
41
|
-
}),
|
|
42
|
-
uid: 101,
|
|
43
|
-
version: 0,
|
|
44
|
-
deleted: false
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// now interface with proxy preminter - sign and execute the premint
|
|
48
|
-
contractConfig = ContractCreationConfig({contractAdmin: creator, contractName: "blahb", contractURI: "blah.contract"});
|
|
49
|
-
address deterministicAddress = preminterAtProxy.getContractAddress(contractConfig);
|
|
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
|
-
|
|
66
|
-
uint256 quantityToMint = 1;
|
|
67
|
-
|
|
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(payable(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);
|
|
94
|
-
|
|
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
|
|
111
|
-
});
|
|
112
|
-
|
|
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
|
-
}
|
|
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;
|
|
133
|
-
// execute the premint
|
|
134
|
-
uint256 tokenId = preminterAtProxy
|
|
135
|
-
.premintV2{value: mintFee(quantityToMint)}(contractConfig, premintConfig, signature, quantityToMint, mintArguments).tokenId;
|
|
136
|
-
|
|
137
|
-
require(
|
|
138
|
-
ZoraCreator1155Impl(payable(preminterAtProxy.getContractAddress(contractConfig))).delegatedTokenId(premintConfig.uid) == tokenId,
|
|
139
|
-
"token id not created for uid"
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function signPremint(PremintConfigV2 memory premintConfig, address deterministicAddress, uint256 privateKey) private view returns (bytes memory signature) {
|
|
144
|
-
bytes32 signatureVersion = ZoraCreator1155Attribution.HASHED_VERSION_2;
|
|
145
|
-
bytes32 structHash = ZoraCreator1155Attribution.hashPremint(premintConfig);
|
|
146
|
-
// sign the premint
|
|
147
|
-
bytes32 digest = ZoraCreator1155Attribution.premintHashedTypeDataV4(structHash, deterministicAddress, signatureVersion, block.chainid);
|
|
148
|
-
|
|
149
|
-
(uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest);
|
|
150
|
-
return abi.encodePacked(r, s, v);
|
|
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
|
-
}
|
|
166
|
-
}
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
// spdx-license-identifier: mit
|
|
2
|
-
pragma solidity ^0.8.17;
|
|
3
|
-
|
|
4
|
-
import "forge-std/Script.sol";
|
|
5
|
-
import {Deployment, ChainConfig} from "./DeploymentConfig.sol";
|
|
6
|
-
import {ProxyShim} from "@zoralabs/zora-1155-contracts/src/utils/ProxyShim.sol";
|
|
7
|
-
import {DeterministicProxyDeployer} from "./DeterministicProxyDeployer.sol";
|
|
8
|
-
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
|
|
9
|
-
import {UpgradeGate} from "@zoralabs/zora-1155-contracts/src/upgrades/UpgradeGate.sol";
|
|
10
|
-
import {LibString} from "solady/utils/LibString.sol";
|
|
11
|
-
import {ZoraDeployerUtils} from "./ZoraDeployerUtils.sol";
|
|
12
|
-
|
|
13
|
-
struct DeterministicParams {
|
|
14
|
-
bytes proxyDeployerCreationCode;
|
|
15
|
-
bytes proxyCreationCode;
|
|
16
|
-
address deployerAddress;
|
|
17
|
-
address proxyDeployerAddress;
|
|
18
|
-
bytes32 proxyDeployerSalt;
|
|
19
|
-
bytes32 proxyShimSalt;
|
|
20
|
-
bytes32 proxySalt;
|
|
21
|
-
address deterministicProxyAddress;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
contract DeterministicDeployerScript is Script {
|
|
25
|
-
using stdJson for string;
|
|
26
|
-
|
|
27
|
-
// copied from: https://github.com/karmacoma-eth/foundry-playground/blob/main/script/MineSaltScript.sol#L17C1-L36C9
|
|
28
|
-
function mineSalt(address deployer, bytes32 initCodeHash, string memory startsWith) internal returns (bytes32 salt, address expectedAddress) {
|
|
29
|
-
string[] memory args = new string[](8);
|
|
30
|
-
args[0] = "cast";
|
|
31
|
-
args[1] = "create2";
|
|
32
|
-
args[2] = "--starts-with";
|
|
33
|
-
args[3] = startsWith;
|
|
34
|
-
args[4] = "--deployer";
|
|
35
|
-
args[5] = LibString.toHexString(deployer);
|
|
36
|
-
args[6] = "--init-code-hash";
|
|
37
|
-
args[7] = LibString.toHexStringNoPrefix(uint256(initCodeHash), 32);
|
|
38
|
-
string memory result = string(vm.ffi(args));
|
|
39
|
-
|
|
40
|
-
uint256 addressIndex = LibString.indexOf(result, "Address: ");
|
|
41
|
-
string memory addressStr = LibString.slice(result, addressIndex + 9, addressIndex + 9 + 42);
|
|
42
|
-
expectedAddress = vm.parseAddress(addressStr);
|
|
43
|
-
|
|
44
|
-
uint256 saltIndex = LibString.indexOf(result, "Salt: ");
|
|
45
|
-
string memory saltStr = LibString.slice(result, saltIndex + 6, bytes(result).length);
|
|
46
|
-
|
|
47
|
-
salt = bytes32(vm.parseUint(saltStr));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function saltWithAddressInFirst20Bytes(address addressToMakeSaltWith, uint256 suffix) internal pure returns (bytes32) {
|
|
51
|
-
uint256 shifted = uint256(uint160(address(addressToMakeSaltWith))) << 96;
|
|
52
|
-
|
|
53
|
-
// shifted on the left, suffix on the right:
|
|
54
|
-
|
|
55
|
-
return bytes32(shifted | suffix);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function paramsFilePath(string memory proxyName) internal pure returns (string memory) {
|
|
59
|
-
return string.concat("deterministicConfig/", proxyName, "/params.json");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function signaturesFilePath(string memory proxyName) internal pure returns (string memory) {
|
|
63
|
-
return string.concat("deterministicConfig/", proxyName, "/signatures.json");
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function serializeAndSaveOutput(DeterministicParams memory params, string memory proxyName) internal {
|
|
67
|
-
string memory result = "deterministicKey";
|
|
68
|
-
|
|
69
|
-
vm.serializeBytes(result, "proxyDeployerCreationCode", params.proxyDeployerCreationCode);
|
|
70
|
-
vm.serializeBytes(result, "proxyCreationCode", params.proxyCreationCode);
|
|
71
|
-
vm.serializeAddress(result, "deployerAddress", params.deployerAddress);
|
|
72
|
-
vm.serializeAddress(result, "proxyDeployerAddress", params.proxyDeployerAddress);
|
|
73
|
-
vm.serializeBytes32(result, "proxyDeployerSalt", params.proxyDeployerSalt);
|
|
74
|
-
vm.serializeBytes32(result, "proxyShimSalt", params.proxyShimSalt);
|
|
75
|
-
vm.serializeBytes32(result, "proxySalt", params.proxySalt);
|
|
76
|
-
|
|
77
|
-
string memory finalOutput = vm.serializeAddress(result, "deterministicProxyAddress", params.deterministicProxyAddress);
|
|
78
|
-
|
|
79
|
-
console2.log(finalOutput);
|
|
80
|
-
|
|
81
|
-
vm.writeJson(finalOutput, paramsFilePath(proxyName));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function readDeterministicParams(string memory proxyName) internal view returns (DeterministicParams memory params) {
|
|
85
|
-
string memory deployConfig = vm.readFile(paramsFilePath(proxyName));
|
|
86
|
-
|
|
87
|
-
return
|
|
88
|
-
DeterministicParams({
|
|
89
|
-
proxyDeployerCreationCode: deployConfig.readBytes(".proxyDeployerCreationCode"),
|
|
90
|
-
proxyCreationCode: deployConfig.readBytes(".proxyCreationCode"),
|
|
91
|
-
deployerAddress: deployConfig.readAddress(".deployerAddress"),
|
|
92
|
-
proxyDeployerAddress: deployConfig.readAddress(".proxyDeployerAddress"),
|
|
93
|
-
proxyDeployerSalt: deployConfig.readBytes32(".proxyDeployerSalt"),
|
|
94
|
-
proxyShimSalt: deployConfig.readBytes32(".proxyShimSalt"),
|
|
95
|
-
proxySalt: deployConfig.readBytes32(".proxySalt"),
|
|
96
|
-
deterministicProxyAddress: deployConfig.readAddress(".deterministicProxyAddress")
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function readDeterministicParamsAndSig(
|
|
101
|
-
string memory proxyName,
|
|
102
|
-
uint256 chain
|
|
103
|
-
) internal view returns (DeterministicParams memory params, bytes memory signature) {
|
|
104
|
-
string memory signatures = vm.readFile(signaturesFilePath(proxyName));
|
|
105
|
-
|
|
106
|
-
params = readDeterministicParams(proxyName);
|
|
107
|
-
|
|
108
|
-
signature = signatures.readBytes(string.concat(".", string.concat(vm.toString(chain))));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function getProxyDeployerParams() internal view returns (bytes32 proxyDeployerSalt, bytes memory proxyDeployerCreationCode, address proxyDeployerAddress) {
|
|
112
|
-
proxyDeployerSalt = ZoraDeployerUtils.FACTORY_DEPLOYER_DEPLOYMENT_SALT;
|
|
113
|
-
|
|
114
|
-
proxyDeployerCreationCode = type(DeterministicProxyDeployer).creationCode;
|
|
115
|
-
|
|
116
|
-
// we can know deterministically what the address of the new factory proxy deployer will be, given it's deployed from with the salt and init code,
|
|
117
|
-
// from the ImmutableCreate2Factory
|
|
118
|
-
proxyDeployerAddress = ZoraDeployerUtils.IMMUTABLE_CREATE2_FACTORY.findCreate2Address(proxyDeployerSalt, proxyDeployerCreationCode);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function getProxyShimParams(
|
|
122
|
-
address proxyDeployerAddress,
|
|
123
|
-
address deployerAddress,
|
|
124
|
-
uint256 proxyShimSaltSuffix
|
|
125
|
-
) internal pure returns (bytes memory proxyShimInitCode, bytes32 proxyShimSalt, address proxyShimAddress) {
|
|
126
|
-
proxyShimInitCode = abi.encodePacked(type(ProxyShim).creationCode, abi.encode(proxyDeployerAddress));
|
|
127
|
-
|
|
128
|
-
// create any arbitrary salt for proxy shim (this can be anything, we just care about the resulting address)
|
|
129
|
-
proxyShimSalt = saltWithAddressInFirst20Bytes(deployerAddress, proxyShimSaltSuffix);
|
|
130
|
-
|
|
131
|
-
// now get deterministic proxy shim address based on salt, deployer address, which will be DeterministicProxyDeployer address and init code
|
|
132
|
-
proxyShimAddress = Create2.computeAddress(proxyShimSalt, keccak256(proxyShimInitCode), proxyDeployerAddress);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function getProxyParams(
|
|
136
|
-
bytes memory proxyCreationCode,
|
|
137
|
-
address proxyShimAddress,
|
|
138
|
-
address proxyDeployerAddress
|
|
139
|
-
) internal returns (bytes32 proxySalt, address deterministicProxyAddress) {
|
|
140
|
-
bytes memory factoryProxyInitCode = abi.encodePacked(proxyCreationCode, abi.encode(proxyShimAddress, ""));
|
|
141
|
-
bytes32 creationCodeHash = keccak256(factoryProxyInitCode);
|
|
142
|
-
|
|
143
|
-
(proxySalt, deterministicProxyAddress) = mineSalt(proxyDeployerAddress, creationCodeHash, "777777");
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function getDeterministicDeploymentParams(
|
|
147
|
-
address deployerAddress,
|
|
148
|
-
bytes memory proxyCreationCode,
|
|
149
|
-
uint256 proxyShimSaltSuffix
|
|
150
|
-
) internal returns (DeterministicParams memory) {
|
|
151
|
-
// 1. Get salt with first bytes that match address, and resulting determinisitic factory proxy deployer address
|
|
152
|
-
(bytes32 proxyDeployerSalt, bytes memory proxyDeployerCreationCode, address proxyDeployerAddress) = getProxyDeployerParams();
|
|
153
|
-
// replace first 20 characters of salt with deployer address, so that the salt can be used with
|
|
154
|
-
// ImmutableCreate2Factory.safeCreate2 when called by this deployer's account:
|
|
155
|
-
|
|
156
|
-
// 2. Get random proxy shim salt, and resulting deterministic address
|
|
157
|
-
// Proxy shim will be initialized with the factory deployer address as the owner, allowing only the factory deployer to upgrade the proxy,
|
|
158
|
-
// to the eventual factory implementation
|
|
159
|
-
(, bytes32 proxyShimSalt, address proxyShimAddress) = getProxyShimParams({
|
|
160
|
-
proxyDeployerAddress: proxyDeployerAddress,
|
|
161
|
-
deployerAddress: deployerAddress,
|
|
162
|
-
proxyShimSaltSuffix: proxyShimSaltSuffix
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// 3. Mine for a salt that can be used to deterministically create the factory proxy, given the proxy shim address, which is passed as the
|
|
166
|
-
// constructor argument, and the deployer, which is the new factory proxy deployer, which we know the address of deterministically
|
|
167
|
-
(bytes32 proxySalt, address deterministicProxyAddress) = getProxyParams({
|
|
168
|
-
proxyCreationCode: proxyCreationCode,
|
|
169
|
-
proxyShimAddress: proxyShimAddress,
|
|
170
|
-
proxyDeployerAddress: proxyDeployerAddress
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
return
|
|
174
|
-
DeterministicParams({
|
|
175
|
-
proxyDeployerCreationCode: proxyDeployerCreationCode,
|
|
176
|
-
proxyCreationCode: proxyCreationCode,
|
|
177
|
-
deployerAddress: deployerAddress,
|
|
178
|
-
proxyDeployerAddress: proxyDeployerAddress,
|
|
179
|
-
proxyDeployerSalt: proxyDeployerSalt,
|
|
180
|
-
proxyShimSalt: proxyShimSalt,
|
|
181
|
-
proxySalt: proxySalt,
|
|
182
|
-
deterministicProxyAddress: deterministicProxyAddress
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
error MismatchedAddress(address expected, address actual);
|
|
187
|
-
|
|
188
|
-
function readFactoryProxyDeterminsticParams() internal view returns (DeterministicParams memory) {
|
|
189
|
-
return readDeterministicParams("factoryProxy");
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function readPreminterProxyDeterminsticParams() internal view returns (DeterministicParams memory) {
|
|
193
|
-
return readDeterministicParams("premintExecutorProxy");
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function getOrCreateProxyDeployer() internal returns (DeterministicProxyDeployer factoryDeployer) {
|
|
197
|
-
DeterministicParams memory params = readFactoryProxyDeterminsticParams();
|
|
198
|
-
address proxyDeployerAddress = params.proxyDeployerAddress;
|
|
199
|
-
bytes32 proxyDeployerSalt = params.proxyDeployerSalt;
|
|
200
|
-
bytes memory proxyDeployerCreationCode = params.proxyDeployerCreationCode;
|
|
201
|
-
|
|
202
|
-
ZoraDeployerUtils.getOrImmutable2Create(proxyDeployerAddress, proxyDeployerSalt, proxyDeployerCreationCode);
|
|
203
|
-
|
|
204
|
-
factoryDeployer = DeterministicProxyDeployer(proxyDeployerAddress);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function deployDeterministicProxy(string memory proxyName, address implementation, address owner, uint256 chain) internal returns (address) {
|
|
208
|
-
(DeterministicParams memory params, bytes memory signature) = readDeterministicParamsAndSig(proxyName, chain);
|
|
209
|
-
|
|
210
|
-
DeterministicProxyDeployer factoryDeployer = getOrCreateProxyDeployer();
|
|
211
|
-
|
|
212
|
-
address resultAddress = factoryDeployer.createFactoryProxyDeterministic(
|
|
213
|
-
params.proxyShimSalt,
|
|
214
|
-
params.proxySalt,
|
|
215
|
-
params.proxyCreationCode,
|
|
216
|
-
params.deterministicProxyAddress,
|
|
217
|
-
implementation,
|
|
218
|
-
owner,
|
|
219
|
-
signature
|
|
220
|
-
);
|
|
221
|
-
|
|
222
|
-
require(resultAddress == params.deterministicProxyAddress, "DeterministicDeployerScript: proxy address mismatch");
|
|
223
|
-
|
|
224
|
-
return resultAddress;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function deployUpgradeGate(uint256 chain, address upgradeGateOwner) internal returns (address) {
|
|
228
|
-
string memory signatures = vm.readFile(signaturesFilePath("upgradeGate"));
|
|
229
|
-
bytes memory signature = signatures.readBytes(string.concat(".", string.concat(vm.toString(chain))));
|
|
230
|
-
|
|
231
|
-
string memory upgradeGateParams = vm.readFile("./deterministicConfig/upgradeGate/params.json");
|
|
232
|
-
|
|
233
|
-
bytes32 genericCreationSalt = vm.parseJsonBytes32(upgradeGateParams, ".salt");
|
|
234
|
-
bytes memory creationCode = vm.parseJsonBytes(upgradeGateParams, ".creationCode");
|
|
235
|
-
|
|
236
|
-
DeterministicProxyDeployer factoryDeployer = getOrCreateProxyDeployer();
|
|
237
|
-
|
|
238
|
-
address resultAddress = factoryDeployer.createAndInitGenericContractDeterministic({
|
|
239
|
-
genericCreationSalt: genericCreationSalt,
|
|
240
|
-
creationCode: creationCode,
|
|
241
|
-
initCall: abi.encodeWithSelector(UpgradeGate.initialize.selector, upgradeGateOwner),
|
|
242
|
-
signature: signature
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
require(resultAddress == vm.parseJsonAddress(upgradeGateParams, ".upgradeGateAddress"), "DeterministicDeployerScript: upgrade gate address mismatch");
|
|
246
|
-
|
|
247
|
-
return resultAddress;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
// spdx-license-identifier: mit
|
|
2
|
-
pragma solidity ^0.8.17;
|
|
3
|
-
|
|
4
|
-
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
|
|
5
|
-
import {ProxyShim} from "@zoralabs/zora-1155-contracts/src/utils/ProxyShim.sol";
|
|
6
|
-
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
|
|
7
|
-
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
|
8
|
-
|
|
9
|
-
interface IUpgradeableProxy {
|
|
10
|
-
function upgradeTo(address newImplementation) external;
|
|
11
|
-
|
|
12
|
-
function initialize(address newOwner) external;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/// @notice Deterministic proxy deployer for deploying zora 1155 contract suite
|
|
16
|
-
/// @dev Supports both generic contracts and the UUPS shim proxy pattern used for ZORA 1155
|
|
17
|
-
/// @dev Requires approved signatures depending on the salt hashes (pattern from IMMUTABLE_CREATE2_FACTORY)
|
|
18
|
-
contract DeterministicProxyDeployer is EIP712 {
|
|
19
|
-
error FactoryProxyAddressMismatch(address expected, address actual);
|
|
20
|
-
error FailedToInitGenericDeployedContract();
|
|
21
|
-
|
|
22
|
-
constructor() EIP712("DeterministicProxyDeployer", "1") {}
|
|
23
|
-
|
|
24
|
-
/// Creates a new factory proxy at a Deterministic address, with this address as the owner
|
|
25
|
-
/// Upgrades the proxy to the factory implementation, and sets the new owner as the owner.
|
|
26
|
-
/// @param proxyShimSalt Salt for deterministic proxy shim address
|
|
27
|
-
/// @param factoryProxySalt Salt for deterministic factory proxy address
|
|
28
|
-
function _createAndInitializeNewFactoryProxyDeterministic(
|
|
29
|
-
bytes32 proxyShimSalt,
|
|
30
|
-
bytes32 factoryProxySalt,
|
|
31
|
-
bytes calldata proxyCreationCode,
|
|
32
|
-
address expectedFactoryProxyAddress,
|
|
33
|
-
address implementationAddress,
|
|
34
|
-
address newOwner
|
|
35
|
-
) internal returns (address factoryProxyAddress) {
|
|
36
|
-
// create proxy shim and factory proxy deterministically
|
|
37
|
-
ProxyShim proxyShim = new ProxyShim{salt: proxyShimSalt}({_canUpgrade: address(this)});
|
|
38
|
-
|
|
39
|
-
bytes memory creationCode = abi.encodePacked(proxyCreationCode, abi.encode(address(proxyShim), ""));
|
|
40
|
-
|
|
41
|
-
address factoryProxy = Create2.deploy(0, factoryProxySalt, creationCode);
|
|
42
|
-
|
|
43
|
-
if (factoryProxy != expectedFactoryProxyAddress) {
|
|
44
|
-
revert FactoryProxyAddressMismatch(expectedFactoryProxyAddress, address(factoryProxy));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
factoryProxyAddress = address(factoryProxy);
|
|
48
|
-
IUpgradeableProxy proxy = IUpgradeableProxy(address(factoryProxy));
|
|
49
|
-
proxy.upgradeTo(implementationAddress);
|
|
50
|
-
proxy.initialize(newOwner);
|
|
51
|
-
|
|
52
|
-
return factoryProxyAddress;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function _createAndInitGenericContractDeterministic(
|
|
56
|
-
bytes32 genericCreationSalt,
|
|
57
|
-
bytes calldata creationCode,
|
|
58
|
-
bytes calldata initCall
|
|
59
|
-
) internal returns (address resultAddress) {
|
|
60
|
-
resultAddress = Create2.deploy(0, genericCreationSalt, creationCode);
|
|
61
|
-
|
|
62
|
-
(bool success, ) = resultAddress.call(initCall);
|
|
63
|
-
if (!success) {
|
|
64
|
-
revert FailedToInitGenericDeployedContract();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
bytes32 constant DOMAIN_UPGRADEABLE_PROXY =
|
|
69
|
-
keccak256("createProxy(bytes32 proxyShimSalt,bytes32 proxySalt,bytes proxyCreationCode,address implementationAddress,address owner)");
|
|
70
|
-
bytes32 constant DOMAIN_GENERIC_CREATION = keccak256("createGenericContract(bytes32 salt,bytes creationCode,bytes initCall)");
|
|
71
|
-
|
|
72
|
-
function recoverSignature(bytes32 digest, bytes calldata signature) public pure returns (address) {
|
|
73
|
-
return ECDSA.recover(digest, signature);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function hashedDigestFactoryProxy(
|
|
77
|
-
bytes32 proxyShimSalt,
|
|
78
|
-
bytes32 proxySalt,
|
|
79
|
-
bytes calldata proxyCreationCode,
|
|
80
|
-
address implementationAddress,
|
|
81
|
-
address newOwner
|
|
82
|
-
) public view returns (bytes32) {
|
|
83
|
-
return
|
|
84
|
-
_hashTypedDataV4(
|
|
85
|
-
keccak256(abi.encode(DOMAIN_UPGRADEABLE_PROXY, proxyShimSalt, proxySalt, keccak256(proxyCreationCode), implementationAddress, newOwner))
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function hashedDigestGenericCreation(bytes32 salt, bytes calldata creationCode, bytes calldata initCall) public view returns (bytes32) {
|
|
90
|
-
return _hashTypedDataV4(keccak256(abi.encode(DOMAIN_GENERIC_CREATION, salt, keccak256(creationCode), keccak256(initCall))));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function requireContainsCaller(address caller, bytes32 salt) private pure {
|
|
94
|
-
// prevent contract submissions from being stolen from tx.pool by requiring
|
|
95
|
-
// that the first 20 bytes of the submitted salt match msg.sender.
|
|
96
|
-
require((address(bytes20(salt)) == caller) || (bytes20(salt) == bytes20(0)), "Invalid salt - first 20 bytes of the salt must match calling address.");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/// Creates a new factory proxy at a Deterministic address, with this address as the owner
|
|
100
|
-
/// Upgrades the proxy to the factory implementation, and sets the new owner as the owner.
|
|
101
|
-
/// @param proxyShimSalt Salt for deterministic proxy shim address
|
|
102
|
-
/// @param proxySalt Salt for deterministic factory proxy address
|
|
103
|
-
function createFactoryProxyDeterministic(
|
|
104
|
-
bytes32 proxyShimSalt,
|
|
105
|
-
bytes32 proxySalt,
|
|
106
|
-
bytes calldata proxyCreationCode,
|
|
107
|
-
address expectedFactoryProxyAddress,
|
|
108
|
-
address implementationAddress,
|
|
109
|
-
address owner,
|
|
110
|
-
bytes calldata signature
|
|
111
|
-
) external returns (address factoryProxyAddress) {
|
|
112
|
-
address signer = recoverSignature(hashedDigestFactoryProxy(proxyShimSalt, proxySalt, proxyCreationCode, implementationAddress, owner), signature);
|
|
113
|
-
|
|
114
|
-
requireContainsCaller(signer, proxyShimSalt);
|
|
115
|
-
|
|
116
|
-
return
|
|
117
|
-
_createAndInitializeNewFactoryProxyDeterministic(
|
|
118
|
-
proxyShimSalt,
|
|
119
|
-
proxySalt,
|
|
120
|
-
proxyCreationCode,
|
|
121
|
-
expectedFactoryProxyAddress,
|
|
122
|
-
implementationAddress,
|
|
123
|
-
owner
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function createAndInitGenericContractDeterministic(
|
|
128
|
-
bytes32 genericCreationSalt,
|
|
129
|
-
bytes calldata creationCode,
|
|
130
|
-
bytes calldata initCall,
|
|
131
|
-
bytes calldata signature
|
|
132
|
-
) external returns (address resultAddress) {
|
|
133
|
-
address signer = recoverSignature(hashedDigestGenericCreation(genericCreationSalt, creationCode, initCall), signature);
|
|
134
|
-
|
|
135
|
-
requireContainsCaller(signer, genericCreationSalt);
|
|
136
|
-
|
|
137
|
-
return _createAndInitGenericContractDeterministic(genericCreationSalt, creationCode, initCall);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.17;
|
|
3
|
-
|
|
4
|
-
// Extracted interface of ImmutableCreate2Factory.sol, located at https://raw.githubusercontent.com/0age/metamorphic/master/contracts/ImmutableCreate2Factory.sol
|
|
5
|
-
|
|
6
|
-
interface IImmutableCreate2Factory {
|
|
7
|
-
/**
|
|
8
|
-
* @dev Create a contract using CREATE2 by submitting a given salt or nonce
|
|
9
|
-
* along with the initialization code for the contract. Note that the first 20
|
|
10
|
-
* bytes of the salt must match those of the calling address, which prevents
|
|
11
|
-
* contract creation events from being submitted by unintended parties.
|
|
12
|
-
* @param salt bytes32 The nonce that will be passed into the CREATE2 call.
|
|
13
|
-
* @param initializationCode bytes The initialization code that will be passed
|
|
14
|
-
* into the CREATE2 call.
|
|
15
|
-
* @return deploymentAddress Address of the contract that will be created, or the null address
|
|
16
|
-
* if a contract already exists at that address.
|
|
17
|
-
*/
|
|
18
|
-
function safeCreate2(bytes32 salt, bytes calldata initializationCode) external payable returns (address deploymentAddress);
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @dev Compute the address of the contract that will be created when
|
|
22
|
-
* submitting a given salt or nonce to the contract along with the contract's
|
|
23
|
-
* initialization code. The CREATE2 address is computed in accordance with
|
|
24
|
-
* EIP-1014, and adheres to the formula therein of
|
|
25
|
-
* `keccak256( 0xff ++ address ++ salt ++ keccak256(init_code)))[12:]` when
|
|
26
|
-
* performing the computation. The computed address is then checked for any
|
|
27
|
-
* existing contract code - if so, the null address will be returned instead.
|
|
28
|
-
* @param salt bytes32 The nonce passed into the CREATE2 address calculation.
|
|
29
|
-
* @param initCode bytes The contract initialization code to be used.
|
|
30
|
-
* that will be passed into the CREATE2 address calculation.
|
|
31
|
-
* @return deploymentAddress Address of the contract that will be created, or the null address
|
|
32
|
-
* if a contract has already been deployed to that address.
|
|
33
|
-
*/
|
|
34
|
-
function findCreate2Address(bytes32 salt, bytes calldata initCode) external view returns (address deploymentAddress);
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @dev Compute the address of the contract that will be created when
|
|
38
|
-
* submitting a given salt or nonce to the contract along with the keccak256
|
|
39
|
-
* hash of the contract's initialization code. The CREATE2 address is computed
|
|
40
|
-
* in accordance with EIP-1014, and adheres to the formula therein of
|
|
41
|
-
* `keccak256( 0xff ++ address ++ salt ++ keccak256(init_code)))[12:]` when
|
|
42
|
-
* performing the computation. The computed address is then checked for any
|
|
43
|
-
* existing contract code - if so, the null address will be returned instead.
|
|
44
|
-
* @param salt bytes32 The nonce passed into the CREATE2 address calculation.
|
|
45
|
-
* @param initCodeHash bytes32 The keccak256 hash of the initialization code
|
|
46
|
-
* that will be passed into the CREATE2 address calculation.
|
|
47
|
-
* @return deploymentAddress Address of the contract that will be created, or the null address
|
|
48
|
-
* if a contract has already been deployed to that address.
|
|
49
|
-
*/
|
|
50
|
-
function findCreate2AddressViaHash(bytes32 salt, bytes32 initCodeHash) external view returns (address deploymentAddress);
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @dev Determine if a contract has already been deployed by the factory to a
|
|
54
|
-
* given address.
|
|
55
|
-
* @param deploymentAddress address The contract address to check.
|
|
56
|
-
* @return True if the contract has been deployed, false otherwise.
|
|
57
|
-
*/
|
|
58
|
-
function hasBeenDeployed(address deploymentAddress) external view returns (bool);
|
|
59
|
-
}
|