@zoralabs/protocol-sdk 0.5.8-DEV.2 → 0.5.8
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 +15 -0
- package/CHANGELOG.md +5 -12
- package/dist/index.cjs +218 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +218 -50
- package/dist/index.js.map +1 -1
- package/dist/mints/mints-contracts.d.ts +2849 -74
- package/dist/mints/mints-contracts.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/create/1155-create-helper.test.ts +104 -0
- package/src/mint/mint-client.test.ts +114 -0
- package/src/mints/mints-contracts.test.ts +719 -0
- package/src/mints/mints-contracts.ts +310 -63
- package/src/mints/mints-queries.test.ts +105 -0
- package/src/premint/premint-client.test.ts +239 -0
- package/src/premint/preminter.test.ts +619 -0
- package/test-integration/premint-client.test.ts +146 -0
- package/tsconfig.build.json +10 -0
- package/tsup.config.ts +12 -0
package/dist/index.js
CHANGED
|
@@ -1699,10 +1699,16 @@ var getMINTsBalance = async ({
|
|
|
1699
1699
|
// src/mints/mints-contracts.ts
|
|
1700
1700
|
import {
|
|
1701
1701
|
zoraMints1155Config,
|
|
1702
|
-
|
|
1702
|
+
zoraMintsManagerImplABI,
|
|
1703
|
+
zoraMintsManagerImplConfig,
|
|
1704
|
+
mintsEthUnwrapperAndCallerConfig,
|
|
1705
|
+
iUnwrapAndForwardActionABI
|
|
1703
1706
|
} from "@zoralabs/protocol-deployments";
|
|
1704
1707
|
import {
|
|
1708
|
+
decodeErrorResult,
|
|
1709
|
+
encodeAbiParameters as encodeAbiParameters2,
|
|
1705
1710
|
encodeFunctionData as encodeFunctionData2,
|
|
1711
|
+
parseAbiParameters as parseAbiParameters2,
|
|
1706
1712
|
zeroAddress as zeroAddress5
|
|
1707
1713
|
} from "viem";
|
|
1708
1714
|
function mintWithEthParams({
|
|
@@ -1726,6 +1732,9 @@ var getPaidMintValue = (quantities, pricePerMint) => {
|
|
|
1726
1732
|
return;
|
|
1727
1733
|
return quantities.reduce((a, b) => a + b, 0n) * pricePerMint;
|
|
1728
1734
|
};
|
|
1735
|
+
var fixedPriceMinterMinterArguments = ({
|
|
1736
|
+
mintRecipient
|
|
1737
|
+
}) => encodeAbiParameters2(parseAbiParameters2("address"), [mintRecipient]);
|
|
1729
1738
|
var mintsBalanceOfAccountParams = ({
|
|
1730
1739
|
account,
|
|
1731
1740
|
chainId
|
|
@@ -1735,18 +1744,7 @@ var mintsBalanceOfAccountParams = ({
|
|
|
1735
1744
|
functionName: "balanceOfAccount",
|
|
1736
1745
|
args: [account]
|
|
1737
1746
|
});
|
|
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
1747
|
var encodeCollectOnManager = ({
|
|
1748
|
-
tokenIds,
|
|
1749
|
-
quantities,
|
|
1750
1748
|
zoraCreator1155Contract,
|
|
1751
1749
|
minter,
|
|
1752
1750
|
zoraCreator1155TokenId,
|
|
@@ -1755,8 +1753,6 @@ var encodeCollectOnManager = ({
|
|
|
1755
1753
|
abi: zoraMintsManagerImplConfig.abi,
|
|
1756
1754
|
functionName: "collect",
|
|
1757
1755
|
args: [
|
|
1758
|
-
tokenIds,
|
|
1759
|
-
quantities,
|
|
1760
1756
|
zoraCreator1155Contract,
|
|
1761
1757
|
minter,
|
|
1762
1758
|
zoraCreator1155TokenId,
|
|
@@ -1780,7 +1776,7 @@ function collectWithMintsParams({
|
|
|
1780
1776
|
abi: zoraMints1155Config.abi,
|
|
1781
1777
|
address: zoraMints1155Config.address[chainId],
|
|
1782
1778
|
functionName: "transferBatchToManagerAndCall",
|
|
1783
|
-
args: [tokenIds, quantities,
|
|
1779
|
+
args: [tokenIds, quantities, call],
|
|
1784
1780
|
value: getPaidMintValue(quantities, pricePerToken),
|
|
1785
1781
|
account
|
|
1786
1782
|
};
|
|
@@ -1794,19 +1790,22 @@ var collectWithMintsTypedDataDefinition = ({
|
|
|
1794
1790
|
deadline,
|
|
1795
1791
|
...rest
|
|
1796
1792
|
}) => {
|
|
1797
|
-
const
|
|
1793
|
+
const safeTransferData = encodeCollectOnManager({
|
|
1798
1794
|
tokenIds,
|
|
1799
1795
|
quantities,
|
|
1800
1796
|
...rest
|
|
1801
1797
|
});
|
|
1802
|
-
return
|
|
1798
|
+
return makePermitTransferBatchAndTypeData({
|
|
1803
1799
|
tokenIds,
|
|
1804
1800
|
quantities,
|
|
1805
1801
|
chainId,
|
|
1806
1802
|
account,
|
|
1807
1803
|
nonce,
|
|
1808
1804
|
deadline,
|
|
1809
|
-
|
|
1805
|
+
safeTransferData,
|
|
1806
|
+
// will safe transfer to manager contract before doing the
|
|
1807
|
+
// collect operation
|
|
1808
|
+
to: zoraMintsManagerImplConfig.address[chainId]
|
|
1810
1809
|
});
|
|
1811
1810
|
};
|
|
1812
1811
|
var collectPremintWithMintsTypedDataDefinition = ({
|
|
@@ -1818,41 +1817,72 @@ var collectPremintWithMintsTypedDataDefinition = ({
|
|
|
1818
1817
|
deadline,
|
|
1819
1818
|
...rest
|
|
1820
1819
|
}) => {
|
|
1821
|
-
const
|
|
1822
|
-
tokenIds,
|
|
1823
|
-
quantities,
|
|
1820
|
+
const safeTransferData = encodePremintOnManager({
|
|
1824
1821
|
...rest
|
|
1825
1822
|
});
|
|
1826
|
-
return
|
|
1823
|
+
return makePermitTransferBatchAndTypeData({
|
|
1827
1824
|
tokenIds,
|
|
1828
1825
|
quantities,
|
|
1829
1826
|
chainId,
|
|
1830
1827
|
account,
|
|
1831
1828
|
nonce,
|
|
1832
1829
|
deadline,
|
|
1833
|
-
|
|
1830
|
+
safeTransferData,
|
|
1831
|
+
// will safe transfer to manager contract before doing the
|
|
1832
|
+
// collect operation
|
|
1833
|
+
to: zoraMintsManagerImplConfig.address[chainId]
|
|
1834
1834
|
});
|
|
1835
1835
|
};
|
|
1836
|
-
function
|
|
1836
|
+
function makePermitTransferBatchAndTypeData({
|
|
1837
1837
|
tokenIds,
|
|
1838
1838
|
quantities,
|
|
1839
1839
|
chainId,
|
|
1840
1840
|
account,
|
|
1841
|
+
to,
|
|
1841
1842
|
nonce,
|
|
1842
1843
|
deadline,
|
|
1843
|
-
|
|
1844
|
+
safeTransferData
|
|
1844
1845
|
}) {
|
|
1845
1846
|
const permit = {
|
|
1846
1847
|
owner: typeof account === "string" ? account : account.address,
|
|
1848
|
+
to,
|
|
1847
1849
|
tokenIds,
|
|
1848
1850
|
quantities,
|
|
1849
|
-
call,
|
|
1850
1851
|
deadline,
|
|
1851
|
-
|
|
1852
|
+
nonce,
|
|
1853
|
+
safeTransferData
|
|
1852
1854
|
};
|
|
1853
|
-
const typedData =
|
|
1855
|
+
const typedData = permitBatchTypedDataDefinition({
|
|
1854
1856
|
chainId,
|
|
1857
|
+
permit,
|
|
1858
|
+
account
|
|
1859
|
+
});
|
|
1860
|
+
return {
|
|
1861
|
+
permit,
|
|
1862
|
+
typedData
|
|
1863
|
+
};
|
|
1864
|
+
}
|
|
1865
|
+
function makePermitTransferTypeData({
|
|
1866
|
+
tokenId,
|
|
1867
|
+
quantity,
|
|
1868
|
+
chainId,
|
|
1869
|
+
account,
|
|
1870
|
+
to,
|
|
1871
|
+
nonce,
|
|
1872
|
+
deadline,
|
|
1873
|
+
safeTransferData
|
|
1874
|
+
}) {
|
|
1875
|
+
const permit = {
|
|
1876
|
+
owner: typeof account === "string" ? account : account.address,
|
|
1877
|
+
to,
|
|
1878
|
+
tokenId,
|
|
1879
|
+
quantity,
|
|
1880
|
+
deadline,
|
|
1855
1881
|
nonce,
|
|
1882
|
+
safeTransferData
|
|
1883
|
+
};
|
|
1884
|
+
const typedData = permitTransferTypedDataDefinition({
|
|
1885
|
+
chainId,
|
|
1856
1886
|
permit,
|
|
1857
1887
|
account
|
|
1858
1888
|
});
|
|
@@ -1862,8 +1892,6 @@ function makePermitAndTypeData({
|
|
|
1862
1892
|
};
|
|
1863
1893
|
}
|
|
1864
1894
|
var encodePremintOnManager = ({
|
|
1865
|
-
tokenIds,
|
|
1866
|
-
quantities,
|
|
1867
1895
|
contractCreationConfig,
|
|
1868
1896
|
premintConfig,
|
|
1869
1897
|
premintSignature,
|
|
@@ -1873,8 +1901,6 @@ var encodePremintOnManager = ({
|
|
|
1873
1901
|
abi: zoraMintsManagerImplConfig.abi,
|
|
1874
1902
|
functionName: "collectPremintV2",
|
|
1875
1903
|
args: [
|
|
1876
|
-
tokenIds,
|
|
1877
|
-
quantities,
|
|
1878
1904
|
contractCreationConfig,
|
|
1879
1905
|
premintConfig,
|
|
1880
1906
|
premintSignature,
|
|
@@ -1891,15 +1917,13 @@ function collectPremintV2WithMintsParams({
|
|
|
1891
1917
|
...rest
|
|
1892
1918
|
}) {
|
|
1893
1919
|
const call = encodePremintOnManager({
|
|
1894
|
-
tokenIds,
|
|
1895
|
-
quantities,
|
|
1896
1920
|
...rest
|
|
1897
1921
|
});
|
|
1898
1922
|
return {
|
|
1899
1923
|
abi: zoraMints1155Config.abi,
|
|
1900
1924
|
address: zoraMints1155Config.address[chainId],
|
|
1901
1925
|
functionName: "transferBatchToManagerAndCall",
|
|
1902
|
-
args: [tokenIds, quantities,
|
|
1926
|
+
args: [tokenIds, quantities, call],
|
|
1903
1927
|
value: getPaidMintValue(quantities, pricePerToken),
|
|
1904
1928
|
account
|
|
1905
1929
|
};
|
|
@@ -1907,10 +1931,9 @@ function collectPremintV2WithMintsParams({
|
|
|
1907
1931
|
function makeTypeData(args) {
|
|
1908
1932
|
return args;
|
|
1909
1933
|
}
|
|
1910
|
-
function
|
|
1934
|
+
function permitBatchTypedDataDefinition({
|
|
1911
1935
|
permit,
|
|
1912
1936
|
chainId,
|
|
1913
|
-
nonce,
|
|
1914
1937
|
account
|
|
1915
1938
|
}) {
|
|
1916
1939
|
return makeTypeData({
|
|
@@ -1921,6 +1944,10 @@ function permitTypedDataDefinition({
|
|
|
1921
1944
|
name: "owner",
|
|
1922
1945
|
type: "address"
|
|
1923
1946
|
},
|
|
1947
|
+
{
|
|
1948
|
+
name: "to",
|
|
1949
|
+
type: "address"
|
|
1950
|
+
},
|
|
1924
1951
|
{
|
|
1925
1952
|
name: "tokenIds",
|
|
1926
1953
|
type: "uint256[]"
|
|
@@ -1934,7 +1961,53 @@ function permitTypedDataDefinition({
|
|
|
1934
1961
|
type: "bytes"
|
|
1935
1962
|
},
|
|
1936
1963
|
{
|
|
1937
|
-
name: "
|
|
1964
|
+
name: "nonce",
|
|
1965
|
+
type: "uint256"
|
|
1966
|
+
},
|
|
1967
|
+
{
|
|
1968
|
+
name: "deadline",
|
|
1969
|
+
type: "uint256"
|
|
1970
|
+
}
|
|
1971
|
+
]
|
|
1972
|
+
},
|
|
1973
|
+
message: permit,
|
|
1974
|
+
domain: {
|
|
1975
|
+
chainId,
|
|
1976
|
+
name: "Mints",
|
|
1977
|
+
version: "1",
|
|
1978
|
+
verifyingContract: zoraMints1155Config.address[chainId]
|
|
1979
|
+
},
|
|
1980
|
+
// signing account must be permit owner
|
|
1981
|
+
account
|
|
1982
|
+
});
|
|
1983
|
+
}
|
|
1984
|
+
function permitTransferTypedDataDefinition({
|
|
1985
|
+
permit,
|
|
1986
|
+
chainId,
|
|
1987
|
+
account
|
|
1988
|
+
}) {
|
|
1989
|
+
return makeTypeData({
|
|
1990
|
+
primaryType: "PermitSafeTransfer",
|
|
1991
|
+
types: {
|
|
1992
|
+
PermitSafeTransfer: [
|
|
1993
|
+
{
|
|
1994
|
+
name: "owner",
|
|
1995
|
+
type: "address"
|
|
1996
|
+
},
|
|
1997
|
+
{
|
|
1998
|
+
name: "to",
|
|
1999
|
+
type: "address"
|
|
2000
|
+
},
|
|
2001
|
+
{
|
|
2002
|
+
name: "tokenId",
|
|
2003
|
+
type: "uint256"
|
|
2004
|
+
},
|
|
2005
|
+
{
|
|
2006
|
+
name: "quantity",
|
|
2007
|
+
type: "uint256"
|
|
2008
|
+
},
|
|
2009
|
+
{
|
|
2010
|
+
name: "safeTransferData",
|
|
1938
2011
|
type: "bytes"
|
|
1939
2012
|
},
|
|
1940
2013
|
{
|
|
@@ -1947,15 +2020,7 @@ function permitTypedDataDefinition({
|
|
|
1947
2020
|
}
|
|
1948
2021
|
]
|
|
1949
2022
|
},
|
|
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
|
-
},
|
|
2023
|
+
message: permit,
|
|
1959
2024
|
domain: {
|
|
1960
2025
|
chainId,
|
|
1961
2026
|
name: "Mints",
|
|
@@ -1974,11 +2039,109 @@ var permitTransferBatchToManagerAndCallParams = ({
|
|
|
1974
2039
|
const result = {
|
|
1975
2040
|
abi: zoraMints1155Config.abi,
|
|
1976
2041
|
address: zoraMints1155Config.address[chainId],
|
|
1977
|
-
functionName: "
|
|
2042
|
+
functionName: "permitSafeTransferBatch",
|
|
1978
2043
|
args: [permit, signature]
|
|
1979
2044
|
};
|
|
1980
2045
|
return result;
|
|
1981
2046
|
};
|
|
2047
|
+
var safeTransferAndUnwrapTypedDataDefinition = ({
|
|
2048
|
+
chainId,
|
|
2049
|
+
tokenId,
|
|
2050
|
+
quantity,
|
|
2051
|
+
from,
|
|
2052
|
+
addressToCall,
|
|
2053
|
+
functionToCall,
|
|
2054
|
+
valueToSend,
|
|
2055
|
+
deadline,
|
|
2056
|
+
nonce
|
|
2057
|
+
}) => {
|
|
2058
|
+
const callArgument = encodeFunctionData2({
|
|
2059
|
+
abi: iUnwrapAndForwardActionABI,
|
|
2060
|
+
functionName: "callWithEth",
|
|
2061
|
+
args: [addressToCall, functionToCall, valueToSend]
|
|
2062
|
+
});
|
|
2063
|
+
return makePermitTransferTypeData({
|
|
2064
|
+
account: from,
|
|
2065
|
+
chainId,
|
|
2066
|
+
deadline,
|
|
2067
|
+
tokenId,
|
|
2068
|
+
quantity,
|
|
2069
|
+
safeTransferData: callArgument,
|
|
2070
|
+
to: mintsEthUnwrapperAndCallerConfig.address[chainId],
|
|
2071
|
+
nonce
|
|
2072
|
+
});
|
|
2073
|
+
};
|
|
2074
|
+
var safeTransferBatchAndUnwrapTypedDataDefinition = ({
|
|
2075
|
+
chainId,
|
|
2076
|
+
tokenIds,
|
|
2077
|
+
quantities,
|
|
2078
|
+
from,
|
|
2079
|
+
addressToCall,
|
|
2080
|
+
functionToCall,
|
|
2081
|
+
valueToSend,
|
|
2082
|
+
deadline,
|
|
2083
|
+
nonce
|
|
2084
|
+
}) => {
|
|
2085
|
+
const callArgument = encodeFunctionData2({
|
|
2086
|
+
abi: iUnwrapAndForwardActionABI,
|
|
2087
|
+
functionName: "callWithEth",
|
|
2088
|
+
args: [addressToCall, functionToCall, valueToSend]
|
|
2089
|
+
});
|
|
2090
|
+
return makePermitTransferBatchAndTypeData({
|
|
2091
|
+
account: from,
|
|
2092
|
+
chainId,
|
|
2093
|
+
deadline,
|
|
2094
|
+
tokenIds,
|
|
2095
|
+
quantities,
|
|
2096
|
+
safeTransferData: callArgument,
|
|
2097
|
+
to: mintsEthUnwrapperAndCallerConfig.address[chainId],
|
|
2098
|
+
nonce
|
|
2099
|
+
});
|
|
2100
|
+
};
|
|
2101
|
+
var safeTransferAndUnwrapEthParams = ({
|
|
2102
|
+
chainId,
|
|
2103
|
+
tokenIds,
|
|
2104
|
+
quantities,
|
|
2105
|
+
from,
|
|
2106
|
+
addressToCall,
|
|
2107
|
+
functionToCall,
|
|
2108
|
+
valueToSend
|
|
2109
|
+
}) => {
|
|
2110
|
+
const callArgument = encodeFunctionData2({
|
|
2111
|
+
abi: iUnwrapAndForwardActionABI,
|
|
2112
|
+
functionName: "callWithEth",
|
|
2113
|
+
args: [addressToCall, functionToCall, valueToSend]
|
|
2114
|
+
});
|
|
2115
|
+
const result = {
|
|
2116
|
+
abi: zoraMints1155Config.abi,
|
|
2117
|
+
functionName: "safeBatchTransferFrom",
|
|
2118
|
+
address: zoraMints1155Config.address[chainId],
|
|
2119
|
+
args: [
|
|
2120
|
+
typeof from === "string" ? from : from.address,
|
|
2121
|
+
// the mints will be transferred to this address, which
|
|
2122
|
+
// will burn/redeem their eth value
|
|
2123
|
+
mintsEthUnwrapperAndCallerConfig.address[chainId],
|
|
2124
|
+
// token ids to transfer/burn/unwrap - must be eth based tokens
|
|
2125
|
+
tokenIds,
|
|
2126
|
+
// quantities to transfer/burn/unwrap
|
|
2127
|
+
quantities,
|
|
2128
|
+
// this is the safeTransferData - which gets forwarded to the eth transferrer
|
|
2129
|
+
callArgument
|
|
2130
|
+
],
|
|
2131
|
+
// the account whos mints will be transferred from
|
|
2132
|
+
account: from
|
|
2133
|
+
};
|
|
2134
|
+
return result;
|
|
2135
|
+
};
|
|
2136
|
+
function decodeCallFailedError(error) {
|
|
2137
|
+
if (error.data?.errorName !== "CallFailed")
|
|
2138
|
+
throw new Error("Not a CallFailed error");
|
|
2139
|
+
const internalErrorData = error.data?.args?.[0];
|
|
2140
|
+
return decodeErrorResult({
|
|
2141
|
+
abi: zoraMintsManagerImplABI,
|
|
2142
|
+
data: internalErrorData
|
|
2143
|
+
});
|
|
2144
|
+
}
|
|
1982
2145
|
export {
|
|
1983
2146
|
DEFAULT_SALE_SETTINGS,
|
|
1984
2147
|
Errors,
|
|
@@ -1987,7 +2150,6 @@ export {
|
|
|
1987
2150
|
PremintConfigVersion,
|
|
1988
2151
|
PreminterDomain,
|
|
1989
2152
|
ZORA_API_BASE,
|
|
1990
|
-
accountNonceParams,
|
|
1991
2153
|
applyUpdateToPremint,
|
|
1992
2154
|
collectPremintV2WithMintsParams,
|
|
1993
2155
|
collectPremintWithMintsTypedDataDefinition,
|
|
@@ -2000,12 +2162,14 @@ export {
|
|
|
2000
2162
|
create1155TokenSetupArgs,
|
|
2001
2163
|
createMintClient,
|
|
2002
2164
|
createPremintClient,
|
|
2165
|
+
decodeCallFailedError,
|
|
2003
2166
|
defaultTokenConfigV1MintArguments,
|
|
2004
2167
|
defaultTokenConfigV2MintArguments,
|
|
2005
2168
|
encodeCollectOnManager,
|
|
2006
2169
|
encodePostSignatureInput,
|
|
2007
2170
|
encodePremintForAPI,
|
|
2008
2171
|
encodePremintOnManager,
|
|
2172
|
+
fixedPriceMinterMinterArguments,
|
|
2009
2173
|
getApiNetworkConfigForChain,
|
|
2010
2174
|
getDefaultFixedPriceMinterAddress,
|
|
2011
2175
|
getMINTsBalance,
|
|
@@ -2026,11 +2190,15 @@ export {
|
|
|
2026
2190
|
migratePremintConfigToV2,
|
|
2027
2191
|
mintWithEthParams,
|
|
2028
2192
|
mintsBalanceOfAccountParams,
|
|
2193
|
+
permitBatchTypedDataDefinition,
|
|
2029
2194
|
permitTransferBatchToManagerAndCallParams,
|
|
2030
|
-
|
|
2195
|
+
permitTransferTypedDataDefinition,
|
|
2031
2196
|
premintTypedDataDefinition,
|
|
2032
2197
|
recoverCreatorFromCreatorAttribution,
|
|
2033
2198
|
recoverPremintSigner,
|
|
2199
|
+
safeTransferAndUnwrapEthParams,
|
|
2200
|
+
safeTransferAndUnwrapTypedDataDefinition,
|
|
2201
|
+
safeTransferBatchAndUnwrapTypedDataDefinition,
|
|
2034
2202
|
selectMintsToCollectWithFromQueryResult,
|
|
2035
2203
|
sumBalances,
|
|
2036
2204
|
supportedPremintVersions,
|