@zoralabs/protocol-sdk 0.5.4-MINT.0 → 0.5.4
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 -6
- package/CHANGELOG.md +2 -5
- package/dist/apis/chain-constants.d.ts +0 -1
- package/dist/apis/chain-constants.d.ts.map +1 -1
- package/dist/index.cjs +4 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -83
- package/dist/index.js.map +1 -1
- package/package.json +16 -9
- package/src/apis/chain-constants.ts +0 -10
- package/src/index.ts +0 -2
- package/dist/mints/mints-queries.d.ts +0 -44
- package/dist/mints/mints-queries.d.ts.map +0 -1
- package/src/mints/mints-queries.test.ts +0 -78
- package/src/mints/mints-queries.ts +0 -121
package/dist/index.js
CHANGED
|
@@ -502,13 +502,6 @@ var networkConfigByChain = {
|
|
|
502
502
|
subgraphUrl: getSubgraph("zora-create-zora-testnet", "stable")
|
|
503
503
|
}
|
|
504
504
|
};
|
|
505
|
-
var getSubgraphUrl = (chainId) => {
|
|
506
|
-
const networkConfig = networkConfigByChain[chainId];
|
|
507
|
-
if (!networkConfig) {
|
|
508
|
-
throw new Error(`Network not configured for chain id ${chainId}`);
|
|
509
|
-
}
|
|
510
|
-
return networkConfig.subgraphUrl;
|
|
511
|
-
};
|
|
512
505
|
|
|
513
506
|
// src/mint/mint-api-client.ts
|
|
514
507
|
var getApiNetworkConfigForChain = (chainId) => {
|
|
@@ -1581,7 +1574,7 @@ function create1155CreatorClient({
|
|
|
1581
1574
|
throw new Error("Invariant: contract cannot be missing and an address");
|
|
1582
1575
|
}
|
|
1583
1576
|
if (!contractExists && typeof contract !== "string") {
|
|
1584
|
-
const
|
|
1577
|
+
const request = {
|
|
1585
1578
|
abi: zoraCreator1155FactoryImplABI,
|
|
1586
1579
|
functionName: "createContractDeterministic",
|
|
1587
1580
|
account,
|
|
@@ -1600,13 +1593,13 @@ function create1155CreatorClient({
|
|
|
1600
1593
|
]
|
|
1601
1594
|
};
|
|
1602
1595
|
return {
|
|
1603
|
-
request
|
|
1596
|
+
request,
|
|
1604
1597
|
tokenSetupActions,
|
|
1605
1598
|
contractAddress,
|
|
1606
1599
|
contractExists
|
|
1607
1600
|
};
|
|
1608
1601
|
} else if (contractExists) {
|
|
1609
|
-
const
|
|
1602
|
+
const request = {
|
|
1610
1603
|
abi: zoraCreator1155ImplABI3,
|
|
1611
1604
|
functionName: "multicall",
|
|
1612
1605
|
account,
|
|
@@ -1614,7 +1607,7 @@ function create1155CreatorClient({
|
|
|
1614
1607
|
args: [tokenSetupActions]
|
|
1615
1608
|
};
|
|
1616
1609
|
return {
|
|
1617
|
-
request
|
|
1610
|
+
request,
|
|
1618
1611
|
tokenSetupActions,
|
|
1619
1612
|
contractAddress,
|
|
1620
1613
|
contractExists
|
|
@@ -1624,75 +1617,6 @@ function create1155CreatorClient({
|
|
|
1624
1617
|
}
|
|
1625
1618
|
return { createNew1155Token };
|
|
1626
1619
|
}
|
|
1627
|
-
|
|
1628
|
-
// src/mints/mints-queries.ts
|
|
1629
|
-
import { request, gql } from "graphql-request";
|
|
1630
|
-
var getMintsAccountBalanceQuery = (account) => {
|
|
1631
|
-
const query = gql`
|
|
1632
|
-
query GetMintAccountBalances($account: String!) {
|
|
1633
|
-
mintTokenBalances(where: { account: $account }) {
|
|
1634
|
-
balance
|
|
1635
|
-
mintToken {
|
|
1636
|
-
id
|
|
1637
|
-
pricePerToken
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
}
|
|
1641
|
-
`;
|
|
1642
|
-
return {
|
|
1643
|
-
query,
|
|
1644
|
-
variables: { account }
|
|
1645
|
-
};
|
|
1646
|
-
};
|
|
1647
|
-
var selectMintsToCollectWithFromQueryResult = (mintAccountBalances, quantityToCollect) => {
|
|
1648
|
-
const parsed = mintAccountBalances.map((r) => {
|
|
1649
|
-
return {
|
|
1650
|
-
tokenId: BigInt(r.mintToken.id),
|
|
1651
|
-
quantity: BigInt(r.balance),
|
|
1652
|
-
pricePerToken: BigInt(r.mintToken.pricePerToken)
|
|
1653
|
-
};
|
|
1654
|
-
});
|
|
1655
|
-
const sorted = parsed.sort((a, b) => {
|
|
1656
|
-
if (a.pricePerToken < b.pricePerToken) {
|
|
1657
|
-
return -1;
|
|
1658
|
-
}
|
|
1659
|
-
return 1;
|
|
1660
|
-
});
|
|
1661
|
-
let remainingQuantity = quantityToCollect;
|
|
1662
|
-
const tokenIds = [];
|
|
1663
|
-
const quantities = [];
|
|
1664
|
-
while (remainingQuantity > 0) {
|
|
1665
|
-
const next = sorted.shift();
|
|
1666
|
-
if (!next) {
|
|
1667
|
-
throw new Error("Not enough MINTs to collect with");
|
|
1668
|
-
}
|
|
1669
|
-
const quantityToUse = remainingQuantity > next.quantity ? next.quantity : remainingQuantity;
|
|
1670
|
-
tokenIds.push(next.tokenId);
|
|
1671
|
-
quantities.push(quantityToUse);
|
|
1672
|
-
remainingQuantity -= quantityToUse;
|
|
1673
|
-
}
|
|
1674
|
-
return {
|
|
1675
|
-
tokenIds,
|
|
1676
|
-
quantities
|
|
1677
|
-
};
|
|
1678
|
-
};
|
|
1679
|
-
var getMINTsToCollectWith = async ({
|
|
1680
|
-
account,
|
|
1681
|
-
chainId,
|
|
1682
|
-
quantityToCollect
|
|
1683
|
-
}) => {
|
|
1684
|
-
const subgraphUrl = getSubgraphUrl(chainId);
|
|
1685
|
-
const { query, variables } = getMintsAccountBalanceQuery(account);
|
|
1686
|
-
const result = await request(
|
|
1687
|
-
subgraphUrl,
|
|
1688
|
-
query,
|
|
1689
|
-
variables
|
|
1690
|
-
);
|
|
1691
|
-
return selectMintsToCollectWithFromQueryResult(
|
|
1692
|
-
result.mintTokenBalances,
|
|
1693
|
-
quantityToCollect
|
|
1694
|
-
);
|
|
1695
|
-
};
|
|
1696
1620
|
export {
|
|
1697
1621
|
DEFAULT_SALE_SETTINGS,
|
|
1698
1622
|
Errors,
|
|
@@ -1715,9 +1639,7 @@ export {
|
|
|
1715
1639
|
encodePremintForAPI,
|
|
1716
1640
|
getApiNetworkConfigForChain,
|
|
1717
1641
|
getDefaultFixedPriceMinterAddress,
|
|
1718
|
-
getMINTsToCollectWith,
|
|
1719
1642
|
getMintCosts,
|
|
1720
|
-
getMintsAccountBalanceQuery,
|
|
1721
1643
|
getPremintCollectionAddress,
|
|
1722
1644
|
getPremintExecutorAddress,
|
|
1723
1645
|
getPremintMintCosts,
|
|
@@ -1733,7 +1655,6 @@ export {
|
|
|
1733
1655
|
premintTypedDataDefinition,
|
|
1734
1656
|
recoverCreatorFromCreatorAttribution,
|
|
1735
1657
|
recoverPremintSigner,
|
|
1736
|
-
selectMintsToCollectWithFromQueryResult,
|
|
1737
1658
|
supportedPremintVersions,
|
|
1738
1659
|
supportsPremintVersion,
|
|
1739
1660
|
tryRecoverPremintSigner,
|