@zoralabs/protocol-sdk 0.7.3-SPARKS.0 → 0.7.4
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 -0
- package/CHANGELOG.md +17 -4
- package/LICENSE +21 -0
- package/dist/anvil.d.ts +2 -2
- package/dist/anvil.d.ts.map +1 -1
- package/dist/apis/http-api-base.d.ts.map +1 -1
- package/dist/index.cjs +2265 -319
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2289 -320
- package/dist/index.js.map +1 -1
- package/dist/ipfs/token-metadata.d.ts.map +1 -1
- package/dist/mint/mint-client.d.ts +1 -1
- package/dist/mint/mint-queries.d.ts +1 -1
- package/dist/mint/types.d.ts.map +1 -1
- package/dist/mints/mints-contracts.d.ts +1 -1
- package/dist/mints/mints-contracts.d.ts.map +1 -1
- package/dist/mints/mints-eth-unwrapper-and-caller.d.ts.map +1 -1
- package/dist/mints/mints-queries.d.ts.map +1 -1
- package/dist/mints/mints-relay-example.d.ts +7 -7
- package/dist/mints/mints-relay-example.d.ts.map +1 -1
- package/dist/premint/conversions.d.ts +5 -5
- package/dist/premint/conversions.d.ts.map +1 -1
- package/dist/premint/premint-api-client.d.ts +1 -1
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +4 -4
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +3 -3
- package/dist/premint/preminter.d.ts.map +1 -1
- package/dist/preminter.d.ts +2 -2
- package/dist/preminter.d.ts.map +1 -1
- package/dist/test-utils.d.ts.map +1 -1
- package/package.json +21 -16
- package/src/create/1155-create-helper.test.ts +325 -0
- package/src/mint/mint-client.test.ts +263 -0
- package/src/mints/mints-contracts.test.ts +529 -0
- package/src/mints/mints-eth-unwrapper-and-caller.test.ts +467 -0
- package/src/mints/mints-eth-unwrapper-and-caller.ts +2 -2
- package/src/mints/mints-queries.test.ts +105 -0
- package/src/mints/mints-relay-example.ts +22 -13
- package/src/premint/premint-client.test.ts +290 -0
- package/src/premint/preminter.test.ts +866 -0
- package/test-integration/setup-test-contracts.ts +96 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +1 -1
- package/tsup.config.ts +12 -0
- package/yarn-error.log +0 -8602
|
@@ -0,0 +1,290 @@
|
|
|
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
|
+
});
|