@zoralabs/protocol-sdk 0.5.15 → 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 +19 -0
- package/dist/anvil.d.ts +4 -4
- package/dist/anvil.d.ts.map +1 -1
- 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/create/1155-create-helper.d.ts +3 -4
- package/dist/create/1155-create-helper.d.ts.map +1 -1
- package/dist/index.cjs +495 -371
- 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 +478 -352
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-client.d.ts +22 -17
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mints/mints-contracts.d.ts +688 -3
- package/dist/mints/mints-contracts.d.ts.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 +122 -1476
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +29 -16
- package/dist/premint/preminter.d.ts.map +1 -1
- package/dist/utils.d.ts +6872 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/apis/generated/premint-api-types.ts +9 -2
- package/src/create/1155-create-helper.test.ts +10 -3
- package/src/create/1155-create-helper.ts +8 -7
- package/src/index.ts +6 -0
- package/src/mint/mint-client.ts +31 -30
- 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 +112 -88
- package/src/premint/premint-client.ts +614 -409
- package/src/premint/preminter.test.ts +154 -2
- package/src/premint/preminter.ts +87 -36
- package/src/utils.ts +25 -0
- package/test-integration/premint-client.test.ts +2 -2
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,
|
|
@@ -61,6 +63,7 @@ __export(src_exports, {
|
|
|
61
63
|
makePermitToCollectPremintOrNonPremint: () => makePermitToCollectPremintOrNonPremint,
|
|
62
64
|
makePermitTransferBatchAndTypeData: () => makePermitTransferBatchAndTypeData,
|
|
63
65
|
makePermitTransferTypeData: () => makePermitTransferTypeData,
|
|
66
|
+
makeUrls: () => makeUrls,
|
|
64
67
|
migratePremintConfigToV2: () => migratePremintConfigToV2,
|
|
65
68
|
mintWithEthParams: () => mintWithEthParams,
|
|
66
69
|
mintsBalanceOfAccountParams: () => mintsBalanceOfAccountParams,
|
|
@@ -70,13 +73,14 @@ __export(src_exports, {
|
|
|
70
73
|
sumBalances: () => sumBalances,
|
|
71
74
|
supportedPremintVersions: () => supportedPremintVersions,
|
|
72
75
|
supportsPremintVersion: () => supportsPremintVersion,
|
|
76
|
+
toContractCreationConfigOrAddress: () => toContractCreationConfigOrAddress,
|
|
73
77
|
tryRecoverPremintSigner: () => tryRecoverPremintSigner,
|
|
74
78
|
unwrapAndForwardEthPermitAndTypedDataDefinition: () => unwrapAndForwardEthPermitAndTypedDataDefinition
|
|
75
79
|
});
|
|
76
80
|
module.exports = __toCommonJS(src_exports);
|
|
77
81
|
|
|
78
82
|
// src/premint/premint-client.ts
|
|
79
|
-
var
|
|
83
|
+
var import_viem5 = require("viem");
|
|
80
84
|
var import_protocol_deployments3 = require("@zoralabs/protocol-deployments");
|
|
81
85
|
|
|
82
86
|
// src/premint/preminter.ts
|
|
@@ -84,22 +88,21 @@ var import_protocol_deployments = require("@zoralabs/protocol-deployments");
|
|
|
84
88
|
var import_viem = require("viem");
|
|
85
89
|
var getPremintExecutorAddress = () => import_protocol_deployments.zoraCreator1155PremintExecutorImplAddress[999];
|
|
86
90
|
async function isAuthorizedToCreatePremint({
|
|
87
|
-
|
|
91
|
+
contractAdmin = import_viem.zeroAddress,
|
|
92
|
+
additionalAdmins = [],
|
|
88
93
|
collectionAddress,
|
|
89
94
|
publicClient,
|
|
90
95
|
signer
|
|
91
96
|
}) {
|
|
92
|
-
if (collection.additionalAdmins.length > 0)
|
|
93
|
-
throw new Error("additionalAdmins not supported yet.");
|
|
94
97
|
return await publicClient.readContract({
|
|
95
98
|
abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
|
|
96
99
|
address: getPremintExecutorAddress(),
|
|
97
100
|
functionName: "isAuthorizedToCreatePremintWithAdditionalAdmins",
|
|
98
101
|
args: [
|
|
99
|
-
signer,
|
|
100
|
-
|
|
102
|
+
typeof signer === "string" ? signer : signer.address,
|
|
103
|
+
contractAdmin,
|
|
101
104
|
collectionAddress,
|
|
102
|
-
|
|
105
|
+
additionalAdmins
|
|
103
106
|
]
|
|
104
107
|
});
|
|
105
108
|
}
|
|
@@ -124,17 +127,14 @@ async function isValidSignature({
|
|
|
124
127
|
signature,
|
|
125
128
|
publicClient,
|
|
126
129
|
collection,
|
|
130
|
+
collectionAddress,
|
|
127
131
|
chainId,
|
|
128
132
|
...premintConfigAndVersion
|
|
129
133
|
}) {
|
|
130
|
-
const tokenContract = await getPremintCollectionAddress({
|
|
131
|
-
collection,
|
|
132
|
-
publicClient
|
|
133
|
-
});
|
|
134
134
|
const recoveredAddress = await tryRecoverPremintSigner({
|
|
135
135
|
...premintConfigAndVersion,
|
|
136
136
|
signature,
|
|
137
|
-
verifyingContract:
|
|
137
|
+
verifyingContract: collectionAddress,
|
|
138
138
|
chainId
|
|
139
139
|
});
|
|
140
140
|
if (!import_viem.recoverAddress) {
|
|
@@ -144,8 +144,9 @@ async function isValidSignature({
|
|
|
144
144
|
}
|
|
145
145
|
const isAuthorized = await isAuthorizedToCreatePremint({
|
|
146
146
|
signer: recoveredAddress,
|
|
147
|
-
collection,
|
|
148
|
-
|
|
147
|
+
additionalAdmins: collection?.additionalAdmins,
|
|
148
|
+
contractAdmin: collection?.contractAdmin,
|
|
149
|
+
collectionAddress,
|
|
149
150
|
publicClient
|
|
150
151
|
});
|
|
151
152
|
return {
|
|
@@ -226,15 +227,24 @@ var supportsPremintVersion = async ({
|
|
|
226
227
|
return (await supportedPremintVersions({ tokenContract, publicClient })).includes(version);
|
|
227
228
|
};
|
|
228
229
|
async function getPremintCollectionAddress({
|
|
230
|
+
publicClient,
|
|
229
231
|
collection,
|
|
230
|
-
|
|
232
|
+
collectionAddress
|
|
231
233
|
}) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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;
|
|
238
248
|
}
|
|
239
249
|
function applyUpdateToPremint({
|
|
240
250
|
uid,
|
|
@@ -303,6 +313,34 @@ function makeMintRewardsRecipient({
|
|
|
303
313
|
function getDefaultFixedPriceMinterAddress(chainId) {
|
|
304
314
|
return import_protocol_deployments.zoraCreatorFixedPriceSaleStrategyAddress[chainId];
|
|
305
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
|
+
};
|
|
306
344
|
|
|
307
345
|
// src/premint/premint-client.ts
|
|
308
346
|
var import_protocol_deployments4 = require("@zoralabs/protocol-deployments");
|
|
@@ -587,11 +625,16 @@ var MintAPIClient = class {
|
|
|
587
625
|
|
|
588
626
|
// src/premint/conversions.ts
|
|
589
627
|
var import_protocol_deployments2 = require("@zoralabs/protocol-deployments");
|
|
590
|
-
var convertCollectionFromApi = (collection) =>
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
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
|
+
};
|
|
595
638
|
var convertPremintFromApi = (premint) => {
|
|
596
639
|
if (premint.config_version === import_protocol_deployments2.PremintConfigVersion.V1 || !premint.config_version) {
|
|
597
640
|
const tokenConfig = premint.tokenConfig;
|
|
@@ -639,6 +682,7 @@ var convertPremintFromApi = (premint) => {
|
|
|
639
682
|
var convertGetPremintApiResponse = (response) => ({
|
|
640
683
|
...convertPremintFromApi(response.premint),
|
|
641
684
|
collection: convertCollectionFromApi(response.collection),
|
|
685
|
+
collectionAddress: response.collection_address,
|
|
642
686
|
signature: response.signature
|
|
643
687
|
});
|
|
644
688
|
var encodePremintV1ForAPI = ({
|
|
@@ -685,6 +729,7 @@ var encodePremintForAPI = ({
|
|
|
685
729
|
};
|
|
686
730
|
var encodePostSignatureInput = ({
|
|
687
731
|
collection,
|
|
732
|
+
collectionAddress,
|
|
688
733
|
premintConfigVersion,
|
|
689
734
|
premintConfig,
|
|
690
735
|
signature,
|
|
@@ -696,6 +741,7 @@ var encodePostSignatureInput = ({
|
|
|
696
741
|
}),
|
|
697
742
|
signature,
|
|
698
743
|
collection,
|
|
744
|
+
collection_address: collectionAddress,
|
|
699
745
|
chain_name: networkConfigByChain[chainId].zoraBackendChainName
|
|
700
746
|
});
|
|
701
747
|
|
|
@@ -731,13 +777,11 @@ var getSignature = async ({
|
|
|
731
777
|
var PremintAPIClient = class {
|
|
732
778
|
constructor(chainId, httpClient2) {
|
|
733
779
|
this.postSignature = async ({
|
|
734
|
-
collection,
|
|
735
780
|
signature,
|
|
736
|
-
...
|
|
781
|
+
...rest
|
|
737
782
|
}) => {
|
|
738
783
|
const data = encodePostSignatureInput({
|
|
739
|
-
|
|
740
|
-
...premintConfigAndVersion,
|
|
784
|
+
...rest,
|
|
741
785
|
chainId: this.networkConfig.chainId,
|
|
742
786
|
signature
|
|
743
787
|
});
|
|
@@ -769,7 +813,15 @@ var PremintAPIClient = class {
|
|
|
769
813
|
};
|
|
770
814
|
|
|
771
815
|
// src/utils.ts
|
|
816
|
+
var import_viem4 = require("viem");
|
|
772
817
|
var makeSimulateContractParamaters = (args) => args;
|
|
818
|
+
function setupClient({ chain, httpClient: httpClient2, publicClient }) {
|
|
819
|
+
return {
|
|
820
|
+
chain,
|
|
821
|
+
httpClient: httpClient2 || httpClient,
|
|
822
|
+
publicClient: publicClient || (0, import_viem4.createPublicClient)({ chain, transport: (0, import_viem4.http)() })
|
|
823
|
+
};
|
|
824
|
+
}
|
|
773
825
|
|
|
774
826
|
// src/premint/premint-client.ts
|
|
775
827
|
var defaultTokenConfigV1MintArguments = () => ({
|
|
@@ -783,6 +835,37 @@ var defaultTokenConfigV1MintArguments = () => ({
|
|
|
783
835
|
royaltyBPS: 1e3
|
|
784
836
|
// 10%,
|
|
785
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
|
+
});
|
|
786
869
|
var defaultTokenConfigV2MintArguments = () => ({
|
|
787
870
|
maxSupply: OPEN_EDITION_MINT_SIZE,
|
|
788
871
|
maxTokensPerAddress: 0n,
|
|
@@ -795,37 +878,34 @@ var defaultTokenConfigV2MintArguments = () => ({
|
|
|
795
878
|
});
|
|
796
879
|
var makeTokenConfigWithDefaults = ({
|
|
797
880
|
chainId,
|
|
798
|
-
premintConfigVersion,
|
|
799
881
|
tokenCreationConfig,
|
|
800
|
-
|
|
882
|
+
supportedPremintVersions: supportedPremintVersions2
|
|
801
883
|
}) => {
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
return {
|
|
808
|
-
fixedPriceMinter,
|
|
809
|
-
...defaultTokenConfigV1MintArguments(),
|
|
810
|
-
royaltyRecipient: creatorAccount,
|
|
811
|
-
...tokenCreationConfig
|
|
812
|
-
};
|
|
813
|
-
} 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
|
+
}
|
|
814
889
|
return {
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
890
|
+
premintConfigVersion: import_protocol_deployments4.PremintConfigVersion.V1,
|
|
891
|
+
tokenConfig: tokenConfigV1WithDefault(
|
|
892
|
+
tokenCreationConfig,
|
|
893
|
+
fixedPriceMinter
|
|
894
|
+
)
|
|
820
895
|
};
|
|
821
|
-
} else {
|
|
822
|
-
throw new Error(`Invalid premint config version ${premintConfigVersion}`);
|
|
823
896
|
}
|
|
897
|
+
return {
|
|
898
|
+
premintConfigVersion: import_protocol_deployments4.PremintConfigVersion.V2,
|
|
899
|
+
tokenConfig: tokenConfigV2WithDefault(
|
|
900
|
+
tokenCreationConfig,
|
|
901
|
+
fixedPriceMinter
|
|
902
|
+
)
|
|
903
|
+
};
|
|
824
904
|
};
|
|
825
905
|
function getPremintedLogFromReceipt(receipt) {
|
|
826
906
|
for (const data of receipt.logs) {
|
|
827
907
|
try {
|
|
828
|
-
const decodedLog = (0,
|
|
908
|
+
const decodedLog = (0, import_viem5.decodeEventLog)({
|
|
829
909
|
abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
|
|
830
910
|
eventName: "PremintedV2",
|
|
831
911
|
...data
|
|
@@ -841,7 +921,7 @@ var PremintClient = class {
|
|
|
841
921
|
constructor(chain, publicClient, httpClient2) {
|
|
842
922
|
this.chain = chain;
|
|
843
923
|
this.apiClient = new PremintAPIClient(chain.id, httpClient2);
|
|
844
|
-
this.publicClient = publicClient
|
|
924
|
+
this.publicClient = publicClient;
|
|
845
925
|
}
|
|
846
926
|
getDataFromPremintReceipt(receipt) {
|
|
847
927
|
const premintedLog = getPremintedLogFromReceipt(receipt);
|
|
@@ -854,174 +934,45 @@ var PremintClient = class {
|
|
|
854
934
|
};
|
|
855
935
|
}
|
|
856
936
|
/**
|
|
857
|
-
*
|
|
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
|
|
937
|
+
* Prepares data for updating a premint
|
|
917
938
|
*
|
|
939
|
+
* @param parameters - Parameters for updating the premint {@link UpdatePremintParams}
|
|
940
|
+
* @returns A PremintReturn. {@link PremintReturn}
|
|
918
941
|
*/
|
|
919
|
-
async
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
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
|
|
942
|
+
async updatePremint(args) {
|
|
943
|
+
return await updatePremint({
|
|
944
|
+
...args,
|
|
945
|
+
apiClient: this.apiClient,
|
|
946
|
+
publicClient: this.publicClient,
|
|
947
|
+
chainId: this.chain.id
|
|
946
948
|
});
|
|
947
949
|
}
|
|
948
950
|
/**
|
|
949
|
-
*
|
|
951
|
+
* Prepares data for deleting a premint
|
|
950
952
|
*
|
|
951
|
-
* @param
|
|
952
|
-
* @returns
|
|
953
|
+
* @param parameters - Parameters for deleting the premint {@link DeletePremintParams}
|
|
954
|
+
* @returns A PremintReturn. {@link PremintReturn}
|
|
953
955
|
*/
|
|
954
|
-
async
|
|
955
|
-
|
|
956
|
+
async deletePremint(params) {
|
|
957
|
+
return deletePremint({
|
|
956
958
|
...params,
|
|
957
|
-
chainId: this.chain.id,
|
|
958
959
|
apiClient: this.apiClient,
|
|
959
|
-
publicClient: this.publicClient
|
|
960
|
+
publicClient: this.publicClient,
|
|
961
|
+
chainId: this.chain.id
|
|
960
962
|
});
|
|
961
|
-
const uid = params.premintConfig.uid;
|
|
962
|
-
return {
|
|
963
|
-
urls: this.makeUrls({ address: verifyingContract, uid }),
|
|
964
|
-
uid,
|
|
965
|
-
verifyingContract
|
|
966
|
-
};
|
|
967
963
|
}
|
|
968
964
|
/**
|
|
969
|
-
*
|
|
965
|
+
* Prepares data for creating a premint
|
|
970
966
|
*
|
|
971
|
-
* @param
|
|
972
|
-
* @
|
|
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
|
|
967
|
+
* @param parameters - Parameters for creating the premint {@link CreatePremintParameters}
|
|
968
|
+
* @returns A PremintReturn. {@link PremintReturn}
|
|
979
969
|
*/
|
|
980
|
-
async createPremint({
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
tokenCreationConfig,
|
|
984
|
-
premintConfigVersion,
|
|
985
|
-
walletClient,
|
|
986
|
-
uid,
|
|
987
|
-
checkSignature = false
|
|
988
|
-
}) {
|
|
989
|
-
const newContractAddress = await getPremintCollectionAddress({
|
|
970
|
+
async createPremint(parameters) {
|
|
971
|
+
return createPremint({
|
|
972
|
+
...parameters,
|
|
990
973
|
publicClient: this.publicClient,
|
|
991
|
-
|
|
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,
|
|
1000
|
-
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
|
|
974
|
+
apiClient: this.apiClient,
|
|
975
|
+
chainId: this.chain.id
|
|
1025
976
|
});
|
|
1026
977
|
}
|
|
1027
978
|
/**
|
|
@@ -1059,17 +1010,22 @@ var PremintClient = class {
|
|
|
1059
1010
|
*/
|
|
1060
1011
|
async isValidSignature({
|
|
1061
1012
|
signature,
|
|
1062
|
-
collection,
|
|
1063
1013
|
premintConfig,
|
|
1064
|
-
premintConfigVersion
|
|
1014
|
+
premintConfigVersion,
|
|
1015
|
+
...collectionAndOrAddress
|
|
1065
1016
|
}) {
|
|
1017
|
+
const collectionAddressToUse = await getPremintCollectionAddress({
|
|
1018
|
+
...collectionAndOrAddress,
|
|
1019
|
+
publicClient: this.publicClient
|
|
1020
|
+
});
|
|
1066
1021
|
const { isAuthorized, recoveredAddress } = await isValidSignature({
|
|
1067
1022
|
chainId: this.chain.id,
|
|
1068
1023
|
signature,
|
|
1069
|
-
collection,
|
|
1070
1024
|
publicClient: this.publicClient,
|
|
1071
1025
|
premintConfig,
|
|
1072
|
-
premintConfigVersion: premintConfigVersion || import_protocol_deployments4.PremintConfigVersion.V1
|
|
1026
|
+
premintConfigVersion: premintConfigVersion || import_protocol_deployments4.PremintConfigVersion.V1,
|
|
1027
|
+
collectionAddress: collectionAddressToUse,
|
|
1028
|
+
collection: collectionAndOrAddress.collection
|
|
1073
1029
|
});
|
|
1074
1030
|
return { isValid: isAuthorized, recoveredSigner: recoveredAddress };
|
|
1075
1031
|
}
|
|
@@ -1098,91 +1054,308 @@ var PremintClient = class {
|
|
|
1098
1054
|
});
|
|
1099
1055
|
}
|
|
1100
1056
|
/**
|
|
1101
|
-
*
|
|
1057
|
+
* Prepares the parameters to collect a premint; it brings the contract and token onchain, then collects
|
|
1058
|
+
* tokens on that contract for the mint recipient.
|
|
1102
1059
|
*
|
|
1103
|
-
* @param
|
|
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.
|
|
1060
|
+
* @param parameters - Parameters for collecting the Premint {@link MakeMintParametersArguments}
|
|
1110
1061
|
* @returns receipt, log, zoraURL
|
|
1111
1062
|
*/
|
|
1112
|
-
async makeMintParameters({
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
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
|
|
1063
|
+
async makeMintParameters(parameters) {
|
|
1064
|
+
return await makeMintParameters({
|
|
1065
|
+
...parameters,
|
|
1066
|
+
apiClient: this.apiClient,
|
|
1067
|
+
publicClient: this.publicClient
|
|
1127
1068
|
});
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
function createPremintClient(clientConfig) {
|
|
1072
|
+
const { chain, httpClient: httpClient2, publicClient } = setupClient(clientConfig);
|
|
1073
|
+
return new PremintClient(chain, publicClient, httpClient2);
|
|
1074
|
+
}
|
|
1075
|
+
function makePremintReturn({
|
|
1076
|
+
premintConfig,
|
|
1077
|
+
premintConfigVersion,
|
|
1078
|
+
publicClient,
|
|
1079
|
+
apiClient,
|
|
1080
|
+
chainId,
|
|
1081
|
+
...collectionAndAddress
|
|
1082
|
+
}) {
|
|
1083
|
+
const { collection, collectionAddress } = collectionAndAddress;
|
|
1084
|
+
const typedDataDefinition = (0, import_protocol_deployments4.premintTypedDataDefinition)({
|
|
1085
|
+
verifyingContract: collectionAddress,
|
|
1086
|
+
premintConfig,
|
|
1087
|
+
premintConfigVersion,
|
|
1088
|
+
chainId
|
|
1089
|
+
});
|
|
1090
|
+
const signAndSubmit = async ({
|
|
1091
|
+
walletClient,
|
|
1092
|
+
account,
|
|
1093
|
+
checkSignature
|
|
1094
|
+
}) => {
|
|
1095
|
+
const { signature, signerAccount } = await signPremint({
|
|
1096
|
+
account,
|
|
1097
|
+
walletClient,
|
|
1098
|
+
typedDataDefinition
|
|
1099
|
+
});
|
|
1100
|
+
await submit({
|
|
1101
|
+
signature,
|
|
1102
|
+
checkSignature,
|
|
1103
|
+
signerAccount
|
|
1104
|
+
});
|
|
1105
|
+
return {
|
|
1106
|
+
signature,
|
|
1107
|
+
signerAccount
|
|
1145
1108
|
};
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
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
|
-
]
|
|
1109
|
+
};
|
|
1110
|
+
const submit = async ({
|
|
1111
|
+
signature,
|
|
1112
|
+
checkSignature,
|
|
1113
|
+
signerAccount
|
|
1114
|
+
}) => {
|
|
1115
|
+
if (checkSignature) {
|
|
1116
|
+
const isAuthorized = await isAuthorizedToCreatePremint({
|
|
1117
|
+
collectionAddress,
|
|
1118
|
+
additionalAdmins: collection?.additionalAdmins,
|
|
1119
|
+
contractAdmin: collection?.contractAdmin,
|
|
1120
|
+
publicClient,
|
|
1121
|
+
signer: signerAccount
|
|
1175
1122
|
});
|
|
1123
|
+
if (!isAuthorized) {
|
|
1124
|
+
throw new Error("Not authorized to create premint");
|
|
1125
|
+
}
|
|
1176
1126
|
}
|
|
1177
|
-
|
|
1127
|
+
await apiClient.postSignature({
|
|
1128
|
+
...toContractCreationConfigOrAddress(collectionAndAddress),
|
|
1129
|
+
signature,
|
|
1130
|
+
premintConfig,
|
|
1131
|
+
premintConfigVersion
|
|
1132
|
+
});
|
|
1133
|
+
};
|
|
1134
|
+
return {
|
|
1135
|
+
premintConfig,
|
|
1136
|
+
premintConfigVersion,
|
|
1137
|
+
typedDataDefinition,
|
|
1138
|
+
collectionAddress,
|
|
1139
|
+
signAndSubmit,
|
|
1140
|
+
submit
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
async function signPremint({
|
|
1144
|
+
account,
|
|
1145
|
+
walletClient,
|
|
1146
|
+
typedDataDefinition
|
|
1147
|
+
}) {
|
|
1148
|
+
if (!account) {
|
|
1149
|
+
account = walletClient.account;
|
|
1178
1150
|
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1151
|
+
if (!account) {
|
|
1152
|
+
throw new Error("No account provided");
|
|
1153
|
+
}
|
|
1154
|
+
const signature = await walletClient.signTypedData({
|
|
1155
|
+
account,
|
|
1156
|
+
...typedDataDefinition
|
|
1157
|
+
});
|
|
1158
|
+
return {
|
|
1159
|
+
signature,
|
|
1160
|
+
signerAccount: account
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
async function createPremint({
|
|
1164
|
+
tokenCreationConfig,
|
|
1165
|
+
uid,
|
|
1166
|
+
publicClient,
|
|
1167
|
+
apiClient,
|
|
1168
|
+
chainId,
|
|
1169
|
+
...collectionOrAddress
|
|
1170
|
+
}) {
|
|
1171
|
+
const {
|
|
1172
|
+
premintConfig,
|
|
1173
|
+
premintConfigVersion,
|
|
1174
|
+
collectionAddress: collectionAddressToUse
|
|
1175
|
+
} = await prepareCreatePremintConfig({
|
|
1176
|
+
...collectionOrAddress,
|
|
1177
|
+
tokenCreationConfig,
|
|
1178
|
+
uid,
|
|
1179
|
+
publicClient,
|
|
1180
|
+
apiClient,
|
|
1181
|
+
chainId
|
|
1182
|
+
});
|
|
1183
|
+
return makePremintReturn({
|
|
1184
|
+
premintConfig,
|
|
1185
|
+
premintConfigVersion,
|
|
1186
|
+
collectionAddress: collectionAddressToUse,
|
|
1187
|
+
collection: collectionOrAddress.collection,
|
|
1188
|
+
publicClient,
|
|
1189
|
+
apiClient,
|
|
1190
|
+
chainId
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
async function prepareCreatePremintConfig({
|
|
1194
|
+
tokenCreationConfig,
|
|
1195
|
+
uid,
|
|
1196
|
+
publicClient,
|
|
1197
|
+
apiClient,
|
|
1198
|
+
chainId,
|
|
1199
|
+
...collectionOrAddress
|
|
1200
|
+
}) {
|
|
1201
|
+
const newContractAddress = await getPremintCollectionAddress({
|
|
1202
|
+
publicClient,
|
|
1203
|
+
...collectionOrAddress
|
|
1204
|
+
});
|
|
1205
|
+
let uidToUse = uid;
|
|
1206
|
+
if (typeof uidToUse !== "number") {
|
|
1207
|
+
uidToUse = await apiClient.getNextUID(newContractAddress);
|
|
1208
|
+
}
|
|
1209
|
+
const supportedVersions = await supportedPremintVersions({
|
|
1210
|
+
tokenContract: newContractAddress,
|
|
1211
|
+
publicClient
|
|
1212
|
+
});
|
|
1213
|
+
const tokenConfigAndVersion = makeTokenConfigWithDefaults({
|
|
1214
|
+
tokenCreationConfig,
|
|
1215
|
+
chainId,
|
|
1216
|
+
supportedPremintVersions: supportedVersions
|
|
1217
|
+
});
|
|
1218
|
+
const premintConfig = makeNewPremint({
|
|
1219
|
+
...tokenConfigAndVersion,
|
|
1220
|
+
uid: uidToUse
|
|
1221
|
+
});
|
|
1222
|
+
const premintConfigAndVersion = {
|
|
1223
|
+
premintConfig,
|
|
1224
|
+
premintConfigVersion: tokenConfigAndVersion.premintConfigVersion
|
|
1225
|
+
};
|
|
1226
|
+
return {
|
|
1227
|
+
...premintConfigAndVersion,
|
|
1228
|
+
collectionAddress: newContractAddress
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
async function updatePremint({
|
|
1232
|
+
uid,
|
|
1233
|
+
collection,
|
|
1234
|
+
tokenConfigUpdates,
|
|
1235
|
+
apiClient,
|
|
1236
|
+
publicClient,
|
|
1237
|
+
chainId
|
|
1238
|
+
}) {
|
|
1239
|
+
const {
|
|
1240
|
+
premintConfig,
|
|
1241
|
+
collection: collectionCreationConfig,
|
|
1242
|
+
premintConfigVersion
|
|
1243
|
+
} = await apiClient.getSignature({
|
|
1244
|
+
collectionAddress: collection,
|
|
1245
|
+
uid
|
|
1246
|
+
});
|
|
1247
|
+
const updatedPremint = applyUpdateToPremint({
|
|
1248
|
+
uid: premintConfig.uid,
|
|
1249
|
+
version: premintConfig.version,
|
|
1250
|
+
tokenConfig: premintConfig.tokenConfig,
|
|
1251
|
+
tokenConfigUpdates
|
|
1252
|
+
});
|
|
1253
|
+
return makePremintReturn({
|
|
1254
|
+
premintConfig: updatedPremint,
|
|
1255
|
+
premintConfigVersion,
|
|
1256
|
+
collectionAddress: collection,
|
|
1257
|
+
collection: collectionCreationConfig,
|
|
1258
|
+
publicClient,
|
|
1259
|
+
apiClient,
|
|
1260
|
+
chainId
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
async function deletePremint({
|
|
1264
|
+
uid,
|
|
1265
|
+
collection,
|
|
1266
|
+
publicClient,
|
|
1267
|
+
apiClient,
|
|
1268
|
+
chainId
|
|
1269
|
+
}) {
|
|
1270
|
+
const {
|
|
1271
|
+
premintConfig,
|
|
1272
|
+
premintConfigVersion,
|
|
1273
|
+
collection: collectionCreationConfig,
|
|
1274
|
+
collectionAddress
|
|
1275
|
+
} = await apiClient.getSignature({
|
|
1276
|
+
collectionAddress: collection,
|
|
1277
|
+
uid
|
|
1278
|
+
});
|
|
1279
|
+
const deletedPremint = {
|
|
1280
|
+
...premintConfig,
|
|
1281
|
+
version: premintConfig.version + 1,
|
|
1282
|
+
deleted: true
|
|
1283
|
+
};
|
|
1284
|
+
return makePremintReturn({
|
|
1285
|
+
premintConfig: deletedPremint,
|
|
1286
|
+
premintConfigVersion,
|
|
1287
|
+
collectionAddress,
|
|
1288
|
+
collection: collectionCreationConfig,
|
|
1289
|
+
publicClient,
|
|
1290
|
+
apiClient,
|
|
1291
|
+
chainId
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
async function makeMintParameters({
|
|
1295
|
+
uid,
|
|
1296
|
+
tokenContract,
|
|
1297
|
+
minterAccount,
|
|
1298
|
+
mintArguments,
|
|
1299
|
+
firstMinter,
|
|
1300
|
+
apiClient,
|
|
1183
1301
|
publicClient
|
|
1184
1302
|
}) {
|
|
1185
|
-
|
|
1303
|
+
if (mintArguments && mintArguments?.quantityToMint < 1) {
|
|
1304
|
+
throw new Error("Quantity to mint cannot be below 1");
|
|
1305
|
+
}
|
|
1306
|
+
if (!minterAccount) {
|
|
1307
|
+
throw new Error("Wallet not passed in");
|
|
1308
|
+
}
|
|
1309
|
+
const {
|
|
1310
|
+
premintConfig,
|
|
1311
|
+
premintConfigVersion,
|
|
1312
|
+
collection,
|
|
1313
|
+
collectionAddress,
|
|
1314
|
+
signature
|
|
1315
|
+
} = await apiClient.getSignature({
|
|
1316
|
+
collectionAddress: tokenContract,
|
|
1317
|
+
uid
|
|
1318
|
+
});
|
|
1319
|
+
const numberToMint = BigInt(mintArguments?.quantityToMint || 1);
|
|
1320
|
+
if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V3) {
|
|
1321
|
+
throw new Error("PremintV3 not supported in premint SDK");
|
|
1322
|
+
}
|
|
1323
|
+
const value = (await getPremintMintCosts({
|
|
1324
|
+
tokenContract,
|
|
1325
|
+
quantityToMint: numberToMint,
|
|
1326
|
+
publicClient,
|
|
1327
|
+
tokenPrice: premintConfig.tokenConfig.pricePerToken
|
|
1328
|
+
})).totalCost;
|
|
1329
|
+
const mintArgumentsContract = {
|
|
1330
|
+
mintComment: mintArguments?.mintComment || "",
|
|
1331
|
+
mintRecipient: mintArguments?.mintRecipient || (typeof minterAccount === "string" ? minterAccount : minterAccount.address),
|
|
1332
|
+
mintRewardsRecipients: makeMintRewardsRecipient({
|
|
1333
|
+
mintReferral: mintArguments?.mintReferral
|
|
1334
|
+
})
|
|
1335
|
+
};
|
|
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)({
|
|
1349
|
+
premintConfig,
|
|
1350
|
+
premintConfigVersion
|
|
1351
|
+
}),
|
|
1352
|
+
signature,
|
|
1353
|
+
numberToMint,
|
|
1354
|
+
mintArgumentsContract,
|
|
1355
|
+
firstMinterToSubmit,
|
|
1356
|
+
import_viem5.zeroAddress
|
|
1357
|
+
]
|
|
1358
|
+
});
|
|
1186
1359
|
}
|
|
1187
1360
|
function makeUrls({
|
|
1188
1361
|
uid,
|
|
@@ -1201,52 +1374,6 @@ function makeUrls({
|
|
|
1201
1374
|
zoraManage: `https://${network.isTestnet ? "testnet." : ""}zora.co/collect/${network.zoraCollectPathChainName}:${address}/${zoraTokenPath}`
|
|
1202
1375
|
};
|
|
1203
1376
|
}
|
|
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
1377
|
|
|
1251
1378
|
// src/premint/contract-types.ts
|
|
1252
1379
|
var import_protocol_deployments5 = require("@zoralabs/protocol-deployments");
|
|
@@ -1258,7 +1385,7 @@ var PremintConfigVersion3 = ((PremintConfigVersion4) => {
|
|
|
1258
1385
|
})(PremintConfigVersion3 || {});
|
|
1259
1386
|
|
|
1260
1387
|
// src/mint/mint-client.ts
|
|
1261
|
-
var
|
|
1388
|
+
var import_viem6 = require("viem");
|
|
1262
1389
|
var import_protocol_deployments6 = require("@zoralabs/protocol-deployments");
|
|
1263
1390
|
var MintError = class extends Error {
|
|
1264
1391
|
};
|
|
@@ -1271,30 +1398,24 @@ var Errors = {
|
|
|
1271
1398
|
var MintClient = class {
|
|
1272
1399
|
constructor(chain, publicClient, httpClient2) {
|
|
1273
1400
|
this.apiClient = new MintAPIClient(chain.id, httpClient2);
|
|
1274
|
-
this.publicClient = publicClient
|
|
1401
|
+
this.publicClient = publicClient;
|
|
1275
1402
|
}
|
|
1276
1403
|
/**
|
|
1277
1404
|
* Returns the parameters needed to prepare a transaction mint a token.
|
|
1278
|
-
*
|
|
1279
|
-
* @param
|
|
1280
|
-
* @
|
|
1281
|
-
* @returns
|
|
1405
|
+
*
|
|
1406
|
+
* @param parameters - Parameters for collecting the token {@link MintTokenParams}
|
|
1407
|
+
* @returns Parameters for simulating/executing the mint transaction
|
|
1282
1408
|
*/
|
|
1283
|
-
async makePrepareMintTokenParams({
|
|
1284
|
-
...rest
|
|
1285
|
-
}) {
|
|
1409
|
+
async makePrepareMintTokenParams(parameters) {
|
|
1286
1410
|
return makePrepareMintTokenParams({
|
|
1287
|
-
...
|
|
1411
|
+
...parameters,
|
|
1288
1412
|
apiClient: this.apiClient,
|
|
1289
1413
|
publicClient: this.publicClient
|
|
1290
1414
|
});
|
|
1291
1415
|
}
|
|
1292
1416
|
};
|
|
1293
|
-
function createMintClient({
|
|
1294
|
-
chain,
|
|
1295
|
-
publicClient,
|
|
1296
|
-
httpClient: httpClient2
|
|
1297
|
-
}) {
|
|
1417
|
+
function createMintClient(clientConfig) {
|
|
1418
|
+
const { chain, publicClient, httpClient: httpClient2 } = setupClient(clientConfig);
|
|
1298
1419
|
return new MintClient(chain, publicClient, httpClient2);
|
|
1299
1420
|
}
|
|
1300
1421
|
async function makePrepareMintTokenParams({
|
|
@@ -1346,7 +1467,7 @@ async function makePrepareMint721TokenParams({
|
|
|
1346
1467
|
mintArguments.mintToAddress,
|
|
1347
1468
|
BigInt(mintArguments.quantityToMint),
|
|
1348
1469
|
mintArguments.mintComment || "",
|
|
1349
|
-
mintArguments.mintReferral ||
|
|
1470
|
+
mintArguments.mintReferral || import_viem6.zeroAddress
|
|
1350
1471
|
]
|
|
1351
1472
|
});
|
|
1352
1473
|
}
|
|
@@ -1388,11 +1509,11 @@ async function makePrepareMint1155TokenParams({
|
|
|
1388
1509
|
salesConfigAndTokenInfo.salesConfig.address || import_protocol_deployments6.zoraCreatorFixedPriceSaleStrategyAddress[999999999],
|
|
1389
1510
|
BigInt(tokenId),
|
|
1390
1511
|
mintQuantity,
|
|
1391
|
-
(0,
|
|
1512
|
+
(0, import_viem6.encodeAbiParameters)((0, import_viem6.parseAbiParameters)("address, string"), [
|
|
1392
1513
|
fixedPriceArgs.mintToAddress,
|
|
1393
1514
|
fixedPriceArgs.mintComment || ""
|
|
1394
1515
|
]),
|
|
1395
|
-
fixedPriceArgs.mintReferral ||
|
|
1516
|
+
fixedPriceArgs.mintReferral || import_viem6.zeroAddress
|
|
1396
1517
|
]
|
|
1397
1518
|
});
|
|
1398
1519
|
case "erc20":
|
|
@@ -1410,7 +1531,7 @@ async function makePrepareMint1155TokenParams({
|
|
|
1410
1531
|
BigInt(tokenId),
|
|
1411
1532
|
salesConfigAndTokenInfo.salesConfig.pricePerToken,
|
|
1412
1533
|
salesConfigAndTokenInfo.salesConfig.currency,
|
|
1413
|
-
erc20Args.mintReferral ||
|
|
1534
|
+
erc20Args.mintReferral || import_viem6.zeroAddress,
|
|
1414
1535
|
erc20Args.mintComment || ""
|
|
1415
1536
|
]
|
|
1416
1537
|
});
|
|
@@ -1421,11 +1542,11 @@ async function makePrepareMint1155TokenParams({
|
|
|
1421
1542
|
|
|
1422
1543
|
// src/create/1155-create-helper.ts
|
|
1423
1544
|
var import_protocol_deployments7 = require("@zoralabs/protocol-deployments");
|
|
1424
|
-
var
|
|
1545
|
+
var import_viem7 = require("viem");
|
|
1425
1546
|
var SALE_END_FOREVER = 18446744073709551615n;
|
|
1426
1547
|
var ROYALTY_BPS_DEFAULT = 1e3;
|
|
1427
1548
|
var DEFAULT_SALE_SETTINGS = {
|
|
1428
|
-
fundsRecipient:
|
|
1549
|
+
fundsRecipient: import_viem7.zeroAddress,
|
|
1429
1550
|
// Free Mint
|
|
1430
1551
|
pricePerToken: 0n,
|
|
1431
1552
|
// Sale start time – defaults to beginning of unix time
|
|
@@ -1464,32 +1585,32 @@ function create1155TokenSetupArgs({
|
|
|
1464
1585
|
...salesConfig
|
|
1465
1586
|
};
|
|
1466
1587
|
const setupActions = [
|
|
1467
|
-
(0,
|
|
1588
|
+
(0, import_viem7.encodeFunctionData)({
|
|
1468
1589
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1469
1590
|
functionName: "assumeLastTokenIdMatches",
|
|
1470
1591
|
args: [nextTokenId - 1n]
|
|
1471
1592
|
}),
|
|
1472
|
-
createReferral ? (0,
|
|
1593
|
+
createReferral ? (0, import_viem7.encodeFunctionData)({
|
|
1473
1594
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1474
1595
|
functionName: "setupNewTokenWithCreateReferral",
|
|
1475
1596
|
args: [tokenMetadataURI, maxSupply, createReferral]
|
|
1476
|
-
}) : (0,
|
|
1597
|
+
}) : (0, import_viem7.encodeFunctionData)({
|
|
1477
1598
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1478
1599
|
functionName: "setupNewToken",
|
|
1479
1600
|
args: [tokenMetadataURI, maxSupply]
|
|
1480
1601
|
}),
|
|
1481
|
-
(0,
|
|
1602
|
+
(0, import_viem7.encodeFunctionData)({
|
|
1482
1603
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1483
1604
|
functionName: "addPermission",
|
|
1484
1605
|
args: [0n, fixedPriceMinterAddress, PERMISSION_BIT_MINTER]
|
|
1485
1606
|
}),
|
|
1486
|
-
(0,
|
|
1607
|
+
(0, import_viem7.encodeFunctionData)({
|
|
1487
1608
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1488
1609
|
functionName: "callSale",
|
|
1489
1610
|
args: [
|
|
1490
1611
|
nextTokenId,
|
|
1491
1612
|
fixedPriceMinterAddress,
|
|
1492
|
-
(0,
|
|
1613
|
+
(0, import_viem7.encodeFunctionData)({
|
|
1493
1614
|
abi: import_protocol_deployments7.zoraCreatorFixedPriceSaleStrategyABI,
|
|
1494
1615
|
functionName: "setSale",
|
|
1495
1616
|
args: [nextTokenId, salesConfigWithDefaults]
|
|
@@ -1499,7 +1620,7 @@ function create1155TokenSetupArgs({
|
|
|
1499
1620
|
];
|
|
1500
1621
|
if (mintToCreatorCount) {
|
|
1501
1622
|
setupActions.push(
|
|
1502
|
-
(0,
|
|
1623
|
+
(0, import_viem7.encodeFunctionData)({
|
|
1503
1624
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1504
1625
|
functionName: "adminMint",
|
|
1505
1626
|
args: [account, nextTokenId, mintToCreatorCount, "0x"]
|
|
@@ -1508,7 +1629,7 @@ function create1155TokenSetupArgs({
|
|
|
1508
1629
|
}
|
|
1509
1630
|
if (royaltySettings) {
|
|
1510
1631
|
setupActions.push(
|
|
1511
|
-
(0,
|
|
1632
|
+
(0, import_viem7.encodeFunctionData)({
|
|
1512
1633
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1513
1634
|
functionName: "updateRoyaltiesForToken",
|
|
1514
1635
|
args: [
|
|
@@ -1527,7 +1648,7 @@ function create1155TokenSetupArgs({
|
|
|
1527
1648
|
var getTokenIdFromCreateReceipt = (receipt) => {
|
|
1528
1649
|
for (const data of receipt.logs) {
|
|
1529
1650
|
try {
|
|
1530
|
-
const decodedLog = (0,
|
|
1651
|
+
const decodedLog = (0, import_viem7.decodeEventLog)({
|
|
1531
1652
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1532
1653
|
eventName: "SetupNewToken",
|
|
1533
1654
|
...data
|
|
@@ -1571,9 +1692,8 @@ async function getContractExists(publicClient, contract, account) {
|
|
|
1571
1692
|
contractAddress: contract
|
|
1572
1693
|
};
|
|
1573
1694
|
}
|
|
1574
|
-
function create1155CreatorClient({
|
|
1575
|
-
publicClient
|
|
1576
|
-
}) {
|
|
1695
|
+
function create1155CreatorClient(clientConfig) {
|
|
1696
|
+
const { publicClient } = setupClient(clientConfig);
|
|
1577
1697
|
async function createNew1155Token({
|
|
1578
1698
|
contract,
|
|
1579
1699
|
tokenMetadataURI,
|
|
@@ -1726,7 +1846,7 @@ var sumBalances = (mintAccountBalances) => {
|
|
|
1726
1846
|
|
|
1727
1847
|
// src/mints/mints-contracts.ts
|
|
1728
1848
|
var import_protocol_deployments8 = require("@zoralabs/protocol-deployments");
|
|
1729
|
-
var
|
|
1849
|
+
var import_viem8 = require("viem");
|
|
1730
1850
|
var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
|
|
1731
1851
|
var mintWithEthParams = ({
|
|
1732
1852
|
quantity,
|
|
@@ -1761,7 +1881,7 @@ var encodeCollectOnManager = ({
|
|
|
1761
1881
|
minter,
|
|
1762
1882
|
zoraCreator1155TokenId,
|
|
1763
1883
|
mintArguments
|
|
1764
|
-
}) => (0,
|
|
1884
|
+
}) => (0, import_viem8.encodeFunctionData)({
|
|
1765
1885
|
abi: import_protocol_deployments8.zoraMintsManagerImplConfig.abi,
|
|
1766
1886
|
functionName: "collect",
|
|
1767
1887
|
args: [
|
|
@@ -1881,8 +2001,8 @@ var encodePremintOnManager = ({
|
|
|
1881
2001
|
premintConfig,
|
|
1882
2002
|
premintSignature,
|
|
1883
2003
|
mintArguments,
|
|
1884
|
-
signerContract =
|
|
1885
|
-
}) => (0,
|
|
2004
|
+
signerContract = import_viem8.zeroAddress
|
|
2005
|
+
}) => (0, import_viem8.encodeFunctionData)({
|
|
1886
2006
|
abi: import_protocol_deployments8.zoraMintsManagerImplConfig.abi,
|
|
1887
2007
|
functionName: "collectPremintV2",
|
|
1888
2008
|
args: [
|
|
@@ -1949,7 +2069,7 @@ function decodeCallFailedError(error) {
|
|
|
1949
2069
|
if (error.data?.errorName !== "CallFailed")
|
|
1950
2070
|
throw new Error("Not a CallFailed error");
|
|
1951
2071
|
const internalErrorData = error.data?.args?.[0];
|
|
1952
|
-
return (0,
|
|
2072
|
+
return (0, import_viem8.decodeErrorResult)({
|
|
1953
2073
|
abi: import_protocol_deployments8.zoraMintsManagerImplABI,
|
|
1954
2074
|
data: internalErrorData
|
|
1955
2075
|
});
|
|
@@ -1957,12 +2077,12 @@ function decodeCallFailedError(error) {
|
|
|
1957
2077
|
|
|
1958
2078
|
// src/mints/mints-eth-unwrapper-and-caller.ts
|
|
1959
2079
|
var import_protocol_deployments9 = require("@zoralabs/protocol-deployments");
|
|
1960
|
-
var
|
|
2080
|
+
var import_viem9 = require("viem");
|
|
1961
2081
|
var makeCallWithEthSafeTransferData = ({
|
|
1962
2082
|
address: addressToCall,
|
|
1963
2083
|
call: functionToCall,
|
|
1964
2084
|
value: valueToSend
|
|
1965
|
-
}) => (0,
|
|
2085
|
+
}) => (0, import_viem9.encodeFunctionData)({
|
|
1966
2086
|
abi: import_protocol_deployments9.iUnwrapAndForwardActionABI,
|
|
1967
2087
|
functionName: "callWithEth",
|
|
1968
2088
|
args: [addressToCall, functionToCall, valueToSend]
|
|
@@ -2005,8 +2125,10 @@ var unwrapAndForwardEthPermitAndTypedDataDefinition = ({
|
|
|
2005
2125
|
createMintClient,
|
|
2006
2126
|
createPremintClient,
|
|
2007
2127
|
decodeCallFailedError,
|
|
2128
|
+
defaultAdditionalAdmins,
|
|
2008
2129
|
defaultTokenConfigV1MintArguments,
|
|
2009
2130
|
defaultTokenConfigV2MintArguments,
|
|
2131
|
+
emptyContractCreationConfig,
|
|
2010
2132
|
encodeCollectOnManager,
|
|
2011
2133
|
encodePostSignatureInput,
|
|
2012
2134
|
encodePremintForAPI,
|
|
@@ -2029,6 +2151,7 @@ var unwrapAndForwardEthPermitAndTypedDataDefinition = ({
|
|
|
2029
2151
|
makePermitToCollectPremintOrNonPremint,
|
|
2030
2152
|
makePermitTransferBatchAndTypeData,
|
|
2031
2153
|
makePermitTransferTypeData,
|
|
2154
|
+
makeUrls,
|
|
2032
2155
|
migratePremintConfigToV2,
|
|
2033
2156
|
mintWithEthParams,
|
|
2034
2157
|
mintsBalanceOfAccountParams,
|
|
@@ -2038,6 +2161,7 @@ var unwrapAndForwardEthPermitAndTypedDataDefinition = ({
|
|
|
2038
2161
|
sumBalances,
|
|
2039
2162
|
supportedPremintVersions,
|
|
2040
2163
|
supportsPremintVersion,
|
|
2164
|
+
toContractCreationConfigOrAddress,
|
|
2041
2165
|
tryRecoverPremintSigner,
|
|
2042
2166
|
unwrapAndForwardEthPermitAndTypedDataDefinition
|
|
2043
2167
|
});
|