@zoralabs/protocol-sdk 0.7.6 → 0.9.0
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 +7 -7
- package/CHANGELOG.md +17 -0
- package/dist/allow-list/allow-list-client.d.ts +26 -0
- package/dist/allow-list/allow-list-client.d.ts.map +1 -0
- package/dist/allow-list/types.d.ts +14 -0
- package/dist/allow-list/types.d.ts.map +1 -0
- package/dist/apis/generated/allow-list-api-types.d.ts +288 -0
- package/dist/apis/generated/allow-list-api-types.d.ts.map +1 -0
- package/dist/apis/http-api-base.d.ts.map +1 -1
- package/dist/apis/subgraph-querier.d.ts +18 -0
- package/dist/apis/subgraph-querier.d.ts.map +1 -0
- package/dist/create/1155-create-helper.d.ts +14 -11
- package/dist/create/1155-create-helper.d.ts.map +1 -1
- package/dist/create/contract-setup.d.ts +13 -8
- package/dist/create/contract-setup.d.ts.map +1 -1
- package/dist/create/minter-defaults.d.ts +5 -0
- package/dist/create/minter-defaults.d.ts.map +1 -0
- package/dist/create/minter-setup.d.ts +14 -0
- package/dist/create/minter-setup.d.ts.map +1 -0
- package/dist/create/token-setup.d.ts +4 -19
- package/dist/create/token-setup.d.ts.map +1 -1
- package/dist/create/types.d.ts +53 -13
- package/dist/create/types.d.ts.map +1 -1
- package/dist/create/update.d.ts +15 -0
- package/dist/create/update.d.ts.map +1 -0
- package/dist/index.cjs +1660 -1246
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1681 -1264
- package/dist/index.js.map +1 -1
- package/dist/ipfs/token-metadata.d.ts +1 -0
- package/dist/ipfs/token-metadata.d.ts.map +1 -1
- package/dist/mint/mint-client.d.ts +2 -6
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/mint-queries.d.ts +3 -1
- package/dist/mint/mint-queries.d.ts.map +1 -1
- package/dist/mint/mint-transactions.d.ts +9 -7
- package/dist/mint/mint-transactions.d.ts.map +1 -1
- package/dist/mint/subgraph-mint-getter.d.ts +5 -4
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
- package/dist/mint/subgraph-queries.d.ts +42 -15
- package/dist/mint/subgraph-queries.d.ts.map +1 -1
- package/dist/mint/types.d.ts +32 -13
- package/dist/mint/types.d.ts.map +1 -1
- package/dist/sdk.d.ts +2 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sparks/sparks-contracts.d.ts +96 -96
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +1 -8
- package/dist/utils.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/allow-list/allow-list-client.ts +105 -0
- package/src/allow-list/types.ts +15 -0
- package/src/apis/generated/allow-list-api-types.ts +288 -0
- package/src/apis/http-api-base.ts +12 -0
- package/src/apis/subgraph-querier.ts +38 -0
- package/src/create/1155-create-helper.test.ts +269 -113
- package/src/create/1155-create-helper.ts +204 -90
- package/src/create/contract-setup.ts +54 -44
- package/src/create/minter-defaults.test.ts +21 -0
- package/src/create/minter-defaults.ts +134 -0
- package/src/create/minter-setup.ts +293 -0
- package/src/create/token-setup.ts +14 -190
- package/src/create/types.ts +94 -25
- package/src/create/update.ts +93 -0
- package/src/index.ts +4 -0
- package/src/ipfs/token-metadata.ts +18 -0
- package/src/mint/mint-client.test.ts +219 -15
- package/src/mint/mint-client.ts +2 -34
- package/src/mint/mint-queries.ts +34 -13
- package/src/mint/mint-transactions.ts +104 -17
- package/src/mint/subgraph-mint-getter.ts +107 -50
- package/src/mint/subgraph-queries.ts +67 -37
- package/src/mint/types.ts +55 -16
- package/src/premint/premint-client.test.ts +6 -5
- package/src/sdk.ts +5 -2
- package/src/types.ts +1 -1
- package/src/utils.ts +1 -25
package/dist/index.cjs
CHANGED
|
@@ -716,8 +716,8 @@ var require_gte = __commonJS({
|
|
|
716
716
|
"../../node_modules/.pnpm/semver@7.6.3/node_modules/semver/functions/gte.js"(exports2, module2) {
|
|
717
717
|
"use strict";
|
|
718
718
|
var compare = require_compare();
|
|
719
|
-
var
|
|
720
|
-
module2.exports =
|
|
719
|
+
var gte3 = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
720
|
+
module2.exports = gte3;
|
|
721
721
|
}
|
|
722
722
|
});
|
|
723
723
|
|
|
@@ -738,7 +738,7 @@ var require_cmp = __commonJS({
|
|
|
738
738
|
var eq = require_eq();
|
|
739
739
|
var neq = require_neq();
|
|
740
740
|
var gt = require_gt();
|
|
741
|
-
var
|
|
741
|
+
var gte3 = require_gte();
|
|
742
742
|
var lt = require_lt();
|
|
743
743
|
var lte = require_lte();
|
|
744
744
|
var cmp = (a, op, b, loose) => {
|
|
@@ -768,7 +768,7 @@ var require_cmp = __commonJS({
|
|
|
768
768
|
case ">":
|
|
769
769
|
return gt(a, b, loose);
|
|
770
770
|
case ">=":
|
|
771
|
-
return
|
|
771
|
+
return gte3(a, b, loose);
|
|
772
772
|
case "<":
|
|
773
773
|
return lt(a, b, loose);
|
|
774
774
|
case "<=":
|
|
@@ -788,7 +788,7 @@ var require_coerce = __commonJS({
|
|
|
788
788
|
var SemVer = require_semver();
|
|
789
789
|
var parse = require_parse();
|
|
790
790
|
var { safeRe: re, t } = require_re();
|
|
791
|
-
var
|
|
791
|
+
var coerce4 = (version, options) => {
|
|
792
792
|
if (version instanceof SemVer) {
|
|
793
793
|
return version;
|
|
794
794
|
}
|
|
@@ -823,7 +823,7 @@ var require_coerce = __commonJS({
|
|
|
823
823
|
const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
|
|
824
824
|
return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
|
|
825
825
|
};
|
|
826
|
-
module2.exports =
|
|
826
|
+
module2.exports = coerce4;
|
|
827
827
|
}
|
|
828
828
|
});
|
|
829
829
|
|
|
@@ -1524,7 +1524,7 @@ var require_outside = __commonJS({
|
|
|
1524
1524
|
var gt = require_gt();
|
|
1525
1525
|
var lt = require_lt();
|
|
1526
1526
|
var lte = require_lte();
|
|
1527
|
-
var
|
|
1527
|
+
var gte3 = require_gte();
|
|
1528
1528
|
var outside = (version, range, hilo, options) => {
|
|
1529
1529
|
version = new SemVer(version, options);
|
|
1530
1530
|
range = new Range(range, options);
|
|
@@ -1539,7 +1539,7 @@ var require_outside = __commonJS({
|
|
|
1539
1539
|
break;
|
|
1540
1540
|
case "<":
|
|
1541
1541
|
gtfn = lt;
|
|
1542
|
-
ltefn =
|
|
1542
|
+
ltefn = gte3;
|
|
1543
1543
|
ltfn = gt;
|
|
1544
1544
|
comp = "<";
|
|
1545
1545
|
ecomp = "<=";
|
|
@@ -1855,10 +1855,10 @@ var require_semver2 = __commonJS({
|
|
|
1855
1855
|
var lt = require_lt();
|
|
1856
1856
|
var eq = require_eq();
|
|
1857
1857
|
var neq = require_neq();
|
|
1858
|
-
var
|
|
1858
|
+
var gte3 = require_gte();
|
|
1859
1859
|
var lte = require_lte();
|
|
1860
1860
|
var cmp = require_cmp();
|
|
1861
|
-
var
|
|
1861
|
+
var coerce4 = require_coerce();
|
|
1862
1862
|
var Comparator = require_comparator();
|
|
1863
1863
|
var Range = require_range();
|
|
1864
1864
|
var satisfies = require_satisfies();
|
|
@@ -1893,10 +1893,10 @@ var require_semver2 = __commonJS({
|
|
|
1893
1893
|
lt,
|
|
1894
1894
|
eq,
|
|
1895
1895
|
neq,
|
|
1896
|
-
gte:
|
|
1896
|
+
gte: gte3,
|
|
1897
1897
|
lte,
|
|
1898
1898
|
cmp,
|
|
1899
|
-
coerce:
|
|
1899
|
+
coerce: coerce4,
|
|
1900
1900
|
Comparator,
|
|
1901
1901
|
Range,
|
|
1902
1902
|
satisfies,
|
|
@@ -1936,7 +1936,6 @@ __export(src_exports, {
|
|
|
1936
1936
|
ZORA_API_BASE: () => ZORA_API_BASE,
|
|
1937
1937
|
applyUpdateToPremint: () => applyUpdateToPremint,
|
|
1938
1938
|
buildPremintMintCall: () => buildPremintMintCall,
|
|
1939
|
-
collectOnchain: () => collectOnchain,
|
|
1940
1939
|
collectPremint: () => collectPremint,
|
|
1941
1940
|
collectPremintV2WithMintsParams: () => collectPremintV2WithMintsParams,
|
|
1942
1941
|
collectWithMintsParams: () => collectWithMintsParams,
|
|
@@ -1944,6 +1943,7 @@ __export(src_exports, {
|
|
|
1944
1943
|
convertGetPremintApiResponse: () => convertGetPremintApiResponse,
|
|
1945
1944
|
convertGetPremintOfCollectionApiResponse: () => convertGetPremintOfCollectionApiResponse,
|
|
1946
1945
|
convertPremintFromApi: () => convertPremintFromApi,
|
|
1946
|
+
createAllowList: () => createAllowList,
|
|
1947
1947
|
createCollectorClient: () => createCollectorClient,
|
|
1948
1948
|
createCreatorClient: () => createCreatorClient,
|
|
1949
1949
|
decodeCallFailedError: () => decodeCallFailedError,
|
|
@@ -1956,6 +1956,7 @@ __export(src_exports, {
|
|
|
1956
1956
|
encodePremintForAPI: () => encodePremintForAPI,
|
|
1957
1957
|
generateTextNftMetadataFiles: () => generateTextNftMetadataFiles,
|
|
1958
1958
|
getApiNetworkConfigForChain: () => getApiNetworkConfigForChain,
|
|
1959
|
+
getContractAddressFromReceipt: () => getContractAddressFromReceipt,
|
|
1959
1960
|
getDataFromPremintReceipt: () => getDataFromPremintReceipt,
|
|
1960
1961
|
getDefaultFixedPriceMinterAddress: () => getDefaultFixedPriceMinterAddress,
|
|
1961
1962
|
getMintsAccountBalanceWithPriceQuery: () => getMintsAccountBalanceWithPriceQuery,
|
|
@@ -1973,6 +1974,7 @@ __export(src_exports, {
|
|
|
1973
1974
|
isPremintConfigV1: () => isPremintConfigV1,
|
|
1974
1975
|
isPremintConfigV2: () => isPremintConfigV2,
|
|
1975
1976
|
isValidSignature: () => isValidSignature,
|
|
1977
|
+
makeCreateContractAndTokenCall: () => makeCreateContractAndTokenCall,
|
|
1976
1978
|
makeMediaTokenMetadata: () => makeMediaTokenMetadata,
|
|
1977
1979
|
makeMintRewardsRecipient: () => makeMintRewardsRecipient,
|
|
1978
1980
|
makeNewPremint: () => makeNewPremint,
|
|
@@ -2580,14 +2582,20 @@ var get = async (url) => {
|
|
|
2580
2582
|
return await response.json();
|
|
2581
2583
|
};
|
|
2582
2584
|
var post = async (url, data) => {
|
|
2585
|
+
const controller = new AbortController();
|
|
2586
|
+
const { signal } = controller;
|
|
2587
|
+
const timeout = 30 * 60 * 1e3;
|
|
2588
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
2583
2589
|
const response = await fetch(url, {
|
|
2584
2590
|
method: "POST",
|
|
2585
2591
|
headers: {
|
|
2586
2592
|
"content-type": "application/json",
|
|
2587
2593
|
accept: "application/json"
|
|
2588
2594
|
},
|
|
2589
|
-
body: JSON.stringify(data)
|
|
2595
|
+
body: JSON.stringify(data),
|
|
2596
|
+
signal
|
|
2590
2597
|
});
|
|
2598
|
+
clearTimeout(timeoutId);
|
|
2591
2599
|
if (response.status !== 200) {
|
|
2592
2600
|
let json;
|
|
2593
2601
|
try {
|
|
@@ -2623,36 +2631,26 @@ var httpClient = {
|
|
|
2623
2631
|
retries
|
|
2624
2632
|
};
|
|
2625
2633
|
|
|
2626
|
-
// src/
|
|
2627
|
-
var
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
httpClient: httpClient2,
|
|
2643
|
-
subgraphUrl,
|
|
2644
|
-
query,
|
|
2645
|
-
variables
|
|
2646
|
-
}) {
|
|
2647
|
-
const { retries: retries2, post: post2 } = httpClient2;
|
|
2648
|
-
const result = await retries2(async () => {
|
|
2649
|
-
return await post2(subgraphUrl, {
|
|
2650
|
-
query,
|
|
2651
|
-
variables
|
|
2634
|
+
// src/apis/subgraph-querier.ts
|
|
2635
|
+
var SubgraphQuerier = class {
|
|
2636
|
+
constructor(httpClient2) {
|
|
2637
|
+
this.httpClient = httpClient2;
|
|
2638
|
+
}
|
|
2639
|
+
async query({
|
|
2640
|
+
subgraphUrl,
|
|
2641
|
+
query,
|
|
2642
|
+
variables
|
|
2643
|
+
}) {
|
|
2644
|
+
const { retries: retries2, post: post2 } = this.httpClient;
|
|
2645
|
+
const result = await retries2(async () => {
|
|
2646
|
+
return await post2(subgraphUrl, {
|
|
2647
|
+
query,
|
|
2648
|
+
variables
|
|
2649
|
+
});
|
|
2652
2650
|
});
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
}
|
|
2651
|
+
return result?.data;
|
|
2652
|
+
}
|
|
2653
|
+
};
|
|
2656
2654
|
|
|
2657
2655
|
// src/mint/subgraph-queries.ts
|
|
2658
2656
|
var NFT_SALE_STRATEGY_FRAGMENT = `
|
|
@@ -2673,6 +2671,23 @@ fragment SaleStrategy on SalesStrategyConfig {
|
|
|
2673
2671
|
saleStart
|
|
2674
2672
|
maxTokensPerAddress
|
|
2675
2673
|
}
|
|
2674
|
+
presale {
|
|
2675
|
+
address
|
|
2676
|
+
presaleStart
|
|
2677
|
+
presaleEnd
|
|
2678
|
+
merkleRoot
|
|
2679
|
+
}
|
|
2680
|
+
zoraTimedMinter {
|
|
2681
|
+
address
|
|
2682
|
+
mintFee
|
|
2683
|
+
saleStart
|
|
2684
|
+
saleEnd
|
|
2685
|
+
erc20Z {
|
|
2686
|
+
id
|
|
2687
|
+
pool
|
|
2688
|
+
}
|
|
2689
|
+
secondaryActivated
|
|
2690
|
+
}
|
|
2676
2691
|
}`;
|
|
2677
2692
|
var TOKEN_FRAGMENT = `
|
|
2678
2693
|
fragment Token on ZoraCreateToken {
|
|
@@ -2682,7 +2697,7 @@ fragment Token on ZoraCreateToken {
|
|
|
2682
2697
|
totalMinted
|
|
2683
2698
|
maxSupply
|
|
2684
2699
|
tokenStandard
|
|
2685
|
-
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
2700
|
+
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER", "PRESALE", "ZORA_TIMED"]}) {
|
|
2686
2701
|
...SaleStrategy
|
|
2687
2702
|
}
|
|
2688
2703
|
contract {
|
|
@@ -2691,7 +2706,7 @@ fragment Token on ZoraCreateToken {
|
|
|
2691
2706
|
contractVersion
|
|
2692
2707
|
contractURI
|
|
2693
2708
|
name
|
|
2694
|
-
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
2709
|
+
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER", "PRESALE", "ZORA_TIMED"]}) {
|
|
2695
2710
|
...SaleStrategy
|
|
2696
2711
|
}
|
|
2697
2712
|
}
|
|
@@ -2722,19 +2737,6 @@ query ($id: ID!) {
|
|
|
2722
2737
|
parseResponseData: (responseData) => responseData?.zoraCreateToken
|
|
2723
2738
|
};
|
|
2724
2739
|
}
|
|
2725
|
-
function buildGetDefaultMintPriceQuery({}) {
|
|
2726
|
-
return {
|
|
2727
|
-
query: `
|
|
2728
|
-
{
|
|
2729
|
-
defaultMintPrice(id: "0x0000000000000000000000000000000000000000") {
|
|
2730
|
-
pricePerToken
|
|
2731
|
-
}
|
|
2732
|
-
}
|
|
2733
|
-
`,
|
|
2734
|
-
variables: {},
|
|
2735
|
-
parseResponseData: (responseData) => responseData?.defaultMintPrice?.pricePerToken ? BigInt(responseData?.defaultMintPrice?.pricePerToken) : void 0
|
|
2736
|
-
};
|
|
2737
|
-
}
|
|
2738
2740
|
function buildContractTokensQuery({
|
|
2739
2741
|
tokenAddress
|
|
2740
2742
|
}) {
|
|
@@ -2775,14 +2777,13 @@ function buildPremintsOfContractQuery({
|
|
|
2775
2777
|
}
|
|
2776
2778
|
|
|
2777
2779
|
// src/mint/subgraph-mint-getter.ts
|
|
2778
|
-
var semver = __toESM(require_semver2(), 1);
|
|
2779
2780
|
var getApiNetworkConfigForChain = (chainId) => {
|
|
2780
2781
|
if (!networkConfigByChain[chainId]) {
|
|
2781
2782
|
throw new Error(`chain id ${chainId} network not configured `);
|
|
2782
2783
|
}
|
|
2783
2784
|
return networkConfigByChain[chainId];
|
|
2784
2785
|
};
|
|
2785
|
-
function parseSalesConfig(targetStrategy) {
|
|
2786
|
+
function parseSalesConfig(targetStrategy, contractMintFee) {
|
|
2786
2787
|
if (targetStrategy.type === "FIXED_PRICE")
|
|
2787
2788
|
return {
|
|
2788
2789
|
saleType: "fixedPrice",
|
|
@@ -2790,7 +2791,8 @@ function parseSalesConfig(targetStrategy) {
|
|
|
2790
2791
|
maxTokensPerAddress: BigInt(
|
|
2791
2792
|
targetStrategy.fixedPrice.maxTokensPerAddress
|
|
2792
2793
|
),
|
|
2793
|
-
pricePerToken: BigInt(targetStrategy.fixedPrice.pricePerToken)
|
|
2794
|
+
pricePerToken: BigInt(targetStrategy.fixedPrice.pricePerToken),
|
|
2795
|
+
mintFeePerQuantity: contractMintFee
|
|
2794
2796
|
};
|
|
2795
2797
|
if (targetStrategy.type === "ERC_20_MINTER") {
|
|
2796
2798
|
return {
|
|
@@ -2799,31 +2801,72 @@ function parseSalesConfig(targetStrategy) {
|
|
|
2799
2801
|
maxTokensPerAddress: BigInt(
|
|
2800
2802
|
targetStrategy.erc20Minter.maxTokensPerAddress
|
|
2801
2803
|
),
|
|
2802
|
-
pricePerToken: BigInt(targetStrategy.erc20Minter.pricePerToken)
|
|
2804
|
+
pricePerToken: BigInt(targetStrategy.erc20Minter.pricePerToken),
|
|
2805
|
+
mintFeePerQuantity: 0n
|
|
2806
|
+
};
|
|
2807
|
+
}
|
|
2808
|
+
if (targetStrategy.type === "PRESALE") {
|
|
2809
|
+
return {
|
|
2810
|
+
saleType: "allowlist",
|
|
2811
|
+
address: targetStrategy.presale.address,
|
|
2812
|
+
merkleRoot: targetStrategy.presale.merkleRoot,
|
|
2813
|
+
saleStart: targetStrategy.presale.presaleStart,
|
|
2814
|
+
saleEnd: targetStrategy.presale.presaleEnd,
|
|
2815
|
+
mintFeePerQuantity: contractMintFee
|
|
2816
|
+
};
|
|
2817
|
+
}
|
|
2818
|
+
if (targetStrategy.type === "ZORA_TIMED") {
|
|
2819
|
+
return {
|
|
2820
|
+
saleType: "timed",
|
|
2821
|
+
address: targetStrategy.zoraTimedMinter.address,
|
|
2822
|
+
mintFee: BigInt(targetStrategy.zoraTimedMinter.mintFee),
|
|
2823
|
+
saleStart: targetStrategy.zoraTimedMinter.saleStart,
|
|
2824
|
+
saleEnd: targetStrategy.zoraTimedMinter.saleEnd,
|
|
2825
|
+
erc20Z: targetStrategy.zoraTimedMinter.erc20Z.id,
|
|
2826
|
+
pool: targetStrategy.zoraTimedMinter.erc20Z.pool,
|
|
2827
|
+
secondaryActivated: targetStrategy.zoraTimedMinter.secondaryActivated,
|
|
2828
|
+
mintFeePerQuantity: BigInt(targetStrategy.zoraTimedMinter.mintFee)
|
|
2803
2829
|
};
|
|
2804
2830
|
}
|
|
2805
2831
|
throw new Error("Unknown saleType");
|
|
2806
2832
|
}
|
|
2807
2833
|
function getSaleEnd(a) {
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
)
|
|
2834
|
+
if (a.type === "FIXED_PRICE")
|
|
2835
|
+
return BigInt(a.fixedPrice.saleEnd);
|
|
2836
|
+
if (a.type === "ERC_20_MINTER")
|
|
2837
|
+
return BigInt(a.erc20Minter.saleEnd);
|
|
2838
|
+
if (a.type === "ZORA_TIMED")
|
|
2839
|
+
return BigInt(a.zoraTimedMinter.saleEnd);
|
|
2840
|
+
return BigInt(a.presale.presaleEnd);
|
|
2841
|
+
}
|
|
2842
|
+
function strategyIsStillValid(strategy, blockTime) {
|
|
2843
|
+
if (strategy.type === "FIXED_PRICE") {
|
|
2844
|
+
return BigInt(strategy.fixedPrice.saleEnd) > blockTime;
|
|
2845
|
+
}
|
|
2846
|
+
if (strategy.type === "ERC_20_MINTER") {
|
|
2847
|
+
return BigInt(strategy.erc20Minter.saleEnd) > blockTime;
|
|
2848
|
+
}
|
|
2849
|
+
if (strategy.type === "ZORA_TIMED") {
|
|
2850
|
+
return BigInt(strategy.zoraTimedMinter.saleEnd) > blockTime;
|
|
2851
|
+
}
|
|
2852
|
+
return BigInt(strategy.presale.presaleEnd) > blockTime;
|
|
2811
2853
|
}
|
|
2812
2854
|
function getTargetStrategy({
|
|
2813
2855
|
tokenId,
|
|
2814
2856
|
preferredSaleType,
|
|
2815
|
-
token
|
|
2857
|
+
token,
|
|
2858
|
+
blockTime
|
|
2816
2859
|
}) {
|
|
2817
2860
|
const allStrategies = (typeof tokenId !== "undefined" ? token.salesStrategies : token.contract.salesStrategies) || [];
|
|
2818
|
-
const
|
|
2861
|
+
const stillValidSalesStrategies = allStrategies.filter(
|
|
2862
|
+
(strategy) => strategyIsStillValid(strategy, blockTime)
|
|
2863
|
+
);
|
|
2864
|
+
const saleStrategies = stillValidSalesStrategies.sort(
|
|
2819
2865
|
(a, b) => getSaleEnd(a) > getSaleEnd(b) ? 1 : -1
|
|
2820
2866
|
);
|
|
2821
2867
|
let targetStrategy;
|
|
2822
2868
|
if (!preferredSaleType) {
|
|
2823
|
-
|
|
2824
|
-
if (!targetStrategy) {
|
|
2825
|
-
throw new Error("Cannot find sale strategy");
|
|
2826
|
-
}
|
|
2869
|
+
return saleStrategies[0];
|
|
2827
2870
|
} else {
|
|
2828
2871
|
const mappedSaleType = preferredSaleType === "erc20" ? "ERC_20_MINTER" : "FIXED_PRICE";
|
|
2829
2872
|
targetStrategy = saleStrategies.find(
|
|
@@ -2841,11 +2884,12 @@ function getTargetStrategy({
|
|
|
2841
2884
|
return targetStrategy;
|
|
2842
2885
|
}
|
|
2843
2886
|
var SubgraphMintGetter = class {
|
|
2844
|
-
constructor(chainId,
|
|
2887
|
+
constructor(chainId, subgraphQuerier) {
|
|
2845
2888
|
this.getMintable = async ({
|
|
2846
2889
|
tokenAddress,
|
|
2847
2890
|
tokenId,
|
|
2848
|
-
preferredSaleType: saleType
|
|
2891
|
+
preferredSaleType: saleType,
|
|
2892
|
+
blockTime
|
|
2849
2893
|
}) => {
|
|
2850
2894
|
const token = await this.querySubgraphWithRetries(
|
|
2851
2895
|
buildNftTokenSalesQuery({
|
|
@@ -2861,29 +2905,22 @@ var SubgraphMintGetter = class {
|
|
|
2861
2905
|
token,
|
|
2862
2906
|
defaultMintFee,
|
|
2863
2907
|
tokenId,
|
|
2864
|
-
preferredSaleType: saleType
|
|
2908
|
+
preferredSaleType: saleType,
|
|
2909
|
+
blockTime
|
|
2865
2910
|
});
|
|
2866
2911
|
};
|
|
2867
|
-
this.
|
|
2912
|
+
this.subgraphQuerier = subgraphQuerier || new SubgraphQuerier(httpClient);
|
|
2868
2913
|
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
2869
2914
|
}
|
|
2870
2915
|
async getContractMintFee(contract) {
|
|
2871
|
-
|
|
2872
|
-
if (!contractUsesMintCardsForMintFee(contract.contractVersion)) {
|
|
2873
|
-
return storedMintFee;
|
|
2874
|
-
}
|
|
2875
|
-
const defaultMintFee = await this.querySubgraphWithRetries(
|
|
2876
|
-
buildGetDefaultMintPriceQuery({})
|
|
2877
|
-
);
|
|
2878
|
-
return defaultMintFee || storedMintFee;
|
|
2916
|
+
return BigInt(contract.mintFeePerQuantity);
|
|
2879
2917
|
}
|
|
2880
2918
|
async querySubgraphWithRetries({
|
|
2881
2919
|
query,
|
|
2882
2920
|
variables,
|
|
2883
2921
|
parseResponseData
|
|
2884
2922
|
}) {
|
|
2885
|
-
const responseData = await
|
|
2886
|
-
httpClient: this.httpClient,
|
|
2923
|
+
const responseData = await this.subgraphQuerier.query({
|
|
2887
2924
|
subgraphUrl: this.networkConfig.subgraphUrl,
|
|
2888
2925
|
query,
|
|
2889
2926
|
variables
|
|
@@ -2892,7 +2929,8 @@ var SubgraphMintGetter = class {
|
|
|
2892
2929
|
}
|
|
2893
2930
|
async getContractMintable({
|
|
2894
2931
|
tokenAddress,
|
|
2895
|
-
preferredSaleType
|
|
2932
|
+
preferredSaleType,
|
|
2933
|
+
blockTime
|
|
2896
2934
|
}) {
|
|
2897
2935
|
const tokens = await this.querySubgraphWithRetries(
|
|
2898
2936
|
buildContractTokensQuery({
|
|
@@ -2907,7 +2945,8 @@ var SubgraphMintGetter = class {
|
|
|
2907
2945
|
token,
|
|
2908
2946
|
tokenId: token.tokenId,
|
|
2909
2947
|
preferredSaleType,
|
|
2910
|
-
defaultMintFee
|
|
2948
|
+
defaultMintFee,
|
|
2949
|
+
blockTime
|
|
2911
2950
|
})
|
|
2912
2951
|
);
|
|
2913
2952
|
}
|
|
@@ -2925,34 +2964,49 @@ var SubgraphMintGetter = class {
|
|
|
2925
2964
|
})) || [];
|
|
2926
2965
|
}
|
|
2927
2966
|
};
|
|
2928
|
-
function
|
|
2967
|
+
function getTargetStrategyAndMintFee({
|
|
2929
2968
|
token,
|
|
2930
2969
|
tokenId,
|
|
2931
2970
|
preferredSaleType,
|
|
2932
|
-
defaultMintFee
|
|
2971
|
+
defaultMintFee,
|
|
2972
|
+
blockTime
|
|
2933
2973
|
}) {
|
|
2934
2974
|
const targetStrategy = getTargetStrategy({
|
|
2935
2975
|
tokenId,
|
|
2936
2976
|
preferredSaleType,
|
|
2977
|
+
token,
|
|
2978
|
+
blockTime
|
|
2979
|
+
});
|
|
2980
|
+
if (!targetStrategy)
|
|
2981
|
+
return void 0;
|
|
2982
|
+
const salesConfig = parseSalesConfig(targetStrategy, defaultMintFee);
|
|
2983
|
+
return salesConfig;
|
|
2984
|
+
}
|
|
2985
|
+
function parseTokenQueryResult({
|
|
2986
|
+
token,
|
|
2987
|
+
tokenId,
|
|
2988
|
+
preferredSaleType,
|
|
2989
|
+
defaultMintFee,
|
|
2990
|
+
blockTime
|
|
2991
|
+
}) {
|
|
2992
|
+
const salesConfig = getTargetStrategyAndMintFee({
|
|
2993
|
+
token,
|
|
2994
|
+
tokenId,
|
|
2995
|
+
preferredSaleType,
|
|
2996
|
+
defaultMintFee,
|
|
2997
|
+
blockTime
|
|
2998
|
+
});
|
|
2999
|
+
const tokenInfo = parseTokenInfo({
|
|
2937
3000
|
token
|
|
2938
3001
|
});
|
|
2939
|
-
const tokenInfo = parseTokenInfo(token, defaultMintFee);
|
|
2940
|
-
const salesConfig = parseSalesConfig(targetStrategy);
|
|
2941
|
-
if (isErc20SaleStrategy(salesConfig)) {
|
|
2942
|
-
tokenInfo.mintFeePerQuantity = 0n;
|
|
2943
|
-
}
|
|
2944
3002
|
return {
|
|
2945
3003
|
...tokenInfo,
|
|
2946
3004
|
salesConfig
|
|
2947
3005
|
};
|
|
2948
3006
|
}
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
return false;
|
|
2953
|
-
return semver.gte(semVerContractVersion, "2.9.0");
|
|
2954
|
-
};
|
|
2955
|
-
function parseTokenInfo(token, defaultMintFee) {
|
|
3007
|
+
function parseTokenInfo({
|
|
3008
|
+
token
|
|
3009
|
+
}) {
|
|
2956
3010
|
return {
|
|
2957
3011
|
contract: {
|
|
2958
3012
|
address: token.contract.address,
|
|
@@ -2965,11 +3019,19 @@ function parseTokenInfo(token, defaultMintFee) {
|
|
|
2965
3019
|
creator: token.creator,
|
|
2966
3020
|
totalMinted: BigInt(token.totalMinted),
|
|
2967
3021
|
maxSupply: BigInt(token.maxSupply),
|
|
2968
|
-
mintFeePerQuantity: defaultMintFee,
|
|
2969
3022
|
contractVersion: token.contract.contractVersion
|
|
2970
3023
|
};
|
|
2971
3024
|
}
|
|
2972
3025
|
|
|
3026
|
+
// src/utils.ts
|
|
3027
|
+
var makeContractParameters = (args) => args;
|
|
3028
|
+
function mintRecipientOrAccount({
|
|
3029
|
+
mintRecipient,
|
|
3030
|
+
minterAccount
|
|
3031
|
+
}) {
|
|
3032
|
+
return mintRecipient || (typeof minterAccount === "string" ? minterAccount : minterAccount.address);
|
|
3033
|
+
}
|
|
3034
|
+
|
|
2973
3035
|
// src/premint/premint-client.ts
|
|
2974
3036
|
var defaultTokenConfigV1MintArguments = () => ({
|
|
2975
3037
|
maxSupply: OPEN_EDITION_MINT_SIZE,
|
|
@@ -3615,20 +3677,30 @@ var PremintAPIClient = class {
|
|
|
3615
3677
|
}
|
|
3616
3678
|
};
|
|
3617
3679
|
|
|
3680
|
+
// src/mint/types.ts
|
|
3681
|
+
var isOnChainMint = (mint2) => mint2.mintType !== "premint";
|
|
3682
|
+
var is1155Mint = (mint2) => mint2.mintType === "1155";
|
|
3683
|
+
function isErc20SaleStrategy(salesConfig) {
|
|
3684
|
+
return salesConfig.saleType === "erc20";
|
|
3685
|
+
}
|
|
3686
|
+
|
|
3687
|
+
// src/mint/mint-queries.ts
|
|
3688
|
+
var import_viem6 = require("viem");
|
|
3689
|
+
|
|
3618
3690
|
// src/mint/mint-transactions.ts
|
|
3619
3691
|
var import_viem5 = require("viem");
|
|
3620
3692
|
var import_protocol_deployments6 = require("@zoralabs/protocol-deployments");
|
|
3621
3693
|
|
|
3622
3694
|
// src/mint/utils.ts
|
|
3623
|
-
var
|
|
3695
|
+
var semver = __toESM(require_semver2(), 1);
|
|
3624
3696
|
var contractSupportsNewMintFunction = (contractVersion) => {
|
|
3625
3697
|
if (!contractVersion) {
|
|
3626
3698
|
return false;
|
|
3627
3699
|
}
|
|
3628
|
-
const semVerContractVersion =
|
|
3700
|
+
const semVerContractVersion = semver.coerce(contractVersion)?.raw;
|
|
3629
3701
|
if (!semVerContractVersion)
|
|
3630
3702
|
return false;
|
|
3631
|
-
return
|
|
3703
|
+
return semver.gte(semVerContractVersion, "2.9.0");
|
|
3632
3704
|
};
|
|
3633
3705
|
|
|
3634
3706
|
// src/mint/mint-transactions.ts
|
|
@@ -3658,12 +3730,13 @@ function makePrepareMint1155TokenParams({
|
|
|
3658
3730
|
mintComment,
|
|
3659
3731
|
mintReferral,
|
|
3660
3732
|
mintRecipient,
|
|
3661
|
-
quantityToMint
|
|
3733
|
+
quantityToMint,
|
|
3734
|
+
allowListEntry
|
|
3662
3735
|
}) {
|
|
3663
3736
|
const mintQuantity = BigInt(quantityToMint || 1);
|
|
3664
3737
|
const mintTo = mintRecipientOrAccount({ mintRecipient, minterAccount });
|
|
3665
3738
|
const saleType = salesConfigAndTokenInfo.salesConfig.saleType;
|
|
3666
|
-
if (saleType === "fixedPrice") {
|
|
3739
|
+
if (saleType === "fixedPrice" || saleType === "allowlist") {
|
|
3667
3740
|
return makeEthMintCall({
|
|
3668
3741
|
mintComment,
|
|
3669
3742
|
minterAccount,
|
|
@@ -3672,7 +3745,26 @@ function makePrepareMint1155TokenParams({
|
|
|
3672
3745
|
mintTo,
|
|
3673
3746
|
salesConfigAndTokenInfo,
|
|
3674
3747
|
tokenContract,
|
|
3675
|
-
tokenId
|
|
3748
|
+
tokenId,
|
|
3749
|
+
allowListEntry
|
|
3750
|
+
});
|
|
3751
|
+
}
|
|
3752
|
+
if (saleType === "timed") {
|
|
3753
|
+
return makeContractParameters({
|
|
3754
|
+
abi: import_protocol_deployments6.zoraTimedSaleStrategyABI,
|
|
3755
|
+
functionName: "mint",
|
|
3756
|
+
account: minterAccount,
|
|
3757
|
+
address: salesConfigAndTokenInfo.salesConfig.address,
|
|
3758
|
+
value: salesConfigAndTokenInfo.salesConfig.mintFeePerQuantity * mintQuantity,
|
|
3759
|
+
/* args: mintTo, quantity, collection, tokenId, mintReferral, comment */
|
|
3760
|
+
args: [
|
|
3761
|
+
mintTo,
|
|
3762
|
+
mintQuantity,
|
|
3763
|
+
tokenContract,
|
|
3764
|
+
BigInt(tokenId),
|
|
3765
|
+
mintReferral || import_viem5.zeroAddress,
|
|
3766
|
+
mintComment || ""
|
|
3767
|
+
]
|
|
3676
3768
|
});
|
|
3677
3769
|
}
|
|
3678
3770
|
if (saleType === "erc20") {
|
|
@@ -3707,9 +3799,9 @@ function makePrepareMint721TokenParams({
|
|
|
3707
3799
|
}) {
|
|
3708
3800
|
const actualQuantityToMint = BigInt(quantityToMint || 1);
|
|
3709
3801
|
const mintValue = parseMintCosts({
|
|
3710
|
-
mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
|
|
3711
3802
|
salesConfig: salesConfigAndTokenInfo.salesConfig,
|
|
3712
|
-
quantityToMint: actualQuantityToMint
|
|
3803
|
+
quantityToMint: actualQuantityToMint,
|
|
3804
|
+
allowListEntry: void 0
|
|
3713
3805
|
}).totalCostEth;
|
|
3714
3806
|
return makeContractParameters({
|
|
3715
3807
|
abi: zora721Abi,
|
|
@@ -3725,6 +3817,29 @@ function makePrepareMint721TokenParams({
|
|
|
3725
3817
|
]
|
|
3726
3818
|
});
|
|
3727
3819
|
}
|
|
3820
|
+
function makeFixedPriceMinterArguments({
|
|
3821
|
+
mintTo,
|
|
3822
|
+
mintComment
|
|
3823
|
+
}) {
|
|
3824
|
+
return (0, import_viem5.encodeAbiParameters)((0, import_viem5.parseAbiParameters)("address, string"), [
|
|
3825
|
+
mintTo,
|
|
3826
|
+
mintComment || ""
|
|
3827
|
+
]);
|
|
3828
|
+
}
|
|
3829
|
+
function makeAllowListMinterArguments({
|
|
3830
|
+
mintTo,
|
|
3831
|
+
allowListEntry
|
|
3832
|
+
}) {
|
|
3833
|
+
return (0, import_viem5.encodeAbiParameters)(
|
|
3834
|
+
(0, import_viem5.parseAbiParameters)("address, uint256, uint256, bytes32[]"),
|
|
3835
|
+
[
|
|
3836
|
+
mintTo,
|
|
3837
|
+
BigInt(allowListEntry.maxCanMint),
|
|
3838
|
+
allowListEntry.price,
|
|
3839
|
+
allowListEntry.proof
|
|
3840
|
+
]
|
|
3841
|
+
);
|
|
3842
|
+
}
|
|
3728
3843
|
function makeEthMintCall({
|
|
3729
3844
|
tokenContract,
|
|
3730
3845
|
tokenId,
|
|
@@ -3733,17 +3848,25 @@ function makeEthMintCall({
|
|
|
3733
3848
|
mintComment,
|
|
3734
3849
|
mintReferral,
|
|
3735
3850
|
mintQuantity,
|
|
3736
|
-
mintTo
|
|
3851
|
+
mintTo,
|
|
3852
|
+
allowListEntry
|
|
3737
3853
|
}) {
|
|
3738
3854
|
const mintValue = parseMintCosts({
|
|
3739
|
-
mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
|
|
3740
3855
|
salesConfig: salesConfigAndTokenInfo.salesConfig,
|
|
3741
|
-
quantityToMint: mintQuantity
|
|
3856
|
+
quantityToMint: mintQuantity,
|
|
3857
|
+
allowListEntry
|
|
3742
3858
|
}).totalCostEth;
|
|
3743
|
-
const
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3859
|
+
const saleType = salesConfigAndTokenInfo.salesConfig.saleType;
|
|
3860
|
+
let minterArguments;
|
|
3861
|
+
if (saleType === "fixedPrice") {
|
|
3862
|
+
minterArguments = makeFixedPriceMinterArguments({ mintTo, mintComment });
|
|
3863
|
+
} else if (saleType === "allowlist") {
|
|
3864
|
+
if (!allowListEntry)
|
|
3865
|
+
throw new Error("Missing allowListEntry");
|
|
3866
|
+
minterArguments = makeAllowListMinterArguments({ mintTo, allowListEntry });
|
|
3867
|
+
} else {
|
|
3868
|
+
throw new Error("Unsupported sale type");
|
|
3869
|
+
}
|
|
3747
3870
|
if (contractSupportsNewMintFunction(salesConfigAndTokenInfo.contractVersion)) {
|
|
3748
3871
|
return makeContractParameters({
|
|
3749
3872
|
abi: import_protocol_deployments6.zoraCreator1155ImplABI,
|
|
@@ -3776,13 +3899,21 @@ function makeEthMintCall({
|
|
|
3776
3899
|
]
|
|
3777
3900
|
});
|
|
3778
3901
|
}
|
|
3902
|
+
function paidMintCost(salesConfig, allowListEntry) {
|
|
3903
|
+
if (salesConfig.saleType === "erc20" || salesConfig.saleType === "fixedPrice") {
|
|
3904
|
+
return salesConfig.pricePerToken;
|
|
3905
|
+
}
|
|
3906
|
+
if (allowListEntry)
|
|
3907
|
+
return allowListEntry.price;
|
|
3908
|
+
return 0n;
|
|
3909
|
+
}
|
|
3779
3910
|
function parseMintCosts({
|
|
3780
3911
|
salesConfig,
|
|
3781
|
-
|
|
3782
|
-
|
|
3912
|
+
quantityToMint,
|
|
3913
|
+
allowListEntry
|
|
3783
3914
|
}) {
|
|
3784
|
-
const mintFeeForTokens = mintFeePerQuantity * quantityToMint;
|
|
3785
|
-
const tokenPurchaseCost =
|
|
3915
|
+
const mintFeeForTokens = salesConfig.mintFeePerQuantity * quantityToMint;
|
|
3916
|
+
const tokenPurchaseCost = paidMintCost(salesConfig, allowListEntry) * quantityToMint;
|
|
3786
3917
|
const totalPurchaseCostCurrency = isErc20SaleStrategy(salesConfig) ? salesConfig.currency : void 0;
|
|
3787
3918
|
const totalPurchaseCostEth = totalPurchaseCostCurrency ? 0n : tokenPurchaseCost;
|
|
3788
3919
|
return {
|
|
@@ -3794,7 +3925,6 @@ function parseMintCosts({
|
|
|
3794
3925
|
}
|
|
3795
3926
|
|
|
3796
3927
|
// src/mint/mint-queries.ts
|
|
3797
|
-
var import_viem6 = require("viem");
|
|
3798
3928
|
async function getMint({
|
|
3799
3929
|
params,
|
|
3800
3930
|
mintGetter,
|
|
@@ -3804,10 +3934,12 @@ async function getMint({
|
|
|
3804
3934
|
const { tokenContract } = params;
|
|
3805
3935
|
if (isOnChainMint(params)) {
|
|
3806
3936
|
const tokenId = is1155Mint(params) ? params.tokenId : void 0;
|
|
3937
|
+
const blockTime = (await publicClient.getBlock()).timestamp;
|
|
3807
3938
|
const result = await mintGetter.getMintable({
|
|
3808
3939
|
tokenId,
|
|
3809
3940
|
tokenAddress: tokenContract,
|
|
3810
|
-
preferredSaleType: params.preferredSaleType
|
|
3941
|
+
preferredSaleType: params.preferredSaleType,
|
|
3942
|
+
blockTime
|
|
3811
3943
|
});
|
|
3812
3944
|
return toMintableReturn(result);
|
|
3813
3945
|
}
|
|
@@ -3868,6 +4000,7 @@ async function getMintsOfContract({
|
|
|
3868
4000
|
}
|
|
3869
4001
|
async function getMintCosts({
|
|
3870
4002
|
params,
|
|
4003
|
+
allowListEntry,
|
|
3871
4004
|
mintGetter,
|
|
3872
4005
|
premintGetter,
|
|
3873
4006
|
publicClient
|
|
@@ -3875,14 +4008,19 @@ async function getMintCosts({
|
|
|
3875
4008
|
const { quantityMinted: quantityToMint, collection } = params;
|
|
3876
4009
|
if (isOnChainMint(params)) {
|
|
3877
4010
|
const tokenId = is1155Mint(params) ? params.tokenId : void 0;
|
|
4011
|
+
const blockTime = (await publicClient.getBlock()).timestamp;
|
|
3878
4012
|
const salesConfigAndTokenInfo = await mintGetter.getMintable({
|
|
3879
4013
|
tokenId,
|
|
3880
|
-
tokenAddress: collection
|
|
4014
|
+
tokenAddress: collection,
|
|
4015
|
+
blockTime
|
|
3881
4016
|
});
|
|
4017
|
+
if (!salesConfigAndTokenInfo.salesConfig) {
|
|
4018
|
+
throw new Error("No valid sales config found for token");
|
|
4019
|
+
}
|
|
3882
4020
|
return parseMintCosts({
|
|
3883
|
-
mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
|
|
3884
4021
|
salesConfig: salesConfigAndTokenInfo.salesConfig,
|
|
3885
|
-
quantityToMint: BigInt(quantityToMint)
|
|
4022
|
+
quantityToMint: BigInt(quantityToMint),
|
|
4023
|
+
allowListEntry
|
|
3886
4024
|
});
|
|
3887
4025
|
}
|
|
3888
4026
|
return getPremintMintCostsWithUnknownTokenPrice({
|
|
@@ -3938,7 +4076,6 @@ function parsePremint({
|
|
|
3938
4076
|
return {
|
|
3939
4077
|
creator: premint.signer,
|
|
3940
4078
|
maxSupply: premint.premint.premintConfig.tokenConfig.maxSupply,
|
|
3941
|
-
mintFeePerQuantity: mintFee,
|
|
3942
4079
|
mintType: "premint",
|
|
3943
4080
|
uid: premint.premint.premintConfig.uid,
|
|
3944
4081
|
contract: {
|
|
@@ -3952,21 +4089,30 @@ function parsePremint({
|
|
|
3952
4089
|
duration: premint.premint.premintConfig.tokenConfig.mintDuration,
|
|
3953
4090
|
maxTokensPerAddress: premint.premint.premintConfig.tokenConfig.maxTokensPerAddress,
|
|
3954
4091
|
pricePerToken: premint.premint.premintConfig.tokenConfig.pricePerToken,
|
|
3955
|
-
saleType: "premint"
|
|
4092
|
+
saleType: "premint",
|
|
4093
|
+
mintFeePerQuantity: mintFee
|
|
3956
4094
|
}
|
|
3957
4095
|
};
|
|
3958
4096
|
}
|
|
3959
4097
|
throw new Error("Invalid premint config version");
|
|
3960
4098
|
}
|
|
3961
|
-
var makeOnchainPrepareMint = (result) => (params) =>
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
})
|
|
4099
|
+
var makeOnchainPrepareMint = (result) => (params) => {
|
|
4100
|
+
if (!result.salesConfig) {
|
|
4101
|
+
throw new Error("No valid sales config found for token");
|
|
4102
|
+
}
|
|
4103
|
+
return {
|
|
4104
|
+
parameters: makeOnchainMintCall({
|
|
4105
|
+
token: result,
|
|
4106
|
+
mintParams: params
|
|
4107
|
+
}),
|
|
4108
|
+
erc20Approval: getRequiredErc20Approvals(params, result),
|
|
4109
|
+
costs: parseMintCosts({
|
|
4110
|
+
salesConfig: result.salesConfig,
|
|
4111
|
+
quantityToMint: BigInt(params.quantityToMint),
|
|
4112
|
+
allowListEntry: params.allowListEntry
|
|
4113
|
+
})
|
|
4114
|
+
};
|
|
4115
|
+
};
|
|
3970
4116
|
function toMintableReturn(result) {
|
|
3971
4117
|
return { token: result, prepareMint: makeOnchainPrepareMint(result) };
|
|
3972
4118
|
}
|
|
@@ -3977,9 +4123,9 @@ var makePremintPrepareMint = (mintable, mintFee, premint) => (params) => ({
|
|
|
3977
4123
|
premint
|
|
3978
4124
|
}),
|
|
3979
4125
|
costs: parseMintCosts({
|
|
3980
|
-
mintFeePerQuantity: mintFee,
|
|
3981
4126
|
quantityToMint: BigInt(params.quantityToMint),
|
|
3982
|
-
salesConfig: mintable.salesConfig
|
|
4127
|
+
salesConfig: mintable.salesConfig,
|
|
4128
|
+
allowListEntry: params.allowListEntry
|
|
3983
4129
|
})
|
|
3984
4130
|
});
|
|
3985
4131
|
function toPremintMintReturn({
|
|
@@ -3993,7 +4139,7 @@ function toPremintMintReturn({
|
|
|
3993
4139
|
};
|
|
3994
4140
|
}
|
|
3995
4141
|
function getRequiredErc20Approvals(params, result) {
|
|
3996
|
-
if (result.salesConfig
|
|
4142
|
+
if (result.salesConfig?.saleType !== "erc20")
|
|
3997
4143
|
return void 0;
|
|
3998
4144
|
return {
|
|
3999
4145
|
quantity: result.salesConfig.pricePerToken * BigInt(params.quantityToMint),
|
|
@@ -4099,27 +4245,10 @@ async function mint({
|
|
|
4099
4245
|
mintReferral: parameters.mintReferral
|
|
4100
4246
|
});
|
|
4101
4247
|
}
|
|
4102
|
-
async function collectOnchain({
|
|
4103
|
-
chainId,
|
|
4104
|
-
mintGetter,
|
|
4105
|
-
...parameters
|
|
4106
|
-
}) {
|
|
4107
|
-
const { tokenContract, preferredSaleType: saleType } = parameters;
|
|
4108
|
-
const tokenId = is1155Mint(parameters) ? parameters.tokenId : void 0;
|
|
4109
|
-
const salesConfigAndTokenInfo = await mintGetter.getMintable({
|
|
4110
|
-
tokenId,
|
|
4111
|
-
tokenAddress: tokenContract,
|
|
4112
|
-
preferredSaleType: saleType
|
|
4113
|
-
});
|
|
4114
|
-
return makeOnchainMintCall({
|
|
4115
|
-
mintParams: parameters,
|
|
4116
|
-
token: salesConfigAndTokenInfo
|
|
4117
|
-
});
|
|
4118
|
-
}
|
|
4119
4248
|
|
|
4120
4249
|
// src/create/1155-create-helper.ts
|
|
4121
|
-
var
|
|
4122
|
-
var
|
|
4250
|
+
var import_protocol_deployments10 = require("@zoralabs/protocol-deployments");
|
|
4251
|
+
var import_viem9 = require("viem");
|
|
4123
4252
|
|
|
4124
4253
|
// src/create/contract-setup.ts
|
|
4125
4254
|
var import_protocol_deployments7 = require("@zoralabs/protocol-deployments");
|
|
@@ -4130,1106 +4259,399 @@ function new1155ContractVersion(chainId) {
|
|
|
4130
4259
|
}
|
|
4131
4260
|
return address.CONTRACT_1155_IMPL_VERSION;
|
|
4132
4261
|
}
|
|
4133
|
-
async function
|
|
4262
|
+
async function getContractInfoExistingContract({
|
|
4134
4263
|
publicClient,
|
|
4135
|
-
|
|
4136
|
-
contract,
|
|
4137
|
-
account
|
|
4264
|
+
contractAddress
|
|
4138
4265
|
}) {
|
|
4139
|
-
const contractAddress = typeof contract === "string" ? contract : await publicClient.readContract({
|
|
4140
|
-
abi: import_protocol_deployments7.zoraCreator1155FactoryImplABI,
|
|
4141
|
-
// Since this address is deterministic we can hardcode a chain id safely here.
|
|
4142
|
-
address: import_protocol_deployments7.zoraCreator1155FactoryImplAddress[chainId],
|
|
4143
|
-
functionName: "deterministicContractAddress",
|
|
4144
|
-
args: [
|
|
4145
|
-
account,
|
|
4146
|
-
contract.uri,
|
|
4147
|
-
contract.name,
|
|
4148
|
-
contract.defaultAdmin || account
|
|
4149
|
-
]
|
|
4150
|
-
});
|
|
4151
4266
|
let contractVersion;
|
|
4152
|
-
let contractExists;
|
|
4153
4267
|
try {
|
|
4154
4268
|
contractVersion = await publicClient.readContract({
|
|
4155
4269
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
4156
4270
|
address: contractAddress,
|
|
4157
4271
|
functionName: "contractVersion"
|
|
4158
4272
|
});
|
|
4159
|
-
contractExists = true;
|
|
4160
4273
|
} catch (e) {
|
|
4161
|
-
|
|
4162
|
-
contractExists = false;
|
|
4274
|
+
throw new Error(`Contract does not exist at ${contractAddress}`);
|
|
4163
4275
|
}
|
|
4164
|
-
const nextTokenId =
|
|
4276
|
+
const nextTokenId = await publicClient.readContract({
|
|
4165
4277
|
address: contractAddress,
|
|
4166
4278
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
4167
4279
|
functionName: "nextTokenId"
|
|
4168
|
-
})
|
|
4280
|
+
});
|
|
4281
|
+
const contractName = await publicClient.readContract({
|
|
4282
|
+
address: contractAddress,
|
|
4283
|
+
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
4284
|
+
functionName: "name"
|
|
4285
|
+
});
|
|
4169
4286
|
return {
|
|
4170
|
-
contractExists,
|
|
4171
|
-
contractAddress,
|
|
4172
4287
|
contractVersion,
|
|
4288
|
+
contractName,
|
|
4173
4289
|
nextTokenId
|
|
4174
4290
|
};
|
|
4175
4291
|
}
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
MINTER: 2n ** 2n
|
|
4183
|
-
};
|
|
4184
|
-
var saleSettingsOrDefault = (saleSettings) => {
|
|
4185
|
-
const SALE_END_FOREVER = 18446744073709551615n;
|
|
4186
|
-
const DEFAULT_SALE_SETTINGS = {
|
|
4187
|
-
currency: import_viem7.zeroAddress,
|
|
4188
|
-
// Free Mint
|
|
4189
|
-
pricePerToken: 0n,
|
|
4190
|
-
// Sale start time – defaults to beginning of unix time
|
|
4191
|
-
saleStart: 0n,
|
|
4192
|
-
// This is the end of uint64, plenty of time
|
|
4193
|
-
saleEnd: SALE_END_FOREVER,
|
|
4194
|
-
// 0 Here means no limit
|
|
4195
|
-
maxTokensPerAddress: 0n
|
|
4196
|
-
};
|
|
4197
|
-
return {
|
|
4198
|
-
...DEFAULT_SALE_SETTINGS,
|
|
4199
|
-
...saleSettings
|
|
4200
|
-
};
|
|
4201
|
-
};
|
|
4202
|
-
function applyNew1155Defaults(props, ownerAddress) {
|
|
4203
|
-
const { payoutRecipient: fundsRecipient } = props;
|
|
4204
|
-
const fundsRecipientOrOwner = fundsRecipient && fundsRecipient !== import_viem7.zeroAddress ? fundsRecipient : ownerAddress;
|
|
4205
|
-
return {
|
|
4206
|
-
payoutRecipient: fundsRecipientOrOwner,
|
|
4207
|
-
createReferral: props.createReferral || import_viem7.zeroAddress,
|
|
4208
|
-
maxSupply: typeof props.maxSupply === "undefined" ? OPEN_EDITION_MINT_SIZE : BigInt(props.maxSupply),
|
|
4209
|
-
royaltyBPS: props.royaltyBPS || 1e3,
|
|
4210
|
-
salesConfig: saleSettingsOrDefault(props.salesConfig),
|
|
4211
|
-
tokenMetadataURI: props.tokenMetadataURI
|
|
4212
|
-
};
|
|
4213
|
-
}
|
|
4214
|
-
function setupErc20Minter({
|
|
4215
|
-
pricePerToken,
|
|
4216
|
-
chainId,
|
|
4217
|
-
tokenId: nextTokenId,
|
|
4218
|
-
currency,
|
|
4219
|
-
saleStart,
|
|
4220
|
-
saleEnd,
|
|
4221
|
-
maxTokensPerAddress: mintLimit,
|
|
4222
|
-
fundsRecipient
|
|
4292
|
+
async function getDeterministicContractAddress({
|
|
4293
|
+
publicClient,
|
|
4294
|
+
account,
|
|
4295
|
+
setupActions,
|
|
4296
|
+
contract,
|
|
4297
|
+
chainId
|
|
4223
4298
|
}) {
|
|
4224
|
-
const
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4229
|
-
functionName: "addPermission",
|
|
4230
|
-
args: [BigInt(nextTokenId), erc20MinterAddress, PERMISSION_BITS.MINTER]
|
|
4231
|
-
});
|
|
4232
|
-
const saleData = (0, import_viem7.encodeFunctionData)({
|
|
4233
|
-
abi: import_protocol_deployments8.erc20MinterABI,
|
|
4234
|
-
functionName: "setSale",
|
|
4299
|
+
const contractAddress = await publicClient.readContract({
|
|
4300
|
+
abi: import_protocol_deployments7.zoraCreator1155FactoryImplABI,
|
|
4301
|
+
address: import_protocol_deployments7.zoraCreator1155FactoryImplAddress[chainId],
|
|
4302
|
+
functionName: "deterministicContractAddressWithSetupActions",
|
|
4235
4303
|
args: [
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
pricePerToken,
|
|
4242
|
-
fundsRecipient,
|
|
4243
|
-
currency
|
|
4244
|
-
}
|
|
4304
|
+
account,
|
|
4305
|
+
contract.uri,
|
|
4306
|
+
contract.name,
|
|
4307
|
+
contract.defaultAdmin || account,
|
|
4308
|
+
setupActions
|
|
4245
4309
|
]
|
|
4246
4310
|
});
|
|
4247
|
-
|
|
4248
|
-
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4249
|
-
functionName: "callSale",
|
|
4250
|
-
args: [BigInt(nextTokenId), erc20MinterAddress, saleData]
|
|
4251
|
-
});
|
|
4252
|
-
return {
|
|
4253
|
-
minter: erc20MinterAddress,
|
|
4254
|
-
setupActions: [erc20MinterApproval, callSale]
|
|
4255
|
-
};
|
|
4311
|
+
return contractAddress;
|
|
4256
4312
|
}
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
const fixedPriceStrategyAddress = import_protocol_deployments8.zoraCreatorFixedPriceSaleStrategyAddress[chainId];
|
|
4267
|
-
const fixedPriceApproval = (0, import_viem7.encodeFunctionData)({
|
|
4268
|
-
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4269
|
-
functionName: "addPermission",
|
|
4270
|
-
args: [
|
|
4271
|
-
BigInt(nextTokenId),
|
|
4272
|
-
fixedPriceStrategyAddress,
|
|
4273
|
-
PERMISSION_BITS.MINTER
|
|
4274
|
-
]
|
|
4275
|
-
});
|
|
4276
|
-
const saleData = (0, import_viem7.encodeFunctionData)({
|
|
4277
|
-
abi: import_protocol_deployments8.zoraCreatorFixedPriceSaleStrategyABI,
|
|
4278
|
-
functionName: "setSale",
|
|
4279
|
-
args: [
|
|
4280
|
-
BigInt(nextTokenId),
|
|
4281
|
-
{
|
|
4282
|
-
pricePerToken: price,
|
|
4283
|
-
saleStart: saleStart || BigInt(0),
|
|
4284
|
-
saleEnd: saleEnd || BigInt(0),
|
|
4285
|
-
maxTokensPerAddress: BigInt(mintLimit || 0),
|
|
4286
|
-
fundsRecipient
|
|
4287
|
-
}
|
|
4288
|
-
]
|
|
4289
|
-
});
|
|
4290
|
-
const callSale = (0, import_viem7.encodeFunctionData)({
|
|
4291
|
-
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4292
|
-
functionName: "callSale",
|
|
4293
|
-
args: [BigInt(nextTokenId), fixedPriceStrategyAddress, saleData]
|
|
4294
|
-
});
|
|
4295
|
-
return {
|
|
4296
|
-
minter: fixedPriceStrategyAddress,
|
|
4297
|
-
setupActions: [fixedPriceApproval, callSale]
|
|
4298
|
-
};
|
|
4299
|
-
}
|
|
4300
|
-
function setupMinters({ salesConfig, ...rest }) {
|
|
4301
|
-
if (!salesConfig)
|
|
4302
|
-
throw new Error("No sales config for token");
|
|
4303
|
-
const { currency: currencyAddress } = salesConfig;
|
|
4304
|
-
if (currencyAddress === import_viem7.zeroAddress) {
|
|
4305
|
-
return setupFixedPriceMinter({
|
|
4306
|
-
...salesConfig,
|
|
4307
|
-
...rest
|
|
4308
|
-
});
|
|
4309
|
-
} else {
|
|
4310
|
-
return setupErc20Minter({
|
|
4311
|
-
...salesConfig,
|
|
4312
|
-
...rest
|
|
4313
|
-
});
|
|
4314
|
-
}
|
|
4313
|
+
|
|
4314
|
+
// src/create/token-setup.ts
|
|
4315
|
+
var import_protocol_deployments9 = require("@zoralabs/protocol-deployments");
|
|
4316
|
+
var import_viem8 = require("viem");
|
|
4317
|
+
var semver2 = __toESM(require_semver2(), 1);
|
|
4318
|
+
|
|
4319
|
+
// src/ipfs/arweave.ts
|
|
4320
|
+
function isArweaveURL(url) {
|
|
4321
|
+
return url && typeof url === "string" ? url.startsWith("ar://") : false;
|
|
4315
4322
|
}
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
if (
|
|
4323
|
-
return
|
|
4324
|
-
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4325
|
-
functionName: "setupNewTokenWithCreateReferral",
|
|
4326
|
-
args: [tokenURI, BigInt(maxSupply), createReferral]
|
|
4327
|
-
});
|
|
4323
|
+
|
|
4324
|
+
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/bytes.js
|
|
4325
|
+
var empty = new Uint8Array(0);
|
|
4326
|
+
function equals(aa, bb) {
|
|
4327
|
+
if (aa === bb)
|
|
4328
|
+
return true;
|
|
4329
|
+
if (aa.byteLength !== bb.byteLength) {
|
|
4330
|
+
return false;
|
|
4328
4331
|
}
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4332
|
+
for (let ii = 0; ii < aa.byteLength; ii++) {
|
|
4333
|
+
if (aa[ii] !== bb[ii]) {
|
|
4334
|
+
return false;
|
|
4335
|
+
}
|
|
4333
4336
|
}
|
|
4334
|
-
return
|
|
4335
|
-
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4336
|
-
functionName: "setupNewToken",
|
|
4337
|
-
args: [tokenURI, BigInt(maxSupply)]
|
|
4338
|
-
});
|
|
4337
|
+
return true;
|
|
4339
4338
|
}
|
|
4340
|
-
function
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
if (
|
|
4346
|
-
return (
|
|
4347
|
-
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4348
|
-
functionName: "updateRoyaltiesForToken",
|
|
4349
|
-
args: [
|
|
4350
|
-
nextTokenId,
|
|
4351
|
-
{
|
|
4352
|
-
royaltyBPS,
|
|
4353
|
-
royaltyRecipient,
|
|
4354
|
-
royaltyMintSchedule: 0
|
|
4355
|
-
}
|
|
4356
|
-
]
|
|
4357
|
-
});
|
|
4339
|
+
function coerce2(o) {
|
|
4340
|
+
if (o instanceof Uint8Array && o.constructor.name === "Uint8Array")
|
|
4341
|
+
return o;
|
|
4342
|
+
if (o instanceof ArrayBuffer)
|
|
4343
|
+
return new Uint8Array(o);
|
|
4344
|
+
if (ArrayBuffer.isView(o)) {
|
|
4345
|
+
return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
|
|
4358
4346
|
}
|
|
4359
|
-
|
|
4347
|
+
throw new Error("Unknown type, must be binary type");
|
|
4360
4348
|
}
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
if (!mintQuantity || mintQuantity <= 0 || !ownerAddress) {
|
|
4367
|
-
return null;
|
|
4349
|
+
|
|
4350
|
+
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/vendor/base-x.js
|
|
4351
|
+
function base2(ALPHABET, name) {
|
|
4352
|
+
if (ALPHABET.length >= 255) {
|
|
4353
|
+
throw new TypeError("Alphabet too long");
|
|
4368
4354
|
}
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
args: [ownerAddress, nextTokenId, BigInt(mintQuantity), import_viem7.zeroAddress]
|
|
4373
|
-
});
|
|
4374
|
-
}
|
|
4375
|
-
function constructCreate1155TokenCalls(props) {
|
|
4376
|
-
const {
|
|
4377
|
-
chainId,
|
|
4378
|
-
nextTokenId,
|
|
4379
|
-
mintToCreatorCount,
|
|
4380
|
-
ownerAddress,
|
|
4381
|
-
contractVersion
|
|
4382
|
-
} = props;
|
|
4383
|
-
const new1155TokenPropsWithDefaults = applyNew1155Defaults(
|
|
4384
|
-
props,
|
|
4385
|
-
ownerAddress
|
|
4386
|
-
);
|
|
4387
|
-
const verifyTokenIdExpected = (0, import_viem7.encodeFunctionData)({
|
|
4388
|
-
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4389
|
-
functionName: "assumeLastTokenIdMatches",
|
|
4390
|
-
args: [nextTokenId - 1n]
|
|
4391
|
-
});
|
|
4392
|
-
const setupNewToken = buildSetupNewToken({
|
|
4393
|
-
tokenURI: new1155TokenPropsWithDefaults.tokenMetadataURI,
|
|
4394
|
-
maxSupply: new1155TokenPropsWithDefaults.maxSupply,
|
|
4395
|
-
createReferral: new1155TokenPropsWithDefaults.createReferral,
|
|
4396
|
-
contractVersion
|
|
4397
|
-
});
|
|
4398
|
-
const royaltyConfig = setupRoyaltyConfig({
|
|
4399
|
-
royaltyBPS: new1155TokenPropsWithDefaults.royaltyBPS,
|
|
4400
|
-
royaltyRecipient: new1155TokenPropsWithDefaults.payoutRecipient,
|
|
4401
|
-
nextTokenId
|
|
4402
|
-
});
|
|
4403
|
-
const { minter, setupActions: mintersSetup } = setupMinters({
|
|
4404
|
-
tokenId: nextTokenId,
|
|
4405
|
-
chainId,
|
|
4406
|
-
fundsRecipient: new1155TokenPropsWithDefaults.payoutRecipient,
|
|
4407
|
-
salesConfig: new1155TokenPropsWithDefaults.salesConfig
|
|
4408
|
-
});
|
|
4409
|
-
const adminMintCall = makeAdminMintCall({
|
|
4410
|
-
ownerAddress,
|
|
4411
|
-
mintQuantity: mintToCreatorCount,
|
|
4412
|
-
nextTokenId
|
|
4413
|
-
});
|
|
4414
|
-
const setupActions = [
|
|
4415
|
-
verifyTokenIdExpected,
|
|
4416
|
-
setupNewToken,
|
|
4417
|
-
...mintersSetup,
|
|
4418
|
-
royaltyConfig,
|
|
4419
|
-
adminMintCall
|
|
4420
|
-
].filter((item) => item !== null);
|
|
4421
|
-
return {
|
|
4422
|
-
setupActions,
|
|
4423
|
-
minter,
|
|
4424
|
-
newToken: new1155TokenPropsWithDefaults
|
|
4425
|
-
};
|
|
4426
|
-
}
|
|
4427
|
-
var contractSupportsMintRewards = (contractVersion, contractStandard) => {
|
|
4428
|
-
if (!contractStandard || !contractVersion) {
|
|
4429
|
-
return false;
|
|
4355
|
+
var BASE_MAP = new Uint8Array(256);
|
|
4356
|
+
for (var j = 0; j < BASE_MAP.length; j++) {
|
|
4357
|
+
BASE_MAP[j] = 255;
|
|
4430
4358
|
}
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4359
|
+
for (var i = 0; i < ALPHABET.length; i++) {
|
|
4360
|
+
var x = ALPHABET.charAt(i);
|
|
4361
|
+
var xc = x.charCodeAt(0);
|
|
4362
|
+
if (BASE_MAP[xc] !== 255) {
|
|
4363
|
+
throw new TypeError(x + " is ambiguous");
|
|
4364
|
+
}
|
|
4365
|
+
BASE_MAP[xc] = i;
|
|
4438
4366
|
}
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
var
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4367
|
+
var BASE = ALPHABET.length;
|
|
4368
|
+
var LEADER = ALPHABET.charAt(0);
|
|
4369
|
+
var FACTOR = Math.log(BASE) / Math.log(256);
|
|
4370
|
+
var iFACTOR = Math.log(256) / Math.log(BASE);
|
|
4371
|
+
function encode3(source) {
|
|
4372
|
+
if (source instanceof Uint8Array)
|
|
4373
|
+
;
|
|
4374
|
+
else if (ArrayBuffer.isView(source)) {
|
|
4375
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
4376
|
+
} else if (Array.isArray(source)) {
|
|
4377
|
+
source = Uint8Array.from(source);
|
|
4378
|
+
}
|
|
4379
|
+
if (!(source instanceof Uint8Array)) {
|
|
4380
|
+
throw new TypeError("Expected Uint8Array");
|
|
4381
|
+
}
|
|
4382
|
+
if (source.length === 0) {
|
|
4383
|
+
return "";
|
|
4384
|
+
}
|
|
4385
|
+
var zeroes = 0;
|
|
4386
|
+
var length2 = 0;
|
|
4387
|
+
var pbegin = 0;
|
|
4388
|
+
var pend = source.length;
|
|
4389
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
4390
|
+
pbegin++;
|
|
4391
|
+
zeroes++;
|
|
4392
|
+
}
|
|
4393
|
+
var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
|
|
4394
|
+
var b58 = new Uint8Array(size);
|
|
4395
|
+
while (pbegin !== pend) {
|
|
4396
|
+
var carry = source[pbegin];
|
|
4397
|
+
var i2 = 0;
|
|
4398
|
+
for (var it1 = size - 1; (carry !== 0 || i2 < length2) && it1 !== -1; it1--, i2++) {
|
|
4399
|
+
carry += 256 * b58[it1] >>> 0;
|
|
4400
|
+
b58[it1] = carry % BASE >>> 0;
|
|
4401
|
+
carry = carry / BASE >>> 0;
|
|
4453
4402
|
}
|
|
4454
|
-
|
|
4403
|
+
if (carry !== 0) {
|
|
4404
|
+
throw new Error("Non-zero carry");
|
|
4405
|
+
}
|
|
4406
|
+
length2 = i2;
|
|
4407
|
+
pbegin++;
|
|
4455
4408
|
}
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
contractExists,
|
|
4460
|
-
contractAddress,
|
|
4461
|
-
contract,
|
|
4462
|
-
account,
|
|
4463
|
-
royaltyBPS,
|
|
4464
|
-
tokenSetupActions,
|
|
4465
|
-
fundsRecipient
|
|
4466
|
-
}) {
|
|
4467
|
-
if (!contractAddress && typeof contract === "string") {
|
|
4468
|
-
throw new Error("Invariant: contract cannot be missing and an address");
|
|
4469
|
-
}
|
|
4470
|
-
if (!contractExists) {
|
|
4471
|
-
if (typeof contract === "string") {
|
|
4472
|
-
throw new Error("Invariant: expected contract object");
|
|
4409
|
+
var it2 = size - length2;
|
|
4410
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
4411
|
+
it2++;
|
|
4473
4412
|
}
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
address: import_protocol_deployments9.zoraCreator1155FactoryImplAddress[999],
|
|
4480
|
-
args: [
|
|
4481
|
-
contract.uri,
|
|
4482
|
-
contract.name,
|
|
4483
|
-
{
|
|
4484
|
-
// deprecated
|
|
4485
|
-
royaltyMintSchedule: 0,
|
|
4486
|
-
royaltyBPS: royaltyBPS || ROYALTY_BPS_DEFAULT,
|
|
4487
|
-
royaltyRecipient: fundsRecipient || accountAddress
|
|
4488
|
-
},
|
|
4489
|
-
contract.defaultAdmin || accountAddress,
|
|
4490
|
-
tokenSetupActions
|
|
4491
|
-
]
|
|
4492
|
-
});
|
|
4413
|
+
var str = LEADER.repeat(zeroes);
|
|
4414
|
+
for (; it2 < size; ++it2) {
|
|
4415
|
+
str += ALPHABET.charAt(b58[it2]);
|
|
4416
|
+
}
|
|
4417
|
+
return str;
|
|
4493
4418
|
}
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4419
|
+
function decodeUnsafe(source) {
|
|
4420
|
+
if (typeof source !== "string") {
|
|
4421
|
+
throw new TypeError("Expected String");
|
|
4422
|
+
}
|
|
4423
|
+
if (source.length === 0) {
|
|
4424
|
+
return new Uint8Array();
|
|
4425
|
+
}
|
|
4426
|
+
var psz = 0;
|
|
4427
|
+
if (source[psz] === " ") {
|
|
4428
|
+
return;
|
|
4429
|
+
}
|
|
4430
|
+
var zeroes = 0;
|
|
4431
|
+
var length2 = 0;
|
|
4432
|
+
while (source[psz] === LEADER) {
|
|
4433
|
+
zeroes++;
|
|
4434
|
+
psz++;
|
|
4435
|
+
}
|
|
4436
|
+
var size = (source.length - psz) * FACTOR + 1 >>> 0;
|
|
4437
|
+
var b256 = new Uint8Array(size);
|
|
4438
|
+
while (source[psz]) {
|
|
4439
|
+
var carry = BASE_MAP[source.charCodeAt(psz)];
|
|
4440
|
+
if (carry === 255) {
|
|
4441
|
+
return;
|
|
4442
|
+
}
|
|
4443
|
+
var i2 = 0;
|
|
4444
|
+
for (var it3 = size - 1; (carry !== 0 || i2 < length2) && it3 !== -1; it3--, i2++) {
|
|
4445
|
+
carry += BASE * b256[it3] >>> 0;
|
|
4446
|
+
b256[it3] = carry % 256 >>> 0;
|
|
4447
|
+
carry = carry / 256 >>> 0;
|
|
4448
|
+
}
|
|
4449
|
+
if (carry !== 0) {
|
|
4450
|
+
throw new Error("Non-zero carry");
|
|
4451
|
+
}
|
|
4452
|
+
length2 = i2;
|
|
4453
|
+
psz++;
|
|
4454
|
+
}
|
|
4455
|
+
if (source[psz] === " ") {
|
|
4456
|
+
return;
|
|
4457
|
+
}
|
|
4458
|
+
var it4 = size - length2;
|
|
4459
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
4460
|
+
it4++;
|
|
4461
|
+
}
|
|
4462
|
+
var vch = new Uint8Array(zeroes + (size - it4));
|
|
4463
|
+
var j2 = zeroes;
|
|
4464
|
+
while (it4 !== size) {
|
|
4465
|
+
vch[j2++] = b256[it4++];
|
|
4466
|
+
}
|
|
4467
|
+
return vch;
|
|
4509
4468
|
}
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
});
|
|
4469
|
+
function decode5(string) {
|
|
4470
|
+
var buffer = decodeUnsafe(string);
|
|
4471
|
+
if (buffer) {
|
|
4472
|
+
return buffer;
|
|
4473
|
+
}
|
|
4474
|
+
throw new Error(`Non-${name} character`);
|
|
4516
4475
|
}
|
|
4517
|
-
};
|
|
4518
|
-
async function createNew1155Token({
|
|
4519
|
-
contract,
|
|
4520
|
-
account,
|
|
4521
|
-
getAdditionalSetupActions,
|
|
4522
|
-
token: tokenConfig,
|
|
4523
|
-
publicClient,
|
|
4524
|
-
chainId
|
|
4525
|
-
}) {
|
|
4526
|
-
const { contractExists, contractAddress, nextTokenId, contractVersion } = await getContractInfo({
|
|
4527
|
-
publicClient,
|
|
4528
|
-
chainId,
|
|
4529
|
-
contract,
|
|
4530
|
-
account
|
|
4531
|
-
});
|
|
4532
|
-
const {
|
|
4533
|
-
minter,
|
|
4534
|
-
newToken,
|
|
4535
|
-
setupActions: tokenSetupActions
|
|
4536
|
-
} = constructCreate1155TokenCalls({
|
|
4537
|
-
chainId,
|
|
4538
|
-
ownerAddress: account,
|
|
4539
|
-
contractVersion,
|
|
4540
|
-
nextTokenId,
|
|
4541
|
-
...tokenConfig
|
|
4542
|
-
});
|
|
4543
|
-
const setupActions = getAdditionalSetupActions ? [
|
|
4544
|
-
...getAdditionalSetupActions({
|
|
4545
|
-
tokenId: nextTokenId,
|
|
4546
|
-
contractAddress
|
|
4547
|
-
}),
|
|
4548
|
-
...tokenSetupActions
|
|
4549
|
-
] : tokenSetupActions;
|
|
4550
|
-
const request = makeCreateContractAndTokenCall({
|
|
4551
|
-
contractExists,
|
|
4552
|
-
contractAddress,
|
|
4553
|
-
contract,
|
|
4554
|
-
account,
|
|
4555
|
-
tokenSetupActions: setupActions,
|
|
4556
|
-
royaltyBPS: tokenConfig.royaltyBPS,
|
|
4557
|
-
fundsRecipient: tokenConfig.payoutRecipient
|
|
4558
|
-
});
|
|
4559
4476
|
return {
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
contractExists,
|
|
4564
|
-
newTokenId: nextTokenId,
|
|
4565
|
-
newToken,
|
|
4566
|
-
minter
|
|
4477
|
+
encode: encode3,
|
|
4478
|
+
decodeUnsafe,
|
|
4479
|
+
decode: decode5
|
|
4567
4480
|
};
|
|
4568
4481
|
}
|
|
4482
|
+
var src = base2;
|
|
4483
|
+
var _brrp__multiformats_scope_baseX = src;
|
|
4484
|
+
var base_x_default = _brrp__multiformats_scope_baseX;
|
|
4569
4485
|
|
|
4570
|
-
// src/
|
|
4571
|
-
var
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4486
|
+
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/bases/base.js
|
|
4487
|
+
var Encoder = class {
|
|
4488
|
+
constructor(name, prefix, baseEncode) {
|
|
4489
|
+
__publicField(this, "name");
|
|
4490
|
+
__publicField(this, "prefix");
|
|
4491
|
+
__publicField(this, "baseEncode");
|
|
4492
|
+
this.name = name;
|
|
4493
|
+
this.prefix = prefix;
|
|
4494
|
+
this.baseEncode = baseEncode;
|
|
4495
|
+
}
|
|
4496
|
+
encode(bytes) {
|
|
4497
|
+
if (bytes instanceof Uint8Array) {
|
|
4498
|
+
return `${this.prefix}${this.baseEncode(bytes)}`;
|
|
4499
|
+
} else {
|
|
4500
|
+
throw Error("Unknown type, must be binary type");
|
|
4581
4501
|
}
|
|
4582
|
-
|
|
4583
|
-
return {
|
|
4584
|
-
query,
|
|
4585
|
-
variables: { account }
|
|
4586
|
-
};
|
|
4502
|
+
}
|
|
4587
4503
|
};
|
|
4588
|
-
var
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
return -1;
|
|
4504
|
+
var Decoder = class {
|
|
4505
|
+
constructor(name, prefix, baseDecode) {
|
|
4506
|
+
__publicField(this, "name");
|
|
4507
|
+
__publicField(this, "prefix");
|
|
4508
|
+
__publicField(this, "baseDecode");
|
|
4509
|
+
__publicField(this, "prefixCodePoint");
|
|
4510
|
+
this.name = name;
|
|
4511
|
+
this.prefix = prefix;
|
|
4512
|
+
if (prefix.codePointAt(0) === void 0) {
|
|
4513
|
+
throw new Error("Invalid prefix character");
|
|
4599
4514
|
}
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4515
|
+
this.prefixCodePoint = prefix.codePointAt(0);
|
|
4516
|
+
this.baseDecode = baseDecode;
|
|
4517
|
+
}
|
|
4518
|
+
decode(text) {
|
|
4519
|
+
if (typeof text === "string") {
|
|
4520
|
+
if (text.codePointAt(0) !== this.prefixCodePoint) {
|
|
4521
|
+
throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
|
|
4522
|
+
}
|
|
4523
|
+
return this.baseDecode(text.slice(this.prefix.length));
|
|
4524
|
+
} else {
|
|
4525
|
+
throw Error("Can only multibase decode strings");
|
|
4609
4526
|
}
|
|
4610
|
-
const quantityToUse = remainingQuantity > next.quantity ? next.quantity : remainingQuantity;
|
|
4611
|
-
tokenIds.push(next.tokenId);
|
|
4612
|
-
quantities.push(quantityToUse);
|
|
4613
|
-
remainingQuantity -= quantityToUse;
|
|
4614
4527
|
}
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
};
|
|
4528
|
+
or(decoder) {
|
|
4529
|
+
return or(this, decoder);
|
|
4530
|
+
}
|
|
4619
4531
|
};
|
|
4620
|
-
var
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4532
|
+
var ComposedDecoder = class {
|
|
4533
|
+
constructor(decoders) {
|
|
4534
|
+
__publicField(this, "decoders");
|
|
4535
|
+
this.decoders = decoders;
|
|
4536
|
+
}
|
|
4537
|
+
or(decoder) {
|
|
4538
|
+
return or(this, decoder);
|
|
4539
|
+
}
|
|
4540
|
+
decode(input) {
|
|
4541
|
+
const prefix = input[0];
|
|
4542
|
+
const decoder = this.decoders[prefix];
|
|
4543
|
+
if (decoder != null) {
|
|
4544
|
+
return decoder.decode(input);
|
|
4545
|
+
} else {
|
|
4546
|
+
throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
|
|
4547
|
+
}
|
|
4548
|
+
}
|
|
4624
4549
|
};
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
|
|
4630
|
-
var mintWithEthParams = ({
|
|
4631
|
-
tokenId,
|
|
4632
|
-
quantity,
|
|
4633
|
-
recipient,
|
|
4634
|
-
chainId,
|
|
4635
|
-
pricePerMint,
|
|
4636
|
-
account
|
|
4637
|
-
}) => makeContractParameters({
|
|
4638
|
-
abi: import_protocol_deployments10.zoraSparksManagerImplABI,
|
|
4639
|
-
address: import_protocol_deployments10.zoraSparksManagerImplAddress[chainId],
|
|
4640
|
-
functionName: "mintWithEth",
|
|
4641
|
-
args: [tokenId, quantity, recipient || addressOrAccountAddress(account)],
|
|
4642
|
-
value: pricePerMint * quantity,
|
|
4643
|
-
account
|
|
4644
|
-
});
|
|
4645
|
-
var getPaidMintValue = (quantities, pricePerMint) => {
|
|
4646
|
-
if (!pricePerMint || pricePerMint === 0n)
|
|
4647
|
-
return;
|
|
4648
|
-
return quantities.reduce((a, b) => a + b, 0n) * pricePerMint;
|
|
4649
|
-
};
|
|
4650
|
-
var mintsBalanceOfAccountParams = ({
|
|
4651
|
-
account,
|
|
4652
|
-
chainId
|
|
4653
|
-
}) => ({
|
|
4654
|
-
abi: import_protocol_deployments10.zoraMints1155Config.abi,
|
|
4655
|
-
address: import_protocol_deployments10.zoraMints1155Config.address[chainId],
|
|
4656
|
-
functionName: "balanceOfAccount",
|
|
4657
|
-
args: [account]
|
|
4658
|
-
});
|
|
4659
|
-
var encodeCollectOnManager = ({
|
|
4660
|
-
zoraCreator1155Contract,
|
|
4661
|
-
minter,
|
|
4662
|
-
zoraCreator1155TokenId,
|
|
4663
|
-
mintArguments
|
|
4664
|
-
}) => (0, import_viem9.encodeFunctionData)({
|
|
4665
|
-
abi: import_protocol_deployments10.zoraMintsManagerImplConfig.abi,
|
|
4666
|
-
functionName: "collect",
|
|
4667
|
-
args: [
|
|
4668
|
-
zoraCreator1155Contract,
|
|
4669
|
-
minter,
|
|
4670
|
-
zoraCreator1155TokenId,
|
|
4671
|
-
mintArguments
|
|
4672
|
-
]
|
|
4673
|
-
});
|
|
4674
|
-
function collectWithMintsParams({
|
|
4675
|
-
tokenIds,
|
|
4676
|
-
quantities,
|
|
4677
|
-
chainId,
|
|
4678
|
-
paidMintPricePerToken,
|
|
4679
|
-
account,
|
|
4680
|
-
mintArguments,
|
|
4681
|
-
minter,
|
|
4682
|
-
zoraCreator1155Contract,
|
|
4683
|
-
zoraCreator1155TokenId
|
|
4684
|
-
}) {
|
|
4685
|
-
const call = encodeCollectOnManager({
|
|
4686
|
-
tokenIds,
|
|
4687
|
-
quantities,
|
|
4688
|
-
zoraCreator1155Contract,
|
|
4689
|
-
zoraCreator1155TokenId,
|
|
4690
|
-
minter,
|
|
4691
|
-
mintArguments
|
|
4692
|
-
});
|
|
4693
|
-
return makeContractParameters({
|
|
4694
|
-
abi: import_protocol_deployments10.zoraMints1155Config.abi,
|
|
4695
|
-
address: import_protocol_deployments10.zoraMints1155Config.address[chainId],
|
|
4696
|
-
functionName: "transferBatchToManagerAndCall",
|
|
4697
|
-
args: [tokenIds, quantities, call],
|
|
4698
|
-
// if it is a paid mint, the aadditional value will be sent to the manager contract and forwarded to the creator 1155 contract
|
|
4699
|
-
// for the paid mint cost.
|
|
4700
|
-
value: getPaidMintValue(quantities, paidMintPricePerToken),
|
|
4701
|
-
account
|
|
4550
|
+
function or(left, right) {
|
|
4551
|
+
return new ComposedDecoder({
|
|
4552
|
+
...left.decoders ?? { [left.prefix]: left },
|
|
4553
|
+
...right.decoders ?? { [right.prefix]: right }
|
|
4702
4554
|
});
|
|
4703
4555
|
}
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4556
|
+
var Codec = class {
|
|
4557
|
+
constructor(name, prefix, baseEncode, baseDecode) {
|
|
4558
|
+
__publicField(this, "name");
|
|
4559
|
+
__publicField(this, "prefix");
|
|
4560
|
+
__publicField(this, "baseEncode");
|
|
4561
|
+
__publicField(this, "baseDecode");
|
|
4562
|
+
__publicField(this, "encoder");
|
|
4563
|
+
__publicField(this, "decoder");
|
|
4564
|
+
this.name = name;
|
|
4565
|
+
this.prefix = prefix;
|
|
4566
|
+
this.baseEncode = baseEncode;
|
|
4567
|
+
this.baseDecode = baseDecode;
|
|
4568
|
+
this.encoder = new Encoder(name, prefix, baseEncode);
|
|
4569
|
+
this.decoder = new Decoder(name, prefix, baseDecode);
|
|
4710
4570
|
}
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
}
|
|
4717
|
-
function makePermitTransferBatchAndTypeData({
|
|
4718
|
-
tokenIds,
|
|
4719
|
-
quantities,
|
|
4720
|
-
chainId,
|
|
4721
|
-
mintsOwner,
|
|
4722
|
-
to,
|
|
4723
|
-
nonce,
|
|
4724
|
-
deadline,
|
|
4725
|
-
safeTransferData
|
|
4726
|
-
}) {
|
|
4727
|
-
const permit = {
|
|
4728
|
-
owner: typeof mintsOwner === "string" ? mintsOwner : mintsOwner.address,
|
|
4729
|
-
to,
|
|
4730
|
-
tokenIds,
|
|
4731
|
-
quantities,
|
|
4732
|
-
deadline,
|
|
4733
|
-
nonce,
|
|
4734
|
-
safeTransferData
|
|
4735
|
-
};
|
|
4736
|
-
const typedData = {
|
|
4737
|
-
...(0, import_protocol_deployments10.mintsSafeTransferBatchTypedDataDefinition)({
|
|
4738
|
-
chainId,
|
|
4739
|
-
message: permit
|
|
4740
|
-
}),
|
|
4741
|
-
account: mintsOwner
|
|
4742
|
-
};
|
|
4743
|
-
return {
|
|
4744
|
-
permit,
|
|
4745
|
-
typedData
|
|
4746
|
-
};
|
|
4747
|
-
}
|
|
4748
|
-
function makePermitTransferTypeData({
|
|
4749
|
-
tokenId,
|
|
4750
|
-
quantity,
|
|
4751
|
-
chainId,
|
|
4752
|
-
mintsOwner,
|
|
4753
|
-
to,
|
|
4754
|
-
nonce,
|
|
4755
|
-
deadline,
|
|
4756
|
-
safeTransferData
|
|
4757
|
-
}) {
|
|
4758
|
-
const permit = {
|
|
4759
|
-
owner: typeof mintsOwner === "string" ? mintsOwner : mintsOwner.address,
|
|
4760
|
-
to,
|
|
4761
|
-
tokenId,
|
|
4762
|
-
quantity,
|
|
4763
|
-
deadline,
|
|
4764
|
-
nonce,
|
|
4765
|
-
safeTransferData
|
|
4766
|
-
};
|
|
4767
|
-
const typedData = {
|
|
4768
|
-
...(0, import_protocol_deployments10.mintsSafeTransferTypedDataDefinition)({
|
|
4769
|
-
chainId,
|
|
4770
|
-
message: permit
|
|
4771
|
-
}),
|
|
4772
|
-
account: mintsOwner
|
|
4773
|
-
};
|
|
4774
|
-
return {
|
|
4775
|
-
permit,
|
|
4776
|
-
typedData
|
|
4777
|
-
};
|
|
4778
|
-
}
|
|
4779
|
-
var encodePremintOnManager = ({
|
|
4780
|
-
contractCreationConfig,
|
|
4781
|
-
premintConfig,
|
|
4782
|
-
premintSignature,
|
|
4783
|
-
mintArguments,
|
|
4784
|
-
signerContract = import_viem9.zeroAddress
|
|
4785
|
-
}) => (0, import_viem9.encodeFunctionData)({
|
|
4786
|
-
abi: import_protocol_deployments10.zoraMintsManagerImplConfig.abi,
|
|
4787
|
-
functionName: "collectPremintV2",
|
|
4788
|
-
args: [
|
|
4789
|
-
contractCreationConfig,
|
|
4790
|
-
premintConfig,
|
|
4791
|
-
premintSignature,
|
|
4792
|
-
mintArguments,
|
|
4793
|
-
signerContract
|
|
4794
|
-
]
|
|
4795
|
-
});
|
|
4796
|
-
var makePermitToCollectPremintOrNonPremint = ({
|
|
4797
|
-
mintsOwner,
|
|
4798
|
-
chainId,
|
|
4799
|
-
deadline,
|
|
4800
|
-
tokenIds,
|
|
4801
|
-
// this quantity of MINTs will be used to collect premint
|
|
4802
|
-
// and will be burned. This same quantity is the quantity of
|
|
4803
|
-
// premint to collect.
|
|
4804
|
-
quantities,
|
|
4805
|
-
nonce,
|
|
4806
|
-
premint,
|
|
4807
|
-
collect
|
|
4808
|
-
}) => {
|
|
4809
|
-
let safeTransferData;
|
|
4810
|
-
if (premint) {
|
|
4811
|
-
safeTransferData = encodePremintOnManager(premint);
|
|
4812
|
-
} else if (collect) {
|
|
4813
|
-
safeTransferData = encodeCollectOnManager(collect);
|
|
4814
|
-
} else {
|
|
4815
|
-
throw new Error("Invalid operation");
|
|
4571
|
+
encode(input) {
|
|
4572
|
+
return this.encoder.encode(input);
|
|
4573
|
+
}
|
|
4574
|
+
decode(input) {
|
|
4575
|
+
return this.decoder.decode(input);
|
|
4816
4576
|
}
|
|
4817
|
-
return makePermitTransferBatchAndTypeData({
|
|
4818
|
-
tokenIds,
|
|
4819
|
-
quantities,
|
|
4820
|
-
chainId,
|
|
4821
|
-
mintsOwner,
|
|
4822
|
-
nonce,
|
|
4823
|
-
deadline,
|
|
4824
|
-
safeTransferData,
|
|
4825
|
-
to: import_protocol_deployments10.zoraMintsManagerImplConfig.address[chainId]
|
|
4826
|
-
});
|
|
4827
4577
|
};
|
|
4828
|
-
function
|
|
4829
|
-
|
|
4830
|
-
quantities,
|
|
4831
|
-
paidMintPricePerToken,
|
|
4832
|
-
account,
|
|
4833
|
-
chainId,
|
|
4834
|
-
...rest
|
|
4835
|
-
}) {
|
|
4836
|
-
const call = encodePremintOnManager({
|
|
4837
|
-
...rest
|
|
4838
|
-
});
|
|
4839
|
-
return makeContractParameters({
|
|
4840
|
-
abi: import_protocol_deployments10.zoraMints1155Config.abi,
|
|
4841
|
-
address: import_protocol_deployments10.zoraMints1155Config.address[chainId],
|
|
4842
|
-
functionName: "transferBatchToManagerAndCall",
|
|
4843
|
-
args: [tokenIds, quantities, call],
|
|
4844
|
-
value: getPaidMintValue(quantities, paidMintPricePerToken),
|
|
4845
|
-
account
|
|
4846
|
-
});
|
|
4847
|
-
}
|
|
4848
|
-
function decodeCallFailedError(error) {
|
|
4849
|
-
if (error.data?.errorName !== "CallFailed")
|
|
4850
|
-
throw new Error("Not a CallFailed error");
|
|
4851
|
-
const internalErrorData = error.data?.args?.[0];
|
|
4852
|
-
return (0, import_viem9.decodeErrorResult)({
|
|
4853
|
-
abi: import_protocol_deployments10.zoraMintsManagerImplABI,
|
|
4854
|
-
data: internalErrorData
|
|
4855
|
-
});
|
|
4856
|
-
}
|
|
4857
|
-
|
|
4858
|
-
// src/sdk.ts
|
|
4859
|
-
function createCreatorClient(clientConfig) {
|
|
4860
|
-
const premintClient = new PremintClient({
|
|
4861
|
-
chainId: clientConfig.chainId,
|
|
4862
|
-
publicClient: clientConfig.publicClient,
|
|
4863
|
-
premintApi: clientConfig.premintApi || new PremintAPIClient(clientConfig.chainId)
|
|
4864
|
-
});
|
|
4865
|
-
const create1155CreatorClient = new Create1155Client({
|
|
4866
|
-
chainId: clientConfig.chainId,
|
|
4867
|
-
publicClient: clientConfig.publicClient
|
|
4868
|
-
});
|
|
4869
|
-
return {
|
|
4870
|
-
createPremint: (p) => premintClient.createPremint(p),
|
|
4871
|
-
updatePremint: (p) => premintClient.updatePremint(p),
|
|
4872
|
-
deletePremint: (p) => premintClient.deletePremint(p),
|
|
4873
|
-
create1155: (p) => create1155CreatorClient.createNew1155Token(p)
|
|
4874
|
-
};
|
|
4578
|
+
function from({ name, prefix, encode: encode3, decode: decode5 }) {
|
|
4579
|
+
return new Codec(name, prefix, encode3, decode5);
|
|
4875
4580
|
}
|
|
4876
|
-
function
|
|
4877
|
-
const
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4581
|
+
function baseX({ name, prefix, alphabet }) {
|
|
4582
|
+
const { encode: encode3, decode: decode5 } = base_x_default(alphabet, name);
|
|
4583
|
+
return from({
|
|
4584
|
+
prefix,
|
|
4585
|
+
name,
|
|
4586
|
+
encode: encode3,
|
|
4587
|
+
decode: (text) => coerce2(decode5(text))
|
|
4883
4588
|
});
|
|
4884
|
-
return {
|
|
4885
|
-
getPremint: (p) => premintGetterToUse.get({
|
|
4886
|
-
collectionAddress: p.address,
|
|
4887
|
-
uid: p.uid
|
|
4888
|
-
}),
|
|
4889
|
-
getCollectDataFromPremintReceipt: (p) => getDataFromPremintReceipt(p, params.chainId),
|
|
4890
|
-
getToken: (p) => mintClient.get(p),
|
|
4891
|
-
getTokensOfContract: (p) => mintClient.getOfContract(p),
|
|
4892
|
-
mint: (p) => mintClient.mint(p),
|
|
4893
|
-
getMintCosts: (p) => mintClient.getMintCosts(p)
|
|
4894
|
-
};
|
|
4895
|
-
}
|
|
4896
|
-
|
|
4897
|
-
// src/ipfs/arweave.ts
|
|
4898
|
-
function isArweaveURL(url) {
|
|
4899
|
-
return url && typeof url === "string" ? url.startsWith("ar://") : false;
|
|
4900
4589
|
}
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
if (aa === bb)
|
|
4906
|
-
return true;
|
|
4907
|
-
if (aa.byteLength !== bb.byteLength) {
|
|
4908
|
-
return false;
|
|
4590
|
+
function decode(string, alphabet, bitsPerChar, name) {
|
|
4591
|
+
const codes = {};
|
|
4592
|
+
for (let i = 0; i < alphabet.length; ++i) {
|
|
4593
|
+
codes[alphabet[i]] = i;
|
|
4909
4594
|
}
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4595
|
+
let end = string.length;
|
|
4596
|
+
while (string[end - 1] === "=") {
|
|
4597
|
+
--end;
|
|
4598
|
+
}
|
|
4599
|
+
const out = new Uint8Array(end * bitsPerChar / 8 | 0);
|
|
4600
|
+
let bits = 0;
|
|
4601
|
+
let buffer = 0;
|
|
4602
|
+
let written = 0;
|
|
4603
|
+
for (let i = 0; i < end; ++i) {
|
|
4604
|
+
const value = codes[string[i]];
|
|
4605
|
+
if (value === void 0) {
|
|
4606
|
+
throw new SyntaxError(`Non-${name} character`);
|
|
4607
|
+
}
|
|
4608
|
+
buffer = buffer << bitsPerChar | value;
|
|
4609
|
+
bits += bitsPerChar;
|
|
4610
|
+
if (bits >= 8) {
|
|
4611
|
+
bits -= 8;
|
|
4612
|
+
out[written++] = 255 & buffer >> bits;
|
|
4913
4613
|
}
|
|
4914
4614
|
}
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
function coerce4(o) {
|
|
4918
|
-
if (o instanceof Uint8Array && o.constructor.name === "Uint8Array")
|
|
4919
|
-
return o;
|
|
4920
|
-
if (o instanceof ArrayBuffer)
|
|
4921
|
-
return new Uint8Array(o);
|
|
4922
|
-
if (ArrayBuffer.isView(o)) {
|
|
4923
|
-
return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
|
|
4615
|
+
if (bits >= bitsPerChar || (255 & buffer << 8 - bits) !== 0) {
|
|
4616
|
+
throw new SyntaxError("Unexpected end of data");
|
|
4924
4617
|
}
|
|
4925
|
-
|
|
4618
|
+
return out;
|
|
4926
4619
|
}
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
var xc = x.charCodeAt(0);
|
|
4940
|
-
if (BASE_MAP[xc] !== 255) {
|
|
4941
|
-
throw new TypeError(x + " is ambiguous");
|
|
4620
|
+
function encode(data, alphabet, bitsPerChar) {
|
|
4621
|
+
const pad = alphabet[alphabet.length - 1] === "=";
|
|
4622
|
+
const mask = (1 << bitsPerChar) - 1;
|
|
4623
|
+
let out = "";
|
|
4624
|
+
let bits = 0;
|
|
4625
|
+
let buffer = 0;
|
|
4626
|
+
for (let i = 0; i < data.length; ++i) {
|
|
4627
|
+
buffer = buffer << 8 | data[i];
|
|
4628
|
+
bits += 8;
|
|
4629
|
+
while (bits > bitsPerChar) {
|
|
4630
|
+
bits -= bitsPerChar;
|
|
4631
|
+
out += alphabet[mask & buffer >> bits];
|
|
4942
4632
|
}
|
|
4943
|
-
BASE_MAP[xc] = i;
|
|
4944
4633
|
}
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
var FACTOR = Math.log(BASE) / Math.log(256);
|
|
4948
|
-
var iFACTOR = Math.log(256) / Math.log(BASE);
|
|
4949
|
-
function encode3(source) {
|
|
4950
|
-
if (source instanceof Uint8Array)
|
|
4951
|
-
;
|
|
4952
|
-
else if (ArrayBuffer.isView(source)) {
|
|
4953
|
-
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
4954
|
-
} else if (Array.isArray(source)) {
|
|
4955
|
-
source = Uint8Array.from(source);
|
|
4956
|
-
}
|
|
4957
|
-
if (!(source instanceof Uint8Array)) {
|
|
4958
|
-
throw new TypeError("Expected Uint8Array");
|
|
4959
|
-
}
|
|
4960
|
-
if (source.length === 0) {
|
|
4961
|
-
return "";
|
|
4962
|
-
}
|
|
4963
|
-
var zeroes = 0;
|
|
4964
|
-
var length2 = 0;
|
|
4965
|
-
var pbegin = 0;
|
|
4966
|
-
var pend = source.length;
|
|
4967
|
-
while (pbegin !== pend && source[pbegin] === 0) {
|
|
4968
|
-
pbegin++;
|
|
4969
|
-
zeroes++;
|
|
4970
|
-
}
|
|
4971
|
-
var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
|
|
4972
|
-
var b58 = new Uint8Array(size);
|
|
4973
|
-
while (pbegin !== pend) {
|
|
4974
|
-
var carry = source[pbegin];
|
|
4975
|
-
var i2 = 0;
|
|
4976
|
-
for (var it1 = size - 1; (carry !== 0 || i2 < length2) && it1 !== -1; it1--, i2++) {
|
|
4977
|
-
carry += 256 * b58[it1] >>> 0;
|
|
4978
|
-
b58[it1] = carry % BASE >>> 0;
|
|
4979
|
-
carry = carry / BASE >>> 0;
|
|
4980
|
-
}
|
|
4981
|
-
if (carry !== 0) {
|
|
4982
|
-
throw new Error("Non-zero carry");
|
|
4983
|
-
}
|
|
4984
|
-
length2 = i2;
|
|
4985
|
-
pbegin++;
|
|
4986
|
-
}
|
|
4987
|
-
var it2 = size - length2;
|
|
4988
|
-
while (it2 !== size && b58[it2] === 0) {
|
|
4989
|
-
it2++;
|
|
4990
|
-
}
|
|
4991
|
-
var str = LEADER.repeat(zeroes);
|
|
4992
|
-
for (; it2 < size; ++it2) {
|
|
4993
|
-
str += ALPHABET.charAt(b58[it2]);
|
|
4994
|
-
}
|
|
4995
|
-
return str;
|
|
4634
|
+
if (bits !== 0) {
|
|
4635
|
+
out += alphabet[mask & buffer << bitsPerChar - bits];
|
|
4996
4636
|
}
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
}
|
|
5001
|
-
if (source.length === 0) {
|
|
5002
|
-
return new Uint8Array();
|
|
5003
|
-
}
|
|
5004
|
-
var psz = 0;
|
|
5005
|
-
if (source[psz] === " ") {
|
|
5006
|
-
return;
|
|
5007
|
-
}
|
|
5008
|
-
var zeroes = 0;
|
|
5009
|
-
var length2 = 0;
|
|
5010
|
-
while (source[psz] === LEADER) {
|
|
5011
|
-
zeroes++;
|
|
5012
|
-
psz++;
|
|
5013
|
-
}
|
|
5014
|
-
var size = (source.length - psz) * FACTOR + 1 >>> 0;
|
|
5015
|
-
var b256 = new Uint8Array(size);
|
|
5016
|
-
while (source[psz]) {
|
|
5017
|
-
var carry = BASE_MAP[source.charCodeAt(psz)];
|
|
5018
|
-
if (carry === 255) {
|
|
5019
|
-
return;
|
|
5020
|
-
}
|
|
5021
|
-
var i2 = 0;
|
|
5022
|
-
for (var it3 = size - 1; (carry !== 0 || i2 < length2) && it3 !== -1; it3--, i2++) {
|
|
5023
|
-
carry += BASE * b256[it3] >>> 0;
|
|
5024
|
-
b256[it3] = carry % 256 >>> 0;
|
|
5025
|
-
carry = carry / 256 >>> 0;
|
|
5026
|
-
}
|
|
5027
|
-
if (carry !== 0) {
|
|
5028
|
-
throw new Error("Non-zero carry");
|
|
5029
|
-
}
|
|
5030
|
-
length2 = i2;
|
|
5031
|
-
psz++;
|
|
5032
|
-
}
|
|
5033
|
-
if (source[psz] === " ") {
|
|
5034
|
-
return;
|
|
5035
|
-
}
|
|
5036
|
-
var it4 = size - length2;
|
|
5037
|
-
while (it4 !== size && b256[it4] === 0) {
|
|
5038
|
-
it4++;
|
|
5039
|
-
}
|
|
5040
|
-
var vch = new Uint8Array(zeroes + (size - it4));
|
|
5041
|
-
var j2 = zeroes;
|
|
5042
|
-
while (it4 !== size) {
|
|
5043
|
-
vch[j2++] = b256[it4++];
|
|
4637
|
+
if (pad) {
|
|
4638
|
+
while ((out.length * bitsPerChar & 7) !== 0) {
|
|
4639
|
+
out += "=";
|
|
5044
4640
|
}
|
|
5045
|
-
return vch;
|
|
5046
4641
|
}
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
4642
|
+
return out;
|
|
4643
|
+
}
|
|
4644
|
+
function rfc4648({ name, prefix, bitsPerChar, alphabet }) {
|
|
4645
|
+
return from({
|
|
4646
|
+
prefix,
|
|
4647
|
+
name,
|
|
4648
|
+
encode(input) {
|
|
4649
|
+
return encode(input, alphabet, bitsPerChar);
|
|
4650
|
+
},
|
|
4651
|
+
decode(input) {
|
|
4652
|
+
return decode(input, alphabet, bitsPerChar, name);
|
|
5051
4653
|
}
|
|
5052
|
-
|
|
5053
|
-
}
|
|
5054
|
-
return {
|
|
5055
|
-
encode: encode3,
|
|
5056
|
-
decodeUnsafe,
|
|
5057
|
-
decode: decode5
|
|
5058
|
-
};
|
|
5059
|
-
}
|
|
5060
|
-
var src = base2;
|
|
5061
|
-
var _brrp__multiformats_scope_baseX = src;
|
|
5062
|
-
var base_x_default = _brrp__multiformats_scope_baseX;
|
|
5063
|
-
|
|
5064
|
-
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/bases/base.js
|
|
5065
|
-
var Encoder = class {
|
|
5066
|
-
constructor(name, prefix, baseEncode) {
|
|
5067
|
-
__publicField(this, "name");
|
|
5068
|
-
__publicField(this, "prefix");
|
|
5069
|
-
__publicField(this, "baseEncode");
|
|
5070
|
-
this.name = name;
|
|
5071
|
-
this.prefix = prefix;
|
|
5072
|
-
this.baseEncode = baseEncode;
|
|
5073
|
-
}
|
|
5074
|
-
encode(bytes) {
|
|
5075
|
-
if (bytes instanceof Uint8Array) {
|
|
5076
|
-
return `${this.prefix}${this.baseEncode(bytes)}`;
|
|
5077
|
-
} else {
|
|
5078
|
-
throw Error("Unknown type, must be binary type");
|
|
5079
|
-
}
|
|
5080
|
-
}
|
|
5081
|
-
};
|
|
5082
|
-
var Decoder = class {
|
|
5083
|
-
constructor(name, prefix, baseDecode) {
|
|
5084
|
-
__publicField(this, "name");
|
|
5085
|
-
__publicField(this, "prefix");
|
|
5086
|
-
__publicField(this, "baseDecode");
|
|
5087
|
-
__publicField(this, "prefixCodePoint");
|
|
5088
|
-
this.name = name;
|
|
5089
|
-
this.prefix = prefix;
|
|
5090
|
-
if (prefix.codePointAt(0) === void 0) {
|
|
5091
|
-
throw new Error("Invalid prefix character");
|
|
5092
|
-
}
|
|
5093
|
-
this.prefixCodePoint = prefix.codePointAt(0);
|
|
5094
|
-
this.baseDecode = baseDecode;
|
|
5095
|
-
}
|
|
5096
|
-
decode(text) {
|
|
5097
|
-
if (typeof text === "string") {
|
|
5098
|
-
if (text.codePointAt(0) !== this.prefixCodePoint) {
|
|
5099
|
-
throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
|
|
5100
|
-
}
|
|
5101
|
-
return this.baseDecode(text.slice(this.prefix.length));
|
|
5102
|
-
} else {
|
|
5103
|
-
throw Error("Can only multibase decode strings");
|
|
5104
|
-
}
|
|
5105
|
-
}
|
|
5106
|
-
or(decoder) {
|
|
5107
|
-
return or(this, decoder);
|
|
5108
|
-
}
|
|
5109
|
-
};
|
|
5110
|
-
var ComposedDecoder = class {
|
|
5111
|
-
constructor(decoders) {
|
|
5112
|
-
__publicField(this, "decoders");
|
|
5113
|
-
this.decoders = decoders;
|
|
5114
|
-
}
|
|
5115
|
-
or(decoder) {
|
|
5116
|
-
return or(this, decoder);
|
|
5117
|
-
}
|
|
5118
|
-
decode(input) {
|
|
5119
|
-
const prefix = input[0];
|
|
5120
|
-
const decoder = this.decoders[prefix];
|
|
5121
|
-
if (decoder != null) {
|
|
5122
|
-
return decoder.decode(input);
|
|
5123
|
-
} else {
|
|
5124
|
-
throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
|
|
5125
|
-
}
|
|
5126
|
-
}
|
|
5127
|
-
};
|
|
5128
|
-
function or(left, right) {
|
|
5129
|
-
return new ComposedDecoder({
|
|
5130
|
-
...left.decoders ?? { [left.prefix]: left },
|
|
5131
|
-
...right.decoders ?? { [right.prefix]: right }
|
|
5132
|
-
});
|
|
5133
|
-
}
|
|
5134
|
-
var Codec = class {
|
|
5135
|
-
constructor(name, prefix, baseEncode, baseDecode) {
|
|
5136
|
-
__publicField(this, "name");
|
|
5137
|
-
__publicField(this, "prefix");
|
|
5138
|
-
__publicField(this, "baseEncode");
|
|
5139
|
-
__publicField(this, "baseDecode");
|
|
5140
|
-
__publicField(this, "encoder");
|
|
5141
|
-
__publicField(this, "decoder");
|
|
5142
|
-
this.name = name;
|
|
5143
|
-
this.prefix = prefix;
|
|
5144
|
-
this.baseEncode = baseEncode;
|
|
5145
|
-
this.baseDecode = baseDecode;
|
|
5146
|
-
this.encoder = new Encoder(name, prefix, baseEncode);
|
|
5147
|
-
this.decoder = new Decoder(name, prefix, baseDecode);
|
|
5148
|
-
}
|
|
5149
|
-
encode(input) {
|
|
5150
|
-
return this.encoder.encode(input);
|
|
5151
|
-
}
|
|
5152
|
-
decode(input) {
|
|
5153
|
-
return this.decoder.decode(input);
|
|
5154
|
-
}
|
|
5155
|
-
};
|
|
5156
|
-
function from({ name, prefix, encode: encode3, decode: decode5 }) {
|
|
5157
|
-
return new Codec(name, prefix, encode3, decode5);
|
|
5158
|
-
}
|
|
5159
|
-
function baseX({ name, prefix, alphabet }) {
|
|
5160
|
-
const { encode: encode3, decode: decode5 } = base_x_default(alphabet, name);
|
|
5161
|
-
return from({
|
|
5162
|
-
prefix,
|
|
5163
|
-
name,
|
|
5164
|
-
encode: encode3,
|
|
5165
|
-
decode: (text) => coerce4(decode5(text))
|
|
5166
|
-
});
|
|
5167
|
-
}
|
|
5168
|
-
function decode(string, alphabet, bitsPerChar, name) {
|
|
5169
|
-
const codes = {};
|
|
5170
|
-
for (let i = 0; i < alphabet.length; ++i) {
|
|
5171
|
-
codes[alphabet[i]] = i;
|
|
5172
|
-
}
|
|
5173
|
-
let end = string.length;
|
|
5174
|
-
while (string[end - 1] === "=") {
|
|
5175
|
-
--end;
|
|
5176
|
-
}
|
|
5177
|
-
const out = new Uint8Array(end * bitsPerChar / 8 | 0);
|
|
5178
|
-
let bits = 0;
|
|
5179
|
-
let buffer = 0;
|
|
5180
|
-
let written = 0;
|
|
5181
|
-
for (let i = 0; i < end; ++i) {
|
|
5182
|
-
const value = codes[string[i]];
|
|
5183
|
-
if (value === void 0) {
|
|
5184
|
-
throw new SyntaxError(`Non-${name} character`);
|
|
5185
|
-
}
|
|
5186
|
-
buffer = buffer << bitsPerChar | value;
|
|
5187
|
-
bits += bitsPerChar;
|
|
5188
|
-
if (bits >= 8) {
|
|
5189
|
-
bits -= 8;
|
|
5190
|
-
out[written++] = 255 & buffer >> bits;
|
|
5191
|
-
}
|
|
5192
|
-
}
|
|
5193
|
-
if (bits >= bitsPerChar || (255 & buffer << 8 - bits) !== 0) {
|
|
5194
|
-
throw new SyntaxError("Unexpected end of data");
|
|
5195
|
-
}
|
|
5196
|
-
return out;
|
|
5197
|
-
}
|
|
5198
|
-
function encode(data, alphabet, bitsPerChar) {
|
|
5199
|
-
const pad = alphabet[alphabet.length - 1] === "=";
|
|
5200
|
-
const mask = (1 << bitsPerChar) - 1;
|
|
5201
|
-
let out = "";
|
|
5202
|
-
let bits = 0;
|
|
5203
|
-
let buffer = 0;
|
|
5204
|
-
for (let i = 0; i < data.length; ++i) {
|
|
5205
|
-
buffer = buffer << 8 | data[i];
|
|
5206
|
-
bits += 8;
|
|
5207
|
-
while (bits > bitsPerChar) {
|
|
5208
|
-
bits -= bitsPerChar;
|
|
5209
|
-
out += alphabet[mask & buffer >> bits];
|
|
5210
|
-
}
|
|
5211
|
-
}
|
|
5212
|
-
if (bits !== 0) {
|
|
5213
|
-
out += alphabet[mask & buffer << bitsPerChar - bits];
|
|
5214
|
-
}
|
|
5215
|
-
if (pad) {
|
|
5216
|
-
while ((out.length * bitsPerChar & 7) !== 0) {
|
|
5217
|
-
out += "=";
|
|
5218
|
-
}
|
|
5219
|
-
}
|
|
5220
|
-
return out;
|
|
5221
|
-
}
|
|
5222
|
-
function rfc4648({ name, prefix, bitsPerChar, alphabet }) {
|
|
5223
|
-
return from({
|
|
5224
|
-
prefix,
|
|
5225
|
-
name,
|
|
5226
|
-
encode(input) {
|
|
5227
|
-
return encode(input, alphabet, bitsPerChar);
|
|
5228
|
-
},
|
|
5229
|
-
decode(input) {
|
|
5230
|
-
return decode(input, alphabet, bitsPerChar, name);
|
|
5231
|
-
}
|
|
5232
|
-
});
|
|
4654
|
+
});
|
|
5233
4655
|
}
|
|
5234
4656
|
|
|
5235
4657
|
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/bases/base32.js
|
|
@@ -5384,7 +4806,7 @@ function create(code, digest) {
|
|
|
5384
4806
|
return new Digest(code, size, digest, bytes);
|
|
5385
4807
|
}
|
|
5386
4808
|
function decode4(multihash) {
|
|
5387
|
-
const bytes =
|
|
4809
|
+
const bytes = coerce2(multihash);
|
|
5388
4810
|
const [code, sizeOffset] = decode3(bytes);
|
|
5389
4811
|
const [size, digestOffset] = decode3(bytes.subarray(sizeOffset));
|
|
5390
4812
|
const digest = bytes.subarray(sizeOffset + digestOffset);
|
|
@@ -5627,7 +5049,7 @@ var CID = class _CID {
|
|
|
5627
5049
|
static decodeFirst(bytes) {
|
|
5628
5050
|
const specs = _CID.inspectBytes(bytes);
|
|
5629
5051
|
const prefixSize = specs.size - specs.multihashSize;
|
|
5630
|
-
const multihashBytes =
|
|
5052
|
+
const multihashBytes = coerce2(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
|
|
5631
5053
|
if (multihashBytes.byteLength !== specs.multihashSize) {
|
|
5632
5054
|
throw new Error("Incorrect length");
|
|
5633
5055
|
}
|
|
@@ -5930,67 +5352,1037 @@ function mimeTypeToMedia(mimeType) {
|
|
|
5930
5352
|
return "UNKNOWN" /* UNKNOWN */;
|
|
5931
5353
|
return mimeToMediaType[mimeType] || "UNKNOWN" /* UNKNOWN */;
|
|
5932
5354
|
}
|
|
5933
|
-
async function getMimeType(uri) {
|
|
5934
|
-
if (!uri)
|
|
5935
|
-
return uri;
|
|
5936
|
-
const res = await fetch(uri, { method: "HEAD" });
|
|
5937
|
-
let mimeType = res.headers.get("content-type");
|
|
5938
|
-
return mimeType;
|
|
5355
|
+
async function getMimeType(uri) {
|
|
5356
|
+
if (!uri)
|
|
5357
|
+
return uri;
|
|
5358
|
+
const res = await fetch(uri, { method: "HEAD" });
|
|
5359
|
+
let mimeType = res.headers.get("content-type");
|
|
5360
|
+
return mimeType;
|
|
5361
|
+
}
|
|
5362
|
+
|
|
5363
|
+
// src/ipfs/token-metadata.ts
|
|
5364
|
+
var makeTextTokenMetadata = (parameters) => {
|
|
5365
|
+
const { name, textFileUrl, thumbnailUrl, attributes = [] } = parameters;
|
|
5366
|
+
const content = textFileUrl ? {
|
|
5367
|
+
mime: TEXT_PLAIN,
|
|
5368
|
+
uri: textFileUrl
|
|
5369
|
+
} : null;
|
|
5370
|
+
const image = thumbnailUrl;
|
|
5371
|
+
const animation_url = textFileUrl;
|
|
5372
|
+
return {
|
|
5373
|
+
name,
|
|
5374
|
+
image,
|
|
5375
|
+
animation_url,
|
|
5376
|
+
content,
|
|
5377
|
+
attributes
|
|
5378
|
+
};
|
|
5379
|
+
};
|
|
5380
|
+
var makeMediaTokenMetadata = async ({
|
|
5381
|
+
name,
|
|
5382
|
+
description,
|
|
5383
|
+
attributes = [],
|
|
5384
|
+
mediaUrl,
|
|
5385
|
+
thumbnailUrl
|
|
5386
|
+
}) => {
|
|
5387
|
+
const contentUrl = mediaUrl;
|
|
5388
|
+
const fetchableContentUrl = getFetchableUrl(contentUrl);
|
|
5389
|
+
if (!fetchableContentUrl)
|
|
5390
|
+
throw new Error(`Content url (${contentUrl}) is not fetchable`);
|
|
5391
|
+
const mimeType = await getMimeType(fetchableContentUrl);
|
|
5392
|
+
const mediaType = mimeTypeToMedia(mimeType);
|
|
5393
|
+
let image = void 0;
|
|
5394
|
+
let animation_url = null;
|
|
5395
|
+
if (isImage(mimeType)) {
|
|
5396
|
+
image = contentUrl;
|
|
5397
|
+
} else {
|
|
5398
|
+
image = thumbnailUrl;
|
|
5399
|
+
animation_url = mediaUrl;
|
|
5400
|
+
}
|
|
5401
|
+
if (!image)
|
|
5402
|
+
image = `ipfs://${DEFAULT_THUMBNAIL_CID_HASHES[mediaType] || DEFAULT_THUMBNAIL_CID_HASHES.default}`;
|
|
5403
|
+
const content = contentUrl ? {
|
|
5404
|
+
mime: mimeType || "application/octet-stream",
|
|
5405
|
+
uri: contentUrl
|
|
5406
|
+
} : null;
|
|
5407
|
+
return {
|
|
5408
|
+
name,
|
|
5409
|
+
description,
|
|
5410
|
+
image,
|
|
5411
|
+
animation_url,
|
|
5412
|
+
content,
|
|
5413
|
+
attributes
|
|
5414
|
+
};
|
|
5415
|
+
};
|
|
5416
|
+
async function fetchTokenMetadata(tokenMetadataURI) {
|
|
5417
|
+
const fetchableUrl = getFetchableUrl(tokenMetadataURI);
|
|
5418
|
+
if (!fetchableUrl) {
|
|
5419
|
+
throw new Error(`Invalid token metadata URI: ${tokenMetadataURI}`);
|
|
5420
|
+
}
|
|
5421
|
+
const json = await (await fetch(fetchableUrl)).json();
|
|
5422
|
+
if (!json) {
|
|
5423
|
+
throw new Error(`Failed to fetch metadata from ${fetchableUrl}`);
|
|
5424
|
+
}
|
|
5425
|
+
return json;
|
|
5426
|
+
}
|
|
5427
|
+
|
|
5428
|
+
// src/create/minter-defaults.ts
|
|
5429
|
+
var SALE_END_FOREVER = 18446744073709551615n;
|
|
5430
|
+
var DEFAULT_SALE_START_AND_END = {
|
|
5431
|
+
// Sale start time – defaults to beginning of unix time
|
|
5432
|
+
saleStart: 0n,
|
|
5433
|
+
// This is the end of uint64, plenty of time
|
|
5434
|
+
saleEnd: SALE_END_FOREVER
|
|
5435
|
+
};
|
|
5436
|
+
var DEFAULT_MAX_TOKENS_PER_ADDRESS = {
|
|
5437
|
+
maxTokensPerAddress: 0n
|
|
5438
|
+
};
|
|
5439
|
+
var erc20SaleSettingsWithDefaults = (params) => ({
|
|
5440
|
+
...DEFAULT_SALE_START_AND_END,
|
|
5441
|
+
...DEFAULT_MAX_TOKENS_PER_ADDRESS,
|
|
5442
|
+
...params
|
|
5443
|
+
});
|
|
5444
|
+
var allowListWithDefaults = (allowlist) => {
|
|
5445
|
+
return {
|
|
5446
|
+
...DEFAULT_SALE_START_AND_END,
|
|
5447
|
+
...allowlist
|
|
5448
|
+
};
|
|
5449
|
+
};
|
|
5450
|
+
var fixedPriceSettingsWithDefaults = (params) => ({
|
|
5451
|
+
...DEFAULT_SALE_START_AND_END,
|
|
5452
|
+
...DEFAULT_MAX_TOKENS_PER_ADDRESS,
|
|
5453
|
+
type: "fixedPrice",
|
|
5454
|
+
...params
|
|
5455
|
+
});
|
|
5456
|
+
var parseNameIntoSymbol = (name) => {
|
|
5457
|
+
if (name === "") {
|
|
5458
|
+
throw new Error("Name must be provided to generate a symbol");
|
|
5459
|
+
}
|
|
5460
|
+
const result = "$" + name.replace(/[^a-zA-Z0-9]/g, "").replace(/^\$+/, "").toUpperCase().replace(/[AEIOU\s]/g, "").slice(0, 4);
|
|
5461
|
+
if (result === "$") {
|
|
5462
|
+
throw new Error("Not enough valid characters to generate a symbol");
|
|
5463
|
+
}
|
|
5464
|
+
return result;
|
|
5465
|
+
};
|
|
5466
|
+
async function fetchTokenNameFromMetadata(tokenMetadataURI) {
|
|
5467
|
+
const tokenMetadata = await fetchTokenMetadata(tokenMetadataURI);
|
|
5468
|
+
if (!tokenMetadata.name) {
|
|
5469
|
+
throw new Error("No name found in token metadata");
|
|
5470
|
+
}
|
|
5471
|
+
return tokenMetadata.name;
|
|
5472
|
+
}
|
|
5473
|
+
var timedSaleSettingsWithDefaults = async (params, tokenMetadataURI) => {
|
|
5474
|
+
const erc20Name = params.erc20Name || await fetchTokenNameFromMetadata(tokenMetadataURI);
|
|
5475
|
+
const symbol = params.erc20Symbol || parseNameIntoSymbol(erc20Name);
|
|
5476
|
+
return {
|
|
5477
|
+
type: "timed",
|
|
5478
|
+
...DEFAULT_SALE_START_AND_END,
|
|
5479
|
+
erc20Name,
|
|
5480
|
+
erc20Symbol: symbol
|
|
5481
|
+
};
|
|
5482
|
+
};
|
|
5483
|
+
var isAllowList = (salesConfig) => salesConfig.type === "allowlistMint";
|
|
5484
|
+
var isErc20 = (salesConfig) => salesConfig.type === "erc20Mint";
|
|
5485
|
+
var isFixedPrice = (salesConfig) => {
|
|
5486
|
+
return salesConfig.pricePerToken > 0n;
|
|
5487
|
+
};
|
|
5488
|
+
var getSalesConfigWithDefaults = async (salesConfig, tokenMetadataURI) => {
|
|
5489
|
+
if (!salesConfig)
|
|
5490
|
+
return timedSaleSettingsWithDefaults({}, tokenMetadataURI);
|
|
5491
|
+
if (isAllowList(salesConfig)) {
|
|
5492
|
+
return allowListWithDefaults(salesConfig);
|
|
5493
|
+
}
|
|
5494
|
+
if (isErc20(salesConfig)) {
|
|
5495
|
+
return erc20SaleSettingsWithDefaults(salesConfig);
|
|
5496
|
+
}
|
|
5497
|
+
if (isFixedPrice(salesConfig)) {
|
|
5498
|
+
return fixedPriceSettingsWithDefaults(salesConfig);
|
|
5499
|
+
}
|
|
5500
|
+
return timedSaleSettingsWithDefaults(salesConfig, tokenMetadataURI);
|
|
5501
|
+
};
|
|
5502
|
+
|
|
5503
|
+
// src/create/minter-setup.ts
|
|
5504
|
+
var import_protocol_deployments8 = require("@zoralabs/protocol-deployments");
|
|
5505
|
+
var import_viem7 = require("viem");
|
|
5506
|
+
var PERMISSION_BITS = {
|
|
5507
|
+
MINTER: 2n ** 2n
|
|
5508
|
+
};
|
|
5509
|
+
function setupErc20Minter({
|
|
5510
|
+
pricePerToken,
|
|
5511
|
+
chainId,
|
|
5512
|
+
tokenId: nextTokenId,
|
|
5513
|
+
currency,
|
|
5514
|
+
saleStart,
|
|
5515
|
+
saleEnd,
|
|
5516
|
+
maxTokensPerAddress: mintLimit,
|
|
5517
|
+
fundsRecipient
|
|
5518
|
+
}) {
|
|
5519
|
+
const erc20MinterAddress = import_protocol_deployments8.erc20MinterAddress[chainId];
|
|
5520
|
+
if (!erc20MinterAddress)
|
|
5521
|
+
throw new Error(`ERC20Minter not deployed on chainId ${chainId}`);
|
|
5522
|
+
const erc20MinterApproval = (0, import_viem7.encodeFunctionData)({
|
|
5523
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
5524
|
+
functionName: "addPermission",
|
|
5525
|
+
args: [BigInt(nextTokenId), erc20MinterAddress, PERMISSION_BITS.MINTER]
|
|
5526
|
+
});
|
|
5527
|
+
const saleData = (0, import_viem7.encodeFunctionData)({
|
|
5528
|
+
abi: import_protocol_deployments8.erc20MinterABI,
|
|
5529
|
+
functionName: "setSale",
|
|
5530
|
+
args: [
|
|
5531
|
+
BigInt(nextTokenId),
|
|
5532
|
+
{
|
|
5533
|
+
saleStart: saleStart || BigInt(0),
|
|
5534
|
+
saleEnd: saleEnd || BigInt(0),
|
|
5535
|
+
maxTokensPerAddress: BigInt(mintLimit || 0),
|
|
5536
|
+
pricePerToken,
|
|
5537
|
+
fundsRecipient,
|
|
5538
|
+
currency
|
|
5539
|
+
}
|
|
5540
|
+
]
|
|
5541
|
+
});
|
|
5542
|
+
const callSale = (0, import_viem7.encodeFunctionData)({
|
|
5543
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
5544
|
+
functionName: "callSale",
|
|
5545
|
+
args: [BigInt(nextTokenId), erc20MinterAddress, saleData]
|
|
5546
|
+
});
|
|
5547
|
+
return {
|
|
5548
|
+
minter: erc20MinterAddress,
|
|
5549
|
+
setupActions: [erc20MinterApproval, callSale]
|
|
5550
|
+
};
|
|
5551
|
+
}
|
|
5552
|
+
function setupFixedPriceMinter({
|
|
5553
|
+
pricePerToken: price,
|
|
5554
|
+
tokenId: nextTokenId,
|
|
5555
|
+
chainId,
|
|
5556
|
+
saleStart,
|
|
5557
|
+
saleEnd,
|
|
5558
|
+
maxTokensPerAddress: mintLimit,
|
|
5559
|
+
fundsRecipient
|
|
5560
|
+
}) {
|
|
5561
|
+
const fixedPriceStrategyAddress = import_protocol_deployments8.zoraCreatorFixedPriceSaleStrategyAddress[chainId];
|
|
5562
|
+
const fixedPriceApproval = (0, import_viem7.encodeFunctionData)({
|
|
5563
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
5564
|
+
functionName: "addPermission",
|
|
5565
|
+
args: [
|
|
5566
|
+
BigInt(nextTokenId),
|
|
5567
|
+
fixedPriceStrategyAddress,
|
|
5568
|
+
PERMISSION_BITS.MINTER
|
|
5569
|
+
]
|
|
5570
|
+
});
|
|
5571
|
+
const saleData = (0, import_viem7.encodeFunctionData)({
|
|
5572
|
+
abi: import_protocol_deployments8.zoraCreatorFixedPriceSaleStrategyABI,
|
|
5573
|
+
functionName: "setSale",
|
|
5574
|
+
args: [
|
|
5575
|
+
BigInt(nextTokenId),
|
|
5576
|
+
{
|
|
5577
|
+
pricePerToken: price,
|
|
5578
|
+
saleStart: saleStart || BigInt(0),
|
|
5579
|
+
saleEnd: saleEnd || BigInt(0),
|
|
5580
|
+
maxTokensPerAddress: BigInt(mintLimit || 0),
|
|
5581
|
+
fundsRecipient
|
|
5582
|
+
}
|
|
5583
|
+
]
|
|
5584
|
+
});
|
|
5585
|
+
const callSale = (0, import_viem7.encodeFunctionData)({
|
|
5586
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
5587
|
+
functionName: "callSale",
|
|
5588
|
+
args: [BigInt(nextTokenId), fixedPriceStrategyAddress, saleData]
|
|
5589
|
+
});
|
|
5590
|
+
return {
|
|
5591
|
+
minter: fixedPriceStrategyAddress,
|
|
5592
|
+
setupActions: [fixedPriceApproval, callSale]
|
|
5593
|
+
};
|
|
5594
|
+
}
|
|
5595
|
+
function setupTimedSaleMinter({
|
|
5596
|
+
chainId,
|
|
5597
|
+
tokenId,
|
|
5598
|
+
erc20Name: erc20zName,
|
|
5599
|
+
erc20Symbol: erc20zSymbol,
|
|
5600
|
+
saleStart,
|
|
5601
|
+
saleEnd
|
|
5602
|
+
}) {
|
|
5603
|
+
const minterAddress = import_protocol_deployments8.zoraTimedSaleStrategyAddress[chainId];
|
|
5604
|
+
const fixedPriceApproval = (0, import_viem7.encodeFunctionData)({
|
|
5605
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
5606
|
+
functionName: "addPermission",
|
|
5607
|
+
args: [BigInt(tokenId), minterAddress, PERMISSION_BITS.MINTER]
|
|
5608
|
+
});
|
|
5609
|
+
const saleData = (0, import_viem7.encodeFunctionData)({
|
|
5610
|
+
abi: import_protocol_deployments8.zoraTimedSaleStrategyABI,
|
|
5611
|
+
functionName: "setSale",
|
|
5612
|
+
args: [
|
|
5613
|
+
BigInt(tokenId),
|
|
5614
|
+
{
|
|
5615
|
+
saleStart,
|
|
5616
|
+
saleEnd,
|
|
5617
|
+
name: erc20zName,
|
|
5618
|
+
symbol: erc20zSymbol
|
|
5619
|
+
}
|
|
5620
|
+
]
|
|
5621
|
+
});
|
|
5622
|
+
const callSale = (0, import_viem7.encodeFunctionData)({
|
|
5623
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
5624
|
+
functionName: "callSale",
|
|
5625
|
+
args: [BigInt(tokenId), minterAddress, saleData]
|
|
5626
|
+
});
|
|
5627
|
+
return {
|
|
5628
|
+
minter: minterAddress,
|
|
5629
|
+
setupActions: [fixedPriceApproval, callSale]
|
|
5630
|
+
};
|
|
5631
|
+
}
|
|
5632
|
+
function setupAllowListMinter({
|
|
5633
|
+
chainId,
|
|
5634
|
+
tokenId: nextTokenId,
|
|
5635
|
+
allowlist,
|
|
5636
|
+
fundsRecipient
|
|
5637
|
+
}) {
|
|
5638
|
+
const merkleSaleStrategyAddress = import_protocol_deployments8.zoraCreatorMerkleMinterStrategyAddress[chainId];
|
|
5639
|
+
const merkleApproval = (0, import_viem7.encodeFunctionData)({
|
|
5640
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
5641
|
+
functionName: "addPermission",
|
|
5642
|
+
args: [nextTokenId, merkleSaleStrategyAddress, PERMISSION_BITS.MINTER]
|
|
5643
|
+
});
|
|
5644
|
+
const merkleRoot = allowlist.presaleMerkleRoot.startsWith("0x") ? allowlist.presaleMerkleRoot : `0x${allowlist.presaleMerkleRoot}`;
|
|
5645
|
+
const saleData = (0, import_viem7.encodeFunctionData)({
|
|
5646
|
+
abi: import_protocol_deployments8.zoraCreatorMerkleMinterStrategyABI,
|
|
5647
|
+
functionName: "setSale",
|
|
5648
|
+
args: [
|
|
5649
|
+
BigInt(nextTokenId),
|
|
5650
|
+
{
|
|
5651
|
+
presaleStart: allowlist.saleStart,
|
|
5652
|
+
presaleEnd: allowlist.saleEnd,
|
|
5653
|
+
merkleRoot,
|
|
5654
|
+
fundsRecipient
|
|
5655
|
+
}
|
|
5656
|
+
]
|
|
5657
|
+
});
|
|
5658
|
+
const callSaleMerkle = (0, import_viem7.encodeFunctionData)({
|
|
5659
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
5660
|
+
functionName: "callSale",
|
|
5661
|
+
args: [BigInt(nextTokenId), merkleSaleStrategyAddress, saleData]
|
|
5662
|
+
});
|
|
5663
|
+
return {
|
|
5664
|
+
minter: merkleSaleStrategyAddress,
|
|
5665
|
+
setupActions: [merkleApproval, callSaleMerkle]
|
|
5666
|
+
};
|
|
5667
|
+
}
|
|
5668
|
+
var isAllowList2 = (salesConfig) => salesConfig.type === "allowlistMint";
|
|
5669
|
+
var isErc202 = (salesConfig) => salesConfig.type === "erc20Mint";
|
|
5670
|
+
var isFixedPrice2 = (salesConfig) => salesConfig.type === "fixedPrice" || salesConfig.pricePerToken > BigInt(0);
|
|
5671
|
+
function setupMinters({ salesConfig, ...rest }) {
|
|
5672
|
+
if (isErc202(salesConfig)) {
|
|
5673
|
+
return setupErc20Minter({
|
|
5674
|
+
...salesConfig,
|
|
5675
|
+
...rest
|
|
5676
|
+
});
|
|
5677
|
+
}
|
|
5678
|
+
if (isAllowList2(salesConfig)) {
|
|
5679
|
+
return setupAllowListMinter({
|
|
5680
|
+
allowlist: salesConfig,
|
|
5681
|
+
...rest
|
|
5682
|
+
});
|
|
5683
|
+
}
|
|
5684
|
+
if (isFixedPrice2(salesConfig))
|
|
5685
|
+
return setupFixedPriceMinter({
|
|
5686
|
+
...salesConfig,
|
|
5687
|
+
...rest
|
|
5688
|
+
});
|
|
5689
|
+
return setupTimedSaleMinter({
|
|
5690
|
+
...salesConfig,
|
|
5691
|
+
...rest
|
|
5692
|
+
});
|
|
5693
|
+
}
|
|
5694
|
+
|
|
5695
|
+
// src/create/token-setup.ts
|
|
5696
|
+
async function applyNew1155Defaults(props, ownerAddress) {
|
|
5697
|
+
const { payoutRecipient: fundsRecipient } = props;
|
|
5698
|
+
const fundsRecipientOrOwner = fundsRecipient && fundsRecipient !== import_viem8.zeroAddress ? fundsRecipient : ownerAddress;
|
|
5699
|
+
return {
|
|
5700
|
+
payoutRecipient: fundsRecipientOrOwner,
|
|
5701
|
+
createReferral: props.createReferral || import_viem8.zeroAddress,
|
|
5702
|
+
maxSupply: typeof props.maxSupply === "undefined" ? OPEN_EDITION_MINT_SIZE : BigInt(props.maxSupply),
|
|
5703
|
+
royaltyBPS: props.royaltyBPS || 1e3,
|
|
5704
|
+
tokenMetadataURI: props.tokenMetadataURI,
|
|
5705
|
+
salesConfig: await getSalesConfigWithDefaults(
|
|
5706
|
+
props.salesConfig,
|
|
5707
|
+
props.tokenMetadataURI
|
|
5708
|
+
)
|
|
5709
|
+
};
|
|
5710
|
+
}
|
|
5711
|
+
function buildSetupNewToken({
|
|
5712
|
+
tokenURI,
|
|
5713
|
+
maxSupply = OPEN_EDITION_MINT_SIZE,
|
|
5714
|
+
createReferral = import_viem8.zeroAddress,
|
|
5715
|
+
contractVersion
|
|
5716
|
+
}) {
|
|
5717
|
+
if (contractSupportsMintRewards(contractVersion, "ERC1155")) {
|
|
5718
|
+
return (0, import_viem8.encodeFunctionData)({
|
|
5719
|
+
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
5720
|
+
functionName: "setupNewTokenWithCreateReferral",
|
|
5721
|
+
args: [tokenURI, BigInt(maxSupply), createReferral]
|
|
5722
|
+
});
|
|
5723
|
+
}
|
|
5724
|
+
if (createReferral !== import_viem8.zeroAddress) {
|
|
5725
|
+
throw new Error(
|
|
5726
|
+
"Contract does not support create referral, but one was provided"
|
|
5727
|
+
);
|
|
5728
|
+
}
|
|
5729
|
+
return (0, import_viem8.encodeFunctionData)({
|
|
5730
|
+
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
5731
|
+
functionName: "setupNewToken",
|
|
5732
|
+
args: [tokenURI, BigInt(maxSupply)]
|
|
5733
|
+
});
|
|
5734
|
+
}
|
|
5735
|
+
function setupRoyaltyConfig({
|
|
5736
|
+
royaltyBPS,
|
|
5737
|
+
royaltyRecipient,
|
|
5738
|
+
nextTokenId
|
|
5739
|
+
}) {
|
|
5740
|
+
if (royaltyBPS > 0 && royaltyRecipient != import_viem8.zeroAddress) {
|
|
5741
|
+
return (0, import_viem8.encodeFunctionData)({
|
|
5742
|
+
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
5743
|
+
functionName: "updateRoyaltiesForToken",
|
|
5744
|
+
args: [
|
|
5745
|
+
nextTokenId,
|
|
5746
|
+
{
|
|
5747
|
+
royaltyBPS,
|
|
5748
|
+
royaltyRecipient,
|
|
5749
|
+
royaltyMintSchedule: 0
|
|
5750
|
+
}
|
|
5751
|
+
]
|
|
5752
|
+
});
|
|
5753
|
+
}
|
|
5754
|
+
return null;
|
|
5755
|
+
}
|
|
5756
|
+
function makeAdminMintCall({
|
|
5757
|
+
ownerAddress,
|
|
5758
|
+
mintQuantity,
|
|
5759
|
+
nextTokenId
|
|
5760
|
+
}) {
|
|
5761
|
+
if (!mintQuantity || mintQuantity <= 0 || !ownerAddress) {
|
|
5762
|
+
return null;
|
|
5763
|
+
}
|
|
5764
|
+
return (0, import_viem8.encodeFunctionData)({
|
|
5765
|
+
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
5766
|
+
functionName: "adminMint",
|
|
5767
|
+
args: [ownerAddress, nextTokenId, BigInt(mintQuantity), import_viem8.zeroAddress]
|
|
5768
|
+
});
|
|
5769
|
+
}
|
|
5770
|
+
async function constructCreate1155TokenCalls(props) {
|
|
5771
|
+
const {
|
|
5772
|
+
chainId,
|
|
5773
|
+
nextTokenId,
|
|
5774
|
+
mintToCreatorCount,
|
|
5775
|
+
ownerAddress,
|
|
5776
|
+
contractVersion
|
|
5777
|
+
} = props;
|
|
5778
|
+
const new1155TokenPropsWithDefaults = await applyNew1155Defaults(
|
|
5779
|
+
props,
|
|
5780
|
+
ownerAddress
|
|
5781
|
+
);
|
|
5782
|
+
const verifyTokenIdExpected = (0, import_viem8.encodeFunctionData)({
|
|
5783
|
+
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
5784
|
+
functionName: "assumeLastTokenIdMatches",
|
|
5785
|
+
args: [nextTokenId - 1n]
|
|
5786
|
+
});
|
|
5787
|
+
const setupNewToken = buildSetupNewToken({
|
|
5788
|
+
tokenURI: new1155TokenPropsWithDefaults.tokenMetadataURI,
|
|
5789
|
+
maxSupply: new1155TokenPropsWithDefaults.maxSupply,
|
|
5790
|
+
createReferral: new1155TokenPropsWithDefaults.createReferral,
|
|
5791
|
+
contractVersion
|
|
5792
|
+
});
|
|
5793
|
+
const royaltyConfig = setupRoyaltyConfig({
|
|
5794
|
+
royaltyBPS: new1155TokenPropsWithDefaults.royaltyBPS,
|
|
5795
|
+
royaltyRecipient: new1155TokenPropsWithDefaults.payoutRecipient,
|
|
5796
|
+
nextTokenId
|
|
5797
|
+
});
|
|
5798
|
+
const { minter, setupActions: mintersSetup } = setupMinters({
|
|
5799
|
+
tokenId: nextTokenId,
|
|
5800
|
+
chainId,
|
|
5801
|
+
fundsRecipient: new1155TokenPropsWithDefaults.payoutRecipient,
|
|
5802
|
+
salesConfig: new1155TokenPropsWithDefaults.salesConfig
|
|
5803
|
+
});
|
|
5804
|
+
const adminMintCall = makeAdminMintCall({
|
|
5805
|
+
ownerAddress,
|
|
5806
|
+
mintQuantity: mintToCreatorCount,
|
|
5807
|
+
nextTokenId
|
|
5808
|
+
});
|
|
5809
|
+
const setupActions = [
|
|
5810
|
+
verifyTokenIdExpected,
|
|
5811
|
+
setupNewToken,
|
|
5812
|
+
...mintersSetup,
|
|
5813
|
+
royaltyConfig,
|
|
5814
|
+
adminMintCall
|
|
5815
|
+
].filter((item) => item !== null);
|
|
5816
|
+
return {
|
|
5817
|
+
setupActions,
|
|
5818
|
+
minter,
|
|
5819
|
+
newToken: new1155TokenPropsWithDefaults
|
|
5820
|
+
};
|
|
5821
|
+
}
|
|
5822
|
+
var contractSupportsMintRewards = (contractVersion, contractStandard) => {
|
|
5823
|
+
if (!contractStandard || !contractVersion) {
|
|
5824
|
+
return false;
|
|
5825
|
+
}
|
|
5826
|
+
const semVerContractVersion = semver2.coerce(contractVersion)?.raw;
|
|
5827
|
+
if (!semVerContractVersion)
|
|
5828
|
+
return false;
|
|
5829
|
+
if (contractStandard === "ERC1155") {
|
|
5830
|
+
return semver2.gte(semVerContractVersion, "1.3.5");
|
|
5831
|
+
} else {
|
|
5832
|
+
return semver2.gte(semVerContractVersion, "14.0.0");
|
|
5833
|
+
}
|
|
5834
|
+
};
|
|
5835
|
+
|
|
5836
|
+
// src/create/1155-create-helper.ts
|
|
5837
|
+
var ROYALTY_BPS_DEFAULT = 1e3;
|
|
5838
|
+
var getTokenIdFromCreateReceipt = (receipt) => {
|
|
5839
|
+
for (const data of receipt.logs) {
|
|
5840
|
+
try {
|
|
5841
|
+
const decodedLog = (0, import_viem9.decodeEventLog)({
|
|
5842
|
+
abi: import_protocol_deployments10.zoraCreator1155ImplABI,
|
|
5843
|
+
eventName: "SetupNewToken",
|
|
5844
|
+
...data
|
|
5845
|
+
});
|
|
5846
|
+
if (decodedLog && decodedLog.eventName === "SetupNewToken") {
|
|
5847
|
+
return decodedLog.args.tokenId;
|
|
5848
|
+
}
|
|
5849
|
+
} catch (err) {
|
|
5850
|
+
}
|
|
5851
|
+
}
|
|
5852
|
+
throw new Error(
|
|
5853
|
+
"No event found in receipt that could be used to get tokenId"
|
|
5854
|
+
);
|
|
5855
|
+
};
|
|
5856
|
+
var getContractAddressFromReceipt = (receipt) => {
|
|
5857
|
+
for (const data of receipt.logs) {
|
|
5858
|
+
try {
|
|
5859
|
+
const decodedLog = (0, import_viem9.decodeEventLog)({
|
|
5860
|
+
abi: import_protocol_deployments10.zoraCreator1155FactoryImplABI,
|
|
5861
|
+
eventName: "SetupNewContract",
|
|
5862
|
+
...data
|
|
5863
|
+
});
|
|
5864
|
+
if (decodedLog && decodedLog.eventName === "SetupNewContract") {
|
|
5865
|
+
return decodedLog.args.newContract;
|
|
5866
|
+
}
|
|
5867
|
+
} catch (err) {
|
|
5868
|
+
}
|
|
5869
|
+
}
|
|
5870
|
+
throw new Error(
|
|
5871
|
+
"No event found in receipt that could be used to get contract address"
|
|
5872
|
+
);
|
|
5873
|
+
};
|
|
5874
|
+
function makeCreateContractAndTokenCall({
|
|
5875
|
+
account,
|
|
5876
|
+
contract,
|
|
5877
|
+
royaltyBPS,
|
|
5878
|
+
fundsRecipient,
|
|
5879
|
+
tokenSetupActions,
|
|
5880
|
+
chainId
|
|
5881
|
+
}) {
|
|
5882
|
+
const accountAddress = typeof account === "string" ? account : account.address;
|
|
5883
|
+
return makeContractParameters({
|
|
5884
|
+
abi: import_protocol_deployments10.zoraCreator1155FactoryImplABI,
|
|
5885
|
+
functionName: "createContractDeterministic",
|
|
5886
|
+
account,
|
|
5887
|
+
address: import_protocol_deployments10.zoraCreator1155FactoryImplAddress[chainId],
|
|
5888
|
+
args: [
|
|
5889
|
+
contract.uri,
|
|
5890
|
+
contract.name,
|
|
5891
|
+
{
|
|
5892
|
+
// deprecated
|
|
5893
|
+
royaltyMintSchedule: 0,
|
|
5894
|
+
royaltyBPS: royaltyBPS || ROYALTY_BPS_DEFAULT,
|
|
5895
|
+
royaltyRecipient: fundsRecipient || accountAddress
|
|
5896
|
+
},
|
|
5897
|
+
contract.defaultAdmin || accountAddress,
|
|
5898
|
+
tokenSetupActions
|
|
5899
|
+
]
|
|
5900
|
+
});
|
|
5901
|
+
}
|
|
5902
|
+
function makeCreateTokenCall({
|
|
5903
|
+
contractAddress,
|
|
5904
|
+
account,
|
|
5905
|
+
tokenSetupActions
|
|
5906
|
+
}) {
|
|
5907
|
+
return makeContractParameters({
|
|
5908
|
+
abi: import_protocol_deployments10.zoraCreator1155ImplABI,
|
|
5909
|
+
functionName: "multicall",
|
|
5910
|
+
account,
|
|
5911
|
+
address: contractAddress,
|
|
5912
|
+
args: [tokenSetupActions]
|
|
5913
|
+
});
|
|
5914
|
+
}
|
|
5915
|
+
var Create1155Client = class {
|
|
5916
|
+
constructor({
|
|
5917
|
+
chainId,
|
|
5918
|
+
publicClient
|
|
5919
|
+
}) {
|
|
5920
|
+
this.chainId = chainId;
|
|
5921
|
+
this.publicClient = publicClient;
|
|
5922
|
+
}
|
|
5923
|
+
async createNew1155(props) {
|
|
5924
|
+
return createNew1155ContractAndToken({
|
|
5925
|
+
...props,
|
|
5926
|
+
publicClient: this.publicClient,
|
|
5927
|
+
chainId: this.chainId
|
|
5928
|
+
});
|
|
5929
|
+
}
|
|
5930
|
+
async createNew1155OnExistingContract({
|
|
5931
|
+
contractAddress: contract,
|
|
5932
|
+
account,
|
|
5933
|
+
token,
|
|
5934
|
+
getAdditionalSetupActions
|
|
5935
|
+
}) {
|
|
5936
|
+
return createNew1155Token({
|
|
5937
|
+
contractAddress: contract,
|
|
5938
|
+
account,
|
|
5939
|
+
token,
|
|
5940
|
+
getAdditionalSetupActions,
|
|
5941
|
+
publicClient: this.publicClient,
|
|
5942
|
+
chainId: this.chainId
|
|
5943
|
+
});
|
|
5944
|
+
}
|
|
5945
|
+
};
|
|
5946
|
+
async function createNew1155ContractAndToken({
|
|
5947
|
+
contract,
|
|
5948
|
+
account,
|
|
5949
|
+
chainId,
|
|
5950
|
+
token,
|
|
5951
|
+
publicClient,
|
|
5952
|
+
getAdditionalSetupActions
|
|
5953
|
+
}) {
|
|
5954
|
+
const nextTokenId = 1n;
|
|
5955
|
+
const contractVersion = new1155ContractVersion(chainId);
|
|
5956
|
+
const {
|
|
5957
|
+
minter,
|
|
5958
|
+
newToken,
|
|
5959
|
+
setupActions: tokenSetupActions
|
|
5960
|
+
} = await prepareSetupActions({
|
|
5961
|
+
chainId,
|
|
5962
|
+
account,
|
|
5963
|
+
contractVersion,
|
|
5964
|
+
nextTokenId,
|
|
5965
|
+
token,
|
|
5966
|
+
getAdditionalSetupActions
|
|
5967
|
+
});
|
|
5968
|
+
const request = makeCreateContractAndTokenCall({
|
|
5969
|
+
contract,
|
|
5970
|
+
account,
|
|
5971
|
+
chainId,
|
|
5972
|
+
tokenSetupActions,
|
|
5973
|
+
fundsRecipient: token.payoutRecipient,
|
|
5974
|
+
royaltyBPS: token.royaltyBPS
|
|
5975
|
+
});
|
|
5976
|
+
const contractAddress = await getDeterministicContractAddress({
|
|
5977
|
+
account,
|
|
5978
|
+
publicClient,
|
|
5979
|
+
setupActions: tokenSetupActions,
|
|
5980
|
+
chainId,
|
|
5981
|
+
contract
|
|
5982
|
+
});
|
|
5983
|
+
return {
|
|
5984
|
+
parameters: request,
|
|
5985
|
+
tokenSetupActions,
|
|
5986
|
+
newTokenId: nextTokenId,
|
|
5987
|
+
newToken,
|
|
5988
|
+
contractAddress,
|
|
5989
|
+
contractVersion,
|
|
5990
|
+
minter
|
|
5991
|
+
};
|
|
5992
|
+
}
|
|
5993
|
+
async function createNew1155Token({
|
|
5994
|
+
contractAddress,
|
|
5995
|
+
account,
|
|
5996
|
+
getAdditionalSetupActions,
|
|
5997
|
+
token,
|
|
5998
|
+
publicClient,
|
|
5999
|
+
chainId
|
|
6000
|
+
}) {
|
|
6001
|
+
const { nextTokenId, contractVersion } = await getContractInfoExistingContract({
|
|
6002
|
+
publicClient,
|
|
6003
|
+
contractAddress
|
|
6004
|
+
});
|
|
6005
|
+
const {
|
|
6006
|
+
minter,
|
|
6007
|
+
newToken,
|
|
6008
|
+
setupActions: tokenSetupActions
|
|
6009
|
+
} = await prepareSetupActions({
|
|
6010
|
+
chainId,
|
|
6011
|
+
account,
|
|
6012
|
+
contractVersion,
|
|
6013
|
+
nextTokenId,
|
|
6014
|
+
token,
|
|
6015
|
+
getAdditionalSetupActions
|
|
6016
|
+
});
|
|
6017
|
+
const request = makeCreateTokenCall({
|
|
6018
|
+
contractAddress,
|
|
6019
|
+
account,
|
|
6020
|
+
tokenSetupActions
|
|
6021
|
+
});
|
|
6022
|
+
return {
|
|
6023
|
+
parameters: request,
|
|
6024
|
+
tokenSetupActions,
|
|
6025
|
+
newTokenId: nextTokenId,
|
|
6026
|
+
newToken,
|
|
6027
|
+
contractVersion,
|
|
6028
|
+
minter
|
|
6029
|
+
};
|
|
6030
|
+
}
|
|
6031
|
+
async function prepareSetupActions({
|
|
6032
|
+
chainId,
|
|
6033
|
+
account,
|
|
6034
|
+
contractVersion,
|
|
6035
|
+
nextTokenId,
|
|
6036
|
+
token,
|
|
6037
|
+
getAdditionalSetupActions
|
|
6038
|
+
}) {
|
|
6039
|
+
const {
|
|
6040
|
+
minter,
|
|
6041
|
+
newToken,
|
|
6042
|
+
setupActions: tokenSetupActions
|
|
6043
|
+
} = await constructCreate1155TokenCalls({
|
|
6044
|
+
chainId,
|
|
6045
|
+
ownerAddress: account,
|
|
6046
|
+
contractVersion,
|
|
6047
|
+
nextTokenId,
|
|
6048
|
+
...token
|
|
6049
|
+
});
|
|
6050
|
+
const setupActions = getAdditionalSetupActions ? [
|
|
6051
|
+
...getAdditionalSetupActions({
|
|
6052
|
+
tokenId: nextTokenId
|
|
6053
|
+
}),
|
|
6054
|
+
...tokenSetupActions
|
|
6055
|
+
] : tokenSetupActions;
|
|
6056
|
+
return { minter, newToken, setupActions };
|
|
6057
|
+
}
|
|
6058
|
+
|
|
6059
|
+
// src/sparks/mints-queries.ts
|
|
6060
|
+
var getMintsAccountBalanceWithPriceQuery = (account) => {
|
|
6061
|
+
const query = `
|
|
6062
|
+
query GetMintAccountBalances($account: String!) {
|
|
6063
|
+
mintAccountBalances(where: { account: $account }) {
|
|
6064
|
+
balance
|
|
6065
|
+
mintToken {
|
|
6066
|
+
id
|
|
6067
|
+
pricePerToken
|
|
6068
|
+
}
|
|
6069
|
+
}
|
|
6070
|
+
}
|
|
6071
|
+
`;
|
|
6072
|
+
return {
|
|
6073
|
+
query,
|
|
6074
|
+
variables: { account }
|
|
6075
|
+
};
|
|
6076
|
+
};
|
|
6077
|
+
var selectMintsToCollectWithFromQueryResult = (mintAccountBalances, quantityToCollect) => {
|
|
6078
|
+
const parsed = mintAccountBalances.map((r) => {
|
|
6079
|
+
return {
|
|
6080
|
+
tokenId: BigInt(r.mintToken.id),
|
|
6081
|
+
quantity: BigInt(r.balance),
|
|
6082
|
+
pricePerToken: BigInt(r.mintToken.pricePerToken)
|
|
6083
|
+
};
|
|
6084
|
+
});
|
|
6085
|
+
const sorted = parsed.sort((a, b) => {
|
|
6086
|
+
if (a.pricePerToken < b.pricePerToken) {
|
|
6087
|
+
return -1;
|
|
6088
|
+
}
|
|
6089
|
+
return 1;
|
|
6090
|
+
});
|
|
6091
|
+
let remainingQuantity = quantityToCollect;
|
|
6092
|
+
const tokenIds = [];
|
|
6093
|
+
const quantities = [];
|
|
6094
|
+
while (remainingQuantity > 0) {
|
|
6095
|
+
const next = sorted.shift();
|
|
6096
|
+
if (!next) {
|
|
6097
|
+
throw new Error("Not enough MINTs to collect with");
|
|
6098
|
+
}
|
|
6099
|
+
const quantityToUse = remainingQuantity > next.quantity ? next.quantity : remainingQuantity;
|
|
6100
|
+
tokenIds.push(next.tokenId);
|
|
6101
|
+
quantities.push(quantityToUse);
|
|
6102
|
+
remainingQuantity -= quantityToUse;
|
|
6103
|
+
}
|
|
6104
|
+
return {
|
|
6105
|
+
tokenIds,
|
|
6106
|
+
quantities
|
|
6107
|
+
};
|
|
6108
|
+
};
|
|
6109
|
+
var sumBalances = (mintAccountBalances) => {
|
|
6110
|
+
return mintAccountBalances.reduce((acc, curr) => {
|
|
6111
|
+
return acc + BigInt(curr.balance);
|
|
6112
|
+
}, BigInt(0));
|
|
6113
|
+
};
|
|
6114
|
+
|
|
6115
|
+
// src/sparks/sparks-contracts.ts
|
|
6116
|
+
var import_protocol_deployments11 = require("@zoralabs/protocol-deployments");
|
|
6117
|
+
var import_viem10 = require("viem");
|
|
6118
|
+
var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
|
|
6119
|
+
var mintWithEthParams = ({
|
|
6120
|
+
tokenId,
|
|
6121
|
+
quantity,
|
|
6122
|
+
recipient,
|
|
6123
|
+
chainId,
|
|
6124
|
+
pricePerMint,
|
|
6125
|
+
account
|
|
6126
|
+
}) => makeContractParameters({
|
|
6127
|
+
abi: import_protocol_deployments11.zoraSparksManagerImplABI,
|
|
6128
|
+
address: import_protocol_deployments11.zoraSparksManagerImplAddress[chainId],
|
|
6129
|
+
functionName: "mintWithEth",
|
|
6130
|
+
args: [tokenId, quantity, recipient || addressOrAccountAddress(account)],
|
|
6131
|
+
value: pricePerMint * quantity,
|
|
6132
|
+
account
|
|
6133
|
+
});
|
|
6134
|
+
var getPaidMintValue = (quantities, pricePerMint) => {
|
|
6135
|
+
if (!pricePerMint || pricePerMint === 0n)
|
|
6136
|
+
return;
|
|
6137
|
+
return quantities.reduce((a, b) => a + b, 0n) * pricePerMint;
|
|
6138
|
+
};
|
|
6139
|
+
var mintsBalanceOfAccountParams = ({
|
|
6140
|
+
account,
|
|
6141
|
+
chainId
|
|
6142
|
+
}) => ({
|
|
6143
|
+
abi: import_protocol_deployments11.zoraMints1155Config.abi,
|
|
6144
|
+
address: import_protocol_deployments11.zoraMints1155Config.address[chainId],
|
|
6145
|
+
functionName: "balanceOfAccount",
|
|
6146
|
+
args: [account]
|
|
6147
|
+
});
|
|
6148
|
+
var encodeCollectOnManager = ({
|
|
6149
|
+
zoraCreator1155Contract,
|
|
6150
|
+
minter,
|
|
6151
|
+
zoraCreator1155TokenId,
|
|
6152
|
+
mintArguments
|
|
6153
|
+
}) => (0, import_viem10.encodeFunctionData)({
|
|
6154
|
+
abi: import_protocol_deployments11.zoraMintsManagerImplConfig.abi,
|
|
6155
|
+
functionName: "collect",
|
|
6156
|
+
args: [
|
|
6157
|
+
zoraCreator1155Contract,
|
|
6158
|
+
minter,
|
|
6159
|
+
zoraCreator1155TokenId,
|
|
6160
|
+
mintArguments
|
|
6161
|
+
]
|
|
6162
|
+
});
|
|
6163
|
+
function collectWithMintsParams({
|
|
6164
|
+
tokenIds,
|
|
6165
|
+
quantities,
|
|
6166
|
+
chainId,
|
|
6167
|
+
paidMintPricePerToken,
|
|
6168
|
+
account,
|
|
6169
|
+
mintArguments,
|
|
6170
|
+
minter,
|
|
6171
|
+
zoraCreator1155Contract,
|
|
6172
|
+
zoraCreator1155TokenId
|
|
6173
|
+
}) {
|
|
6174
|
+
const call = encodeCollectOnManager({
|
|
6175
|
+
tokenIds,
|
|
6176
|
+
quantities,
|
|
6177
|
+
zoraCreator1155Contract,
|
|
6178
|
+
zoraCreator1155TokenId,
|
|
6179
|
+
minter,
|
|
6180
|
+
mintArguments
|
|
6181
|
+
});
|
|
6182
|
+
return makeContractParameters({
|
|
6183
|
+
abi: import_protocol_deployments11.zoraMints1155Config.abi,
|
|
6184
|
+
address: import_protocol_deployments11.zoraMints1155Config.address[chainId],
|
|
6185
|
+
functionName: "transferBatchToManagerAndCall",
|
|
6186
|
+
args: [tokenIds, quantities, call],
|
|
6187
|
+
// if it is a paid mint, the aadditional value will be sent to the manager contract and forwarded to the creator 1155 contract
|
|
6188
|
+
// for the paid mint cost.
|
|
6189
|
+
value: getPaidMintValue(quantities, paidMintPricePerToken),
|
|
6190
|
+
account
|
|
6191
|
+
});
|
|
6192
|
+
}
|
|
6193
|
+
function getMintsEthPrice({
|
|
6194
|
+
publicClient
|
|
6195
|
+
}) {
|
|
6196
|
+
const chainId = publicClient.chain?.id;
|
|
6197
|
+
if (!chainId || !import_protocol_deployments11.zoraMintsManagerImplAddress[chainId]) {
|
|
6198
|
+
throw new Error(`Chain id ${chainId} not supported`);
|
|
6199
|
+
}
|
|
6200
|
+
return publicClient.readContract({
|
|
6201
|
+
abi: import_protocol_deployments11.zoraMintsManagerImplABI,
|
|
6202
|
+
address: import_protocol_deployments11.zoraMintsManagerImplAddress[chainId],
|
|
6203
|
+
functionName: "getEthPrice"
|
|
6204
|
+
});
|
|
5939
6205
|
}
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
6206
|
+
function makePermitTransferBatchAndTypeData({
|
|
6207
|
+
tokenIds,
|
|
6208
|
+
quantities,
|
|
6209
|
+
chainId,
|
|
6210
|
+
mintsOwner,
|
|
6211
|
+
to,
|
|
6212
|
+
nonce,
|
|
6213
|
+
deadline,
|
|
6214
|
+
safeTransferData
|
|
6215
|
+
}) {
|
|
6216
|
+
const permit = {
|
|
6217
|
+
owner: typeof mintsOwner === "string" ? mintsOwner : mintsOwner.address,
|
|
6218
|
+
to,
|
|
6219
|
+
tokenIds,
|
|
6220
|
+
quantities,
|
|
6221
|
+
deadline,
|
|
6222
|
+
nonce,
|
|
6223
|
+
safeTransferData
|
|
6224
|
+
};
|
|
6225
|
+
const typedData = {
|
|
6226
|
+
...(0, import_protocol_deployments11.mintsSafeTransferBatchTypedDataDefinition)({
|
|
6227
|
+
chainId,
|
|
6228
|
+
message: permit
|
|
6229
|
+
}),
|
|
6230
|
+
account: mintsOwner
|
|
6231
|
+
};
|
|
5950
6232
|
return {
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
animation_url,
|
|
5954
|
-
content,
|
|
5955
|
-
attributes
|
|
6233
|
+
permit,
|
|
6234
|
+
typedData
|
|
5956
6235
|
};
|
|
5957
|
-
}
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
6236
|
+
}
|
|
6237
|
+
function makePermitTransferTypeData({
|
|
6238
|
+
tokenId,
|
|
6239
|
+
quantity,
|
|
6240
|
+
chainId,
|
|
6241
|
+
mintsOwner,
|
|
6242
|
+
to,
|
|
6243
|
+
nonce,
|
|
6244
|
+
deadline,
|
|
6245
|
+
safeTransferData
|
|
6246
|
+
}) {
|
|
6247
|
+
const permit = {
|
|
6248
|
+
owner: typeof mintsOwner === "string" ? mintsOwner : mintsOwner.address,
|
|
6249
|
+
to,
|
|
6250
|
+
tokenId,
|
|
6251
|
+
quantity,
|
|
6252
|
+
deadline,
|
|
6253
|
+
nonce,
|
|
6254
|
+
safeTransferData
|
|
6255
|
+
};
|
|
6256
|
+
const typedData = {
|
|
6257
|
+
...(0, import_protocol_deployments11.mintsSafeTransferTypedDataDefinition)({
|
|
6258
|
+
chainId,
|
|
6259
|
+
message: permit
|
|
6260
|
+
}),
|
|
6261
|
+
account: mintsOwner
|
|
6262
|
+
};
|
|
6263
|
+
return {
|
|
6264
|
+
permit,
|
|
6265
|
+
typedData
|
|
6266
|
+
};
|
|
6267
|
+
}
|
|
6268
|
+
var encodePremintOnManager = ({
|
|
6269
|
+
contractCreationConfig,
|
|
6270
|
+
premintConfig,
|
|
6271
|
+
premintSignature,
|
|
6272
|
+
mintArguments,
|
|
6273
|
+
signerContract = import_viem10.zeroAddress
|
|
6274
|
+
}) => (0, import_viem10.encodeFunctionData)({
|
|
6275
|
+
abi: import_protocol_deployments11.zoraMintsManagerImplConfig.abi,
|
|
6276
|
+
functionName: "collectPremintV2",
|
|
6277
|
+
args: [
|
|
6278
|
+
contractCreationConfig,
|
|
6279
|
+
premintConfig,
|
|
6280
|
+
premintSignature,
|
|
6281
|
+
mintArguments,
|
|
6282
|
+
signerContract
|
|
6283
|
+
]
|
|
6284
|
+
});
|
|
6285
|
+
var makePermitToCollectPremintOrNonPremint = ({
|
|
6286
|
+
mintsOwner,
|
|
6287
|
+
chainId,
|
|
6288
|
+
deadline,
|
|
6289
|
+
tokenIds,
|
|
6290
|
+
// this quantity of MINTs will be used to collect premint
|
|
6291
|
+
// and will be burned. This same quantity is the quantity of
|
|
6292
|
+
// premint to collect.
|
|
6293
|
+
quantities,
|
|
6294
|
+
nonce,
|
|
6295
|
+
premint,
|
|
6296
|
+
collect
|
|
5964
6297
|
}) => {
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
const mediaType = mimeTypeToMedia(mimeType);
|
|
5971
|
-
let image = void 0;
|
|
5972
|
-
let animation_url = null;
|
|
5973
|
-
if (isImage(mimeType)) {
|
|
5974
|
-
image = contentUrl;
|
|
6298
|
+
let safeTransferData;
|
|
6299
|
+
if (premint) {
|
|
6300
|
+
safeTransferData = encodePremintOnManager(premint);
|
|
6301
|
+
} else if (collect) {
|
|
6302
|
+
safeTransferData = encodeCollectOnManager(collect);
|
|
5975
6303
|
} else {
|
|
5976
|
-
|
|
5977
|
-
animation_url = mediaUrl;
|
|
6304
|
+
throw new Error("Invalid operation");
|
|
5978
6305
|
}
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
6306
|
+
return makePermitTransferBatchAndTypeData({
|
|
6307
|
+
tokenIds,
|
|
6308
|
+
quantities,
|
|
6309
|
+
chainId,
|
|
6310
|
+
mintsOwner,
|
|
6311
|
+
nonce,
|
|
6312
|
+
deadline,
|
|
6313
|
+
safeTransferData,
|
|
6314
|
+
to: import_protocol_deployments11.zoraMintsManagerImplConfig.address[chainId]
|
|
6315
|
+
});
|
|
6316
|
+
};
|
|
6317
|
+
function collectPremintV2WithMintsParams({
|
|
6318
|
+
tokenIds,
|
|
6319
|
+
quantities,
|
|
6320
|
+
paidMintPricePerToken,
|
|
6321
|
+
account,
|
|
6322
|
+
chainId,
|
|
6323
|
+
...rest
|
|
6324
|
+
}) {
|
|
6325
|
+
const call = encodePremintOnManager({
|
|
6326
|
+
...rest
|
|
6327
|
+
});
|
|
6328
|
+
return makeContractParameters({
|
|
6329
|
+
abi: import_protocol_deployments11.zoraMints1155Config.abi,
|
|
6330
|
+
address: import_protocol_deployments11.zoraMints1155Config.address[chainId],
|
|
6331
|
+
functionName: "transferBatchToManagerAndCall",
|
|
6332
|
+
args: [tokenIds, quantities, call],
|
|
6333
|
+
value: getPaidMintValue(quantities, paidMintPricePerToken),
|
|
6334
|
+
account
|
|
6335
|
+
});
|
|
6336
|
+
}
|
|
6337
|
+
function decodeCallFailedError(error) {
|
|
6338
|
+
if (error.data?.errorName !== "CallFailed")
|
|
6339
|
+
throw new Error("Not a CallFailed error");
|
|
6340
|
+
const internalErrorData = error.data?.args?.[0];
|
|
6341
|
+
return (0, import_viem10.decodeErrorResult)({
|
|
6342
|
+
abi: import_protocol_deployments11.zoraMintsManagerImplABI,
|
|
6343
|
+
data: internalErrorData
|
|
6344
|
+
});
|
|
6345
|
+
}
|
|
6346
|
+
|
|
6347
|
+
// src/sdk.ts
|
|
6348
|
+
function createCreatorClient(clientConfig) {
|
|
6349
|
+
const premintClient = new PremintClient({
|
|
6350
|
+
chainId: clientConfig.chainId,
|
|
6351
|
+
publicClient: clientConfig.publicClient,
|
|
6352
|
+
premintApi: clientConfig.premintApi || new PremintAPIClient(clientConfig.chainId)
|
|
6353
|
+
});
|
|
6354
|
+
const create1155CreatorClient = new Create1155Client({
|
|
6355
|
+
chainId: clientConfig.chainId,
|
|
6356
|
+
publicClient: clientConfig.publicClient
|
|
6357
|
+
});
|
|
5985
6358
|
return {
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
attributes
|
|
6359
|
+
createPremint: (p) => premintClient.createPremint(p),
|
|
6360
|
+
updatePremint: (p) => premintClient.updatePremint(p),
|
|
6361
|
+
deletePremint: (p) => premintClient.deletePremint(p),
|
|
6362
|
+
create1155: (p) => create1155CreatorClient.createNew1155(p),
|
|
6363
|
+
create1155OnExistingContract: (p) => create1155CreatorClient.createNew1155OnExistingContract(p)
|
|
5992
6364
|
};
|
|
5993
|
-
}
|
|
6365
|
+
}
|
|
6366
|
+
function createCollectorClient(params) {
|
|
6367
|
+
const premintGetterToUse = params.premintGetter || new PremintAPIClient(params.chainId);
|
|
6368
|
+
const mintGetterToUse = params.mintGetter || new SubgraphMintGetter(params.chainId);
|
|
6369
|
+
const mintClient = new MintClient({
|
|
6370
|
+
publicClient: params.publicClient,
|
|
6371
|
+
premintGetter: premintGetterToUse,
|
|
6372
|
+
mintGetter: mintGetterToUse
|
|
6373
|
+
});
|
|
6374
|
+
return {
|
|
6375
|
+
getPremint: (p) => premintGetterToUse.get({
|
|
6376
|
+
collectionAddress: p.address,
|
|
6377
|
+
uid: p.uid
|
|
6378
|
+
}),
|
|
6379
|
+
getCollectDataFromPremintReceipt: (p) => getDataFromPremintReceipt(p, params.chainId),
|
|
6380
|
+
getToken: (p) => mintClient.get(p),
|
|
6381
|
+
getTokensOfContract: (p) => mintClient.getOfContract(p),
|
|
6382
|
+
mint: (p) => mintClient.mint(p),
|
|
6383
|
+
getMintCosts: (p) => mintClient.getMintCosts(p)
|
|
6384
|
+
};
|
|
6385
|
+
}
|
|
5994
6386
|
|
|
5995
6387
|
// src/ipfs/text-metadata.ts
|
|
5996
6388
|
var CHAR_LIMIT = 1111;
|
|
@@ -6085,6 +6477,26 @@ async function generateTextNftMetadataFiles(text) {
|
|
|
6085
6477
|
thumbnailFile
|
|
6086
6478
|
};
|
|
6087
6479
|
}
|
|
6480
|
+
|
|
6481
|
+
// src/allow-list/allow-list-client.ts
|
|
6482
|
+
var ALLOW_LIST_API_BASE = "http://allowlist.zora.co/";
|
|
6483
|
+
var createAllowList = async ({
|
|
6484
|
+
allowList,
|
|
6485
|
+
httpClient: httpClient2 = httpClient,
|
|
6486
|
+
baseUrl = ALLOW_LIST_API_BASE
|
|
6487
|
+
}) => {
|
|
6488
|
+
const { post: post2, retries: retries2 } = httpClient2;
|
|
6489
|
+
const data = {
|
|
6490
|
+
entries: allowList.entries.map((entry) => ({
|
|
6491
|
+
user: entry.user,
|
|
6492
|
+
maxCanMint: entry.maxCanMint,
|
|
6493
|
+
price: entry.price.toString()
|
|
6494
|
+
}))
|
|
6495
|
+
};
|
|
6496
|
+
return (await retries2(
|
|
6497
|
+
() => post2(`${baseUrl}allowlist`, data)
|
|
6498
|
+
)).root;
|
|
6499
|
+
};
|
|
6088
6500
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6089
6501
|
0 && (module.exports = {
|
|
6090
6502
|
Create1155Client,
|
|
@@ -6097,7 +6509,6 @@ async function generateTextNftMetadataFiles(text) {
|
|
|
6097
6509
|
ZORA_API_BASE,
|
|
6098
6510
|
applyUpdateToPremint,
|
|
6099
6511
|
buildPremintMintCall,
|
|
6100
|
-
collectOnchain,
|
|
6101
6512
|
collectPremint,
|
|
6102
6513
|
collectPremintV2WithMintsParams,
|
|
6103
6514
|
collectWithMintsParams,
|
|
@@ -6105,6 +6516,7 @@ async function generateTextNftMetadataFiles(text) {
|
|
|
6105
6516
|
convertGetPremintApiResponse,
|
|
6106
6517
|
convertGetPremintOfCollectionApiResponse,
|
|
6107
6518
|
convertPremintFromApi,
|
|
6519
|
+
createAllowList,
|
|
6108
6520
|
createCollectorClient,
|
|
6109
6521
|
createCreatorClient,
|
|
6110
6522
|
decodeCallFailedError,
|
|
@@ -6117,6 +6529,7 @@ async function generateTextNftMetadataFiles(text) {
|
|
|
6117
6529
|
encodePremintForAPI,
|
|
6118
6530
|
generateTextNftMetadataFiles,
|
|
6119
6531
|
getApiNetworkConfigForChain,
|
|
6532
|
+
getContractAddressFromReceipt,
|
|
6120
6533
|
getDataFromPremintReceipt,
|
|
6121
6534
|
getDefaultFixedPriceMinterAddress,
|
|
6122
6535
|
getMintsAccountBalanceWithPriceQuery,
|
|
@@ -6134,6 +6547,7 @@ async function generateTextNftMetadataFiles(text) {
|
|
|
6134
6547
|
isPremintConfigV1,
|
|
6135
6548
|
isPremintConfigV2,
|
|
6136
6549
|
isValidSignature,
|
|
6550
|
+
makeCreateContractAndTokenCall,
|
|
6137
6551
|
makeMediaTokenMetadata,
|
|
6138
6552
|
makeMintRewardsRecipient,
|
|
6139
6553
|
makeNewPremint,
|