@zoralabs/protocol-sdk 0.4.3 → 0.5.1
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 +15 -14
- package/CHANGELOG.md +28 -1
- package/README.md +1 -1
- package/dist/anvil.d.ts +6 -2
- package/dist/anvil.d.ts.map +1 -1
- package/dist/apis/chain-constants.d.ts +4 -12
- package/dist/apis/chain-constants.d.ts.map +1 -1
- package/dist/index.cjs +55 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +58 -71
- package/dist/index.js.map +1 -1
- package/dist/premint/conversions.d.ts +1 -1
- package/dist/premint/conversions.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/package.json +10 -8
- package/src/anvil.ts +10 -3
- package/src/apis/chain-constants.ts +31 -32
- package/src/mint/mint-client.test.ts +1 -1
- package/src/premint/conversions.ts +12 -6
- package/src/premint/premint-client.test.ts +14 -64
- package/src/premint/premint-client.ts +25 -27
- package/src/premint/preminter.test.ts +1 -1
- package/src/premint/preminter.ts +9 -23
- package/test-integration/premint-client.test.ts +146 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +1 -1
- package/tsup.config.js +2 -1
- package/.turbo/turbo-lint.log +0 -5
- package/dist/create/1155-create-helper.test.d.ts +0 -2
- package/dist/create/1155-create-helper.test.d.ts.map +0 -1
- package/dist/mint/mint-client.test.d.ts +0 -2
- package/dist/mint/mint-client.test.d.ts.map +0 -1
- package/dist/premint/premint-client.test.d.ts +0 -2
- package/dist/premint/premint-client.test.d.ts.map +0 -1
- package/dist/premint/preminter.test.d.ts +0 -2
- package/dist/premint/preminter.test.d.ts.map +0 -1
package/src/premint/preminter.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
zoraCreator1155ImplABI,
|
|
5
5
|
zoraCreator1155PremintExecutorImplABI,
|
|
6
6
|
zoraCreator1155PremintExecutorImplAddress,
|
|
7
|
+
zoraCreatorFixedPriceSaleStrategyAddress,
|
|
7
8
|
} from "@zoralabs/protocol-deployments";
|
|
8
9
|
import {
|
|
9
10
|
TypedDataDefinition,
|
|
@@ -85,36 +86,17 @@ export type IsValidSignatureReturn = {
|
|
|
85
86
|
recoveredAddress?: Address;
|
|
86
87
|
};
|
|
87
88
|
|
|
88
|
-
export async function isAuthorizedToCreatePremint
|
|
89
|
-
T extends PremintConfigVersion,
|
|
90
|
-
>({
|
|
89
|
+
export async function isAuthorizedToCreatePremint({
|
|
91
90
|
collection,
|
|
92
91
|
collectionAddress,
|
|
93
92
|
publicClient,
|
|
94
|
-
premintConfig,
|
|
95
|
-
premintConfigVersion,
|
|
96
|
-
signature,
|
|
97
93
|
signer,
|
|
98
94
|
}: {
|
|
99
95
|
collection: ContractCreationConfig;
|
|
100
96
|
collectionAddress: Address;
|
|
101
97
|
publicClient: PublicClient;
|
|
102
|
-
signature: Hex;
|
|
103
98
|
signer: Address;
|
|
104
|
-
}
|
|
105
|
-
// if we are using legacy version of premint config, we can use the function
|
|
106
|
-
// "isValidSignature" which we know exists on the premint executor contract
|
|
107
|
-
if (premintConfigVersion === PremintConfigVersion.V1) {
|
|
108
|
-
const [isValidSignature] = await publicClient.readContract({
|
|
109
|
-
abi: zoraCreator1155PremintExecutorImplABI,
|
|
110
|
-
address: getPremintExecutorAddress(),
|
|
111
|
-
functionName: "isValidSignature",
|
|
112
|
-
args: [collection, premintConfig as PremintConfigV1, signature],
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
return isValidSignature;
|
|
116
|
-
}
|
|
117
|
-
|
|
99
|
+
}) {
|
|
118
100
|
// otherwize, we must assume the newer version of premint executor is deployed, so we call that.
|
|
119
101
|
return await publicClient.readContract({
|
|
120
102
|
abi: preminterAbi,
|
|
@@ -195,8 +177,6 @@ export async function isValidSignature<T extends PremintConfigVersion>({
|
|
|
195
177
|
collection,
|
|
196
178
|
collectionAddress: tokenContract,
|
|
197
179
|
publicClient,
|
|
198
|
-
signature,
|
|
199
|
-
...premintConfigAndVersion,
|
|
200
180
|
});
|
|
201
181
|
|
|
202
182
|
return {
|
|
@@ -442,3 +422,9 @@ export function makeMintRewardsRecipient({
|
|
|
442
422
|
}): Address[] {
|
|
443
423
|
return [mintReferral, platformReferral];
|
|
444
424
|
}
|
|
425
|
+
|
|
426
|
+
export function getDefaultFixedPriceMinterAddress(chainId: number): Address {
|
|
427
|
+
return zoraCreatorFixedPriceSaleStrategyAddress[
|
|
428
|
+
chainId as keyof typeof zoraCreatorFixedPriceSaleStrategyAddress
|
|
429
|
+
]!;
|
|
430
|
+
}
|
|
@@ -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
|
+
});
|
package/tsconfig.json
CHANGED
package/tsup.config.js
CHANGED
|
@@ -4,7 +4,8 @@ export default defineConfig({
|
|
|
4
4
|
entry: ["src/index.ts"],
|
|
5
5
|
sourcemap: true,
|
|
6
6
|
clean: true,
|
|
7
|
+
tsconfig: "tsconfig.build.json",
|
|
7
8
|
dts: false,
|
|
8
9
|
format: ["cjs", "esm"],
|
|
9
|
-
onSuccess: "tsc --emitDeclarationOnly --declaration --declarationMap",
|
|
10
|
+
onSuccess: "tsc --project tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap",
|
|
10
11
|
});
|
package/.turbo/turbo-lint.log
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"1155-create-helper.test.d.ts","sourceRoot":"","sources":["../../src/create/1155-create-helper.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mint-client.test.d.ts","sourceRoot":"","sources":["../../src/mint/mint-client.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"premint-client.test.d.ts","sourceRoot":"","sources":["../../src/premint/premint-client.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preminter.test.d.ts","sourceRoot":"","sources":["../../src/premint/preminter.test.ts"],"names":[],"mappings":""}
|