@zoralabs/protocol-sdk 0.5.8-DEV.1 → 0.5.8

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,146 @@
1
+ import { zoraSepolia, zoraTestnet } from "viem/chains";
2
+ import { describe } from "vitest";
3
+
4
+ import { createPremintClient } from "src/premint/premint-client";
5
+ import { forkUrls, makeAnvilTest } from "src/anvil";
6
+ import { PremintConfigVersion } from "src/premint/contract-types";
7
+
8
+ const zoraGoerliTest = makeAnvilTest({
9
+ forkBlockNumber: 2107926,
10
+ forkUrl: forkUrls.zoraGoerli,
11
+ anvilChainId: zoraTestnet.id,
12
+ });
13
+
14
+ const zoraSepoliaTest = makeAnvilTest({
15
+ forkBlockNumber: 3118200,
16
+ forkUrl: forkUrls.zoraSepolia,
17
+ anvilChainId: zoraSepolia.id,
18
+ });
19
+
20
+ const tests = [
21
+ {
22
+ anvilTest: zoraGoerliTest,
23
+ chain: zoraTestnet,
24
+ },
25
+ {
26
+ anvilTest: zoraSepoliaTest,
27
+ chain: zoraSepolia,
28
+ },
29
+ ];
30
+
31
+ tests.forEach(({ anvilTest, chain }) => {
32
+ describe(chain.name, () => {
33
+ describe("ZoraCreator1155Premint", () => {
34
+ describe("v2 signatures", () => {
35
+ anvilTest(
36
+ "can sign and execute on the forked premint contract",
37
+ async ({
38
+ viemClients: { walletClient, publicClient, testClient },
39
+ }) => {
40
+ const [creatorAccount, createReferralAccount, minterAccount] =
41
+ await walletClient.getAddresses();
42
+ const premintClient = createPremintClient({
43
+ chain,
44
+ publicClient,
45
+ });
46
+
47
+ const { uid, verifyingContract } =
48
+ await premintClient.createPremint({
49
+ walletClient,
50
+ creatorAccount: creatorAccount!,
51
+ checkSignature: true,
52
+ collection: {
53
+ contractAdmin: creatorAccount!,
54
+ contractName: "Testing Contract Premint V2",
55
+ contractURI:
56
+ "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3f",
57
+ },
58
+ premintConfigVersion: PremintConfigVersion.V2,
59
+ tokenCreationConfig: {
60
+ tokenURI:
61
+ "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2f",
62
+ createReferral: createReferralAccount!,
63
+ },
64
+ });
65
+
66
+ const mintParameters = await premintClient.makeMintParameters({
67
+ minterAccount: minterAccount!,
68
+ tokenContract: verifyingContract,
69
+ uid,
70
+ });
71
+
72
+ const mintCosts = await premintClient.getMintCosts({
73
+ tokenContract: verifyingContract,
74
+ quantityToMint: 1n,
75
+ pricePerToken: 0n,
76
+ });
77
+
78
+ await testClient.setBalance({
79
+ address: minterAccount!,
80
+ value: mintCosts.totalCost,
81
+ });
82
+
83
+ // if simulation succeeds, mint will succeed
84
+ await publicClient.simulateContract(mintParameters);
85
+ },
86
+ 20 * 1000,
87
+ );
88
+ });
89
+
90
+ describe("v1 signatures", () => {
91
+ anvilTest(
92
+ "can sign and execute on the forked premint contract",
93
+ async ({
94
+ viemClients: { walletClient, publicClient, testClient },
95
+ }) => {
96
+ const [creatorAccount, minterAccount] =
97
+ await walletClient.getAddresses();
98
+ const premintClient = createPremintClient({
99
+ chain,
100
+ publicClient,
101
+ });
102
+
103
+ const { uid, verifyingContract } =
104
+ await premintClient.createPremint({
105
+ walletClient,
106
+ creatorAccount: creatorAccount!,
107
+ checkSignature: true,
108
+ collection: {
109
+ contractAdmin: creatorAccount!,
110
+ contractName: `Testing Contract Premint V1 ${publicClient.chain?.name}`,
111
+ contractURI:
112
+ "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3fg",
113
+ },
114
+ premintConfigVersion: PremintConfigVersion.V1,
115
+ tokenCreationConfig: {
116
+ tokenURI:
117
+ "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
118
+ },
119
+ });
120
+
121
+ const mintParameters = await premintClient.makeMintParameters({
122
+ minterAccount: minterAccount!,
123
+ tokenContract: verifyingContract,
124
+ uid,
125
+ });
126
+
127
+ const mintCosts = await premintClient.getMintCosts({
128
+ tokenContract: verifyingContract,
129
+ quantityToMint: 1n,
130
+ pricePerToken: 0n,
131
+ });
132
+
133
+ await testClient.setBalance({
134
+ address: minterAccount!,
135
+ value: mintCosts.totalCost,
136
+ });
137
+
138
+ // if simulation succeeds, mint will succeed
139
+ await publicClient.simulateContract(mintParameters);
140
+ },
141
+ 20 * 1000,
142
+ );
143
+ });
144
+ });
145
+ });
146
+ });
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "zoralabs-tsconfig/tsconfig.json",
3
+ "compilerOptions": {
4
+ "lib": ["es2021", "DOM"],
5
+ "baseUrl": ".",
6
+ "outDir": "dist"
7
+ },
8
+ "exclude": ["node_modules/**", "dist/**", "**/*test.ts"],
9
+ "include": ["src/**/*.ts"],
10
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig({
4
+ entry: ["src/index.ts"],
5
+ sourcemap: true,
6
+ clean: true,
7
+ tsconfig: "tsconfig.build.json",
8
+ dts: false,
9
+ format: ["cjs", "esm"],
10
+ onSuccess:
11
+ "tsc --project tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap",
12
+ });