@zoralabs/protocol-sdk 0.5.15 → 0.5.16

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/dist/index.cjs CHANGED
@@ -61,6 +61,7 @@ __export(src_exports, {
61
61
  makePermitToCollectPremintOrNonPremint: () => makePermitToCollectPremintOrNonPremint,
62
62
  makePermitTransferBatchAndTypeData: () => makePermitTransferBatchAndTypeData,
63
63
  makePermitTransferTypeData: () => makePermitTransferTypeData,
64
+ makeUrls: () => makeUrls,
64
65
  migratePremintConfigToV2: () => migratePremintConfigToV2,
65
66
  mintWithEthParams: () => mintWithEthParams,
66
67
  mintsBalanceOfAccountParams: () => mintsBalanceOfAccountParams,
@@ -76,7 +77,7 @@ __export(src_exports, {
76
77
  module.exports = __toCommonJS(src_exports);
77
78
 
78
79
  // src/premint/premint-client.ts
79
- var import_viem4 = require("viem");
80
+ var import_viem5 = require("viem");
80
81
  var import_protocol_deployments3 = require("@zoralabs/protocol-deployments");
81
82
 
82
83
  // src/premint/preminter.ts
@@ -769,7 +770,15 @@ var PremintAPIClient = class {
769
770
  };
770
771
 
771
772
  // src/utils.ts
773
+ var import_viem4 = require("viem");
772
774
  var makeSimulateContractParamaters = (args) => args;
775
+ function setupClient({ chain, httpClient: httpClient2, publicClient }) {
776
+ return {
777
+ chain,
778
+ httpClient: httpClient2 || httpClient,
779
+ publicClient: publicClient || (0, import_viem4.createPublicClient)({ chain, transport: (0, import_viem4.http)() })
780
+ };
781
+ }
773
782
 
774
783
  // src/premint/premint-client.ts
775
784
  var defaultTokenConfigV1MintArguments = () => ({
@@ -797,7 +806,7 @@ var makeTokenConfigWithDefaults = ({
797
806
  chainId,
798
807
  premintConfigVersion,
799
808
  tokenCreationConfig,
800
- creatorAccount
809
+ payoutRecipient
801
810
  }) => {
802
811
  if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V3) {
803
812
  throw new Error("PremintV3 not supported in SDK");
@@ -807,15 +816,15 @@ var makeTokenConfigWithDefaults = ({
807
816
  return {
808
817
  fixedPriceMinter,
809
818
  ...defaultTokenConfigV1MintArguments(),
810
- royaltyRecipient: creatorAccount,
819
+ royaltyRecipient: payoutRecipient,
811
820
  ...tokenCreationConfig
812
821
  };
813
822
  } else if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V2) {
814
823
  return {
815
824
  fixedPriceMinter,
816
825
  ...defaultTokenConfigV2MintArguments(),
817
- payoutRecipient: creatorAccount,
818
- createReferral: import_viem4.zeroAddress,
826
+ payoutRecipient,
827
+ createReferral: import_viem5.zeroAddress,
819
828
  ...tokenCreationConfig
820
829
  };
821
830
  } else {
@@ -825,7 +834,7 @@ var makeTokenConfigWithDefaults = ({
825
834
  function getPremintedLogFromReceipt(receipt) {
826
835
  for (const data of receipt.logs) {
827
836
  try {
828
- const decodedLog = (0, import_viem4.decodeEventLog)({
837
+ const decodedLog = (0, import_viem5.decodeEventLog)({
829
838
  abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
830
839
  eventName: "PremintedV2",
831
840
  ...data
@@ -841,7 +850,7 @@ var PremintClient = class {
841
850
  constructor(chain, publicClient, httpClient2) {
842
851
  this.chain = chain;
843
852
  this.apiClient = new PremintAPIClient(chain.id, httpClient2);
844
- this.publicClient = publicClient || (0, import_viem4.createPublicClient)({ chain, transport: (0, import_viem4.http)() });
853
+ this.publicClient = publicClient;
845
854
  }
846
855
  getDataFromPremintReceipt(receipt) {
847
856
  const premintedLog = getPremintedLogFromReceipt(receipt);
@@ -854,174 +863,45 @@ var PremintClient = class {
854
863
  };
855
864
  }
856
865
  /**
857
- * Update existing premint given collection address and UID of existing premint.
858
- *
859
- * 1. Loads existing premint token
860
- * 2. Updates with settings passed into function
861
- * 3. Increments the version field
862
- * 4. Re-signs the premint
863
- * 5. Uploads the premint to the ZORA API
864
- *
865
- * Updates existing premint
866
- * @param settings Settings for the new premint
867
- * @param settings.account Account to sign the premint update from. Taken from walletClient if none passed in.
868
- * @param settings.collection Collection information for the mint
869
- * @param settings.walletClient viem wallet client to use to sign
870
- * @param settings.uid UID
871
- * @param settings.token Mint argument settings, optional settings are overridden with sensible defaults.
872
- *
873
- */
874
- async updatePremint({
875
- walletClient,
876
- uid,
877
- collection,
878
- account,
879
- tokenConfigUpdates
880
- }) {
881
- const {
882
- premintConfig,
883
- collection: collectionCreationConfig,
884
- premintConfigVersion
885
- } = await this.apiClient.getSignature({
886
- collectionAddress: collection,
887
- uid
888
- });
889
- const updatedPremint = applyUpdateToPremint({
890
- uid: premintConfig.uid,
891
- version: premintConfig.version,
892
- tokenConfig: premintConfig.tokenConfig,
893
- tokenConfigUpdates
894
- });
895
- return await this.signAndSubmitPremint({
896
- walletClient,
897
- account,
898
- checkSignature: true,
899
- verifyingContract: collection,
900
- collection: collectionCreationConfig,
901
- premintConfig: updatedPremint,
902
- premintConfigVersion
903
- });
904
- }
905
- /**
906
- * Delete premint.
907
- *
908
- * 1. Loads current premint from collection address with UID
909
- * 2. Increments version and marks as deleted
910
- * 3. Signs new premint version
911
- * 4. Sends to ZORA Premint API
912
- *
913
- * Deletes existing premint
914
- * @param settings.collection collection address
915
- * @param settings.uid UID
916
- * @param settings.walletClient viem wallet client to use to sign
866
+ * Prepares data for updating a premint
917
867
  *
868
+ * @param parameters - Parameters for updating the premint {@link UpdatePremintParams}
869
+ * @returns A PremintReturn. {@link PremintReturn}
918
870
  */
919
- async deletePremint({
920
- walletClient,
921
- uid,
922
- account,
923
- collection
924
- }) {
925
- const {
926
- premintConfig,
927
- premintConfigVersion,
928
- collection: collectionCreationConfig
929
- } = await this.apiClient.getSignature({
930
- collectionAddress: collection,
931
- uid
932
- });
933
- const deletedPremint = {
934
- ...premintConfig,
935
- version: premintConfig.version + 1,
936
- deleted: true
937
- };
938
- return await this.signAndSubmitPremint({
939
- walletClient,
940
- account,
941
- checkSignature: false,
942
- verifyingContract: collection,
943
- collection: collectionCreationConfig,
944
- premintConfig: deletedPremint,
945
- premintConfigVersion
871
+ async updatePremint(args) {
872
+ return await updatePremint({
873
+ ...args,
874
+ apiClient: this.apiClient,
875
+ publicClient: this.publicClient,
876
+ chainId: this.chain.id
946
877
  });
947
878
  }
948
879
  /**
949
- * Internal function to sign and submit a premint request.
880
+ * Prepares data for deleting a premint
950
881
  *
951
- * @param premintArguments Arguments to premint
952
- * @returns
882
+ * @param parameters - Parameters for deleting the premint {@link DeletePremintParams}
883
+ * @returns A PremintReturn. {@link PremintReturn}
953
884
  */
954
- async signAndSubmitPremint(params) {
955
- const { verifyingContract } = await signAndSubmitPremint({
885
+ async deletePremint(params) {
886
+ return deletePremint({
956
887
  ...params,
957
- chainId: this.chain.id,
958
888
  apiClient: this.apiClient,
959
- publicClient: this.publicClient
889
+ publicClient: this.publicClient,
890
+ chainId: this.chain.id
960
891
  });
961
- const uid = params.premintConfig.uid;
962
- return {
963
- urls: this.makeUrls({ address: verifyingContract, uid }),
964
- uid,
965
- verifyingContract
966
- };
967
892
  }
968
893
  /**
969
- * Create premint
894
+ * Prepares data for creating a premint
970
895
  *
971
- * @param settings Settings for the new premint
972
- * @param settings.account Account to sign the premint with. Taken from walletClient if none passed in.
973
- * @param settings.collection Collection information for the mint
974
- * @param settings.tokenCreationConfig Mint argument settings, optional settings are overridden with sensible defaults.
975
- * @param setings.premintConfigVersion Premint config version to use, defaults to V2
976
- * @param settings.uid the UID to use – optional and retrieved as a fresh UID from ZORA by default.
977
- * @param settings.checkSignature if the signature should have a pre-flight check. Not required but helpful for debugging.
978
- * @returns premint url, uid, newContractAddress, and premint object
896
+ * @param parameters - Parameters for creating the premint {@link CreatePremintParameters}
897
+ * @returns A PremintReturn. {@link PremintReturn}
979
898
  */
980
- async createPremint({
981
- creatorAccount,
982
- collection,
983
- tokenCreationConfig,
984
- premintConfigVersion,
985
- walletClient,
986
- uid,
987
- checkSignature = false
988
- }) {
989
- const newContractAddress = await getPremintCollectionAddress({
990
- publicClient: this.publicClient,
991
- collection
992
- });
993
- let uidToUse = uid;
994
- if (typeof uidToUse !== "number") {
995
- uidToUse = await this.apiClient.getNextUID(newContractAddress);
996
- }
997
- const actualVersion = premintConfigVersion || import_protocol_deployments4.PremintConfigVersion.V1;
998
- if (!await supportsPremintVersion({
999
- version: actualVersion,
899
+ async createPremint(parameters) {
900
+ return createPremint({
901
+ ...parameters,
1000
902
  publicClient: this.publicClient,
1001
- tokenContract: newContractAddress
1002
- })) {
1003
- throw new Error(
1004
- `Premint version ${actualVersion} not supported by contract`
1005
- );
1006
- }
1007
- const premintConfig = makeNewPremint({
1008
- tokenConfig: makeTokenConfigWithDefaults({
1009
- // @ts-ignore
1010
- premintConfigVersion: actualVersion,
1011
- tokenCreationConfig,
1012
- creatorAccount: typeof creatorAccount === "string" ? creatorAccount : creatorAccount.address,
1013
- chainId: this.chain.id
1014
- }),
1015
- uid: uidToUse
1016
- });
1017
- return await this.signAndSubmitPremint({
1018
- verifyingContract: newContractAddress,
1019
- premintConfig,
1020
- premintConfigVersion: actualVersion,
1021
- checkSignature,
1022
- account: creatorAccount,
1023
- walletClient,
1024
- collection
903
+ apiClient: this.apiClient,
904
+ chainId: this.chain.id
1025
905
  });
1026
906
  }
1027
907
  /**
@@ -1098,91 +978,342 @@ var PremintClient = class {
1098
978
  });
1099
979
  }
1100
980
  /**
1101
- * Execute premint on-chain
981
+ * Prepares the parameters to collect a premint; it brings the contract and token onchain, then collects
982
+ * tokens on that contract for the mint recipient.
1102
983
  *
1103
- * @param settings.data Data from the API for the mint
1104
- * @param settings.account Optional account (if omitted taken from wallet client) for the account executing the premint.
1105
- * @param settings.walletClient WalletClient to send execution from.
1106
- * @param settings.mintArguments User minting arguments.
1107
- * @param settings.mintArguments.quantityToMint Quantity to mint, optional, defaults to 1.
1108
- * @param settings.mintArguments.mintComment Optional mint comment, optional, omits when not included.
1109
- * @param settings.publicClient Optional public client for preflight checks.
984
+ * @param parameters - Parameters for collecting the Premint {@link MakeMintParametersArguments}
1110
985
  * @returns receipt, log, zoraURL
1111
986
  */
1112
- async makeMintParameters({
1113
- uid,
1114
- tokenContract,
1115
- minterAccount,
1116
- mintArguments
1117
- }) {
1118
- if (mintArguments && mintArguments?.quantityToMint < 1) {
1119
- throw new Error("Quantity to mint cannot be below 1");
1120
- }
1121
- if (!minterAccount) {
1122
- throw new Error("Wallet not passed in");
1123
- }
1124
- const { premintConfig, premintConfigVersion, collection, signature } = await this.getPremintSignature({
1125
- address: tokenContract,
1126
- uid
987
+ async makeMintParameters(parameters) {
988
+ return await makeMintParameters({
989
+ ...parameters,
990
+ apiClient: this.apiClient,
991
+ publicClient: this.publicClient
1127
992
  });
1128
- const numberToMint = BigInt(mintArguments?.quantityToMint || 1);
1129
- if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V3) {
1130
- throw new Error("PremintV3 not supported in premint SDK");
1131
- }
1132
- const value = (await getPremintMintCosts({
1133
- tokenContract,
1134
- quantityToMint: numberToMint,
1135
- publicClient: this.publicClient,
1136
- tokenPrice: premintConfig.tokenConfig.pricePerToken
1137
- })).totalCost;
1138
- const mintArgumentsContract = {
1139
- mintComment: mintArguments?.mintComment || "",
1140
- mintRecipient: mintArguments?.mintRecipient || (typeof minterAccount === "string" ? minterAccount : minterAccount.address),
1141
- mintRewardsRecipients: makeMintRewardsRecipient({
1142
- mintReferral: mintArguments?.mintReferral,
1143
- platformReferral: mintArguments?.platformReferral
1144
- })
993
+ }
994
+ };
995
+ function createPremintClient(clientConfig) {
996
+ const { chain, httpClient: httpClient2, publicClient } = setupClient(clientConfig);
997
+ return new PremintClient(chain, publicClient, httpClient2);
998
+ }
999
+ function makePremintReturn({
1000
+ premintConfig,
1001
+ premintConfigVersion,
1002
+ collectionAddress,
1003
+ collection,
1004
+ publicClient,
1005
+ apiClient,
1006
+ chainId
1007
+ }) {
1008
+ const typedDataDefinition = (0, import_protocol_deployments4.premintTypedDataDefinition)({
1009
+ verifyingContract: collectionAddress,
1010
+ premintConfig,
1011
+ premintConfigVersion,
1012
+ chainId
1013
+ });
1014
+ const signAndSubmit = async ({
1015
+ walletClient,
1016
+ account,
1017
+ checkSignature
1018
+ }) => {
1019
+ const { signature, signerAccount } = await signPremint({
1020
+ account,
1021
+ walletClient,
1022
+ typedDataDefinition
1023
+ });
1024
+ await submit({
1025
+ signature,
1026
+ checkSignature,
1027
+ signerAccount
1028
+ });
1029
+ return {
1030
+ signature,
1031
+ signerAccount
1145
1032
  };
1146
- if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V1) {
1147
- return makeSimulateContractParamaters({
1148
- account: minterAccount,
1149
- abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
1150
- functionName: "premintV1",
1151
- value,
1152
- address: getPremintExecutorAddress(),
1153
- args: [
1154
- collection,
1155
- premintConfig,
1156
- signature,
1157
- numberToMint,
1158
- mintArgumentsContract
1159
- ]
1160
- });
1161
- } else if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V2) {
1162
- return makeSimulateContractParamaters({
1163
- account: minterAccount,
1164
- abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
1165
- functionName: "premintV2",
1166
- value,
1167
- address: getPremintExecutorAddress(),
1168
- args: [
1169
- collection,
1170
- premintConfig,
1171
- signature,
1172
- numberToMint,
1173
- mintArgumentsContract
1174
- ]
1033
+ };
1034
+ const submit = async ({
1035
+ signature,
1036
+ checkSignature,
1037
+ signerAccount
1038
+ }) => {
1039
+ if (checkSignature) {
1040
+ await validateSignature({
1041
+ collection: {
1042
+ ...collection,
1043
+ additionalAdmins: []
1044
+ },
1045
+ publicClient,
1046
+ signerAccount
1175
1047
  });
1176
1048
  }
1177
- throw new Error(`Invalid premint config version ${premintConfigVersion}`);
1049
+ await apiClient.postSignature({
1050
+ collection: {
1051
+ ...collection,
1052
+ additionalAdmins: []
1053
+ },
1054
+ signature,
1055
+ premintConfig,
1056
+ premintConfigVersion
1057
+ });
1058
+ };
1059
+ return {
1060
+ premintConfig,
1061
+ premintConfigVersion,
1062
+ typedDataDefinition,
1063
+ collectionAddress,
1064
+ signAndSubmit,
1065
+ submit
1066
+ };
1067
+ }
1068
+ async function signPremint({
1069
+ account,
1070
+ walletClient,
1071
+ typedDataDefinition
1072
+ }) {
1073
+ if (!account) {
1074
+ account = walletClient.account;
1075
+ }
1076
+ if (!account) {
1077
+ throw new Error("No account provided");
1078
+ }
1079
+ const signature = await walletClient.signTypedData({
1080
+ account,
1081
+ ...typedDataDefinition
1082
+ });
1083
+ return {
1084
+ signature,
1085
+ signerAccount: account
1086
+ };
1087
+ }
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");
1178
1104
  }
1179
1105
  };
1180
- function createPremintClient({
1181
- chain,
1182
- httpClient: httpClient2,
1106
+ async function createPremint({
1107
+ payoutRecipient: creatorAccount,
1108
+ collection,
1109
+ tokenCreationConfig,
1110
+ premintConfigVersion,
1111
+ uid,
1112
+ publicClient,
1113
+ apiClient,
1114
+ chainId
1115
+ }) {
1116
+ const {
1117
+ premintConfig,
1118
+ premintConfigVersion: actualVersion,
1119
+ collectionAddress
1120
+ } = await prepareCreatePremintConfig({
1121
+ payoutRecipient: creatorAccount,
1122
+ collection,
1123
+ tokenCreationConfig,
1124
+ premintConfigVersion,
1125
+ uid,
1126
+ publicClient,
1127
+ apiClient,
1128
+ chainId
1129
+ });
1130
+ return makePremintReturn({
1131
+ premintConfig,
1132
+ premintConfigVersion: actualVersion,
1133
+ collectionAddress,
1134
+ collection,
1135
+ publicClient,
1136
+ apiClient,
1137
+ chainId
1138
+ });
1139
+ }
1140
+ async function prepareCreatePremintConfig({
1141
+ payoutRecipient,
1142
+ collection,
1143
+ tokenCreationConfig,
1144
+ premintConfigVersion,
1145
+ uid,
1146
+ publicClient,
1147
+ apiClient,
1148
+ chainId
1149
+ }) {
1150
+ const collectionWithAdditionalAdmins = {
1151
+ ...collection,
1152
+ additionalAdmins: collection.additionalAdmins || []
1153
+ };
1154
+ const newContractAddress = await getPremintCollectionAddress({
1155
+ publicClient,
1156
+ collection: collectionWithAdditionalAdmins
1157
+ });
1158
+ let uidToUse = uid;
1159
+ if (typeof uidToUse !== "number") {
1160
+ uidToUse = await apiClient.getNextUID(newContractAddress);
1161
+ }
1162
+ const actualVersion = premintConfigVersion || import_protocol_deployments4.PremintConfigVersion.V1;
1163
+ if (!await supportsPremintVersion({
1164
+ version: actualVersion,
1165
+ publicClient,
1166
+ tokenContract: newContractAddress
1167
+ })) {
1168
+ throw new Error(
1169
+ `Premint version ${actualVersion} not supported by contract`
1170
+ );
1171
+ }
1172
+ const premintConfig = makeNewPremint({
1173
+ tokenConfig: makeTokenConfigWithDefaults({
1174
+ // @ts-ignore
1175
+ premintConfigVersion: actualVersion,
1176
+ tokenCreationConfig,
1177
+ payoutRecipient: typeof payoutRecipient === "string" ? payoutRecipient : payoutRecipient.address,
1178
+ chainId
1179
+ }),
1180
+ uid: uidToUse
1181
+ });
1182
+ return {
1183
+ premintConfig,
1184
+ premintConfigVersion: actualVersion,
1185
+ collectionAddress: newContractAddress
1186
+ };
1187
+ }
1188
+ async function updatePremint({
1189
+ uid,
1190
+ collection,
1191
+ tokenConfigUpdates,
1192
+ apiClient,
1193
+ publicClient,
1194
+ chainId
1195
+ }) {
1196
+ const {
1197
+ premintConfig,
1198
+ collection: collectionCreationConfig,
1199
+ premintConfigVersion
1200
+ } = await apiClient.getSignature({
1201
+ collectionAddress: collection,
1202
+ uid
1203
+ });
1204
+ const updatedPremint = applyUpdateToPremint({
1205
+ uid: premintConfig.uid,
1206
+ version: premintConfig.version,
1207
+ tokenConfig: premintConfig.tokenConfig,
1208
+ tokenConfigUpdates
1209
+ });
1210
+ return makePremintReturn({
1211
+ premintConfig: updatedPremint,
1212
+ premintConfigVersion,
1213
+ collectionAddress: collection,
1214
+ collection: collectionCreationConfig,
1215
+ publicClient,
1216
+ apiClient,
1217
+ chainId
1218
+ });
1219
+ }
1220
+ async function deletePremint({
1221
+ uid,
1222
+ collection,
1223
+ publicClient,
1224
+ apiClient,
1225
+ chainId
1226
+ }) {
1227
+ const {
1228
+ premintConfig,
1229
+ premintConfigVersion,
1230
+ collection: collectionCreationConfig
1231
+ } = await apiClient.getSignature({
1232
+ collectionAddress: collection,
1233
+ uid
1234
+ });
1235
+ const deletedPremint = {
1236
+ ...premintConfig,
1237
+ version: premintConfig.version + 1,
1238
+ deleted: true
1239
+ };
1240
+ return makePremintReturn({
1241
+ premintConfig: deletedPremint,
1242
+ premintConfigVersion,
1243
+ collectionAddress: collection,
1244
+ collection: collectionCreationConfig,
1245
+ publicClient,
1246
+ apiClient,
1247
+ chainId
1248
+ });
1249
+ }
1250
+ async function makeMintParameters({
1251
+ uid,
1252
+ tokenContract,
1253
+ minterAccount,
1254
+ mintArguments,
1255
+ apiClient,
1183
1256
  publicClient
1184
1257
  }) {
1185
- return new PremintClient(chain, publicClient, httpClient2);
1258
+ if (mintArguments && mintArguments?.quantityToMint < 1) {
1259
+ throw new Error("Quantity to mint cannot be below 1");
1260
+ }
1261
+ if (!minterAccount) {
1262
+ throw new Error("Wallet not passed in");
1263
+ }
1264
+ const { premintConfig, premintConfigVersion, collection, signature } = await apiClient.getSignature({
1265
+ collectionAddress: tokenContract,
1266
+ uid
1267
+ });
1268
+ const numberToMint = BigInt(mintArguments?.quantityToMint || 1);
1269
+ if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V3) {
1270
+ throw new Error("PremintV3 not supported in premint SDK");
1271
+ }
1272
+ const value = (await getPremintMintCosts({
1273
+ tokenContract,
1274
+ quantityToMint: numberToMint,
1275
+ publicClient,
1276
+ tokenPrice: premintConfig.tokenConfig.pricePerToken
1277
+ })).totalCost;
1278
+ const mintArgumentsContract = {
1279
+ mintComment: mintArguments?.mintComment || "",
1280
+ mintRecipient: mintArguments?.mintRecipient || (typeof minterAccount === "string" ? minterAccount : minterAccount.address),
1281
+ mintRewardsRecipients: makeMintRewardsRecipient({
1282
+ mintReferral: mintArguments?.mintReferral
1283
+ })
1284
+ };
1285
+ if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V1) {
1286
+ return makeSimulateContractParamaters({
1287
+ account: minterAccount,
1288
+ abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
1289
+ functionName: "premintV1",
1290
+ value,
1291
+ address: getPremintExecutorAddress(),
1292
+ args: [
1293
+ collection,
1294
+ premintConfig,
1295
+ signature,
1296
+ numberToMint,
1297
+ mintArgumentsContract
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,
1309
+ premintConfig,
1310
+ signature,
1311
+ numberToMint,
1312
+ mintArgumentsContract
1313
+ ]
1314
+ });
1315
+ }
1316
+ throw new Error(`Invalid premint config version ${premintConfigVersion}`);
1186
1317
  }
1187
1318
  function makeUrls({
1188
1319
  uid,
@@ -1201,52 +1332,6 @@ function makeUrls({
1201
1332
  zoraManage: `https://${network.isTestnet ? "testnet." : ""}zora.co/collect/${network.zoraCollectPathChainName}:${address}/${zoraTokenPath}`
1202
1333
  };
1203
1334
  }
1204
- async function signAndSubmitPremint({
1205
- walletClient,
1206
- verifyingContract,
1207
- account,
1208
- checkSignature,
1209
- collection,
1210
- chainId,
1211
- publicClient,
1212
- apiClient,
1213
- ...premintConfigAndVersion
1214
- }) {
1215
- if (!account) {
1216
- account = walletClient.account;
1217
- }
1218
- if (!account) {
1219
- throw new Error("No account provided");
1220
- }
1221
- const signature = await walletClient.signTypedData({
1222
- account,
1223
- ...(0, import_protocol_deployments4.premintTypedDataDefinition)({
1224
- verifyingContract,
1225
- ...premintConfigAndVersion,
1226
- chainId
1227
- })
1228
- });
1229
- if (checkSignature) {
1230
- const isAuthorized = await isAuthorizedToCreatePremint({
1231
- collection,
1232
- publicClient,
1233
- signer: typeof account === "string" ? account : account.address,
1234
- collectionAddress: await getPremintCollectionAddress({
1235
- collection,
1236
- publicClient
1237
- })
1238
- });
1239
- if (!isAuthorized) {
1240
- throw new Error("Not authorized to create premint");
1241
- }
1242
- }
1243
- const premint = await apiClient.postSignature({
1244
- collection,
1245
- signature,
1246
- ...premintConfigAndVersion
1247
- });
1248
- return { premint, verifyingContract };
1249
- }
1250
1335
 
1251
1336
  // src/premint/contract-types.ts
1252
1337
  var import_protocol_deployments5 = require("@zoralabs/protocol-deployments");
@@ -1258,7 +1343,7 @@ var PremintConfigVersion3 = ((PremintConfigVersion4) => {
1258
1343
  })(PremintConfigVersion3 || {});
1259
1344
 
1260
1345
  // src/mint/mint-client.ts
1261
- var import_viem5 = require("viem");
1346
+ var import_viem6 = require("viem");
1262
1347
  var import_protocol_deployments6 = require("@zoralabs/protocol-deployments");
1263
1348
  var MintError = class extends Error {
1264
1349
  };
@@ -1271,30 +1356,24 @@ var Errors = {
1271
1356
  var MintClient = class {
1272
1357
  constructor(chain, publicClient, httpClient2) {
1273
1358
  this.apiClient = new MintAPIClient(chain.id, httpClient2);
1274
- this.publicClient = publicClient || (0, import_viem5.createPublicClient)({ chain, transport: (0, import_viem5.http)() });
1359
+ this.publicClient = publicClient;
1275
1360
  }
1276
1361
  /**
1277
1362
  * Returns the parameters needed to prepare a transaction mint a token.
1278
- * @param param0.minterAccount The account that will mint the token.
1279
- * @param param0.mintable The mintable token to mint.
1280
- * @param param0.mintArguments The arguments for the mint (mint recipient, comment, mint referral, quantity to mint)
1281
- * @returns
1363
+ *
1364
+ * @param parameters - Parameters for collecting the token {@link MintTokenParams}
1365
+ * @returns Parameters for simulating/executing the mint transaction
1282
1366
  */
1283
- async makePrepareMintTokenParams({
1284
- ...rest
1285
- }) {
1367
+ async makePrepareMintTokenParams(parameters) {
1286
1368
  return makePrepareMintTokenParams({
1287
- ...rest,
1369
+ ...parameters,
1288
1370
  apiClient: this.apiClient,
1289
1371
  publicClient: this.publicClient
1290
1372
  });
1291
1373
  }
1292
1374
  };
1293
- function createMintClient({
1294
- chain,
1295
- publicClient,
1296
- httpClient: httpClient2
1297
- }) {
1375
+ function createMintClient(clientConfig) {
1376
+ const { chain, publicClient, httpClient: httpClient2 } = setupClient(clientConfig);
1298
1377
  return new MintClient(chain, publicClient, httpClient2);
1299
1378
  }
1300
1379
  async function makePrepareMintTokenParams({
@@ -1346,7 +1425,7 @@ async function makePrepareMint721TokenParams({
1346
1425
  mintArguments.mintToAddress,
1347
1426
  BigInt(mintArguments.quantityToMint),
1348
1427
  mintArguments.mintComment || "",
1349
- mintArguments.mintReferral || import_viem5.zeroAddress
1428
+ mintArguments.mintReferral || import_viem6.zeroAddress
1350
1429
  ]
1351
1430
  });
1352
1431
  }
@@ -1388,11 +1467,11 @@ async function makePrepareMint1155TokenParams({
1388
1467
  salesConfigAndTokenInfo.salesConfig.address || import_protocol_deployments6.zoraCreatorFixedPriceSaleStrategyAddress[999999999],
1389
1468
  BigInt(tokenId),
1390
1469
  mintQuantity,
1391
- (0, import_viem5.encodeAbiParameters)((0, import_viem5.parseAbiParameters)("address, string"), [
1470
+ (0, import_viem6.encodeAbiParameters)((0, import_viem6.parseAbiParameters)("address, string"), [
1392
1471
  fixedPriceArgs.mintToAddress,
1393
1472
  fixedPriceArgs.mintComment || ""
1394
1473
  ]),
1395
- fixedPriceArgs.mintReferral || import_viem5.zeroAddress
1474
+ fixedPriceArgs.mintReferral || import_viem6.zeroAddress
1396
1475
  ]
1397
1476
  });
1398
1477
  case "erc20":
@@ -1410,7 +1489,7 @@ async function makePrepareMint1155TokenParams({
1410
1489
  BigInt(tokenId),
1411
1490
  salesConfigAndTokenInfo.salesConfig.pricePerToken,
1412
1491
  salesConfigAndTokenInfo.salesConfig.currency,
1413
- erc20Args.mintReferral || import_viem5.zeroAddress,
1492
+ erc20Args.mintReferral || import_viem6.zeroAddress,
1414
1493
  erc20Args.mintComment || ""
1415
1494
  ]
1416
1495
  });
@@ -1421,11 +1500,11 @@ async function makePrepareMint1155TokenParams({
1421
1500
 
1422
1501
  // src/create/1155-create-helper.ts
1423
1502
  var import_protocol_deployments7 = require("@zoralabs/protocol-deployments");
1424
- var import_viem6 = require("viem");
1503
+ var import_viem7 = require("viem");
1425
1504
  var SALE_END_FOREVER = 18446744073709551615n;
1426
1505
  var ROYALTY_BPS_DEFAULT = 1e3;
1427
1506
  var DEFAULT_SALE_SETTINGS = {
1428
- fundsRecipient: import_viem6.zeroAddress,
1507
+ fundsRecipient: import_viem7.zeroAddress,
1429
1508
  // Free Mint
1430
1509
  pricePerToken: 0n,
1431
1510
  // Sale start time – defaults to beginning of unix time
@@ -1464,32 +1543,32 @@ function create1155TokenSetupArgs({
1464
1543
  ...salesConfig
1465
1544
  };
1466
1545
  const setupActions = [
1467
- (0, import_viem6.encodeFunctionData)({
1546
+ (0, import_viem7.encodeFunctionData)({
1468
1547
  abi: import_protocol_deployments7.zoraCreator1155ImplABI,
1469
1548
  functionName: "assumeLastTokenIdMatches",
1470
1549
  args: [nextTokenId - 1n]
1471
1550
  }),
1472
- createReferral ? (0, import_viem6.encodeFunctionData)({
1551
+ createReferral ? (0, import_viem7.encodeFunctionData)({
1473
1552
  abi: import_protocol_deployments7.zoraCreator1155ImplABI,
1474
1553
  functionName: "setupNewTokenWithCreateReferral",
1475
1554
  args: [tokenMetadataURI, maxSupply, createReferral]
1476
- }) : (0, import_viem6.encodeFunctionData)({
1555
+ }) : (0, import_viem7.encodeFunctionData)({
1477
1556
  abi: import_protocol_deployments7.zoraCreator1155ImplABI,
1478
1557
  functionName: "setupNewToken",
1479
1558
  args: [tokenMetadataURI, maxSupply]
1480
1559
  }),
1481
- (0, import_viem6.encodeFunctionData)({
1560
+ (0, import_viem7.encodeFunctionData)({
1482
1561
  abi: import_protocol_deployments7.zoraCreator1155ImplABI,
1483
1562
  functionName: "addPermission",
1484
1563
  args: [0n, fixedPriceMinterAddress, PERMISSION_BIT_MINTER]
1485
1564
  }),
1486
- (0, import_viem6.encodeFunctionData)({
1565
+ (0, import_viem7.encodeFunctionData)({
1487
1566
  abi: import_protocol_deployments7.zoraCreator1155ImplABI,
1488
1567
  functionName: "callSale",
1489
1568
  args: [
1490
1569
  nextTokenId,
1491
1570
  fixedPriceMinterAddress,
1492
- (0, import_viem6.encodeFunctionData)({
1571
+ (0, import_viem7.encodeFunctionData)({
1493
1572
  abi: import_protocol_deployments7.zoraCreatorFixedPriceSaleStrategyABI,
1494
1573
  functionName: "setSale",
1495
1574
  args: [nextTokenId, salesConfigWithDefaults]
@@ -1499,7 +1578,7 @@ function create1155TokenSetupArgs({
1499
1578
  ];
1500
1579
  if (mintToCreatorCount) {
1501
1580
  setupActions.push(
1502
- (0, import_viem6.encodeFunctionData)({
1581
+ (0, import_viem7.encodeFunctionData)({
1503
1582
  abi: import_protocol_deployments7.zoraCreator1155ImplABI,
1504
1583
  functionName: "adminMint",
1505
1584
  args: [account, nextTokenId, mintToCreatorCount, "0x"]
@@ -1508,7 +1587,7 @@ function create1155TokenSetupArgs({
1508
1587
  }
1509
1588
  if (royaltySettings) {
1510
1589
  setupActions.push(
1511
- (0, import_viem6.encodeFunctionData)({
1590
+ (0, import_viem7.encodeFunctionData)({
1512
1591
  abi: import_protocol_deployments7.zoraCreator1155ImplABI,
1513
1592
  functionName: "updateRoyaltiesForToken",
1514
1593
  args: [
@@ -1527,7 +1606,7 @@ function create1155TokenSetupArgs({
1527
1606
  var getTokenIdFromCreateReceipt = (receipt) => {
1528
1607
  for (const data of receipt.logs) {
1529
1608
  try {
1530
- const decodedLog = (0, import_viem6.decodeEventLog)({
1609
+ const decodedLog = (0, import_viem7.decodeEventLog)({
1531
1610
  abi: import_protocol_deployments7.zoraCreator1155ImplABI,
1532
1611
  eventName: "SetupNewToken",
1533
1612
  ...data
@@ -1571,9 +1650,8 @@ async function getContractExists(publicClient, contract, account) {
1571
1650
  contractAddress: contract
1572
1651
  };
1573
1652
  }
1574
- function create1155CreatorClient({
1575
- publicClient
1576
- }) {
1653
+ function create1155CreatorClient(clientConfig) {
1654
+ const { publicClient } = setupClient(clientConfig);
1577
1655
  async function createNew1155Token({
1578
1656
  contract,
1579
1657
  tokenMetadataURI,
@@ -1726,7 +1804,7 @@ var sumBalances = (mintAccountBalances) => {
1726
1804
 
1727
1805
  // src/mints/mints-contracts.ts
1728
1806
  var import_protocol_deployments8 = require("@zoralabs/protocol-deployments");
1729
- var import_viem7 = require("viem");
1807
+ var import_viem8 = require("viem");
1730
1808
  var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
1731
1809
  var mintWithEthParams = ({
1732
1810
  quantity,
@@ -1761,7 +1839,7 @@ var encodeCollectOnManager = ({
1761
1839
  minter,
1762
1840
  zoraCreator1155TokenId,
1763
1841
  mintArguments
1764
- }) => (0, import_viem7.encodeFunctionData)({
1842
+ }) => (0, import_viem8.encodeFunctionData)({
1765
1843
  abi: import_protocol_deployments8.zoraMintsManagerImplConfig.abi,
1766
1844
  functionName: "collect",
1767
1845
  args: [
@@ -1881,8 +1959,8 @@ var encodePremintOnManager = ({
1881
1959
  premintConfig,
1882
1960
  premintSignature,
1883
1961
  mintArguments,
1884
- signerContract = import_viem7.zeroAddress
1885
- }) => (0, import_viem7.encodeFunctionData)({
1962
+ signerContract = import_viem8.zeroAddress
1963
+ }) => (0, import_viem8.encodeFunctionData)({
1886
1964
  abi: import_protocol_deployments8.zoraMintsManagerImplConfig.abi,
1887
1965
  functionName: "collectPremintV2",
1888
1966
  args: [
@@ -1949,7 +2027,7 @@ function decodeCallFailedError(error) {
1949
2027
  if (error.data?.errorName !== "CallFailed")
1950
2028
  throw new Error("Not a CallFailed error");
1951
2029
  const internalErrorData = error.data?.args?.[0];
1952
- return (0, import_viem7.decodeErrorResult)({
2030
+ return (0, import_viem8.decodeErrorResult)({
1953
2031
  abi: import_protocol_deployments8.zoraMintsManagerImplABI,
1954
2032
  data: internalErrorData
1955
2033
  });
@@ -1957,12 +2035,12 @@ function decodeCallFailedError(error) {
1957
2035
 
1958
2036
  // src/mints/mints-eth-unwrapper-and-caller.ts
1959
2037
  var import_protocol_deployments9 = require("@zoralabs/protocol-deployments");
1960
- var import_viem8 = require("viem");
2038
+ var import_viem9 = require("viem");
1961
2039
  var makeCallWithEthSafeTransferData = ({
1962
2040
  address: addressToCall,
1963
2041
  call: functionToCall,
1964
2042
  value: valueToSend
1965
- }) => (0, import_viem8.encodeFunctionData)({
2043
+ }) => (0, import_viem9.encodeFunctionData)({
1966
2044
  abi: import_protocol_deployments9.iUnwrapAndForwardActionABI,
1967
2045
  functionName: "callWithEth",
1968
2046
  args: [addressToCall, functionToCall, valueToSend]
@@ -2029,6 +2107,7 @@ var unwrapAndForwardEthPermitAndTypedDataDefinition = ({
2029
2107
  makePermitToCollectPremintOrNonPremint,
2030
2108
  makePermitTransferBatchAndTypeData,
2031
2109
  makePermitTransferTypeData,
2110
+ makeUrls,
2032
2111
  migratePremintConfigToV2,
2033
2112
  mintWithEthParams,
2034
2113
  mintsBalanceOfAccountParams,