@zoralabs/protocol-sdk 0.4.1 → 0.4.3
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 +14 -14
- package/.turbo/turbo-lint.log +5 -0
- package/CHANGELOG.md +14 -0
- package/README.md +1 -1
- package/dist/apis/generated/premint-api-types.d.ts +117 -13
- package/dist/apis/generated/premint-api-types.d.ts.map +1 -1
- package/dist/index.cjs +134 -107
- 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 +129 -107
- package/dist/index.js.map +1 -1
- package/dist/premint/conversions.d.ts +78 -0
- package/dist/premint/conversions.d.ts.map +1 -0
- package/dist/premint/premint-api-client.d.ts +2 -3
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +4 -83
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/anvil.ts +1 -1
- package/src/apis/generated/premint-api-types.ts +124 -12
- package/src/index.ts +2 -0
- package/src/mint/mint-client.test.ts +5 -2
- package/src/premint/conversions.ts +155 -0
- package/src/premint/premint-api-client.ts +19 -125
- package/src/premint/premint-client.test.ts +5 -34
- package/src/premint/premint-client.ts +23 -23
- package/src/premint/preminter.ts +6 -12
package/dist/index.js
CHANGED
|
@@ -244,17 +244,12 @@ var supportedPremintVersions = async ({
|
|
|
244
244
|
tokenContract,
|
|
245
245
|
publicClient
|
|
246
246
|
}) => {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
});
|
|
254
|
-
} catch (e) {
|
|
255
|
-
console.error(e);
|
|
256
|
-
return ["1"];
|
|
257
|
-
}
|
|
247
|
+
return await publicClient.readContract({
|
|
248
|
+
abi: preminterAbi,
|
|
249
|
+
address: getPremintExecutorAddress(),
|
|
250
|
+
functionName: "supportedPremintSignatureVersions",
|
|
251
|
+
args: [tokenContract]
|
|
252
|
+
});
|
|
258
253
|
};
|
|
259
254
|
var supportsPremintVersion = async ({
|
|
260
255
|
version,
|
|
@@ -595,55 +590,55 @@ var MintAPIClient = class {
|
|
|
595
590
|
}
|
|
596
591
|
};
|
|
597
592
|
|
|
598
|
-
// src/premint/
|
|
599
|
-
var
|
|
600
|
-
httpClient: { post: post2, retries: retries2 } = httpClient,
|
|
601
|
-
...data
|
|
602
|
-
}) => retries2(
|
|
603
|
-
() => post2(`${ZORA_API_BASE}premint/signature`, data)
|
|
604
|
-
);
|
|
605
|
-
var getNextUID = async ({
|
|
606
|
-
chain_name,
|
|
607
|
-
collection_address,
|
|
608
|
-
httpClient: { retries: retries2, get: get2 } = httpClient
|
|
609
|
-
}) => retries2(
|
|
610
|
-
() => get2(
|
|
611
|
-
`${ZORA_API_BASE}premint/signature/${chain_name}/${collection_address}/next_uid`
|
|
612
|
-
)
|
|
613
|
-
);
|
|
614
|
-
var getSignature = async ({
|
|
615
|
-
collection_address,
|
|
616
|
-
uid,
|
|
617
|
-
chain_name,
|
|
618
|
-
httpClient: { retries: retries2, get: get2 } = httpClient
|
|
619
|
-
}) => {
|
|
620
|
-
const result = await retries2(
|
|
621
|
-
() => get2(
|
|
622
|
-
`${ZORA_API_BASE}premint/signature/${chain_name}/${collection_address}/${uid}`
|
|
623
|
-
)
|
|
624
|
-
);
|
|
625
|
-
return {
|
|
626
|
-
...result,
|
|
627
|
-
// for now - we stub the backend api to simulate returning v1
|
|
628
|
-
premint_config_version: "1" /* V1 */
|
|
629
|
-
};
|
|
630
|
-
};
|
|
631
|
-
var convertCollection = (collection) => ({
|
|
593
|
+
// src/premint/conversions.ts
|
|
594
|
+
var convertCollectionFromApi = (collection) => ({
|
|
632
595
|
...collection,
|
|
633
596
|
contractAdmin: collection.contractAdmin
|
|
634
597
|
});
|
|
635
|
-
var
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
598
|
+
var convertPremintFromApi = (premint) => {
|
|
599
|
+
if (premint.config_version === "1" /* V1 */ || !premint.config_version) {
|
|
600
|
+
const tokenConfig = premint.tokenConfig;
|
|
601
|
+
return {
|
|
602
|
+
premintConfigVersion: "1" /* V1 */,
|
|
603
|
+
premintConfig: {
|
|
604
|
+
...premint,
|
|
605
|
+
tokenConfig: {
|
|
606
|
+
...tokenConfig,
|
|
607
|
+
fixedPriceMinter: tokenConfig.fixedPriceMinter,
|
|
608
|
+
royaltyRecipient: tokenConfig.royaltyRecipient,
|
|
609
|
+
maxSupply: BigInt(tokenConfig.maxSupply),
|
|
610
|
+
pricePerToken: BigInt(tokenConfig.pricePerToken),
|
|
611
|
+
mintStart: BigInt(tokenConfig.mintStart),
|
|
612
|
+
mintDuration: BigInt(tokenConfig.mintDuration),
|
|
613
|
+
maxTokensPerAddress: BigInt(tokenConfig.maxTokensPerAddress)
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
} else {
|
|
618
|
+
const tokenConfig = premint.tokenConfig;
|
|
619
|
+
return {
|
|
620
|
+
premintConfigVersion: "2" /* V2 */,
|
|
621
|
+
premintConfig: {
|
|
622
|
+
...premint,
|
|
623
|
+
tokenConfig: {
|
|
624
|
+
...tokenConfig,
|
|
625
|
+
fixedPriceMinter: tokenConfig.fixedPriceMinter,
|
|
626
|
+
payoutRecipient: tokenConfig.payoutRecipient,
|
|
627
|
+
createReferral: tokenConfig.createReferral,
|
|
628
|
+
maxSupply: BigInt(tokenConfig.maxSupply),
|
|
629
|
+
pricePerToken: BigInt(tokenConfig.pricePerToken),
|
|
630
|
+
mintStart: BigInt(tokenConfig.mintStart),
|
|
631
|
+
mintDuration: BigInt(tokenConfig.mintDuration),
|
|
632
|
+
maxTokensPerAddress: BigInt(tokenConfig.maxTokensPerAddress)
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
};
|
|
646
636
|
}
|
|
637
|
+
};
|
|
638
|
+
var convertGetPremintApiResponse = (response) => ({
|
|
639
|
+
...convertPremintFromApi(response.premint),
|
|
640
|
+
collection: convertCollectionFromApi(response.collection),
|
|
641
|
+
signature: response.signature
|
|
647
642
|
});
|
|
648
643
|
var encodePremintV1ForAPI = ({
|
|
649
644
|
tokenConfig,
|
|
@@ -685,31 +680,68 @@ var encodePremintForAPI = ({
|
|
|
685
680
|
}
|
|
686
681
|
throw new Error(`Invalid premint config version ${premintConfigVersion}`);
|
|
687
682
|
};
|
|
683
|
+
var encodePostSignatureInput = ({
|
|
684
|
+
collection,
|
|
685
|
+
premintConfigVersion,
|
|
686
|
+
premintConfig,
|
|
687
|
+
signature,
|
|
688
|
+
chainId
|
|
689
|
+
}) => ({
|
|
690
|
+
premint: encodePremintForAPI({
|
|
691
|
+
premintConfig,
|
|
692
|
+
premintConfigVersion
|
|
693
|
+
}),
|
|
694
|
+
signature,
|
|
695
|
+
collection,
|
|
696
|
+
chain_name: networkConfigByChain[chainId].zoraBackendChainName
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
// src/premint/premint-api-client.ts
|
|
700
|
+
var postSignature = async ({
|
|
701
|
+
httpClient: { post: post2, retries: retries2 } = httpClient,
|
|
702
|
+
...data
|
|
703
|
+
}) => retries2(
|
|
704
|
+
() => post2(`${ZORA_API_BASE}premint/signature`, data)
|
|
705
|
+
);
|
|
706
|
+
var getNextUID = async ({
|
|
707
|
+
chain_name,
|
|
708
|
+
collection_address,
|
|
709
|
+
httpClient: { retries: retries2, get: get2 } = httpClient
|
|
710
|
+
}) => retries2(
|
|
711
|
+
() => get2(
|
|
712
|
+
`${ZORA_API_BASE}premint/signature/${chain_name}/${collection_address}/next_uid`
|
|
713
|
+
)
|
|
714
|
+
);
|
|
715
|
+
var getSignature = async ({
|
|
716
|
+
collection_address,
|
|
717
|
+
uid,
|
|
718
|
+
chain_name,
|
|
719
|
+
httpClient: { retries: retries2, get: get2 } = httpClient
|
|
720
|
+
}) => {
|
|
721
|
+
const result = await retries2(
|
|
722
|
+
() => get2(
|
|
723
|
+
`${ZORA_API_BASE}premint/signature/${chain_name}/${collection_address}/${uid}`
|
|
724
|
+
)
|
|
725
|
+
);
|
|
726
|
+
return result;
|
|
727
|
+
};
|
|
688
728
|
var PremintAPIClient = class {
|
|
689
729
|
constructor(chainId, httpClient2) {
|
|
690
730
|
this.postSignature = async ({
|
|
691
731
|
collection,
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
signature
|
|
732
|
+
signature,
|
|
733
|
+
...premintConfigAndVersion
|
|
695
734
|
}) => {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
...data,
|
|
707
|
-
chain_name: this.networkConfig.zoraBackendChainName,
|
|
708
|
-
httpClient: this.httpClient
|
|
709
|
-
});
|
|
710
|
-
} else {
|
|
711
|
-
throw new Error("Unsupported premint config version");
|
|
712
|
-
}
|
|
735
|
+
const data = encodePostSignatureInput({
|
|
736
|
+
collection,
|
|
737
|
+
...premintConfigAndVersion,
|
|
738
|
+
chainId: this.networkConfig.chainId,
|
|
739
|
+
signature
|
|
740
|
+
});
|
|
741
|
+
return postSignature({
|
|
742
|
+
...data,
|
|
743
|
+
httpClient: this.httpClient
|
|
744
|
+
});
|
|
713
745
|
};
|
|
714
746
|
this.getNextUID = async (collectionAddress) => (await getNextUID({
|
|
715
747
|
collection_address: collectionAddress.toLowerCase(),
|
|
@@ -726,21 +758,7 @@ var PremintAPIClient = class {
|
|
|
726
758
|
chain_name: this.networkConfig.zoraBackendChainName,
|
|
727
759
|
httpClient: this.httpClient
|
|
728
760
|
});
|
|
729
|
-
|
|
730
|
-
let premintConfig;
|
|
731
|
-
if (premintConfigVersion === "1" /* V1 */) {
|
|
732
|
-
premintConfig = convertPremintV1(response.premint);
|
|
733
|
-
} else {
|
|
734
|
-
throw new Error(
|
|
735
|
-
`Unsupported premint config version: ${premintConfigVersion}`
|
|
736
|
-
);
|
|
737
|
-
}
|
|
738
|
-
return {
|
|
739
|
-
signature: response.signature,
|
|
740
|
-
collection: convertCollection(response.collection),
|
|
741
|
-
premintConfig,
|
|
742
|
-
premintConfigVersion
|
|
743
|
-
};
|
|
761
|
+
return convertGetPremintApiResponse(response);
|
|
744
762
|
};
|
|
745
763
|
this.httpClient = httpClient2 || httpClient;
|
|
746
764
|
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
@@ -799,10 +817,10 @@ function getPremintedLogFromReceipt(receipt) {
|
|
|
799
817
|
try {
|
|
800
818
|
const decodedLog = decodeEventLog({
|
|
801
819
|
abi: zoraCreator1155PremintExecutorImplABI2,
|
|
802
|
-
eventName: "
|
|
820
|
+
eventName: "PremintedV2",
|
|
803
821
|
...data
|
|
804
822
|
});
|
|
805
|
-
if (decodedLog.eventName === "
|
|
823
|
+
if (decodedLog.eventName === "PremintedV2") {
|
|
806
824
|
return decodedLog.args;
|
|
807
825
|
}
|
|
808
826
|
} catch (err) {
|
|
@@ -920,7 +938,7 @@ var PremintClient = class {
|
|
|
920
938
|
* @returns
|
|
921
939
|
*/
|
|
922
940
|
async signAndSubmitPremint(params) {
|
|
923
|
-
const {
|
|
941
|
+
const { verifyingContract } = await signAndSubmitPremint({
|
|
924
942
|
...params,
|
|
925
943
|
chainId: this.chain.id,
|
|
926
944
|
apiClient: this.apiClient,
|
|
@@ -930,8 +948,7 @@ var PremintClient = class {
|
|
|
930
948
|
return {
|
|
931
949
|
urls: this.makeUrls({ address: verifyingContract, uid }),
|
|
932
950
|
uid,
|
|
933
|
-
verifyingContract
|
|
934
|
-
premint
|
|
951
|
+
verifyingContract
|
|
935
952
|
};
|
|
936
953
|
}
|
|
937
954
|
/**
|
|
@@ -1099,11 +1116,19 @@ var PremintClient = class {
|
|
|
1099
1116
|
publicClient: this.publicClient,
|
|
1100
1117
|
tokenPrice: premintConfig.tokenConfig.pricePerToken
|
|
1101
1118
|
})).totalCost;
|
|
1119
|
+
const mintArgumentsContract = {
|
|
1120
|
+
mintComment: mintArguments?.mintComment || "",
|
|
1121
|
+
mintRecipient: mintArguments?.mintRecipient || (typeof account === "string" ? account : account.address),
|
|
1122
|
+
mintRewardsRecipients: makeMintRewardsRecipient({
|
|
1123
|
+
mintReferral: mintArguments?.mintReferral,
|
|
1124
|
+
platformReferral: mintArguments?.platformReferral
|
|
1125
|
+
})
|
|
1126
|
+
};
|
|
1102
1127
|
if (premintConfigVersion === "1" /* V1 */) {
|
|
1103
1128
|
return {
|
|
1104
1129
|
account,
|
|
1105
1130
|
abi: zoraCreator1155PremintExecutorImplABI2,
|
|
1106
|
-
functionName: "
|
|
1131
|
+
functionName: "premintV1",
|
|
1107
1132
|
value,
|
|
1108
1133
|
address: getPremintExecutorAddress(),
|
|
1109
1134
|
args: [
|
|
@@ -1111,12 +1136,11 @@ var PremintClient = class {
|
|
|
1111
1136
|
premintConfig,
|
|
1112
1137
|
signature,
|
|
1113
1138
|
numberToMint,
|
|
1114
|
-
|
|
1139
|
+
mintArgumentsContract
|
|
1115
1140
|
]
|
|
1116
1141
|
};
|
|
1117
1142
|
} else if (premintConfigVersion === "2" /* V2 */) {
|
|
1118
1143
|
const toPost = premintConfig;
|
|
1119
|
-
const accountAddress = typeof account === "string" ? account : account.address;
|
|
1120
1144
|
return {
|
|
1121
1145
|
account,
|
|
1122
1146
|
abi: zoraCreator1155PremintExecutorImplABI2,
|
|
@@ -1129,14 +1153,7 @@ var PremintClient = class {
|
|
|
1129
1153
|
toPost,
|
|
1130
1154
|
signature,
|
|
1131
1155
|
numberToMint,
|
|
1132
|
-
|
|
1133
|
-
mintComment: mintArguments?.mintComment || "",
|
|
1134
|
-
mintRecipient: mintArguments?.mintRecipient || accountAddress,
|
|
1135
|
-
mintRewardsRecipients: makeMintRewardsRecipient({
|
|
1136
|
-
mintReferral: mintArguments?.mintReferral,
|
|
1137
|
-
platformReferral: mintArguments?.platformReferral
|
|
1138
|
-
})
|
|
1139
|
-
}
|
|
1156
|
+
mintArgumentsContract
|
|
1140
1157
|
]
|
|
1141
1158
|
};
|
|
1142
1159
|
}
|
|
@@ -1623,12 +1640,17 @@ export {
|
|
|
1623
1640
|
PreminterDomain,
|
|
1624
1641
|
ZORA_API_BASE,
|
|
1625
1642
|
applyUpdateToPremint,
|
|
1643
|
+
convertCollectionFromApi,
|
|
1644
|
+
convertGetPremintApiResponse,
|
|
1645
|
+
convertPremintFromApi,
|
|
1626
1646
|
create1155CreatorClient,
|
|
1627
1647
|
create1155TokenSetupArgs,
|
|
1628
1648
|
createMintClient,
|
|
1629
1649
|
createPremintClient,
|
|
1630
1650
|
defaultTokenConfigV1MintArguments,
|
|
1631
1651
|
defaultTokenConfigV2MintArguments,
|
|
1652
|
+
encodePostSignatureInput,
|
|
1653
|
+
encodePremintForAPI,
|
|
1632
1654
|
getApiNetworkConfigForChain,
|
|
1633
1655
|
getMintCosts,
|
|
1634
1656
|
getPremintCollectionAddress,
|