@zoralabs/protocol-sdk 0.5.7-MINT.4 → 0.5.8-DEV.1
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/CHANGELOG.md +13 -15
- package/README.md +2 -2
- package/dist/apis/chain-constants.d.ts.map +1 -1
- package/dist/apis/generated/premint-api-types.d.ts +1 -1
- package/dist/apis/generated/premint-api-types.d.ts.map +1 -1
- package/dist/index.cjs +310 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +308 -29
- package/dist/index.js.map +1 -1
- package/dist/mints/mints-contracts.d.ts +1273 -0
- package/dist/mints/mints-contracts.d.ts.map +1 -0
- package/dist/premint/premint-client.d.ts +1 -1
- package/package.json +3 -3
- package/src/apis/chain-constants.ts +12 -28
- package/src/apis/generated/premint-api-types.ts +3 -1
- package/src/index.ts +2 -0
- package/src/mints/mints-contracts.ts +408 -0
- package/src/premint/premint-client.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -417,16 +417,14 @@ var zora721Abi = parseAbi([
|
|
|
417
417
|
|
|
418
418
|
// src/apis/chain-constants.ts
|
|
419
419
|
import {
|
|
420
|
+
arbitrum,
|
|
420
421
|
base,
|
|
421
|
-
baseGoerli,
|
|
422
422
|
foundry,
|
|
423
|
-
goerli,
|
|
424
423
|
mainnet,
|
|
425
424
|
optimism,
|
|
426
|
-
|
|
425
|
+
sepolia,
|
|
427
426
|
zora,
|
|
428
|
-
zoraSepolia
|
|
429
|
-
zoraTestnet
|
|
427
|
+
zoraSepolia
|
|
430
428
|
} from "viem/chains";
|
|
431
429
|
import { parseEther as parseEther2 } from "viem";
|
|
432
430
|
var REWARD_PER_TOKEN = parseEther2("0.000777");
|
|
@@ -438,12 +436,12 @@ var networkConfigByChain = {
|
|
|
438
436
|
zoraBackendChainName: "ETHEREUM-MAINNET",
|
|
439
437
|
subgraphUrl: getSubgraph("zora-create-mainnet", "stable")
|
|
440
438
|
},
|
|
441
|
-
[
|
|
442
|
-
chainId:
|
|
439
|
+
[sepolia.id]: {
|
|
440
|
+
chainId: sepolia.id,
|
|
443
441
|
isTestnet: true,
|
|
444
|
-
zoraCollectPathChainName: "
|
|
445
|
-
zoraBackendChainName: "ETHEREUM-
|
|
446
|
-
subgraphUrl: getSubgraph("zora-create-
|
|
442
|
+
zoraCollectPathChainName: "sep",
|
|
443
|
+
zoraBackendChainName: "ETHEREUM-SEPOLIA",
|
|
444
|
+
subgraphUrl: getSubgraph("zora-create-sepolia", "stable")
|
|
447
445
|
},
|
|
448
446
|
[zora.id]: {
|
|
449
447
|
chainId: zora.id,
|
|
@@ -452,13 +450,6 @@ var networkConfigByChain = {
|
|
|
452
450
|
zoraBackendChainName: "ZORA-MAINNET",
|
|
453
451
|
subgraphUrl: getSubgraph("zora-create-zora-mainnet", "stable")
|
|
454
452
|
},
|
|
455
|
-
[zoraTestnet.id]: {
|
|
456
|
-
chainId: zoraTestnet.id,
|
|
457
|
-
isTestnet: true,
|
|
458
|
-
zoraCollectPathChainName: "zgor",
|
|
459
|
-
zoraBackendChainName: "ZORA-GOERLI",
|
|
460
|
-
subgraphUrl: getSubgraph("zora-create-zora-testnet", "stable")
|
|
461
|
-
},
|
|
462
453
|
[zoraSepolia.id]: {
|
|
463
454
|
chainId: zoraSepolia.id,
|
|
464
455
|
isTestnet: true,
|
|
@@ -473,12 +464,12 @@ var networkConfigByChain = {
|
|
|
473
464
|
zoraBackendChainName: "OPTIMISM-MAINNET",
|
|
474
465
|
subgraphUrl: getSubgraph("zora-create-optimism", "stable")
|
|
475
466
|
},
|
|
476
|
-
[
|
|
477
|
-
chainId:
|
|
467
|
+
[arbitrum.id]: {
|
|
468
|
+
chainId: arbitrum.id,
|
|
478
469
|
isTestnet: true,
|
|
479
|
-
zoraCollectPathChainName: "
|
|
480
|
-
zoraBackendChainName: "
|
|
481
|
-
subgraphUrl: getSubgraph("zora-create-
|
|
470
|
+
zoraCollectPathChainName: "arb",
|
|
471
|
+
zoraBackendChainName: "ARBITRUM-MAINNET",
|
|
472
|
+
subgraphUrl: getSubgraph("zora-create-arbitrum-one", "stable")
|
|
482
473
|
},
|
|
483
474
|
[base.id]: {
|
|
484
475
|
chainId: base.id,
|
|
@@ -487,13 +478,6 @@ var networkConfigByChain = {
|
|
|
487
478
|
zoraBackendChainName: "BASE-MAINNET",
|
|
488
479
|
subgraphUrl: getSubgraph("zora-create-base-mainnet", "stable")
|
|
489
480
|
},
|
|
490
|
-
[baseGoerli.id]: {
|
|
491
|
-
chainId: baseGoerli.id,
|
|
492
|
-
isTestnet: true,
|
|
493
|
-
zoraCollectPathChainName: "bgor",
|
|
494
|
-
zoraBackendChainName: "BASE-GOERLI",
|
|
495
|
-
subgraphUrl: getSubgraph("zora-create-base-goerli", "stable")
|
|
496
|
-
},
|
|
497
481
|
[foundry.id]: {
|
|
498
482
|
chainId: foundry.id,
|
|
499
483
|
isTestnet: true,
|
|
@@ -1711,6 +1695,290 @@ var getMINTsBalance = async ({
|
|
|
1711
1695
|
);
|
|
1712
1696
|
return sumBalances(result.mintTokenBalances);
|
|
1713
1697
|
};
|
|
1698
|
+
|
|
1699
|
+
// src/mints/mints-contracts.ts
|
|
1700
|
+
import {
|
|
1701
|
+
zoraMints1155Config,
|
|
1702
|
+
zoraMintsManagerImplConfig
|
|
1703
|
+
} from "@zoralabs/protocol-deployments";
|
|
1704
|
+
import {
|
|
1705
|
+
encodeFunctionData as encodeFunctionData2,
|
|
1706
|
+
zeroAddress as zeroAddress5
|
|
1707
|
+
} from "viem";
|
|
1708
|
+
function mintWithEthParams({
|
|
1709
|
+
quantity,
|
|
1710
|
+
recipient,
|
|
1711
|
+
chainId,
|
|
1712
|
+
pricePerMint,
|
|
1713
|
+
account
|
|
1714
|
+
}) {
|
|
1715
|
+
return {
|
|
1716
|
+
abi: zoraMintsManagerImplConfig.abi,
|
|
1717
|
+
address: zoraMintsManagerImplConfig.address[chainId],
|
|
1718
|
+
functionName: "mintWithEth",
|
|
1719
|
+
args: [quantity, recipient],
|
|
1720
|
+
value: pricePerMint * quantity,
|
|
1721
|
+
account
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
var getPaidMintValue = (quantities, pricePerMint) => {
|
|
1725
|
+
if (!pricePerMint || pricePerMint === 0n)
|
|
1726
|
+
return;
|
|
1727
|
+
return quantities.reduce((a, b) => a + b, 0n) * pricePerMint;
|
|
1728
|
+
};
|
|
1729
|
+
var mintsBalanceOfAccountParams = ({
|
|
1730
|
+
account,
|
|
1731
|
+
chainId
|
|
1732
|
+
}) => ({
|
|
1733
|
+
abi: zoraMints1155Config.abi,
|
|
1734
|
+
address: zoraMints1155Config.address[chainId],
|
|
1735
|
+
functionName: "balanceOfAccount",
|
|
1736
|
+
args: [account]
|
|
1737
|
+
});
|
|
1738
|
+
var accountNonceParams = ({
|
|
1739
|
+
chainId,
|
|
1740
|
+
account
|
|
1741
|
+
}) => ({
|
|
1742
|
+
abi: zoraMints1155Config.abi,
|
|
1743
|
+
address: zoraMints1155Config.address[chainId],
|
|
1744
|
+
functionName: "nonces",
|
|
1745
|
+
args: [account]
|
|
1746
|
+
});
|
|
1747
|
+
var encodeCollectOnManager = ({
|
|
1748
|
+
tokenIds,
|
|
1749
|
+
quantities,
|
|
1750
|
+
zoraCreator1155Contract,
|
|
1751
|
+
minter,
|
|
1752
|
+
zoraCreator1155TokenId,
|
|
1753
|
+
mintArguments
|
|
1754
|
+
}) => encodeFunctionData2({
|
|
1755
|
+
abi: zoraMintsManagerImplConfig.abi,
|
|
1756
|
+
functionName: "collect",
|
|
1757
|
+
args: [
|
|
1758
|
+
tokenIds,
|
|
1759
|
+
quantities,
|
|
1760
|
+
zoraCreator1155Contract,
|
|
1761
|
+
minter,
|
|
1762
|
+
zoraCreator1155TokenId,
|
|
1763
|
+
mintArguments
|
|
1764
|
+
]
|
|
1765
|
+
});
|
|
1766
|
+
function collectWithMintsParams({
|
|
1767
|
+
tokenIds,
|
|
1768
|
+
quantities,
|
|
1769
|
+
chainId,
|
|
1770
|
+
pricePerToken,
|
|
1771
|
+
account,
|
|
1772
|
+
...rest
|
|
1773
|
+
}) {
|
|
1774
|
+
const call = encodeCollectOnManager({
|
|
1775
|
+
tokenIds,
|
|
1776
|
+
quantities,
|
|
1777
|
+
...rest
|
|
1778
|
+
});
|
|
1779
|
+
return {
|
|
1780
|
+
abi: zoraMints1155Config.abi,
|
|
1781
|
+
address: zoraMints1155Config.address[chainId],
|
|
1782
|
+
functionName: "transferBatchToManagerAndCall",
|
|
1783
|
+
args: [tokenIds, quantities, "0x", call],
|
|
1784
|
+
value: getPaidMintValue(quantities, pricePerToken),
|
|
1785
|
+
account
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
var collectWithMintsTypedDataDefinition = ({
|
|
1789
|
+
tokenIds,
|
|
1790
|
+
quantities,
|
|
1791
|
+
chainId,
|
|
1792
|
+
account,
|
|
1793
|
+
nonce,
|
|
1794
|
+
deadline,
|
|
1795
|
+
...rest
|
|
1796
|
+
}) => {
|
|
1797
|
+
const call = encodeCollectOnManager({
|
|
1798
|
+
tokenIds,
|
|
1799
|
+
quantities,
|
|
1800
|
+
...rest
|
|
1801
|
+
});
|
|
1802
|
+
return makePermitAndTypeData({
|
|
1803
|
+
tokenIds,
|
|
1804
|
+
quantities,
|
|
1805
|
+
chainId,
|
|
1806
|
+
account,
|
|
1807
|
+
nonce,
|
|
1808
|
+
deadline,
|
|
1809
|
+
call
|
|
1810
|
+
});
|
|
1811
|
+
};
|
|
1812
|
+
var collectPremintWithMintsTypedDataDefinition = ({
|
|
1813
|
+
tokenIds,
|
|
1814
|
+
quantities,
|
|
1815
|
+
chainId,
|
|
1816
|
+
account,
|
|
1817
|
+
nonce,
|
|
1818
|
+
deadline,
|
|
1819
|
+
...rest
|
|
1820
|
+
}) => {
|
|
1821
|
+
const call = encodePremintOnManager({
|
|
1822
|
+
tokenIds,
|
|
1823
|
+
quantities,
|
|
1824
|
+
...rest
|
|
1825
|
+
});
|
|
1826
|
+
return makePermitAndTypeData({
|
|
1827
|
+
tokenIds,
|
|
1828
|
+
quantities,
|
|
1829
|
+
chainId,
|
|
1830
|
+
account,
|
|
1831
|
+
nonce,
|
|
1832
|
+
deadline,
|
|
1833
|
+
call
|
|
1834
|
+
});
|
|
1835
|
+
};
|
|
1836
|
+
function makePermitAndTypeData({
|
|
1837
|
+
tokenIds,
|
|
1838
|
+
quantities,
|
|
1839
|
+
chainId,
|
|
1840
|
+
account,
|
|
1841
|
+
nonce,
|
|
1842
|
+
deadline,
|
|
1843
|
+
call
|
|
1844
|
+
}) {
|
|
1845
|
+
const permit = {
|
|
1846
|
+
owner: typeof account === "string" ? account : account.address,
|
|
1847
|
+
tokenIds,
|
|
1848
|
+
quantities,
|
|
1849
|
+
call,
|
|
1850
|
+
deadline,
|
|
1851
|
+
safeTransferData: "0x"
|
|
1852
|
+
};
|
|
1853
|
+
const typedData = permitTypedDataDefinition({
|
|
1854
|
+
chainId,
|
|
1855
|
+
nonce,
|
|
1856
|
+
permit,
|
|
1857
|
+
account
|
|
1858
|
+
});
|
|
1859
|
+
return {
|
|
1860
|
+
permit,
|
|
1861
|
+
typedData
|
|
1862
|
+
};
|
|
1863
|
+
}
|
|
1864
|
+
var encodePremintOnManager = ({
|
|
1865
|
+
tokenIds,
|
|
1866
|
+
quantities,
|
|
1867
|
+
contractCreationConfig,
|
|
1868
|
+
premintConfig,
|
|
1869
|
+
premintSignature,
|
|
1870
|
+
mintArguments,
|
|
1871
|
+
signerContract = zeroAddress5
|
|
1872
|
+
}) => encodeFunctionData2({
|
|
1873
|
+
abi: zoraMintsManagerImplConfig.abi,
|
|
1874
|
+
functionName: "collectPremintV2",
|
|
1875
|
+
args: [
|
|
1876
|
+
tokenIds,
|
|
1877
|
+
quantities,
|
|
1878
|
+
contractCreationConfig,
|
|
1879
|
+
premintConfig,
|
|
1880
|
+
premintSignature,
|
|
1881
|
+
mintArguments,
|
|
1882
|
+
signerContract
|
|
1883
|
+
]
|
|
1884
|
+
});
|
|
1885
|
+
function collectPremintV2WithMintsParams({
|
|
1886
|
+
tokenIds,
|
|
1887
|
+
quantities,
|
|
1888
|
+
pricePerToken,
|
|
1889
|
+
account,
|
|
1890
|
+
chainId,
|
|
1891
|
+
...rest
|
|
1892
|
+
}) {
|
|
1893
|
+
const call = encodePremintOnManager({
|
|
1894
|
+
tokenIds,
|
|
1895
|
+
quantities,
|
|
1896
|
+
...rest
|
|
1897
|
+
});
|
|
1898
|
+
return {
|
|
1899
|
+
abi: zoraMints1155Config.abi,
|
|
1900
|
+
address: zoraMints1155Config.address[chainId],
|
|
1901
|
+
functionName: "transferBatchToManagerAndCall",
|
|
1902
|
+
args: [tokenIds, quantities, "0x", call],
|
|
1903
|
+
value: getPaidMintValue(quantities, pricePerToken),
|
|
1904
|
+
account
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1907
|
+
function makeTypeData(args) {
|
|
1908
|
+
return args;
|
|
1909
|
+
}
|
|
1910
|
+
function permitTypedDataDefinition({
|
|
1911
|
+
permit,
|
|
1912
|
+
chainId,
|
|
1913
|
+
nonce,
|
|
1914
|
+
account
|
|
1915
|
+
}) {
|
|
1916
|
+
return makeTypeData({
|
|
1917
|
+
primaryType: "Permit",
|
|
1918
|
+
types: {
|
|
1919
|
+
Permit: [
|
|
1920
|
+
{
|
|
1921
|
+
name: "owner",
|
|
1922
|
+
type: "address"
|
|
1923
|
+
},
|
|
1924
|
+
{
|
|
1925
|
+
name: "tokenIds",
|
|
1926
|
+
type: "uint256[]"
|
|
1927
|
+
},
|
|
1928
|
+
{
|
|
1929
|
+
name: "quantities",
|
|
1930
|
+
type: "uint256[]"
|
|
1931
|
+
},
|
|
1932
|
+
{
|
|
1933
|
+
name: "safeTransferData",
|
|
1934
|
+
type: "bytes"
|
|
1935
|
+
},
|
|
1936
|
+
{
|
|
1937
|
+
name: "call",
|
|
1938
|
+
type: "bytes"
|
|
1939
|
+
},
|
|
1940
|
+
{
|
|
1941
|
+
name: "nonce",
|
|
1942
|
+
type: "uint256"
|
|
1943
|
+
},
|
|
1944
|
+
{
|
|
1945
|
+
name: "deadline",
|
|
1946
|
+
type: "uint256"
|
|
1947
|
+
}
|
|
1948
|
+
]
|
|
1949
|
+
},
|
|
1950
|
+
message: {
|
|
1951
|
+
owner: permit.owner,
|
|
1952
|
+
tokenIds: permit.tokenIds,
|
|
1953
|
+
quantities: permit.quantities,
|
|
1954
|
+
safeTransferData: permit.safeTransferData,
|
|
1955
|
+
call: permit.call,
|
|
1956
|
+
nonce,
|
|
1957
|
+
deadline: permit.deadline
|
|
1958
|
+
},
|
|
1959
|
+
domain: {
|
|
1960
|
+
chainId,
|
|
1961
|
+
name: "Mints",
|
|
1962
|
+
version: "1",
|
|
1963
|
+
verifyingContract: zoraMints1155Config.address[chainId]
|
|
1964
|
+
},
|
|
1965
|
+
// signing account must be permit owner
|
|
1966
|
+
account
|
|
1967
|
+
});
|
|
1968
|
+
}
|
|
1969
|
+
var permitTransferBatchToManagerAndCallParams = ({
|
|
1970
|
+
permit,
|
|
1971
|
+
chainId,
|
|
1972
|
+
signature
|
|
1973
|
+
}) => {
|
|
1974
|
+
const result = {
|
|
1975
|
+
abi: zoraMints1155Config.abi,
|
|
1976
|
+
address: zoraMints1155Config.address[chainId],
|
|
1977
|
+
functionName: "permitTransferBatchToManagerAndCall",
|
|
1978
|
+
args: [permit, signature]
|
|
1979
|
+
};
|
|
1980
|
+
return result;
|
|
1981
|
+
};
|
|
1714
1982
|
export {
|
|
1715
1983
|
DEFAULT_SALE_SETTINGS,
|
|
1716
1984
|
Errors,
|
|
@@ -1719,7 +1987,12 @@ export {
|
|
|
1719
1987
|
PremintConfigVersion,
|
|
1720
1988
|
PreminterDomain,
|
|
1721
1989
|
ZORA_API_BASE,
|
|
1990
|
+
accountNonceParams,
|
|
1722
1991
|
applyUpdateToPremint,
|
|
1992
|
+
collectPremintV2WithMintsParams,
|
|
1993
|
+
collectPremintWithMintsTypedDataDefinition,
|
|
1994
|
+
collectWithMintsParams,
|
|
1995
|
+
collectWithMintsTypedDataDefinition,
|
|
1723
1996
|
convertCollectionFromApi,
|
|
1724
1997
|
convertGetPremintApiResponse,
|
|
1725
1998
|
convertPremintFromApi,
|
|
@@ -1729,8 +2002,10 @@ export {
|
|
|
1729
2002
|
createPremintClient,
|
|
1730
2003
|
defaultTokenConfigV1MintArguments,
|
|
1731
2004
|
defaultTokenConfigV2MintArguments,
|
|
2005
|
+
encodeCollectOnManager,
|
|
1732
2006
|
encodePostSignatureInput,
|
|
1733
2007
|
encodePremintForAPI,
|
|
2008
|
+
encodePremintOnManager,
|
|
1734
2009
|
getApiNetworkConfigForChain,
|
|
1735
2010
|
getDefaultFixedPriceMinterAddress,
|
|
1736
2011
|
getMINTsBalance,
|
|
@@ -1749,6 +2024,10 @@ export {
|
|
|
1749
2024
|
makeNewPremint,
|
|
1750
2025
|
markPremintDeleted,
|
|
1751
2026
|
migratePremintConfigToV2,
|
|
2027
|
+
mintWithEthParams,
|
|
2028
|
+
mintsBalanceOfAccountParams,
|
|
2029
|
+
permitTransferBatchToManagerAndCallParams,
|
|
2030
|
+
permitTypedDataDefinition,
|
|
1752
2031
|
premintTypedDataDefinition,
|
|
1753
2032
|
recoverCreatorFromCreatorAttribution,
|
|
1754
2033
|
recoverPremintSigner,
|