@zoralabs/protocol-sdk 0.5.12 → 0.5.14
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 +16 -0
- package/dist/apis/chain-constants.d.ts.map +1 -1
- package/dist/apis/generated/premint-api-types.d.ts +1 -1
- package/dist/apis/generated/premint-api-types.d.ts.map +1 -1
- package/dist/index.cjs +1482 -11683
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1468 -11678
- package/dist/index.js.map +1 -1
- package/dist/mints/mints-contracts.d.ts +127 -154
- package/dist/mints/mints-contracts.d.ts.map +1 -1
- package/dist/mints/mints-eth-unwrapper-and-caller.d.ts +1 -24
- 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/premint/contract-types.d.ts +2 -121
- package/dist/premint/contract-types.d.ts.map +1 -1
- package/dist/premint/conversions.d.ts +15 -35
- 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 +2717 -4
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +3 -17
- package/dist/premint/preminter.d.ts.map +1 -1
- package/dist/preminter.d.ts +1 -1
- package/package.json +2 -3
- package/src/apis/chain-constants.ts +8 -0
- package/src/apis/generated/premint-api-types.ts +1 -0
- package/src/mint/mint-api-client.ts +3 -3
- package/src/mints/mints-contracts.test.ts +3 -5
- package/src/mints/mints-contracts.ts +16 -128
- package/src/mints/mints-queries.ts +1 -2
- package/src/premint/contract-types.ts +4 -106
- package/src/premint/conversions.ts +2 -1
- package/src/premint/premint-api-client.ts +1 -1
- package/src/premint/premint-client.test.ts +17 -6
- package/src/premint/premint-client.ts +28 -23
- package/src/premint/preminter.test.ts +239 -143
- package/src/premint/preminter.ts +11 -64
- package/test-integration/premint-client.test.ts +2 -0
package/src/premint/preminter.ts
CHANGED
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
zoraCreator1155PremintExecutorImplABI,
|
|
6
6
|
zoraCreator1155PremintExecutorImplAddress,
|
|
7
7
|
zoraCreatorFixedPriceSaleStrategyAddress,
|
|
8
|
+
premintTypedDataDefinition,
|
|
8
9
|
} from "@zoralabs/protocol-deployments";
|
|
9
10
|
import {
|
|
10
|
-
TypedDataDefinition,
|
|
11
11
|
recoverTypedDataAddress,
|
|
12
12
|
Hex,
|
|
13
13
|
PublicClient,
|
|
@@ -27,59 +27,12 @@ import {
|
|
|
27
27
|
PremintConfigV2,
|
|
28
28
|
PremintConfigVersion,
|
|
29
29
|
PremintConfigWithVersion,
|
|
30
|
-
PreminterDomain,
|
|
31
30
|
TokenCreationConfig,
|
|
32
|
-
|
|
33
|
-
v2Types,
|
|
34
|
-
} from "./contract-types";
|
|
31
|
+
} from "@zoralabs/protocol-deployments";
|
|
35
32
|
import { MintCosts } from "src/mint/mint-client";
|
|
36
33
|
|
|
37
34
|
export const getPremintExecutorAddress = () =>
|
|
38
|
-
zoraCreator1155PremintExecutorImplAddress[999];
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Creates a typed data definition for a premint config. Works for all versions of the premint config by specifying the premintConfigVersion.
|
|
42
|
-
*
|
|
43
|
-
* @param params.verifyingContract the address of the 1155 contract
|
|
44
|
-
* @param params.chainId the chain id the premint is signed for
|
|
45
|
-
* @param params.premintConfigVersion the version of the premint config
|
|
46
|
-
* @param params.premintConfig the premint config
|
|
47
|
-
* @returns
|
|
48
|
-
*/
|
|
49
|
-
export const premintTypedDataDefinition = <T extends PremintConfigVersion>({
|
|
50
|
-
verifyingContract,
|
|
51
|
-
chainId,
|
|
52
|
-
premintConfigVersion: version,
|
|
53
|
-
premintConfig,
|
|
54
|
-
}: {
|
|
55
|
-
verifyingContract: Address;
|
|
56
|
-
chainId: number;
|
|
57
|
-
} & PremintConfigWithVersion<T>): TypedDataDefinition => {
|
|
58
|
-
const domain = {
|
|
59
|
-
chainId,
|
|
60
|
-
name: PreminterDomain,
|
|
61
|
-
version,
|
|
62
|
-
verifyingContract: verifyingContract,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
if (version === PremintConfigVersion.V1)
|
|
66
|
-
return {
|
|
67
|
-
domain,
|
|
68
|
-
types: v1Types,
|
|
69
|
-
message: premintConfig as PremintConfigV1,
|
|
70
|
-
primaryType: "CreatorAttribution",
|
|
71
|
-
} satisfies TypedDataDefinition<typeof v1Types, "CreatorAttribution">;
|
|
72
|
-
if (version === PremintConfigVersion.V2) {
|
|
73
|
-
return {
|
|
74
|
-
domain,
|
|
75
|
-
types: v2Types,
|
|
76
|
-
message: premintConfig as PremintConfigV2,
|
|
77
|
-
primaryType: "CreatorAttribution",
|
|
78
|
-
} satisfies TypedDataDefinition<typeof v2Types, "CreatorAttribution">;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
throw new Error(`Invalid version ${version}`);
|
|
82
|
-
};
|
|
35
|
+
zoraCreator1155PremintExecutorImplAddress[999] as Address;
|
|
83
36
|
|
|
84
37
|
export type IsValidSignatureReturn = {
|
|
85
38
|
isAuthorized: boolean;
|
|
@@ -101,8 +54,13 @@ export async function isAuthorizedToCreatePremint({
|
|
|
101
54
|
return await publicClient.readContract({
|
|
102
55
|
abi: preminterAbi,
|
|
103
56
|
address: getPremintExecutorAddress(),
|
|
104
|
-
functionName: "
|
|
105
|
-
args: [
|
|
57
|
+
functionName: "isAuthorizedToCreatePremintWithAdditionalAdmins",
|
|
58
|
+
args: [
|
|
59
|
+
signer,
|
|
60
|
+
collection.contractAdmin,
|
|
61
|
+
collectionAddress,
|
|
62
|
+
collection.additionalAdmins,
|
|
63
|
+
],
|
|
106
64
|
});
|
|
107
65
|
}
|
|
108
66
|
|
|
@@ -114,9 +72,8 @@ export async function recoverPremintSigner<T extends PremintConfigVersion>({
|
|
|
114
72
|
chainId: number;
|
|
115
73
|
verifyingContract: Address;
|
|
116
74
|
} & PremintConfigWithVersion<T>): Promise<Address> {
|
|
117
|
-
const typedData = premintTypedDataDefinition(rest);
|
|
118
75
|
return await recoverTypedDataAddress({
|
|
119
|
-
...
|
|
76
|
+
...premintTypedDataDefinition(rest),
|
|
120
77
|
signature,
|
|
121
78
|
});
|
|
122
79
|
}
|
|
@@ -321,16 +278,6 @@ export async function getPremintCollectionAddress({
|
|
|
321
278
|
});
|
|
322
279
|
}
|
|
323
280
|
|
|
324
|
-
export function markPremintDeleted<T extends PremintConfig>(
|
|
325
|
-
premintConfig: T,
|
|
326
|
-
): T {
|
|
327
|
-
return {
|
|
328
|
-
...premintConfig,
|
|
329
|
-
version: premintConfig.version + 1,
|
|
330
|
-
deleted: true,
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
|
|
334
281
|
export function applyUpdateToPremint({
|
|
335
282
|
uid,
|
|
336
283
|
version,
|
|
@@ -54,6 +54,7 @@ tests.forEach(({ anvilTest, chain }) => {
|
|
|
54
54
|
contractName: "Testing Contract Premint V2",
|
|
55
55
|
contractURI:
|
|
56
56
|
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3f",
|
|
57
|
+
additionalAdmins: [],
|
|
57
58
|
},
|
|
58
59
|
premintConfigVersion: PremintConfigVersion.V2,
|
|
59
60
|
tokenCreationConfig: {
|
|
@@ -110,6 +111,7 @@ tests.forEach(({ anvilTest, chain }) => {
|
|
|
110
111
|
contractName: `Testing Contract Premint V1 ${publicClient.chain?.name}`,
|
|
111
112
|
contractURI:
|
|
112
113
|
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3fg",
|
|
114
|
+
additionalAdmins: [],
|
|
113
115
|
},
|
|
114
116
|
premintConfigVersion: PremintConfigVersion.V1,
|
|
115
117
|
tokenCreationConfig: {
|