@zoralabs/protocol-deployments 0.1.8 → 0.1.10

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.
@@ -0,0 +1,226 @@
1
+ import {
2
+ Address,
3
+ TypedDataDomain,
4
+ TypedData,
5
+ TypedDataToPrimitiveTypes,
6
+ } from "abitype";
7
+ import { TypedDataDefinition } from "viem";
8
+ import { zoraMints1155Address } from "./generated/wagmi";
9
+
10
+ const premintTypedDataDomain = ({
11
+ chainId,
12
+ version,
13
+ creator1155Contract: verifyingContract,
14
+ }: {
15
+ chainId: number;
16
+ version: "1" | "2";
17
+ creator1155Contract: Address;
18
+ }): TypedDataDomain => ({
19
+ chainId,
20
+ name: "Preminter",
21
+ version,
22
+ verifyingContract,
23
+ });
24
+
25
+ const premintV1TypedDataType = {
26
+ CreatorAttribution: [
27
+ { name: "tokenConfig", type: "TokenCreationConfig" },
28
+ // unique id scoped to the contract and token to create.
29
+ // ensure that a signature can be replaced, as long as the replacement
30
+ // has the same uid, and a newer version.
31
+ { name: "uid", type: "uint32" },
32
+ { name: "version", type: "uint32" },
33
+ // if this update should result in the signature being deleted.
34
+ { name: "deleted", type: "bool" },
35
+ ],
36
+ TokenCreationConfig: [
37
+ { name: "tokenURI", type: "string" },
38
+ { name: "maxSupply", type: "uint256" },
39
+ { name: "maxTokensPerAddress", type: "uint64" },
40
+ { name: "pricePerToken", type: "uint96" },
41
+ { name: "mintStart", type: "uint64" },
42
+ { name: "mintDuration", type: "uint64" },
43
+ { name: "royaltyMintSchedule", type: "uint32" },
44
+ { name: "royaltyBPS", type: "uint32" },
45
+ { name: "royaltyRecipient", type: "address" },
46
+ { name: "fixedPriceMinter", type: "address" },
47
+ ],
48
+ } as const satisfies TypedData;
49
+
50
+ /**
51
+ * Builds a typed data definition for a PremintConfigV1 to be signed
52
+ * @returns
53
+ */
54
+ export const premintV1TypedDataDefinition = ({
55
+ chainId,
56
+ creator1155Contract,
57
+ message,
58
+ }: {
59
+ chainId: number;
60
+ creator1155Contract: Address;
61
+ message: TypedDataToPrimitiveTypes<
62
+ typeof premintV1TypedDataType
63
+ >["CreatorAttribution"];
64
+ }): TypedDataDefinition<
65
+ typeof premintV1TypedDataType,
66
+ "CreatorAttribution"
67
+ > => ({
68
+ types: premintV1TypedDataType,
69
+ primaryType: "CreatorAttribution",
70
+ domain: premintTypedDataDomain({
71
+ chainId,
72
+ version: "1",
73
+ creator1155Contract,
74
+ }),
75
+ message,
76
+ });
77
+
78
+ const premintV2TypedDataType = {
79
+ CreatorAttribution: [
80
+ { name: "tokenConfig", type: "TokenCreationConfig" },
81
+ // unique id scoped to the contract and token to create.
82
+ // ensure that a signature can be replaced, as long as the replacement
83
+ // has the same uid, and a newer version.
84
+ { name: "uid", type: "uint32" },
85
+ { name: "version", type: "uint32" },
86
+ // if this update should result in the signature being deleted.
87
+ { name: "deleted", type: "bool" },
88
+ ],
89
+ TokenCreationConfig: [
90
+ { name: "tokenURI", type: "string" },
91
+ { name: "maxSupply", type: "uint256" },
92
+ { name: "maxTokensPerAddress", type: "uint64" },
93
+ { name: "pricePerToken", type: "uint96" },
94
+ { name: "mintStart", type: "uint64" },
95
+ { name: "mintDuration", type: "uint64" },
96
+ { name: "royaltyBPS", type: "uint32" },
97
+ { name: "payoutRecipient", type: "address" },
98
+ { name: "fixedPriceMinter", type: "address" },
99
+ { name: "createReferral", type: "address" },
100
+ ],
101
+ } as const satisfies TypedData;
102
+
103
+ /**
104
+ * Builds a typed data definition for a PremintConfigV2 to be signed
105
+ */
106
+ export const premintV2TypedDataDefinition = ({
107
+ chainId,
108
+ creator1155Contract,
109
+ message,
110
+ }: {
111
+ chainId: number;
112
+ creator1155Contract: Address;
113
+ message: TypedDataToPrimitiveTypes<
114
+ typeof premintV2TypedDataType
115
+ >["CreatorAttribution"];
116
+ }): TypedDataDefinition<
117
+ typeof premintV2TypedDataType,
118
+ "CreatorAttribution"
119
+ > => ({
120
+ types: premintV2TypedDataType,
121
+ primaryType: "CreatorAttribution",
122
+ domain: premintTypedDataDomain({
123
+ chainId,
124
+ version: "2",
125
+ creator1155Contract,
126
+ }),
127
+ message,
128
+ });
129
+
130
+ const permitSafeTransferTypedDataType = {
131
+ PermitSafeTransfer: [
132
+ { name: "owner", type: "address" },
133
+ { name: "to", type: "address" },
134
+ { name: "tokenId", type: "uint256" },
135
+ { name: "quantity", type: "uint256" },
136
+ { name: "safeTransferData", type: "bytes" },
137
+ { name: "nonce", type: "uint256" },
138
+ { name: "deadline", type: "uint256" },
139
+ ],
140
+ } as const;
141
+
142
+ /**
143
+ * Builds a typed data definition for a PermitSafeTransfer on the Mints1155 contract to be signed
144
+ */
145
+ export const mintsSafeTransferTypedDataDefinition = ({
146
+ chainId,
147
+ message,
148
+ }: {
149
+ chainId: keyof typeof zoraMints1155Address;
150
+ message: TypedDataToPrimitiveTypes<
151
+ typeof permitSafeTransferTypedDataType
152
+ >["PermitSafeTransfer"];
153
+ }): TypedDataDefinition<
154
+ typeof permitSafeTransferTypedDataType,
155
+ "PermitSafeTransfer"
156
+ > => ({
157
+ types: permitSafeTransferTypedDataType,
158
+ message,
159
+ primaryType: "PermitSafeTransfer",
160
+ domain: {
161
+ chainId,
162
+ name: "Mints",
163
+ version: "1",
164
+ verifyingContract: zoraMints1155Address[chainId],
165
+ },
166
+ });
167
+
168
+ const permitSafeBatchTransferTypedDataType = {
169
+ Permit: [
170
+ {
171
+ name: "owner",
172
+ type: "address",
173
+ },
174
+ {
175
+ name: "to",
176
+ type: "address",
177
+ },
178
+ {
179
+ name: "tokenIds",
180
+ type: "uint256[]",
181
+ },
182
+ {
183
+ name: "quantities",
184
+ type: "uint256[]",
185
+ },
186
+ {
187
+ name: "safeTransferData",
188
+ type: "bytes",
189
+ },
190
+ {
191
+ name: "nonce",
192
+ type: "uint256",
193
+ },
194
+ {
195
+ name: "deadline",
196
+ type: "uint256",
197
+ },
198
+ ],
199
+ } as const;
200
+
201
+ /**
202
+ * Builds a typed data definition for a PermitSafeTransferBatch on the Mints1155 contract to be signed
203
+ * @returns
204
+ */
205
+ export const mintsSafeTransferBatchTypedDataDefinition = ({
206
+ chainId,
207
+ message,
208
+ }: {
209
+ chainId: keyof typeof zoraMints1155Address;
210
+ message: TypedDataToPrimitiveTypes<
211
+ typeof permitSafeBatchTransferTypedDataType
212
+ >["Permit"];
213
+ }): TypedDataDefinition<
214
+ typeof permitSafeBatchTransferTypedDataType,
215
+ "Permit"
216
+ > => ({
217
+ types: permitSafeBatchTransferTypedDataType,
218
+ message,
219
+ primaryType: "Permit",
220
+ domain: {
221
+ chainId,
222
+ name: "Mints",
223
+ version: "1",
224
+ verifyingContract: zoraMints1155Address[chainId],
225
+ },
226
+ });
package/wagmi.config.ts DELETED
@@ -1,189 +0,0 @@
1
- import { defineConfig } from "@wagmi/cli";
2
- import { Abi, zeroAddress } from "viem";
3
- import { readdirSync, readFileSync } from "fs";
4
- import * as abis from "@zoralabs/zora-1155-contracts";
5
- import {
6
- zoraMints1155ABI,
7
- zoraMintsManagerImplABI,
8
- mintsEthUnwrapperAndCallerABI,
9
- iUnwrapAndForwardActionABI,
10
- } from "@zoralabs/mints-contracts";
11
-
12
- type Address = `0x${string}`;
13
-
14
- type Addresses = {
15
- [contractName: string]: {
16
- address: {
17
- [chainId: number]: Address;
18
- };
19
- abi: Abi;
20
- };
21
- };
22
-
23
- const get1155Addresses = () => {
24
- const addresses: Addresses = {};
25
-
26
- const addressesFiles = readdirSync("../1155-deployments/addresses");
27
-
28
- const addAddress = ({
29
- contractName,
30
- chainId,
31
- address,
32
- abi,
33
- }: {
34
- contractName: string;
35
- chainId: number;
36
- address?: Address;
37
- abi: Abi;
38
- }) => {
39
- if (!address || address === zeroAddress) return;
40
- if (!addresses[contractName]) {
41
- addresses[contractName] = {
42
- address: {},
43
- abi,
44
- };
45
- }
46
-
47
- addresses[contractName]!.address[chainId] = address;
48
- };
49
-
50
- const protocolRewardsConfig = JSON.parse(
51
- readFileSync("../protocol-rewards/deterministicConfig.json", "utf-8"),
52
- ) as {
53
- expectedAddress: Address;
54
- };
55
-
56
- for (const addressesFile of addressesFiles) {
57
- const jsonAddress = JSON.parse(
58
- readFileSync(`../1155-deployments/addresses/${addressesFile}`, "utf-8"),
59
- ) as {
60
- FIXED_PRICE_SALE_STRATEGY: Address;
61
- MERKLE_MINT_SALE_STRATEGY: Address;
62
- REDEEM_MINTER_FACTORY: Address;
63
- "1155_IMPL": Address;
64
- FACTORY_IMPL: Address;
65
- FACTORY_PROXY: Address;
66
- PREMINTER_PROXY?: Address;
67
- ERC20_MINTER?: Address;
68
- };
69
-
70
- const chainId = parseInt(addressesFile.split(".")[0]);
71
-
72
- addAddress({
73
- contractName: "ZoraCreatorFixedPriceSaleStrategy",
74
- chainId,
75
- address: jsonAddress.FIXED_PRICE_SALE_STRATEGY,
76
- abi: abis.zoraCreatorFixedPriceSaleStrategyABI,
77
- });
78
- addAddress({
79
- contractName: "ZoraCreatorMerkleMinterStrategy",
80
- chainId,
81
- address: jsonAddress.MERKLE_MINT_SALE_STRATEGY,
82
- abi: abis.zoraCreatorMerkleMinterStrategyABI,
83
- });
84
- addAddress({
85
- contractName: "ZoraCreator1155FactoryImpl",
86
- chainId,
87
- address: jsonAddress.FACTORY_PROXY,
88
- abi: abis.zoraCreator1155FactoryImplABI,
89
- });
90
- addAddress({
91
- contractName: "ZoraCreatorRedeemMinterFactory",
92
- chainId,
93
- address: jsonAddress.REDEEM_MINTER_FACTORY,
94
- abi: abis.zoraCreatorRedeemMinterFactoryABI,
95
- });
96
- addAddress({
97
- contractName: "ZoraCreator1155PremintExecutorImpl",
98
- chainId,
99
- address: jsonAddress.PREMINTER_PROXY,
100
- abi: abis.zoraCreator1155PremintExecutorImplABI,
101
- });
102
- addAddress({
103
- contractName: "ProtocolRewards",
104
- chainId,
105
- address: protocolRewardsConfig.expectedAddress,
106
- abi: abis.protocolRewardsABI,
107
- });
108
- addAddress({
109
- contractName: "ERC20Minter",
110
- chainId,
111
- abi: abis.erc20MinterABI,
112
- address: jsonAddress.ERC20_MINTER,
113
- });
114
- }
115
-
116
- return addresses;
117
- };
118
-
119
- const getMintsAddresses = () => {
120
- const addressesFiles = readdirSync("../mints-deployments/addresses");
121
-
122
- const chainIds = addressesFiles.map((x) => Number(x.split(".")[0]));
123
-
124
- const mintsProxyConfig = JSON.parse(
125
- readFileSync(
126
- "../mints-deployments/deterministicConfig/mintsProxy/params.json",
127
- "utf-8",
128
- ),
129
- );
130
-
131
- const mintsEthUnwrapperAndCallerAddress = JSON.parse(
132
- readFileSync("../mints-deployments/addresses/999999999.json", "utf-8"),
133
- ).MINTS_ETH_UNWRAPPER_AND_CALLER as Address;
134
-
135
- const mintsManagerAddress = mintsProxyConfig.manager
136
- .deployedAddress as Address;
137
- const zoraMints1155Address = mintsProxyConfig.mints1155
138
- .deployedAddress as Address;
139
-
140
- return {
141
- mintsManager: Object.fromEntries(
142
- chainIds.map((chainId) => [chainId, mintsManagerAddress]),
143
- ),
144
- mints1155: Object.fromEntries(
145
- chainIds.map((chainId) => [chainId, zoraMints1155Address as Address]),
146
- ),
147
- mintsEthUnwrapperAndCaller: Object.fromEntries(
148
- chainIds.map((chainId) => [chainId, mintsEthUnwrapperAndCallerAddress]),
149
- ),
150
- };
151
- };
152
-
153
- const mintsAddresses = getMintsAddresses();
154
-
155
- export default defineConfig({
156
- out: "src/generated/wagmi.ts",
157
- contracts: [
158
- ...Object.entries(get1155Addresses()).map(
159
- ([contractName, addressConfig]) => ({
160
- abi: addressConfig.abi,
161
- address: addressConfig.address,
162
- name: contractName,
163
- }),
164
- ),
165
- {
166
- abi: abis.zoraCreator1155ImplABI,
167
- name: "ZoraCreator1155Impl",
168
- },
169
- {
170
- abi: zoraMintsManagerImplABI,
171
- name: "ZoraMintsManagerImpl",
172
- address: mintsAddresses.mintsManager,
173
- },
174
- {
175
- abi: zoraMints1155ABI,
176
- name: "ZoraMints1155",
177
- address: mintsAddresses.mints1155,
178
- },
179
- {
180
- abi: mintsEthUnwrapperAndCallerABI,
181
- name: "MintsEthUnwrapperAndCaller",
182
- address: mintsAddresses.mintsEthUnwrapperAndCaller,
183
- },
184
- {
185
- abi: iUnwrapAndForwardActionABI,
186
- name: "IUnwrapAndForwardAction",
187
- },
188
- ],
189
- });