@zoralabs/protocol-sdk 0.5.16 → 0.5.17
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 +11 -0
- 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/index.cjs +204 -159
- 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 +208 -161
- package/dist/index.js.map +1 -1
- 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 +10 -22
- package/dist/premint/conversions.d.ts.map +1 -1
- package/dist/premint/premint-api-client.d.ts +5 -4
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +25 -25
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +28 -16
- package/dist/premint/preminter.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/apis/generated/premint-api-types.ts +9 -2
- package/src/index.ts +6 -0
- package/src/mints/mints-contracts.test.ts +2 -2
- package/src/premint/contract-types.ts +32 -1
- package/src/premint/conversions.ts +20 -8
- package/src/premint/premint-api-client.ts +7 -7
- package/src/premint/premint-client.test.ts +105 -87
- package/src/premint/premint-client.ts +204 -191
- package/src/premint/preminter.test.ts +154 -2
- package/src/premint/preminter.ts +86 -35
package/dist/index.cjs
CHANGED
|
@@ -37,8 +37,10 @@ __export(src_exports, {
|
|
|
37
37
|
createMintClient: () => createMintClient,
|
|
38
38
|
createPremintClient: () => createPremintClient,
|
|
39
39
|
decodeCallFailedError: () => decodeCallFailedError,
|
|
40
|
+
defaultAdditionalAdmins: () => defaultAdditionalAdmins,
|
|
40
41
|
defaultTokenConfigV1MintArguments: () => defaultTokenConfigV1MintArguments,
|
|
41
42
|
defaultTokenConfigV2MintArguments: () => defaultTokenConfigV2MintArguments,
|
|
43
|
+
emptyContractCreationConfig: () => emptyContractCreationConfig,
|
|
42
44
|
encodeCollectOnManager: () => encodeCollectOnManager,
|
|
43
45
|
encodePostSignatureInput: () => encodePostSignatureInput,
|
|
44
46
|
encodePremintForAPI: () => encodePremintForAPI,
|
|
@@ -71,6 +73,7 @@ __export(src_exports, {
|
|
|
71
73
|
sumBalances: () => sumBalances,
|
|
72
74
|
supportedPremintVersions: () => supportedPremintVersions,
|
|
73
75
|
supportsPremintVersion: () => supportsPremintVersion,
|
|
76
|
+
toContractCreationConfigOrAddress: () => toContractCreationConfigOrAddress,
|
|
74
77
|
tryRecoverPremintSigner: () => tryRecoverPremintSigner,
|
|
75
78
|
unwrapAndForwardEthPermitAndTypedDataDefinition: () => unwrapAndForwardEthPermitAndTypedDataDefinition
|
|
76
79
|
});
|
|
@@ -85,22 +88,21 @@ var import_protocol_deployments = require("@zoralabs/protocol-deployments");
|
|
|
85
88
|
var import_viem = require("viem");
|
|
86
89
|
var getPremintExecutorAddress = () => import_protocol_deployments.zoraCreator1155PremintExecutorImplAddress[999];
|
|
87
90
|
async function isAuthorizedToCreatePremint({
|
|
88
|
-
|
|
91
|
+
contractAdmin = import_viem.zeroAddress,
|
|
92
|
+
additionalAdmins = [],
|
|
89
93
|
collectionAddress,
|
|
90
94
|
publicClient,
|
|
91
95
|
signer
|
|
92
96
|
}) {
|
|
93
|
-
if (collection.additionalAdmins.length > 0)
|
|
94
|
-
throw new Error("additionalAdmins not supported yet.");
|
|
95
97
|
return await publicClient.readContract({
|
|
96
98
|
abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
|
|
97
99
|
address: getPremintExecutorAddress(),
|
|
98
100
|
functionName: "isAuthorizedToCreatePremintWithAdditionalAdmins",
|
|
99
101
|
args: [
|
|
100
|
-
signer,
|
|
101
|
-
|
|
102
|
+
typeof signer === "string" ? signer : signer.address,
|
|
103
|
+
contractAdmin,
|
|
102
104
|
collectionAddress,
|
|
103
|
-
|
|
105
|
+
additionalAdmins
|
|
104
106
|
]
|
|
105
107
|
});
|
|
106
108
|
}
|
|
@@ -125,17 +127,14 @@ async function isValidSignature({
|
|
|
125
127
|
signature,
|
|
126
128
|
publicClient,
|
|
127
129
|
collection,
|
|
130
|
+
collectionAddress,
|
|
128
131
|
chainId,
|
|
129
132
|
...premintConfigAndVersion
|
|
130
133
|
}) {
|
|
131
|
-
const tokenContract = await getPremintCollectionAddress({
|
|
132
|
-
collection,
|
|
133
|
-
publicClient
|
|
134
|
-
});
|
|
135
134
|
const recoveredAddress = await tryRecoverPremintSigner({
|
|
136
135
|
...premintConfigAndVersion,
|
|
137
136
|
signature,
|
|
138
|
-
verifyingContract:
|
|
137
|
+
verifyingContract: collectionAddress,
|
|
139
138
|
chainId
|
|
140
139
|
});
|
|
141
140
|
if (!import_viem.recoverAddress) {
|
|
@@ -145,8 +144,9 @@ async function isValidSignature({
|
|
|
145
144
|
}
|
|
146
145
|
const isAuthorized = await isAuthorizedToCreatePremint({
|
|
147
146
|
signer: recoveredAddress,
|
|
148
|
-
collection,
|
|
149
|
-
|
|
147
|
+
additionalAdmins: collection?.additionalAdmins,
|
|
148
|
+
contractAdmin: collection?.contractAdmin,
|
|
149
|
+
collectionAddress,
|
|
150
150
|
publicClient
|
|
151
151
|
});
|
|
152
152
|
return {
|
|
@@ -227,15 +227,24 @@ var supportsPremintVersion = async ({
|
|
|
227
227
|
return (await supportedPremintVersions({ tokenContract, publicClient })).includes(version);
|
|
228
228
|
};
|
|
229
229
|
async function getPremintCollectionAddress({
|
|
230
|
+
publicClient,
|
|
230
231
|
collection,
|
|
231
|
-
|
|
232
|
+
collectionAddress
|
|
232
233
|
}) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
234
|
+
if (typeof collection !== "undefined") {
|
|
235
|
+
return publicClient.readContract({
|
|
236
|
+
address: getPremintExecutorAddress(),
|
|
237
|
+
abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
|
|
238
|
+
functionName: "getContractWithAdditionalAdminsAddress",
|
|
239
|
+
args: [
|
|
240
|
+
{
|
|
241
|
+
...collection,
|
|
242
|
+
additionalAdmins: collection.additionalAdmins || []
|
|
243
|
+
}
|
|
244
|
+
]
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return collectionAddress;
|
|
239
248
|
}
|
|
240
249
|
function applyUpdateToPremint({
|
|
241
250
|
uid,
|
|
@@ -304,6 +313,34 @@ function makeMintRewardsRecipient({
|
|
|
304
313
|
function getDefaultFixedPriceMinterAddress(chainId) {
|
|
305
314
|
return import_protocol_deployments.zoraCreatorFixedPriceSaleStrategyAddress[chainId];
|
|
306
315
|
}
|
|
316
|
+
var emptyContractCreationConfig = () => ({
|
|
317
|
+
contractAdmin: import_viem.zeroAddress,
|
|
318
|
+
contractURI: "",
|
|
319
|
+
contractName: "",
|
|
320
|
+
additionalAdmins: []
|
|
321
|
+
});
|
|
322
|
+
function defaultAdditionalAdmins(collection) {
|
|
323
|
+
return {
|
|
324
|
+
...collection,
|
|
325
|
+
additionalAdmins: collection.additionalAdmins || []
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
var toContractCreationConfigOrAddress = ({
|
|
329
|
+
collection,
|
|
330
|
+
collectionAddress
|
|
331
|
+
}) => {
|
|
332
|
+
if (typeof collection !== "undefined") {
|
|
333
|
+
return {
|
|
334
|
+
collection
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
if (typeof collectionAddress !== "undefined") {
|
|
338
|
+
return {
|
|
339
|
+
collectionAddress
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
throw new Error("Must provide either a collection or a collection address");
|
|
343
|
+
};
|
|
307
344
|
|
|
308
345
|
// src/premint/premint-client.ts
|
|
309
346
|
var import_protocol_deployments4 = require("@zoralabs/protocol-deployments");
|
|
@@ -588,11 +625,16 @@ var MintAPIClient = class {
|
|
|
588
625
|
|
|
589
626
|
// src/premint/conversions.ts
|
|
590
627
|
var import_protocol_deployments2 = require("@zoralabs/protocol-deployments");
|
|
591
|
-
var convertCollectionFromApi = (collection) =>
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
628
|
+
var convertCollectionFromApi = (collection) => {
|
|
629
|
+
if (!collection)
|
|
630
|
+
return void 0;
|
|
631
|
+
return {
|
|
632
|
+
additionalAdmins: collection.additionalAdmins || [],
|
|
633
|
+
contractAdmin: collection.contractAdmin,
|
|
634
|
+
contractName: collection.contractName,
|
|
635
|
+
contractURI: collection.contractURI
|
|
636
|
+
};
|
|
637
|
+
};
|
|
596
638
|
var convertPremintFromApi = (premint) => {
|
|
597
639
|
if (premint.config_version === import_protocol_deployments2.PremintConfigVersion.V1 || !premint.config_version) {
|
|
598
640
|
const tokenConfig = premint.tokenConfig;
|
|
@@ -640,6 +682,7 @@ var convertPremintFromApi = (premint) => {
|
|
|
640
682
|
var convertGetPremintApiResponse = (response) => ({
|
|
641
683
|
...convertPremintFromApi(response.premint),
|
|
642
684
|
collection: convertCollectionFromApi(response.collection),
|
|
685
|
+
collectionAddress: response.collection_address,
|
|
643
686
|
signature: response.signature
|
|
644
687
|
});
|
|
645
688
|
var encodePremintV1ForAPI = ({
|
|
@@ -686,6 +729,7 @@ var encodePremintForAPI = ({
|
|
|
686
729
|
};
|
|
687
730
|
var encodePostSignatureInput = ({
|
|
688
731
|
collection,
|
|
732
|
+
collectionAddress,
|
|
689
733
|
premintConfigVersion,
|
|
690
734
|
premintConfig,
|
|
691
735
|
signature,
|
|
@@ -697,6 +741,7 @@ var encodePostSignatureInput = ({
|
|
|
697
741
|
}),
|
|
698
742
|
signature,
|
|
699
743
|
collection,
|
|
744
|
+
collection_address: collectionAddress,
|
|
700
745
|
chain_name: networkConfigByChain[chainId].zoraBackendChainName
|
|
701
746
|
});
|
|
702
747
|
|
|
@@ -732,13 +777,11 @@ var getSignature = async ({
|
|
|
732
777
|
var PremintAPIClient = class {
|
|
733
778
|
constructor(chainId, httpClient2) {
|
|
734
779
|
this.postSignature = async ({
|
|
735
|
-
collection,
|
|
736
780
|
signature,
|
|
737
|
-
...
|
|
781
|
+
...rest
|
|
738
782
|
}) => {
|
|
739
783
|
const data = encodePostSignatureInput({
|
|
740
|
-
|
|
741
|
-
...premintConfigAndVersion,
|
|
784
|
+
...rest,
|
|
742
785
|
chainId: this.networkConfig.chainId,
|
|
743
786
|
signature
|
|
744
787
|
});
|
|
@@ -792,6 +835,37 @@ var defaultTokenConfigV1MintArguments = () => ({
|
|
|
792
835
|
royaltyBPS: 1e3
|
|
793
836
|
// 10%,
|
|
794
837
|
});
|
|
838
|
+
var pickTokenConfigV1 = (tokenConfig) => ({
|
|
839
|
+
maxSupply: tokenConfig.maxSupply,
|
|
840
|
+
maxTokensPerAddress: tokenConfig.maxTokensPerAddress,
|
|
841
|
+
pricePerToken: tokenConfig.pricePerToken,
|
|
842
|
+
mintDuration: tokenConfig.mintDuration,
|
|
843
|
+
mintStart: tokenConfig.mintStart,
|
|
844
|
+
royaltyBPS: tokenConfig.royaltyBPS,
|
|
845
|
+
tokenURI: tokenConfig.tokenURI,
|
|
846
|
+
royaltyRecipient: tokenConfig.payoutRecipient
|
|
847
|
+
});
|
|
848
|
+
var pickTokenConfigV2 = (tokenConfig) => ({
|
|
849
|
+
maxSupply: tokenConfig.maxSupply,
|
|
850
|
+
maxTokensPerAddress: tokenConfig.maxTokensPerAddress,
|
|
851
|
+
pricePerToken: tokenConfig.pricePerToken,
|
|
852
|
+
mintDuration: tokenConfig.mintDuration,
|
|
853
|
+
mintStart: tokenConfig.mintStart,
|
|
854
|
+
royaltyBPS: tokenConfig.royaltyBPS,
|
|
855
|
+
tokenURI: tokenConfig.tokenURI,
|
|
856
|
+
payoutRecipient: tokenConfig.payoutRecipient,
|
|
857
|
+
createReferral: tokenConfig.createReferral || import_viem5.zeroAddress
|
|
858
|
+
});
|
|
859
|
+
var tokenConfigV1WithDefault = (tokenConfig, fixedPriceMinter) => ({
|
|
860
|
+
...pickTokenConfigV1(tokenConfig),
|
|
861
|
+
...defaultTokenConfigV1MintArguments(),
|
|
862
|
+
fixedPriceMinter
|
|
863
|
+
});
|
|
864
|
+
var tokenConfigV2WithDefault = (tokenConfig, fixedPriceMinter) => ({
|
|
865
|
+
...pickTokenConfigV2(tokenConfig),
|
|
866
|
+
...defaultTokenConfigV2MintArguments(),
|
|
867
|
+
fixedPriceMinter
|
|
868
|
+
});
|
|
795
869
|
var defaultTokenConfigV2MintArguments = () => ({
|
|
796
870
|
maxSupply: OPEN_EDITION_MINT_SIZE,
|
|
797
871
|
maxTokensPerAddress: 0n,
|
|
@@ -804,32 +878,29 @@ var defaultTokenConfigV2MintArguments = () => ({
|
|
|
804
878
|
});
|
|
805
879
|
var makeTokenConfigWithDefaults = ({
|
|
806
880
|
chainId,
|
|
807
|
-
premintConfigVersion,
|
|
808
881
|
tokenCreationConfig,
|
|
809
|
-
|
|
882
|
+
supportedPremintVersions: supportedPremintVersions2
|
|
810
883
|
}) => {
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
return {
|
|
817
|
-
fixedPriceMinter,
|
|
818
|
-
...defaultTokenConfigV1MintArguments(),
|
|
819
|
-
royaltyRecipient: payoutRecipient,
|
|
820
|
-
...tokenCreationConfig
|
|
821
|
-
};
|
|
822
|
-
} else if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V2) {
|
|
884
|
+
const fixedPriceMinter = getDefaultFixedPriceMinterAddress(chainId);
|
|
885
|
+
if (!supportedPremintVersions2.includes(import_protocol_deployments4.PremintConfigVersion.V2)) {
|
|
886
|
+
if (tokenCreationConfig.createReferral) {
|
|
887
|
+
throw new Error("Contract does not support create referral");
|
|
888
|
+
}
|
|
823
889
|
return {
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
890
|
+
premintConfigVersion: import_protocol_deployments4.PremintConfigVersion.V1,
|
|
891
|
+
tokenConfig: tokenConfigV1WithDefault(
|
|
892
|
+
tokenCreationConfig,
|
|
893
|
+
fixedPriceMinter
|
|
894
|
+
)
|
|
829
895
|
};
|
|
830
|
-
} else {
|
|
831
|
-
throw new Error(`Invalid premint config version ${premintConfigVersion}`);
|
|
832
896
|
}
|
|
897
|
+
return {
|
|
898
|
+
premintConfigVersion: import_protocol_deployments4.PremintConfigVersion.V2,
|
|
899
|
+
tokenConfig: tokenConfigV2WithDefault(
|
|
900
|
+
tokenCreationConfig,
|
|
901
|
+
fixedPriceMinter
|
|
902
|
+
)
|
|
903
|
+
};
|
|
833
904
|
};
|
|
834
905
|
function getPremintedLogFromReceipt(receipt) {
|
|
835
906
|
for (const data of receipt.logs) {
|
|
@@ -939,17 +1010,22 @@ var PremintClient = class {
|
|
|
939
1010
|
*/
|
|
940
1011
|
async isValidSignature({
|
|
941
1012
|
signature,
|
|
942
|
-
collection,
|
|
943
1013
|
premintConfig,
|
|
944
|
-
premintConfigVersion
|
|
1014
|
+
premintConfigVersion,
|
|
1015
|
+
...collectionAndOrAddress
|
|
945
1016
|
}) {
|
|
1017
|
+
const collectionAddressToUse = await getPremintCollectionAddress({
|
|
1018
|
+
...collectionAndOrAddress,
|
|
1019
|
+
publicClient: this.publicClient
|
|
1020
|
+
});
|
|
946
1021
|
const { isAuthorized, recoveredAddress } = await isValidSignature({
|
|
947
1022
|
chainId: this.chain.id,
|
|
948
1023
|
signature,
|
|
949
|
-
collection,
|
|
950
1024
|
publicClient: this.publicClient,
|
|
951
1025
|
premintConfig,
|
|
952
|
-
premintConfigVersion: premintConfigVersion || import_protocol_deployments4.PremintConfigVersion.V1
|
|
1026
|
+
premintConfigVersion: premintConfigVersion || import_protocol_deployments4.PremintConfigVersion.V1,
|
|
1027
|
+
collectionAddress: collectionAddressToUse,
|
|
1028
|
+
collection: collectionAndOrAddress.collection
|
|
953
1029
|
});
|
|
954
1030
|
return { isValid: isAuthorized, recoveredSigner: recoveredAddress };
|
|
955
1031
|
}
|
|
@@ -999,12 +1075,12 @@ function createPremintClient(clientConfig) {
|
|
|
999
1075
|
function makePremintReturn({
|
|
1000
1076
|
premintConfig,
|
|
1001
1077
|
premintConfigVersion,
|
|
1002
|
-
collectionAddress,
|
|
1003
|
-
collection,
|
|
1004
1078
|
publicClient,
|
|
1005
1079
|
apiClient,
|
|
1006
|
-
chainId
|
|
1080
|
+
chainId,
|
|
1081
|
+
...collectionAndAddress
|
|
1007
1082
|
}) {
|
|
1083
|
+
const { collection, collectionAddress } = collectionAndAddress;
|
|
1008
1084
|
const typedDataDefinition = (0, import_protocol_deployments4.premintTypedDataDefinition)({
|
|
1009
1085
|
verifyingContract: collectionAddress,
|
|
1010
1086
|
premintConfig,
|
|
@@ -1037,20 +1113,19 @@ function makePremintReturn({
|
|
|
1037
1113
|
signerAccount
|
|
1038
1114
|
}) => {
|
|
1039
1115
|
if (checkSignature) {
|
|
1040
|
-
await
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
},
|
|
1116
|
+
const isAuthorized = await isAuthorizedToCreatePremint({
|
|
1117
|
+
collectionAddress,
|
|
1118
|
+
additionalAdmins: collection?.additionalAdmins,
|
|
1119
|
+
contractAdmin: collection?.contractAdmin,
|
|
1045
1120
|
publicClient,
|
|
1046
|
-
signerAccount
|
|
1121
|
+
signer: signerAccount
|
|
1047
1122
|
});
|
|
1123
|
+
if (!isAuthorized) {
|
|
1124
|
+
throw new Error("Not authorized to create premint");
|
|
1125
|
+
}
|
|
1048
1126
|
}
|
|
1049
1127
|
await apiClient.postSignature({
|
|
1050
|
-
|
|
1051
|
-
...collection,
|
|
1052
|
-
additionalAdmins: []
|
|
1053
|
-
},
|
|
1128
|
+
...toContractCreationConfigOrAddress(collectionAndAddress),
|
|
1054
1129
|
signature,
|
|
1055
1130
|
premintConfig,
|
|
1056
1131
|
premintConfigVersion
|
|
@@ -1085,43 +1160,21 @@ async function signPremint({
|
|
|
1085
1160
|
signerAccount: account
|
|
1086
1161
|
};
|
|
1087
1162
|
}
|
|
1088
|
-
var validateSignature = async ({
|
|
1089
|
-
collection,
|
|
1090
|
-
publicClient,
|
|
1091
|
-
signerAccount
|
|
1092
|
-
}) => {
|
|
1093
|
-
const isAuthorized = await isAuthorizedToCreatePremint({
|
|
1094
|
-
collection,
|
|
1095
|
-
publicClient,
|
|
1096
|
-
signer: typeof signerAccount === "string" ? signerAccount : signerAccount.address,
|
|
1097
|
-
collectionAddress: await getPremintCollectionAddress({
|
|
1098
|
-
collection,
|
|
1099
|
-
publicClient
|
|
1100
|
-
})
|
|
1101
|
-
});
|
|
1102
|
-
if (!isAuthorized) {
|
|
1103
|
-
throw new Error("Not authorized to create premint");
|
|
1104
|
-
}
|
|
1105
|
-
};
|
|
1106
1163
|
async function createPremint({
|
|
1107
|
-
payoutRecipient: creatorAccount,
|
|
1108
|
-
collection,
|
|
1109
1164
|
tokenCreationConfig,
|
|
1110
|
-
premintConfigVersion,
|
|
1111
1165
|
uid,
|
|
1112
1166
|
publicClient,
|
|
1113
1167
|
apiClient,
|
|
1114
|
-
chainId
|
|
1168
|
+
chainId,
|
|
1169
|
+
...collectionOrAddress
|
|
1115
1170
|
}) {
|
|
1116
1171
|
const {
|
|
1117
1172
|
premintConfig,
|
|
1118
|
-
premintConfigVersion
|
|
1119
|
-
collectionAddress
|
|
1173
|
+
premintConfigVersion,
|
|
1174
|
+
collectionAddress: collectionAddressToUse
|
|
1120
1175
|
} = await prepareCreatePremintConfig({
|
|
1121
|
-
|
|
1122
|
-
collection,
|
|
1176
|
+
...collectionOrAddress,
|
|
1123
1177
|
tokenCreationConfig,
|
|
1124
|
-
premintConfigVersion,
|
|
1125
1178
|
uid,
|
|
1126
1179
|
publicClient,
|
|
1127
1180
|
apiClient,
|
|
@@ -1129,59 +1182,49 @@ async function createPremint({
|
|
|
1129
1182
|
});
|
|
1130
1183
|
return makePremintReturn({
|
|
1131
1184
|
premintConfig,
|
|
1132
|
-
premintConfigVersion
|
|
1133
|
-
collectionAddress,
|
|
1134
|
-
collection,
|
|
1185
|
+
premintConfigVersion,
|
|
1186
|
+
collectionAddress: collectionAddressToUse,
|
|
1187
|
+
collection: collectionOrAddress.collection,
|
|
1135
1188
|
publicClient,
|
|
1136
1189
|
apiClient,
|
|
1137
1190
|
chainId
|
|
1138
1191
|
});
|
|
1139
1192
|
}
|
|
1140
1193
|
async function prepareCreatePremintConfig({
|
|
1141
|
-
payoutRecipient,
|
|
1142
|
-
collection,
|
|
1143
1194
|
tokenCreationConfig,
|
|
1144
|
-
premintConfigVersion,
|
|
1145
1195
|
uid,
|
|
1146
1196
|
publicClient,
|
|
1147
1197
|
apiClient,
|
|
1148
|
-
chainId
|
|
1198
|
+
chainId,
|
|
1199
|
+
...collectionOrAddress
|
|
1149
1200
|
}) {
|
|
1150
|
-
const collectionWithAdditionalAdmins = {
|
|
1151
|
-
...collection,
|
|
1152
|
-
additionalAdmins: collection.additionalAdmins || []
|
|
1153
|
-
};
|
|
1154
1201
|
const newContractAddress = await getPremintCollectionAddress({
|
|
1155
1202
|
publicClient,
|
|
1156
|
-
|
|
1203
|
+
...collectionOrAddress
|
|
1157
1204
|
});
|
|
1158
1205
|
let uidToUse = uid;
|
|
1159
1206
|
if (typeof uidToUse !== "number") {
|
|
1160
1207
|
uidToUse = await apiClient.getNextUID(newContractAddress);
|
|
1161
1208
|
}
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
}
|
|
1209
|
+
const supportedVersions = await supportedPremintVersions({
|
|
1210
|
+
tokenContract: newContractAddress,
|
|
1211
|
+
publicClient
|
|
1212
|
+
});
|
|
1213
|
+
const tokenConfigAndVersion = makeTokenConfigWithDefaults({
|
|
1214
|
+
tokenCreationConfig,
|
|
1215
|
+
chainId,
|
|
1216
|
+
supportedPremintVersions: supportedVersions
|
|
1217
|
+
});
|
|
1172
1218
|
const premintConfig = makeNewPremint({
|
|
1173
|
-
|
|
1174
|
-
// @ts-ignore
|
|
1175
|
-
premintConfigVersion: actualVersion,
|
|
1176
|
-
tokenCreationConfig,
|
|
1177
|
-
payoutRecipient: typeof payoutRecipient === "string" ? payoutRecipient : payoutRecipient.address,
|
|
1178
|
-
chainId
|
|
1179
|
-
}),
|
|
1219
|
+
...tokenConfigAndVersion,
|
|
1180
1220
|
uid: uidToUse
|
|
1181
1221
|
});
|
|
1182
|
-
|
|
1222
|
+
const premintConfigAndVersion = {
|
|
1183
1223
|
premintConfig,
|
|
1184
|
-
premintConfigVersion:
|
|
1224
|
+
premintConfigVersion: tokenConfigAndVersion.premintConfigVersion
|
|
1225
|
+
};
|
|
1226
|
+
return {
|
|
1227
|
+
...premintConfigAndVersion,
|
|
1185
1228
|
collectionAddress: newContractAddress
|
|
1186
1229
|
};
|
|
1187
1230
|
}
|
|
@@ -1227,7 +1270,8 @@ async function deletePremint({
|
|
|
1227
1270
|
const {
|
|
1228
1271
|
premintConfig,
|
|
1229
1272
|
premintConfigVersion,
|
|
1230
|
-
collection: collectionCreationConfig
|
|
1273
|
+
collection: collectionCreationConfig,
|
|
1274
|
+
collectionAddress
|
|
1231
1275
|
} = await apiClient.getSignature({
|
|
1232
1276
|
collectionAddress: collection,
|
|
1233
1277
|
uid
|
|
@@ -1240,7 +1284,7 @@ async function deletePremint({
|
|
|
1240
1284
|
return makePremintReturn({
|
|
1241
1285
|
premintConfig: deletedPremint,
|
|
1242
1286
|
premintConfigVersion,
|
|
1243
|
-
collectionAddress
|
|
1287
|
+
collectionAddress,
|
|
1244
1288
|
collection: collectionCreationConfig,
|
|
1245
1289
|
publicClient,
|
|
1246
1290
|
apiClient,
|
|
@@ -1252,6 +1296,7 @@ async function makeMintParameters({
|
|
|
1252
1296
|
tokenContract,
|
|
1253
1297
|
minterAccount,
|
|
1254
1298
|
mintArguments,
|
|
1299
|
+
firstMinter,
|
|
1255
1300
|
apiClient,
|
|
1256
1301
|
publicClient
|
|
1257
1302
|
}) {
|
|
@@ -1261,7 +1306,13 @@ async function makeMintParameters({
|
|
|
1261
1306
|
if (!minterAccount) {
|
|
1262
1307
|
throw new Error("Wallet not passed in");
|
|
1263
1308
|
}
|
|
1264
|
-
const {
|
|
1309
|
+
const {
|
|
1310
|
+
premintConfig,
|
|
1311
|
+
premintConfigVersion,
|
|
1312
|
+
collection,
|
|
1313
|
+
collectionAddress,
|
|
1314
|
+
signature
|
|
1315
|
+
} = await apiClient.getSignature({
|
|
1265
1316
|
collectionAddress: tokenContract,
|
|
1266
1317
|
uid
|
|
1267
1318
|
});
|
|
@@ -1282,38 +1333,29 @@ async function makeMintParameters({
|
|
|
1282
1333
|
mintReferral: mintArguments?.mintReferral
|
|
1283
1334
|
})
|
|
1284
1335
|
};
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
]
|
|
1299
|
-
});
|
|
1300
|
-
} else if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V2) {
|
|
1301
|
-
return makeSimulateContractParamaters({
|
|
1302
|
-
account: minterAccount,
|
|
1303
|
-
abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
|
|
1304
|
-
functionName: "premintV2",
|
|
1305
|
-
value,
|
|
1306
|
-
address: getPremintExecutorAddress(),
|
|
1307
|
-
args: [
|
|
1308
|
-
collection,
|
|
1336
|
+
const collectionOrEmpty = collection ? defaultAdditionalAdmins(collection) : emptyContractCreationConfig();
|
|
1337
|
+
const collectionAddressToSubmit = collection ? import_viem5.zeroAddress : collectionAddress;
|
|
1338
|
+
const firstMinterToSubmit = firstMinter || (typeof minterAccount === "string" ? minterAccount : minterAccount.address);
|
|
1339
|
+
return makeSimulateContractParamaters({
|
|
1340
|
+
account: minterAccount,
|
|
1341
|
+
abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
|
|
1342
|
+
functionName: "premint",
|
|
1343
|
+
value,
|
|
1344
|
+
address: getPremintExecutorAddress(),
|
|
1345
|
+
args: [
|
|
1346
|
+
collectionOrEmpty,
|
|
1347
|
+
collectionAddressToSubmit,
|
|
1348
|
+
(0, import_protocol_deployments3.encodePremintConfig)({
|
|
1309
1349
|
premintConfig,
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1350
|
+
premintConfigVersion
|
|
1351
|
+
}),
|
|
1352
|
+
signature,
|
|
1353
|
+
numberToMint,
|
|
1354
|
+
mintArgumentsContract,
|
|
1355
|
+
firstMinterToSubmit,
|
|
1356
|
+
import_viem5.zeroAddress
|
|
1357
|
+
]
|
|
1358
|
+
});
|
|
1317
1359
|
}
|
|
1318
1360
|
function makeUrls({
|
|
1319
1361
|
uid,
|
|
@@ -2083,8 +2125,10 @@ var unwrapAndForwardEthPermitAndTypedDataDefinition = ({
|
|
|
2083
2125
|
createMintClient,
|
|
2084
2126
|
createPremintClient,
|
|
2085
2127
|
decodeCallFailedError,
|
|
2128
|
+
defaultAdditionalAdmins,
|
|
2086
2129
|
defaultTokenConfigV1MintArguments,
|
|
2087
2130
|
defaultTokenConfigV2MintArguments,
|
|
2131
|
+
emptyContractCreationConfig,
|
|
2088
2132
|
encodeCollectOnManager,
|
|
2089
2133
|
encodePostSignatureInput,
|
|
2090
2134
|
encodePremintForAPI,
|
|
@@ -2117,6 +2161,7 @@ var unwrapAndForwardEthPermitAndTypedDataDefinition = ({
|
|
|
2117
2161
|
sumBalances,
|
|
2118
2162
|
supportedPremintVersions,
|
|
2119
2163
|
supportsPremintVersion,
|
|
2164
|
+
toContractCreationConfigOrAddress,
|
|
2120
2165
|
tryRecoverPremintSigner,
|
|
2121
2166
|
unwrapAndForwardEthPermitAndTypedDataDefinition
|
|
2122
2167
|
});
|