@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,302 +0,0 @@
|
|
|
1
|
-
import { createAccount } from "@turnkey/viem";
|
|
2
|
-
import { TurnkeyClient } from "@turnkey/http";
|
|
3
|
-
import { Address, encodeFunctionData, parseAbi, LocalAccount, Hex } from "viem";
|
|
4
|
-
import { ApiKeyStamper } from "@turnkey/api-key-stamper";
|
|
5
|
-
import { glob } from "glob";
|
|
6
|
-
import * as path from "path";
|
|
7
|
-
import * as dotenv from "dotenv";
|
|
8
|
-
import { writeFile, readFile } from "fs/promises";
|
|
9
|
-
import {
|
|
10
|
-
ConfiguredSalt,
|
|
11
|
-
DeterministicDeploymentConfig,
|
|
12
|
-
GenericDeploymentConfiguration,
|
|
13
|
-
signDeployFactory,
|
|
14
|
-
signGenericDeploy,
|
|
15
|
-
} from "../package/deployment";
|
|
16
|
-
import { fileURLToPath } from "url";
|
|
17
|
-
import { dirname } from "path";
|
|
18
|
-
|
|
19
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
-
const __dirname = dirname(__filename);
|
|
21
|
-
|
|
22
|
-
// Load environment variables from `.env.local`
|
|
23
|
-
dotenv.config({ path: path.resolve(__dirname, "../.env") });
|
|
24
|
-
|
|
25
|
-
type ChainConfig = {
|
|
26
|
-
chainId: number;
|
|
27
|
-
implementationAddress: Address;
|
|
28
|
-
owner: Address;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
async function signAndSaveSignatures({
|
|
32
|
-
turnkeyAccount,
|
|
33
|
-
chainConfigs,
|
|
34
|
-
proxyName,
|
|
35
|
-
chainId,
|
|
36
|
-
}: {
|
|
37
|
-
turnkeyAccount: LocalAccount;
|
|
38
|
-
chainConfigs: ChainConfig[];
|
|
39
|
-
proxyName: "factoryProxy" | "premintExecutorProxy";
|
|
40
|
-
chainId: number;
|
|
41
|
-
}) {
|
|
42
|
-
const configFolder = path.resolve(
|
|
43
|
-
__dirname,
|
|
44
|
-
`../deterministicConfig/${proxyName}/`,
|
|
45
|
-
);
|
|
46
|
-
const configFile = path.join(configFolder, "params.json");
|
|
47
|
-
const deterministicDeployConfig = JSON.parse(
|
|
48
|
-
await readFile(configFile, "utf-8"),
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const deploymentConfig: DeterministicDeploymentConfig = {
|
|
52
|
-
proxyDeployerAddress:
|
|
53
|
-
deterministicDeployConfig.proxyDeployerAddress as Address,
|
|
54
|
-
proxySalt: deterministicDeployConfig.proxySalt as ConfiguredSalt,
|
|
55
|
-
proxyShimSalt: deterministicDeployConfig.proxyShimSalt as ConfiguredSalt,
|
|
56
|
-
proxyCreationCode: deterministicDeployConfig.proxyCreationCode as Address,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const chainConfig = chainConfigs.find((x) => x.chainId === chainId);
|
|
60
|
-
|
|
61
|
-
if (!chainConfig) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const signature = await signDeployFactory({
|
|
66
|
-
account: turnkeyAccount,
|
|
67
|
-
implementationAddress: chainConfig.implementationAddress,
|
|
68
|
-
owner: chainConfig.owner,
|
|
69
|
-
chainId: chainConfig.chainId,
|
|
70
|
-
deterministicDeploymentConfig: deploymentConfig,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const existingSignatures = JSON.parse(
|
|
74
|
-
await readFile(path.join(configFolder, "signatures.json"), "utf-8"),
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const updated = {
|
|
78
|
-
...existingSignatures,
|
|
79
|
-
[chainId]: signature,
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// aggregate above to object of key value pair indexed by chain id as number:
|
|
83
|
-
// write as json to ../deterministicConfig/factoryDeploySignatures.json:
|
|
84
|
-
await writeFile(
|
|
85
|
-
path.join(configFolder, "signatures.json"),
|
|
86
|
-
JSON.stringify(updated, null, 2),
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async function signAndSaveUpgradeGate({
|
|
91
|
-
turnkeyAccount,
|
|
92
|
-
chainConfigs,
|
|
93
|
-
proxyName,
|
|
94
|
-
chainId,
|
|
95
|
-
}: {
|
|
96
|
-
turnkeyAccount: LocalAccount;
|
|
97
|
-
chainConfigs: {
|
|
98
|
-
chainId: number;
|
|
99
|
-
owner: Address;
|
|
100
|
-
}[];
|
|
101
|
-
proxyName: "upgradeGate";
|
|
102
|
-
chainId: number;
|
|
103
|
-
}) {
|
|
104
|
-
const configFolder = path.resolve(
|
|
105
|
-
__dirname,
|
|
106
|
-
`../deterministicConfig/${proxyName}/`,
|
|
107
|
-
);
|
|
108
|
-
const configFile = path.join(configFolder, "params.json");
|
|
109
|
-
|
|
110
|
-
const deterministicDeployConfig = JSON.parse(
|
|
111
|
-
await readFile(configFile, "utf-8"),
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
const deploymentConfig: GenericDeploymentConfiguration = {
|
|
115
|
-
creationCode: deterministicDeployConfig.creationCode! as Hex,
|
|
116
|
-
salt: deterministicDeployConfig.salt! as Hex,
|
|
117
|
-
deployerAddress: deterministicDeployConfig.deployerAddress! as Address,
|
|
118
|
-
upgradeGateAddress:
|
|
119
|
-
deterministicDeployConfig.upgradeGateAddress! as Address,
|
|
120
|
-
proxyDeployerAddress:
|
|
121
|
-
deterministicDeployConfig.proxyDeployerAddress! as Address,
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const upgradeGateAbi = parseAbi(["function initialize(address owner)"]);
|
|
125
|
-
|
|
126
|
-
const chainConfig = chainConfigs.find((x) => x.chainId === chainId);
|
|
127
|
-
|
|
128
|
-
if (!chainConfig) {
|
|
129
|
-
throw new Error(`No chain config found for chain id ${chainId}`);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const initCall = encodeFunctionData({
|
|
133
|
-
abi: upgradeGateAbi,
|
|
134
|
-
functionName: "initialize",
|
|
135
|
-
args: [chainConfig.owner],
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
console.log("signing", { turnkeyAccount, deploymentConfig });
|
|
139
|
-
|
|
140
|
-
const signature = await signGenericDeploy({
|
|
141
|
-
account: turnkeyAccount,
|
|
142
|
-
chainId: chainConfig.chainId,
|
|
143
|
-
config: deploymentConfig,
|
|
144
|
-
initCall,
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
const existingSignatures = JSON.parse(
|
|
148
|
-
await readFile(path.join(configFolder, "signatures.json"), "utf-8"),
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
const updated = {
|
|
152
|
-
...existingSignatures,
|
|
153
|
-
[chainId]: signature,
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
// write as json to ../deterministicConfig/factoryDeploySignatures.json:
|
|
157
|
-
await writeFile(
|
|
158
|
-
path.join(configFolder, "signatures.json"),
|
|
159
|
-
JSON.stringify(updated, null, 2),
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const getChainConfigs = async () => {
|
|
164
|
-
const chainConfigsFiles = await glob(
|
|
165
|
-
path.resolve(__dirname, "../chainConfigs/*.json"),
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
const chainConfigs = await Promise.all(
|
|
169
|
-
chainConfigsFiles.map(async (chainConfigFile) => {
|
|
170
|
-
const chainId = parseInt(path.basename(chainConfigFile).split(".")[0]!);
|
|
171
|
-
|
|
172
|
-
// read file and process JSON contents:
|
|
173
|
-
const fileContents = await import(chainConfigFile);
|
|
174
|
-
|
|
175
|
-
return {
|
|
176
|
-
chainId,
|
|
177
|
-
owner: fileContents["FACTORY_OWNER"]! as Address,
|
|
178
|
-
};
|
|
179
|
-
}),
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
return chainConfigs;
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const getFactoryImplConfigs = async () => {
|
|
186
|
-
const addresseFiles = await glob(
|
|
187
|
-
path.resolve(__dirname, "../addresses/*.json"),
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
const chainConfigs = await Promise.all(
|
|
191
|
-
addresseFiles.map(async (addressConfigFile) => {
|
|
192
|
-
const chainId = parseInt(path.basename(addressConfigFile).split(".")[0]!);
|
|
193
|
-
|
|
194
|
-
// read file and process JSON contents:
|
|
195
|
-
const fileContents = await import(addressConfigFile);
|
|
196
|
-
|
|
197
|
-
// read chain config file as json, which is located at: ../chainConfigs/${chainId}.json:
|
|
198
|
-
const chainConfig = await import(
|
|
199
|
-
path.resolve(__dirname, `../chainConfigs/${chainId}.json`)
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
return {
|
|
203
|
-
chainId,
|
|
204
|
-
implementationAddress: fileContents["FACTORY_IMPL"] as Address,
|
|
205
|
-
owner: chainConfig["FACTORY_OWNER"] as Address,
|
|
206
|
-
};
|
|
207
|
-
}),
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
return chainConfigs;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
const getPreminterImplConfigs = async () => {
|
|
214
|
-
const addresseFiles = await glob(
|
|
215
|
-
path.resolve(__dirname, "../addresses/*.json"),
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
const chainConfigs = await Promise.all(
|
|
219
|
-
addresseFiles.map(async (addressConfigFile) => {
|
|
220
|
-
const chainId = parseInt(path.basename(addressConfigFile).split(".")[0]!);
|
|
221
|
-
|
|
222
|
-
// read file and process JSON contents:
|
|
223
|
-
const fileContents = await import(addressConfigFile);
|
|
224
|
-
|
|
225
|
-
// read chain config file as json, which is located at: ../chainConfigs/${chainId}.json:
|
|
226
|
-
const chainConfig = await import(
|
|
227
|
-
path.resolve(__dirname, `../chainConfigs/${chainId}.json`)
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
return {
|
|
231
|
-
chainId,
|
|
232
|
-
implementationAddress: fileContents["PREMINTER_IMPL"] as Address,
|
|
233
|
-
owner: chainConfig["FACTORY_OWNER"] as Address,
|
|
234
|
-
};
|
|
235
|
-
}),
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
return chainConfigs.filter((x) => x.implementationAddress !== undefined);
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
function getChainIdPositionalArg() {
|
|
242
|
-
// parse chain id as first argument:
|
|
243
|
-
const chainIdArg = process.argv[2];
|
|
244
|
-
|
|
245
|
-
if (!chainIdArg) {
|
|
246
|
-
throw new Error("Must provide chain id as first argument");
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return parseInt(chainIdArg);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
async function main() {
|
|
253
|
-
// Create a Turnkey HTTP client with API key credentials
|
|
254
|
-
const httpClient = new TurnkeyClient(
|
|
255
|
-
{
|
|
256
|
-
baseUrl: "https://api.turnkey.com",
|
|
257
|
-
},
|
|
258
|
-
// This uses API key credentials.
|
|
259
|
-
// If you're using passkeys, use `@turnkey/webauthn-stamper` to collect webauthn signatures:
|
|
260
|
-
new ApiKeyStamper({
|
|
261
|
-
apiPublicKey: process.env.TURNKEY_API_PUBLIC_KEY!,
|
|
262
|
-
apiPrivateKey: process.env.TURNKEY_API_PRIVATE_KEY!,
|
|
263
|
-
}),
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
// Create the Viem custom account
|
|
267
|
-
const turnkeyAccount = await createAccount({
|
|
268
|
-
client: httpClient,
|
|
269
|
-
organizationId: process.env.TURNKEY_ORGANIZATION_ID!,
|
|
270
|
-
signWith: process.env.TURNKEY_PRIVATE_KEY_ID!,
|
|
271
|
-
// optional; will be fetched from Turnkey if not provided
|
|
272
|
-
ethereumAddress: process.env.TURNKEY_TARGET_ADDRESS!,
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
const chainId = getChainIdPositionalArg();
|
|
276
|
-
|
|
277
|
-
await signAndSaveSignatures({
|
|
278
|
-
turnkeyAccount,
|
|
279
|
-
chainConfigs: await getFactoryImplConfigs(),
|
|
280
|
-
proxyName: "factoryProxy",
|
|
281
|
-
chainId,
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
await signAndSaveSignatures({
|
|
285
|
-
turnkeyAccount,
|
|
286
|
-
chainConfigs: await getPreminterImplConfigs(),
|
|
287
|
-
proxyName: "premintExecutorProxy",
|
|
288
|
-
chainId,
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
await signAndSaveUpgradeGate({
|
|
292
|
-
turnkeyAccount,
|
|
293
|
-
chainConfigs: await getChainConfigs(),
|
|
294
|
-
proxyName: "upgradeGate",
|
|
295
|
-
chainId,
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
main().catch((error) => {
|
|
300
|
-
console.error(error);
|
|
301
|
-
process.exit(1);
|
|
302
|
-
});
|
package/src/DeploymentConfig.sol
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.17;
|
|
3
|
-
|
|
4
|
-
import "forge-std/Test.sol";
|
|
5
|
-
import {CommonBase} from "forge-std/Base.sol";
|
|
6
|
-
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
|
|
7
|
-
import {Script} from "forge-std/Script.sol";
|
|
8
|
-
|
|
9
|
-
/// @notice Chain configuration for constants set manually during deploy. Does not get written to after deploys.
|
|
10
|
-
struct ChainConfig {
|
|
11
|
-
/// @notice The user that owns the factory proxy. Allows ability to upgrade for new implementations deployed.
|
|
12
|
-
address factoryOwner;
|
|
13
|
-
/// @notice Mint fee recipient user
|
|
14
|
-
address mintFeeRecipient;
|
|
15
|
-
/// @notice Protocol rewards contract address
|
|
16
|
-
address protocolRewards;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/// @notice Deployment addresses – set to new deployed addresses by the scripts.
|
|
20
|
-
struct Deployment {
|
|
21
|
-
/// @notice Fixed price minter strategy configuration contract
|
|
22
|
-
address fixedPriceSaleStrategy;
|
|
23
|
-
/// @notice Merkle minter strategy (formerly presale) configuration
|
|
24
|
-
address merkleMintSaleStrategy;
|
|
25
|
-
/// @notice Redeem minter factory contract for redeem sales configurations
|
|
26
|
-
address redeemMinterFactory;
|
|
27
|
-
/// @notice Implementation contract for the 1155 contract
|
|
28
|
-
address contract1155Impl;
|
|
29
|
-
/// @notice Implementation contract version for the 1155 contract
|
|
30
|
-
string contract1155ImplVersion;
|
|
31
|
-
/// @notice Factory implementation contract that is the impl for the above proxy.
|
|
32
|
-
address factoryImpl;
|
|
33
|
-
/// @notice Factory proxy contract that creates zora drops style NFT contracts
|
|
34
|
-
address factoryProxy;
|
|
35
|
-
/// @notice Preminter proxy contract address
|
|
36
|
-
address preminterImpl;
|
|
37
|
-
/// @notice Preminter implementation contract address
|
|
38
|
-
address preminterProxy;
|
|
39
|
-
/// @notice Upgrade gate
|
|
40
|
-
address upgradeGate;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
abstract contract DeploymentConfig is Script {
|
|
44
|
-
using stdJson for string;
|
|
45
|
-
|
|
46
|
-
/// @notice ChainID convenience getter
|
|
47
|
-
/// @return id chainId
|
|
48
|
-
function chainId() internal view virtual returns (uint256 id);
|
|
49
|
-
|
|
50
|
-
///
|
|
51
|
-
// These are the JSON key constants to standardize writing and reading configuration
|
|
52
|
-
///
|
|
53
|
-
|
|
54
|
-
string constant FACTORY_OWNER = "FACTORY_OWNER";
|
|
55
|
-
string constant MINT_FEE_RECIPIENT = "MINT_FEE_RECIPIENT";
|
|
56
|
-
string constant PROTOCOL_REWARDS = "PROTOCOL_REWARDS";
|
|
57
|
-
|
|
58
|
-
string constant FIXED_PRICE_SALE_STRATEGY = "FIXED_PRICE_SALE_STRATEGY";
|
|
59
|
-
string constant MERKLE_MINT_SALE_STRATEGY = "MERKLE_MINT_SALE_STRATEGY";
|
|
60
|
-
string constant REDEEM_MINTER_FACTORY = "REDEEM_MINTER_FACTORY";
|
|
61
|
-
string constant CONTRACT_1155_IMPL = "CONTRACT_1155_IMPL";
|
|
62
|
-
string constant CONTRACT_1155_IMPL_VERSION = "CONTRACT_1155_IMPL_VERSION";
|
|
63
|
-
string constant FACTORY_IMPL = "FACTORY_IMPL";
|
|
64
|
-
string constant FACTORY_PROXY = "FACTORY_PROXY";
|
|
65
|
-
string constant PREMINTER_PROXY = "PREMINTER_PROXY";
|
|
66
|
-
string constant PREMINTER_IMPL = "PREMINTER_IMPL";
|
|
67
|
-
string constant UPGRADE_GATE = "UPGRADE_GATE";
|
|
68
|
-
|
|
69
|
-
/// @notice Return a prefixed key for reading with a ".".
|
|
70
|
-
/// @param key key to prefix
|
|
71
|
-
/// @return prefixed key
|
|
72
|
-
function getKeyPrefix(string memory key) internal pure returns (string memory) {
|
|
73
|
-
return string.concat(".", key);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/// @notice Returns the chain configuration struct from the JSON configuration file
|
|
77
|
-
/// @return chainConfig structure
|
|
78
|
-
function getChainConfig() internal view returns (ChainConfig memory chainConfig) {
|
|
79
|
-
string memory json = vm.readFile(string.concat("chainConfigs/", Strings.toString(chainId()), ".json"));
|
|
80
|
-
chainConfig.factoryOwner = json.readAddress(getKeyPrefix(FACTORY_OWNER));
|
|
81
|
-
chainConfig.mintFeeRecipient = json.readAddress(getKeyPrefix(MINT_FEE_RECIPIENT));
|
|
82
|
-
chainConfig.protocolRewards = json.readAddress(getKeyPrefix(PROTOCOL_REWARDS));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function readAddressOrDefaultToZero(string memory json, string memory key) internal view returns (address addr) {
|
|
86
|
-
string memory keyPrefix = getKeyPrefix(key);
|
|
87
|
-
|
|
88
|
-
if (vm.keyExists(json, keyPrefix)) {
|
|
89
|
-
addr = json.readAddress(keyPrefix);
|
|
90
|
-
} else {
|
|
91
|
-
addr = address(0);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/// @notice Get the deployment configuration struct from the JSON configuration file
|
|
96
|
-
/// @return deployment deployment configuration structure
|
|
97
|
-
function getDeployment() internal view returns (Deployment memory deployment) {
|
|
98
|
-
string memory json = vm.readFile(string.concat("addresses/", Strings.toString(chainId()), ".json"));
|
|
99
|
-
deployment.fixedPriceSaleStrategy = readAddressOrDefaultToZero(json, FIXED_PRICE_SALE_STRATEGY);
|
|
100
|
-
deployment.merkleMintSaleStrategy = readAddressOrDefaultToZero(json, MERKLE_MINT_SALE_STRATEGY);
|
|
101
|
-
deployment.redeemMinterFactory = readAddressOrDefaultToZero(json, REDEEM_MINTER_FACTORY);
|
|
102
|
-
deployment.contract1155Impl = readAddressOrDefaultToZero(json, CONTRACT_1155_IMPL);
|
|
103
|
-
deployment.contract1155ImplVersion = json.readString(getKeyPrefix(CONTRACT_1155_IMPL_VERSION));
|
|
104
|
-
deployment.factoryImpl = readAddressOrDefaultToZero(json, FACTORY_IMPL);
|
|
105
|
-
deployment.factoryProxy = readAddressOrDefaultToZero(json, FACTORY_PROXY);
|
|
106
|
-
deployment.preminterImpl = readAddressOrDefaultToZero(json, PREMINTER_IMPL);
|
|
107
|
-
deployment.preminterProxy = readAddressOrDefaultToZero(json, PREMINTER_PROXY);
|
|
108
|
-
deployment.upgradeGate = readAddressOrDefaultToZero(json, UPGRADE_GATE);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
contract ForkDeploymentConfig is DeploymentConfig {
|
|
113
|
-
function chainId() internal view override returns (uint256 id) {
|
|
114
|
-
return block.chainid;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
contract ScriptDeploymentConfig is DeploymentConfig {
|
|
119
|
-
function chainId() internal view override returns (uint256 id) {
|
|
120
|
-
assembly {
|
|
121
|
-
id := chainid()
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
@@ -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
|
-
}
|