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