@zoralabs/protocol-sdk 0.3.5 → 0.4.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 +12 -0
- package/README.md +23 -32
- package/dist/anvil.d.ts +1 -1
- package/dist/index.cjs +423 -254
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +420 -253
- package/dist/index.js.map +1 -1
- package/dist/premint/contract-types.d.ts +125 -0
- package/dist/premint/contract-types.d.ts.map +1 -0
- package/dist/premint/premint-api-client.d.ts +14 -7
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +39 -155
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +28 -34
- package/dist/premint/preminter.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/anvil.ts +1 -1
- package/src/index.ts +2 -0
- package/src/premint/contract-types.ts +109 -0
- package/src/premint/premint-api-client.ts +162 -22
- package/src/premint/premint-client.test.ts +188 -87
- package/src/premint/premint-client.ts +330 -314
- package/src/premint/preminter.test.ts +9 -7
- package/src/premint/preminter.ts +107 -121
package/.turbo/turbo-build.log
CHANGED
|
@@ -7,9 +7,9 @@ $ tsup
|
|
|
7
7
|
[34mCLI[39m Cleaning output folder
|
|
8
8
|
[34mCJS[39m Build start
|
|
9
9
|
[34mESM[39m Build start
|
|
10
|
-
[32mCJS[39m [1mdist/index.cjs [22m[
|
|
11
|
-
[32mCJS[39m [1mdist/index.cjs.map [22m[
|
|
12
|
-
[32mCJS[39m ⚡️ Build success in
|
|
13
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
14
|
-
[32mESM[39m [1mdist/index.js.map [22m[
|
|
15
|
-
[32mESM[39m ⚡️ Build success in
|
|
10
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m48.03 KB[39m
|
|
11
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m93.11 KB[39m
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 46ms
|
|
13
|
+
[32mESM[39m [1mdist/index.js [22m[32m44.64 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m93.23 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 45ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @zoralabs/protocol-sdk
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 28884c9: \* `PremintClient` now takes a premint config v1 or v2, and a premint config version, for every call to create/update/delete a premint. PremintClient methods have been simplified and are easier to use - for example `createPremint` no longer allows to specify `deleted` = true. For `makeMintParameters` - it now just takes the uid and contract address (instead of full premint config)
|
|
8
|
+
- `PremintAPIClient` now converts entities to contract entities before returning them, and correspondingly expects them as contract entities when passed in. It internally converts them to backend entities before sending them to the backend.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies [4b77307]
|
|
13
|
+
- @zoralabs/protocol-deployments@0.0.8
|
|
14
|
+
|
|
3
15
|
## 0.3.5
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -203,32 +203,33 @@ import type {Address, PublicClient, WalletClient} from "viem";
|
|
|
203
203
|
|
|
204
204
|
async function createForFree({
|
|
205
205
|
walletClient,
|
|
206
|
+
publicClient,
|
|
206
207
|
creatorAccount,
|
|
207
208
|
}: {
|
|
208
209
|
// wallet client that will submit the transaction
|
|
209
210
|
walletClient: WalletClient;
|
|
211
|
+
// public client that will simulate the transaction
|
|
212
|
+
publicClient: PublicClient;
|
|
210
213
|
// address of the token contract
|
|
211
214
|
creatorAccount: Address;
|
|
212
215
|
}) {
|
|
213
|
-
const premintClient = createPremintClient({
|
|
216
|
+
const premintClient = createPremintClient({chain: walletClient.chain!, publicClient});
|
|
214
217
|
|
|
215
218
|
// create and sign a free token creation.
|
|
216
219
|
const createdPremint = await premintClient.createPremint({
|
|
217
220
|
walletClient,
|
|
218
|
-
|
|
221
|
+
creatorAccount,
|
|
219
222
|
// if true, will validate that the creator is authorized to create premints on the contract.
|
|
220
223
|
checkSignature: true,
|
|
221
224
|
// collection info of collection to create
|
|
222
225
|
collection: {
|
|
223
226
|
contractAdmin: creatorAccount,
|
|
224
227
|
contractName: "Testing Contract",
|
|
225
|
-
contractURI:
|
|
226
|
-
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
228
|
+
contractURI: "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
227
229
|
},
|
|
228
230
|
// token info of token to create
|
|
229
|
-
|
|
230
|
-
tokenURI:
|
|
231
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
231
|
+
tokenCreationConfig: {
|
|
232
|
+
tokenURI: "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
232
233
|
},
|
|
233
234
|
});
|
|
234
235
|
|
|
@@ -236,12 +237,13 @@ async function createForFree({
|
|
|
236
237
|
const premintCollectionAddress = createdPremint.verifyingContract;
|
|
237
238
|
|
|
238
239
|
return {
|
|
239
|
-
// unique id of created premint, which can be used later to
|
|
240
|
+
// unique id of created premint, which can be used later to
|
|
240
241
|
// update or delete the premint
|
|
241
242
|
uid: premintUid,
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
}
|
|
243
|
+
tokenContractAddress: premintCollectionAddress,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
245
247
|
```
|
|
246
248
|
|
|
247
249
|
### Updating a token that was created for free (before it was brought onchain):
|
|
@@ -253,8 +255,7 @@ import {createPremintClient} from "@zoralabs/protocol-sdk";
|
|
|
253
255
|
import type {Address, PublicClient, WalletClient} from "viem";
|
|
254
256
|
|
|
255
257
|
async function updateCreatedForFreeToken(walletClient: WalletClient, premintUid: number) {
|
|
256
|
-
|
|
257
|
-
const premintClient = createPremintClient({ chain: walletClient.chain! });
|
|
258
|
+
const premintClient = createPremintClient({chain: walletClient.chain!});
|
|
258
259
|
|
|
259
260
|
// sign a message to update the created for free token, and store the update
|
|
260
261
|
await premintClient.updatePremint({
|
|
@@ -263,9 +264,8 @@ async function updateCreatedForFreeToken(walletClient: WalletClient, premintUid:
|
|
|
263
264
|
// WalletClient doing the signature
|
|
264
265
|
walletClient,
|
|
265
266
|
// Token information, falls back to defaults set in DefaultMintArguments.
|
|
266
|
-
|
|
267
|
-
tokenURI:
|
|
268
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
267
|
+
tokenConfigUpdates: {
|
|
268
|
+
tokenURI: "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
269
269
|
},
|
|
270
270
|
});
|
|
271
271
|
}
|
|
@@ -276,11 +276,8 @@ async function updateCreatedForFreeToken(walletClient: WalletClient, premintUid:
|
|
|
276
276
|
Before a token that was created for free is brought onchain, it can be deleted by the original creator of that token, by having that creator sign a message indicating the deletion:
|
|
277
277
|
|
|
278
278
|
```ts
|
|
279
|
-
import {createPremintClient} from "@zoralabs/protocol-sdk";
|
|
280
|
-
import type {Address, PublicClient, WalletClient} from "viem";
|
|
281
|
-
|
|
282
279
|
async function deleteCreatedForFreeToken(walletClient: WalletClient) {
|
|
283
|
-
const premintClient = createPremintClient({
|
|
280
|
+
const premintClient = createPremintClient({chain: walletClient.chain!});
|
|
284
281
|
|
|
285
282
|
// sign a message to delete the premint, and store the deletion
|
|
286
283
|
await premintClient.deletePremint({
|
|
@@ -299,19 +296,13 @@ async function deleteCreatedForFreeToken(walletClient: WalletClient) {
|
|
|
299
296
|
import {createPremintClient} from "@zoralabs/protocol-sdk";
|
|
300
297
|
import type {Address, PublicClient, WalletClient} from "viem";
|
|
301
298
|
|
|
302
|
-
async function mintCreatedForFreeToken(
|
|
303
|
-
|
|
304
|
-
publicClient: PublicClient,
|
|
305
|
-
minterAccount: Address,
|
|
306
|
-
) {
|
|
307
|
-
const premintClient = createPremintClient({ chain: walletClient.chain! });
|
|
299
|
+
async function mintCreatedForFreeToken(walletClient: WalletClient, publicClient: PublicClient, minterAccount: Address) {
|
|
300
|
+
const premintClient = createPremintClient({chain: walletClient.chain!});
|
|
308
301
|
|
|
309
302
|
const simulateContractParameters = await premintClient.makeMintParameters({
|
|
310
303
|
account: minterAccount,
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
uid: 3,
|
|
314
|
-
}),
|
|
304
|
+
tokenContract: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
|
|
305
|
+
uid: 3,
|
|
315
306
|
mintArguments: {
|
|
316
307
|
quantityToMint: 1,
|
|
317
308
|
mintComment: "",
|
|
@@ -319,7 +310,7 @@ async function mintCreatedForFreeToken(
|
|
|
319
310
|
});
|
|
320
311
|
|
|
321
312
|
// simulate the transaction and get any validation errors
|
|
322
|
-
const {
|
|
313
|
+
const {request} = await publicClient.simulateContract(simulateContractParameters);
|
|
323
314
|
|
|
324
315
|
// submit the transaction to the network
|
|
325
316
|
const txHash = await walletClient.writeContract(request);
|
|
@@ -327,7 +318,7 @@ async function mintCreatedForFreeToken(
|
|
|
327
318
|
// wait for the transaction to be complete
|
|
328
319
|
const receipt = await publicClient.waitForTransactionReceipt({hash: txHash});
|
|
329
320
|
|
|
330
|
-
const {
|
|
321
|
+
const {urls} = await premintClient.getDataFromPremintReceipt(receipt);
|
|
331
322
|
|
|
332
323
|
// block explorer url:
|
|
333
324
|
console.log(urls.explorer);
|
package/dist/anvil.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare const makeAnvilTest: ({ forkUrl, forkBlockNumber, }: AnvilTestFor
|
|
|
20
20
|
export declare const forkUrls: {
|
|
21
21
|
zoraMainnet: string;
|
|
22
22
|
zoraGoerli: string;
|
|
23
|
-
|
|
23
|
+
zoraSepolia: string;
|
|
24
24
|
};
|
|
25
25
|
export declare const anvilTest: import("@vitest/runner/dist/tasks-e594cd24").e<{
|
|
26
26
|
viemClients: {
|