@zoralabs/protocol-sdk 0.7.0 → 0.7.2-ALLOWLIST.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/CHANGELOG.md +12 -0
- package/dist/allow-list/allow-list-client.d.ts +25 -0
- package/dist/allow-list/allow-list-client.d.ts.map +1 -0
- package/dist/allow-list/types.d.ts +14 -0
- package/dist/allow-list/types.d.ts.map +1 -0
- package/dist/apis/generated/allow-list-api-types.d.ts +288 -0
- package/dist/apis/generated/allow-list-api-types.d.ts.map +1 -0
- package/dist/apis/http-api-base.d.ts.map +1 -1
- package/dist/create/1155-create-helper.d.ts +1 -0
- package/dist/create/1155-create-helper.d.ts.map +1 -1
- package/dist/create/token-setup.d.ts +3 -4
- package/dist/create/token-setup.d.ts.map +1 -1
- package/dist/create/types.d.ts +24 -4
- package/dist/create/types.d.ts.map +1 -1
- package/dist/index.cjs +1388 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1382 -51
- package/dist/index.js.map +1 -1
- package/dist/ipfs/arweave.d.ts +3 -0
- package/dist/ipfs/arweave.d.ts.map +1 -0
- package/dist/ipfs/gateway.d.ts +4 -0
- package/dist/ipfs/gateway.d.ts.map +1 -0
- package/dist/ipfs/index.d.ts +4 -0
- package/dist/ipfs/index.d.ts.map +1 -0
- package/dist/ipfs/ipfs.d.ts +5 -0
- package/dist/ipfs/ipfs.d.ts.map +1 -0
- package/dist/ipfs/mimeTypes.d.ts +25 -0
- package/dist/ipfs/mimeTypes.d.ts.map +1 -0
- package/dist/ipfs/text-metadata.d.ts +5 -0
- package/dist/ipfs/text-metadata.d.ts.map +1 -0
- package/dist/ipfs/token-metadata.d.ts +14 -0
- package/dist/ipfs/token-metadata.d.ts.map +1 -0
- package/dist/ipfs/types.d.ts +49 -0
- package/dist/ipfs/types.d.ts.map +1 -0
- package/dist/mint/mint-queries.d.ts +3 -1
- package/dist/mint/mint-queries.d.ts.map +1 -1
- package/dist/mint/mint-transactions.d.ts +5 -3
- package/dist/mint/mint-transactions.d.ts.map +1 -1
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
- package/dist/mint/subgraph-queries.d.ts +27 -13
- package/dist/mint/subgraph-queries.d.ts.map +1 -1
- package/dist/mint/types.d.ts +22 -11
- package/dist/mint/types.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +2 -1
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/package.json +3 -1
- package/src/allow-list/allow-list-client.ts +102 -0
- package/src/allow-list/types.ts +15 -0
- package/src/apis/generated/allow-list-api-types.ts +288 -0
- package/src/apis/http-api-base.ts +12 -0
- package/src/create/1155-create-helper.ts +17 -0
- package/src/create/token-setup.ts +116 -19
- package/src/create/types.ts +32 -4
- package/src/index.ts +6 -0
- package/src/ipfs/arweave.ts +5 -0
- package/src/ipfs/gateway.ts +48 -0
- package/src/ipfs/index.ts +7 -0
- package/src/ipfs/ipfs.ts +82 -0
- package/src/ipfs/mimeTypes.ts +141 -0
- package/src/ipfs/text-metadata.ts +128 -0
- package/src/ipfs/token-metadata.ts +99 -0
- package/src/ipfs/types.ts +54 -0
- package/src/mint/mint-queries.ts +6 -0
- package/src/mint/mint-transactions.ts +72 -6
- package/src/mint/subgraph-mint-getter.ts +12 -3
- package/src/mint/subgraph-queries.ts +39 -17
- package/src/mint/types.ts +38 -12
- package/src/premint/premint-client.ts +9 -1
- package/yarn-error.log +8602 -0
- package/.turbo/turbo-build.log +0 -15
- package/src/create/1155-create-helper.test.ts +0 -325
- package/src/mint/mint-client.test.ts +0 -263
- package/src/mints/mints-contracts.test.ts +0 -529
- package/src/mints/mints-eth-unwrapper-and-caller.test.ts +0 -467
- package/src/mints/mints-queries.test.ts +0 -105
- package/src/premint/premint-client.test.ts +0 -290
- package/src/premint/preminter.test.ts +0 -866
- package/test-integration/setup-test-contracts.ts +0 -96
- package/tsconfig.build.json +0 -10
- package/tsup.config.ts +0 -12
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
import { zoraSepolia } from "viem/chains";
|
|
2
|
-
import { describe, expect, vi } from "vitest";
|
|
3
|
-
|
|
4
|
-
import { PremintConfigVersion } from "./contract-types";
|
|
5
|
-
import {
|
|
6
|
-
getDefaultFixedPriceMinterAddress,
|
|
7
|
-
getPremintCollectionAddress,
|
|
8
|
-
} from "./preminter";
|
|
9
|
-
import { forkUrls, makeAnvilTest } from "src/anvil";
|
|
10
|
-
import {
|
|
11
|
-
ContractCreationConfig,
|
|
12
|
-
PremintConfigV2,
|
|
13
|
-
} from "@zoralabs/protocol-deployments";
|
|
14
|
-
import { PremintAPIClient } from "./premint-api-client";
|
|
15
|
-
import { createCollectorClient, createCreatorClient } from "src/sdk";
|
|
16
|
-
|
|
17
|
-
const anvilTest = makeAnvilTest({
|
|
18
|
-
forkUrl: forkUrls.zoraSepolia,
|
|
19
|
-
forkBlockNumber: 9678162,
|
|
20
|
-
anvilChainId: zoraSepolia.id,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
describe("ZoraCreator1155Premint", () => {
|
|
24
|
-
anvilTest(
|
|
25
|
-
"can mint premints",
|
|
26
|
-
async ({ viemClients: { walletClient, publicClient, chain } }) => {
|
|
27
|
-
const [deployerAccount] = await walletClient.getAddresses();
|
|
28
|
-
|
|
29
|
-
const premintApiClient = new PremintAPIClient(chain.id);
|
|
30
|
-
|
|
31
|
-
premintApiClient.get = vi
|
|
32
|
-
.fn<any, ReturnType<typeof premintApiClient.get>>()
|
|
33
|
-
.mockResolvedValue({
|
|
34
|
-
collection: {
|
|
35
|
-
contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
36
|
-
contractName: "Testing Contract",
|
|
37
|
-
contractURI:
|
|
38
|
-
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
39
|
-
additionalAdmins: [],
|
|
40
|
-
},
|
|
41
|
-
collectionAddress: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
|
|
42
|
-
premint: {
|
|
43
|
-
premintConfig: {
|
|
44
|
-
deleted: false,
|
|
45
|
-
tokenConfig: {
|
|
46
|
-
fixedPriceMinter: getDefaultFixedPriceMinterAddress(chain.id),
|
|
47
|
-
maxSupply: 18446744073709551615n,
|
|
48
|
-
maxTokensPerAddress: 0n,
|
|
49
|
-
mintDuration: 604800n,
|
|
50
|
-
mintStart: 0n,
|
|
51
|
-
pricePerToken: 0n,
|
|
52
|
-
royaltyBPS: 1000,
|
|
53
|
-
royaltyMintSchedule: 0,
|
|
54
|
-
royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
55
|
-
tokenURI:
|
|
56
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
57
|
-
},
|
|
58
|
-
uid: 3,
|
|
59
|
-
version: 0,
|
|
60
|
-
},
|
|
61
|
-
premintConfigVersion: PremintConfigVersion.V1,
|
|
62
|
-
},
|
|
63
|
-
signer: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
64
|
-
signature:
|
|
65
|
-
"0x4d191dd60d428adfe507932a1758bee8ac5bbb77dcd3c05840c237416a3a25035bb8cc7c62177a4e9acb5f40c4032cdb3dbfefdd1575f2c3b4c57945b2076e2e1c",
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
premintApiClient.postSignature = vi.fn();
|
|
69
|
-
|
|
70
|
-
const collectorClient = createCollectorClient({
|
|
71
|
-
chainId: chain.id,
|
|
72
|
-
publicClient,
|
|
73
|
-
premintGetter: premintApiClient,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const { parameters } = await collectorClient.mint({
|
|
77
|
-
mintType: "premint",
|
|
78
|
-
minterAccount: deployerAccount!,
|
|
79
|
-
tokenContract: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
|
|
80
|
-
uid: 3,
|
|
81
|
-
quantityToMint: 1,
|
|
82
|
-
mintComment: "",
|
|
83
|
-
});
|
|
84
|
-
const { request: simulateRequest } =
|
|
85
|
-
await publicClient.simulateContract(parameters);
|
|
86
|
-
const hash = await walletClient.writeContract(simulateRequest);
|
|
87
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
88
|
-
|
|
89
|
-
const { premintedLog, urls } =
|
|
90
|
-
collectorClient.getCollectDataFromPremintReceipt(receipt);
|
|
91
|
-
|
|
92
|
-
expect(urls).toEqual({
|
|
93
|
-
explorer:
|
|
94
|
-
"https://undefined/token/0xf8dA7f53c283d898818af7FB9d98103F559bDac2/instance/1",
|
|
95
|
-
zoraCollect:
|
|
96
|
-
"https://testnet.zora.co/collect/zsep:0xf8dA7f53c283d898818af7FB9d98103F559bDac2/1",
|
|
97
|
-
zoraManage:
|
|
98
|
-
"https://testnet.zora.co/collect/zsep:0xf8dA7f53c283d898818af7FB9d98103F559bDac2/1",
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
expect(premintedLog).toEqual({
|
|
102
|
-
contractAddress: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
|
|
103
|
-
createdNewContract: expect.any(Boolean),
|
|
104
|
-
minter: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
105
|
-
quantityMinted: 1n,
|
|
106
|
-
tokenId: 1n,
|
|
107
|
-
uid: 3,
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
20 * 1000,
|
|
111
|
-
);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
115
|
-
anvilTest(
|
|
116
|
-
"can sign and submit new premints on new contracts",
|
|
117
|
-
async ({ viemClients: { walletClient, publicClient, chain } }) => {
|
|
118
|
-
const [creatorAccount, createReferralAccount] =
|
|
119
|
-
await walletClient.getAddresses();
|
|
120
|
-
const premintApiClient = new PremintAPIClient(chain.id);
|
|
121
|
-
|
|
122
|
-
premintApiClient.getNextUID = vi
|
|
123
|
-
.fn<any, ReturnType<typeof premintApiClient.getNextUID>>()
|
|
124
|
-
.mockResolvedValue(3);
|
|
125
|
-
premintApiClient.postSignature = vi
|
|
126
|
-
.fn<Parameters<typeof premintApiClient.postSignature>>()
|
|
127
|
-
.mockResolvedValue({ ok: true });
|
|
128
|
-
|
|
129
|
-
const creatorClient = createCreatorClient({
|
|
130
|
-
chainId: chain.id,
|
|
131
|
-
premintApi: premintApiClient,
|
|
132
|
-
publicClient,
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
const { signAndSubmit } = await creatorClient.createPremint({
|
|
136
|
-
contract: {
|
|
137
|
-
contractAdmin: creatorAccount!,
|
|
138
|
-
contractName: "Testing Contract Premint V2",
|
|
139
|
-
contractURI:
|
|
140
|
-
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
141
|
-
},
|
|
142
|
-
token: {
|
|
143
|
-
tokenURI:
|
|
144
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
145
|
-
payoutRecipient: creatorAccount!,
|
|
146
|
-
createReferral: createReferralAccount,
|
|
147
|
-
},
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
await signAndSubmit({
|
|
151
|
-
account: creatorAccount!,
|
|
152
|
-
walletClient,
|
|
153
|
-
checkSignature: true,
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
const expectedPostSignatureArgs: Parameters<
|
|
157
|
-
typeof premintApiClient.postSignature
|
|
158
|
-
>[0] = {
|
|
159
|
-
contract: {
|
|
160
|
-
contractAdmin: creatorAccount!,
|
|
161
|
-
contractName: "Testing Contract Premint V2",
|
|
162
|
-
contractURI:
|
|
163
|
-
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
164
|
-
},
|
|
165
|
-
contractAddress: undefined,
|
|
166
|
-
premintConfig: {
|
|
167
|
-
deleted: false,
|
|
168
|
-
tokenConfig: {
|
|
169
|
-
fixedPriceMinter: "0x6d28164C3CE04A190D5F9f0f8881fc807EAD975A",
|
|
170
|
-
maxSupply: 18446744073709551615n,
|
|
171
|
-
maxTokensPerAddress: 0n,
|
|
172
|
-
mintDuration: 0n,
|
|
173
|
-
mintStart: 0n,
|
|
174
|
-
pricePerToken: 0n,
|
|
175
|
-
royaltyBPS: 1000,
|
|
176
|
-
payoutRecipient: creatorAccount!,
|
|
177
|
-
createReferral: createReferralAccount!,
|
|
178
|
-
tokenURI:
|
|
179
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
180
|
-
},
|
|
181
|
-
uid: 3,
|
|
182
|
-
version: 0,
|
|
183
|
-
},
|
|
184
|
-
premintConfigVersion: PremintConfigVersion.V2,
|
|
185
|
-
signature:
|
|
186
|
-
"0xfe5725c05754ad17a73cc9706bf940e30bd7b4a674bb1b283a66a1cc87022c8c13fcf8989f9feb675f8932a6a8ddb8d16af2abef28fa2fff3282487ef5385b3d1b",
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
expect(premintApiClient.postSignature).toHaveBeenCalledWith(
|
|
190
|
-
expectedPostSignatureArgs,
|
|
191
|
-
);
|
|
192
|
-
},
|
|
193
|
-
20 * 1000,
|
|
194
|
-
);
|
|
195
|
-
|
|
196
|
-
anvilTest(
|
|
197
|
-
"can mint premints with additional admins",
|
|
198
|
-
async ({ viemClients: { walletClient, publicClient, chain } }) => {
|
|
199
|
-
const [deployerAccount, creatorAccount, additionalAdmin] =
|
|
200
|
-
await walletClient.getAddresses();
|
|
201
|
-
|
|
202
|
-
const premintApiClient = new PremintAPIClient(chain.id);
|
|
203
|
-
|
|
204
|
-
const collectorClient = createCollectorClient({
|
|
205
|
-
chainId: chain.id,
|
|
206
|
-
publicClient,
|
|
207
|
-
premintGetter: premintApiClient,
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
const creatorClient = createCreatorClient({
|
|
211
|
-
chainId: chain.id,
|
|
212
|
-
publicClient,
|
|
213
|
-
premintApi: premintApiClient,
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
const collection: ContractCreationConfig = {
|
|
217
|
-
contractAdmin: creatorAccount!,
|
|
218
|
-
contractName: "Testing Contract",
|
|
219
|
-
contractURI:
|
|
220
|
-
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
221
|
-
additionalAdmins: [additionalAdmin!],
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
const collectionAddress = await getPremintCollectionAddress({
|
|
225
|
-
contract: collection,
|
|
226
|
-
publicClient,
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
const { premintConfig, typedDataDefinition } =
|
|
230
|
-
await creatorClient.createPremint({
|
|
231
|
-
contract: collection,
|
|
232
|
-
token: {
|
|
233
|
-
tokenURI:
|
|
234
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
235
|
-
payoutRecipient: creatorAccount!,
|
|
236
|
-
},
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
const signature = await walletClient.signTypedData({
|
|
240
|
-
...typedDataDefinition,
|
|
241
|
-
account: additionalAdmin!,
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
premintApiClient.get = vi
|
|
245
|
-
.fn<any, ReturnType<typeof premintApiClient.get>>()
|
|
246
|
-
.mockResolvedValue({
|
|
247
|
-
collection,
|
|
248
|
-
collectionAddress,
|
|
249
|
-
premint: {
|
|
250
|
-
premintConfig: premintConfig as PremintConfigV2,
|
|
251
|
-
premintConfigVersion: PremintConfigVersion.V2,
|
|
252
|
-
},
|
|
253
|
-
signer: collection.contractAdmin,
|
|
254
|
-
signature,
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
const { parameters } = await collectorClient.mint({
|
|
258
|
-
mintType: "premint",
|
|
259
|
-
uid: premintConfig.uid,
|
|
260
|
-
minterAccount: deployerAccount!,
|
|
261
|
-
tokenContract: collectionAddress,
|
|
262
|
-
quantityToMint: 1,
|
|
263
|
-
mintComment: "",
|
|
264
|
-
});
|
|
265
|
-
const { request: simulateRequest } =
|
|
266
|
-
await publicClient.simulateContract(parameters);
|
|
267
|
-
const hash = await walletClient.writeContract(simulateRequest);
|
|
268
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
269
|
-
|
|
270
|
-
const { premintedLog, urls } =
|
|
271
|
-
collectorClient.getCollectDataFromPremintReceipt(receipt);
|
|
272
|
-
|
|
273
|
-
expect(urls).toEqual({
|
|
274
|
-
explorer: `https://undefined/token/${collectionAddress}/instance/1`,
|
|
275
|
-
zoraCollect: `https://testnet.zora.co/collect/zsep:${collectionAddress}/1`,
|
|
276
|
-
zoraManage: `https://testnet.zora.co/collect/zsep:${collectionAddress}/1`,
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
expect(premintedLog).toEqual({
|
|
280
|
-
contractAddress: collectionAddress,
|
|
281
|
-
createdNewContract: expect.any(Boolean),
|
|
282
|
-
minter: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
283
|
-
quantityMinted: 1n,
|
|
284
|
-
tokenId: 1n,
|
|
285
|
-
uid: premintConfig.uid,
|
|
286
|
-
});
|
|
287
|
-
},
|
|
288
|
-
20 * 1000,
|
|
289
|
-
);
|
|
290
|
-
});
|