@zoralabs/protocol-sdk 0.5.8-DEV.1 → 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.
@@ -0,0 +1,15 @@
1
+ $ tsup
2
+ CLI Building entry: src/index.ts
3
+ CLI Using tsconfig: tsconfig.build.json
4
+ CLI tsup v7.3.0
5
+ CLI Using tsup config: /home/runner/work/zora-protocol-private/zora-protocol-private/packages/protocol-sdk/tsup.config.ts
6
+ CLI Target: es2021
7
+ CLI Cleaning output folder
8
+ CJS Build start
9
+ ESM Build start
10
+ CJS dist/index.cjs 64.16 KB
11
+ CJS dist/index.cjs.map 123.76 KB
12
+ CJS ⚡️ Build success in 76ms
13
+ ESM dist/index.js 58.17 KB
14
+ ESM dist/index.js.map 123.79 KB
15
+ ESM ⚡️ Build success in 84ms
package/CHANGELOG.md CHANGED
@@ -1,20 +1,13 @@
1
1
  # @zoralabs/protocol-sdk
2
2
 
3
- ## 0.5.8-DEV.1
3
+ ## 0.5.8
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies [042edbe0]
8
- - @zoralabs/protocol-deployments@0.1.5-DEV.1
9
-
10
- ## 0.5.8-DEV.0
11
-
12
- ### Patch Changes
13
-
14
- - 965c59c7: Added sdk method to get total MINT balance
15
- - 965c59c7: Added functionality to be able to query for MINTs to use when collecting from an account
16
- - Updated dependencies [965c59c7]
17
- - @zoralabs/protocol-deployments@0.1.5-DEV.0
7
+ - 50a4e09: Added sdk method to get total MINT balance
8
+ - Updated dependencies [042edbe]
9
+ - Updated dependencies [50a4e09]
10
+ - @zoralabs/protocol-deployments@0.1.5
18
11
 
19
12
  ## 0.5.7
20
13
 
package/dist/index.cjs CHANGED
@@ -27,7 +27,6 @@ __export(src_exports, {
27
27
  PremintConfigVersion: () => PremintConfigVersion,
28
28
  PreminterDomain: () => PreminterDomain,
29
29
  ZORA_API_BASE: () => ZORA_API_BASE,
30
- accountNonceParams: () => accountNonceParams,
31
30
  applyUpdateToPremint: () => applyUpdateToPremint,
32
31
  collectPremintV2WithMintsParams: () => collectPremintV2WithMintsParams,
33
32
  collectPremintWithMintsTypedDataDefinition: () => collectPremintWithMintsTypedDataDefinition,
@@ -40,12 +39,14 @@ __export(src_exports, {
40
39
  create1155TokenSetupArgs: () => create1155TokenSetupArgs,
41
40
  createMintClient: () => createMintClient,
42
41
  createPremintClient: () => createPremintClient,
42
+ decodeCallFailedError: () => decodeCallFailedError,
43
43
  defaultTokenConfigV1MintArguments: () => defaultTokenConfigV1MintArguments,
44
44
  defaultTokenConfigV2MintArguments: () => defaultTokenConfigV2MintArguments,
45
45
  encodeCollectOnManager: () => encodeCollectOnManager,
46
46
  encodePostSignatureInput: () => encodePostSignatureInput,
47
47
  encodePremintForAPI: () => encodePremintForAPI,
48
48
  encodePremintOnManager: () => encodePremintOnManager,
49
+ fixedPriceMinterMinterArguments: () => fixedPriceMinterMinterArguments,
49
50
  getApiNetworkConfigForChain: () => getApiNetworkConfigForChain,
50
51
  getDefaultFixedPriceMinterAddress: () => getDefaultFixedPriceMinterAddress,
51
52
  getMINTsBalance: () => getMINTsBalance,
@@ -66,11 +67,15 @@ __export(src_exports, {
66
67
  migratePremintConfigToV2: () => migratePremintConfigToV2,
67
68
  mintWithEthParams: () => mintWithEthParams,
68
69
  mintsBalanceOfAccountParams: () => mintsBalanceOfAccountParams,
70
+ permitBatchTypedDataDefinition: () => permitBatchTypedDataDefinition,
69
71
  permitTransferBatchToManagerAndCallParams: () => permitTransferBatchToManagerAndCallParams,
70
- permitTypedDataDefinition: () => permitTypedDataDefinition,
72
+ permitTransferTypedDataDefinition: () => permitTransferTypedDataDefinition,
71
73
  premintTypedDataDefinition: () => premintTypedDataDefinition,
72
74
  recoverCreatorFromCreatorAttribution: () => recoverCreatorFromCreatorAttribution,
73
75
  recoverPremintSigner: () => recoverPremintSigner,
76
+ safeTransferAndUnwrapEthParams: () => safeTransferAndUnwrapEthParams,
77
+ safeTransferAndUnwrapTypedDataDefinition: () => safeTransferAndUnwrapTypedDataDefinition,
78
+ safeTransferBatchAndUnwrapTypedDataDefinition: () => safeTransferBatchAndUnwrapTypedDataDefinition,
74
79
  selectMintsToCollectWithFromQueryResult: () => selectMintsToCollectWithFromQueryResult,
75
80
  sumBalances: () => sumBalances,
76
81
  supportedPremintVersions: () => supportedPremintVersions,
@@ -1767,6 +1772,9 @@ var getPaidMintValue = (quantities, pricePerMint) => {
1767
1772
  return;
1768
1773
  return quantities.reduce((a, b) => a + b, 0n) * pricePerMint;
1769
1774
  };
1775
+ var fixedPriceMinterMinterArguments = ({
1776
+ mintRecipient
1777
+ }) => (0, import_viem7.encodeAbiParameters)((0, import_viem7.parseAbiParameters)("address"), [mintRecipient]);
1770
1778
  var mintsBalanceOfAccountParams = ({
1771
1779
  account,
1772
1780
  chainId
@@ -1776,18 +1784,7 @@ var mintsBalanceOfAccountParams = ({
1776
1784
  functionName: "balanceOfAccount",
1777
1785
  args: [account]
1778
1786
  });
1779
- var accountNonceParams = ({
1780
- chainId,
1781
- account
1782
- }) => ({
1783
- abi: import_protocol_deployments5.zoraMints1155Config.abi,
1784
- address: import_protocol_deployments5.zoraMints1155Config.address[chainId],
1785
- functionName: "nonces",
1786
- args: [account]
1787
- });
1788
1787
  var encodeCollectOnManager = ({
1789
- tokenIds,
1790
- quantities,
1791
1788
  zoraCreator1155Contract,
1792
1789
  minter,
1793
1790
  zoraCreator1155TokenId,
@@ -1796,8 +1793,6 @@ var encodeCollectOnManager = ({
1796
1793
  abi: import_protocol_deployments5.zoraMintsManagerImplConfig.abi,
1797
1794
  functionName: "collect",
1798
1795
  args: [
1799
- tokenIds,
1800
- quantities,
1801
1796
  zoraCreator1155Contract,
1802
1797
  minter,
1803
1798
  zoraCreator1155TokenId,
@@ -1821,7 +1816,7 @@ function collectWithMintsParams({
1821
1816
  abi: import_protocol_deployments5.zoraMints1155Config.abi,
1822
1817
  address: import_protocol_deployments5.zoraMints1155Config.address[chainId],
1823
1818
  functionName: "transferBatchToManagerAndCall",
1824
- args: [tokenIds, quantities, "0x", call],
1819
+ args: [tokenIds, quantities, call],
1825
1820
  value: getPaidMintValue(quantities, pricePerToken),
1826
1821
  account
1827
1822
  };
@@ -1835,19 +1830,22 @@ var collectWithMintsTypedDataDefinition = ({
1835
1830
  deadline,
1836
1831
  ...rest
1837
1832
  }) => {
1838
- const call = encodeCollectOnManager({
1833
+ const safeTransferData = encodeCollectOnManager({
1839
1834
  tokenIds,
1840
1835
  quantities,
1841
1836
  ...rest
1842
1837
  });
1843
- return makePermitAndTypeData({
1838
+ return makePermitTransferBatchAndTypeData({
1844
1839
  tokenIds,
1845
1840
  quantities,
1846
1841
  chainId,
1847
1842
  account,
1848
1843
  nonce,
1849
1844
  deadline,
1850
- call
1845
+ safeTransferData,
1846
+ // will safe transfer to manager contract before doing the
1847
+ // collect operation
1848
+ to: import_protocol_deployments5.zoraMintsManagerImplConfig.address[chainId]
1851
1849
  });
1852
1850
  };
1853
1851
  var collectPremintWithMintsTypedDataDefinition = ({
@@ -1859,41 +1857,72 @@ var collectPremintWithMintsTypedDataDefinition = ({
1859
1857
  deadline,
1860
1858
  ...rest
1861
1859
  }) => {
1862
- const call = encodePremintOnManager({
1863
- tokenIds,
1864
- quantities,
1860
+ const safeTransferData = encodePremintOnManager({
1865
1861
  ...rest
1866
1862
  });
1867
- return makePermitAndTypeData({
1863
+ return makePermitTransferBatchAndTypeData({
1868
1864
  tokenIds,
1869
1865
  quantities,
1870
1866
  chainId,
1871
1867
  account,
1872
1868
  nonce,
1873
1869
  deadline,
1874
- call
1870
+ safeTransferData,
1871
+ // will safe transfer to manager contract before doing the
1872
+ // collect operation
1873
+ to: import_protocol_deployments5.zoraMintsManagerImplConfig.address[chainId]
1875
1874
  });
1876
1875
  };
1877
- function makePermitAndTypeData({
1876
+ function makePermitTransferBatchAndTypeData({
1878
1877
  tokenIds,
1879
1878
  quantities,
1880
1879
  chainId,
1881
1880
  account,
1881
+ to,
1882
1882
  nonce,
1883
1883
  deadline,
1884
- call
1884
+ safeTransferData
1885
1885
  }) {
1886
1886
  const permit = {
1887
1887
  owner: typeof account === "string" ? account : account.address,
1888
+ to,
1888
1889
  tokenIds,
1889
1890
  quantities,
1890
- call,
1891
1891
  deadline,
1892
- safeTransferData: "0x"
1892
+ nonce,
1893
+ safeTransferData
1893
1894
  };
1894
- const typedData = permitTypedDataDefinition({
1895
+ const typedData = permitBatchTypedDataDefinition({
1895
1896
  chainId,
1897
+ permit,
1898
+ account
1899
+ });
1900
+ return {
1901
+ permit,
1902
+ typedData
1903
+ };
1904
+ }
1905
+ function makePermitTransferTypeData({
1906
+ tokenId,
1907
+ quantity,
1908
+ chainId,
1909
+ account,
1910
+ to,
1911
+ nonce,
1912
+ deadline,
1913
+ safeTransferData
1914
+ }) {
1915
+ const permit = {
1916
+ owner: typeof account === "string" ? account : account.address,
1917
+ to,
1918
+ tokenId,
1919
+ quantity,
1920
+ deadline,
1896
1921
  nonce,
1922
+ safeTransferData
1923
+ };
1924
+ const typedData = permitTransferTypedDataDefinition({
1925
+ chainId,
1897
1926
  permit,
1898
1927
  account
1899
1928
  });
@@ -1903,8 +1932,6 @@ function makePermitAndTypeData({
1903
1932
  };
1904
1933
  }
1905
1934
  var encodePremintOnManager = ({
1906
- tokenIds,
1907
- quantities,
1908
1935
  contractCreationConfig,
1909
1936
  premintConfig,
1910
1937
  premintSignature,
@@ -1914,8 +1941,6 @@ var encodePremintOnManager = ({
1914
1941
  abi: import_protocol_deployments5.zoraMintsManagerImplConfig.abi,
1915
1942
  functionName: "collectPremintV2",
1916
1943
  args: [
1917
- tokenIds,
1918
- quantities,
1919
1944
  contractCreationConfig,
1920
1945
  premintConfig,
1921
1946
  premintSignature,
@@ -1932,15 +1957,13 @@ function collectPremintV2WithMintsParams({
1932
1957
  ...rest
1933
1958
  }) {
1934
1959
  const call = encodePremintOnManager({
1935
- tokenIds,
1936
- quantities,
1937
1960
  ...rest
1938
1961
  });
1939
1962
  return {
1940
1963
  abi: import_protocol_deployments5.zoraMints1155Config.abi,
1941
1964
  address: import_protocol_deployments5.zoraMints1155Config.address[chainId],
1942
1965
  functionName: "transferBatchToManagerAndCall",
1943
- args: [tokenIds, quantities, "0x", call],
1966
+ args: [tokenIds, quantities, call],
1944
1967
  value: getPaidMintValue(quantities, pricePerToken),
1945
1968
  account
1946
1969
  };
@@ -1948,10 +1971,9 @@ function collectPremintV2WithMintsParams({
1948
1971
  function makeTypeData(args) {
1949
1972
  return args;
1950
1973
  }
1951
- function permitTypedDataDefinition({
1974
+ function permitBatchTypedDataDefinition({
1952
1975
  permit,
1953
1976
  chainId,
1954
- nonce,
1955
1977
  account
1956
1978
  }) {
1957
1979
  return makeTypeData({
@@ -1962,6 +1984,10 @@ function permitTypedDataDefinition({
1962
1984
  name: "owner",
1963
1985
  type: "address"
1964
1986
  },
1987
+ {
1988
+ name: "to",
1989
+ type: "address"
1990
+ },
1965
1991
  {
1966
1992
  name: "tokenIds",
1967
1993
  type: "uint256[]"
@@ -1975,7 +2001,53 @@ function permitTypedDataDefinition({
1975
2001
  type: "bytes"
1976
2002
  },
1977
2003
  {
1978
- name: "call",
2004
+ name: "nonce",
2005
+ type: "uint256"
2006
+ },
2007
+ {
2008
+ name: "deadline",
2009
+ type: "uint256"
2010
+ }
2011
+ ]
2012
+ },
2013
+ message: permit,
2014
+ domain: {
2015
+ chainId,
2016
+ name: "Mints",
2017
+ version: "1",
2018
+ verifyingContract: import_protocol_deployments5.zoraMints1155Config.address[chainId]
2019
+ },
2020
+ // signing account must be permit owner
2021
+ account
2022
+ });
2023
+ }
2024
+ function permitTransferTypedDataDefinition({
2025
+ permit,
2026
+ chainId,
2027
+ account
2028
+ }) {
2029
+ return makeTypeData({
2030
+ primaryType: "PermitSafeTransfer",
2031
+ types: {
2032
+ PermitSafeTransfer: [
2033
+ {
2034
+ name: "owner",
2035
+ type: "address"
2036
+ },
2037
+ {
2038
+ name: "to",
2039
+ type: "address"
2040
+ },
2041
+ {
2042
+ name: "tokenId",
2043
+ type: "uint256"
2044
+ },
2045
+ {
2046
+ name: "quantity",
2047
+ type: "uint256"
2048
+ },
2049
+ {
2050
+ name: "safeTransferData",
1979
2051
  type: "bytes"
1980
2052
  },
1981
2053
  {
@@ -1988,15 +2060,7 @@ function permitTypedDataDefinition({
1988
2060
  }
1989
2061
  ]
1990
2062
  },
1991
- message: {
1992
- owner: permit.owner,
1993
- tokenIds: permit.tokenIds,
1994
- quantities: permit.quantities,
1995
- safeTransferData: permit.safeTransferData,
1996
- call: permit.call,
1997
- nonce,
1998
- deadline: permit.deadline
1999
- },
2063
+ message: permit,
2000
2064
  domain: {
2001
2065
  chainId,
2002
2066
  name: "Mints",
@@ -2015,11 +2079,109 @@ var permitTransferBatchToManagerAndCallParams = ({
2015
2079
  const result = {
2016
2080
  abi: import_protocol_deployments5.zoraMints1155Config.abi,
2017
2081
  address: import_protocol_deployments5.zoraMints1155Config.address[chainId],
2018
- functionName: "permitTransferBatchToManagerAndCall",
2082
+ functionName: "permitSafeTransferBatch",
2019
2083
  args: [permit, signature]
2020
2084
  };
2021
2085
  return result;
2022
2086
  };
2087
+ var safeTransferAndUnwrapTypedDataDefinition = ({
2088
+ chainId,
2089
+ tokenId,
2090
+ quantity,
2091
+ from,
2092
+ addressToCall,
2093
+ functionToCall,
2094
+ valueToSend,
2095
+ deadline,
2096
+ nonce
2097
+ }) => {
2098
+ const callArgument = (0, import_viem7.encodeFunctionData)({
2099
+ abi: import_protocol_deployments5.iUnwrapAndForwardActionABI,
2100
+ functionName: "callWithEth",
2101
+ args: [addressToCall, functionToCall, valueToSend]
2102
+ });
2103
+ return makePermitTransferTypeData({
2104
+ account: from,
2105
+ chainId,
2106
+ deadline,
2107
+ tokenId,
2108
+ quantity,
2109
+ safeTransferData: callArgument,
2110
+ to: import_protocol_deployments5.mintsEthUnwrapperAndCallerConfig.address[chainId],
2111
+ nonce
2112
+ });
2113
+ };
2114
+ var safeTransferBatchAndUnwrapTypedDataDefinition = ({
2115
+ chainId,
2116
+ tokenIds,
2117
+ quantities,
2118
+ from,
2119
+ addressToCall,
2120
+ functionToCall,
2121
+ valueToSend,
2122
+ deadline,
2123
+ nonce
2124
+ }) => {
2125
+ const callArgument = (0, import_viem7.encodeFunctionData)({
2126
+ abi: import_protocol_deployments5.iUnwrapAndForwardActionABI,
2127
+ functionName: "callWithEth",
2128
+ args: [addressToCall, functionToCall, valueToSend]
2129
+ });
2130
+ return makePermitTransferBatchAndTypeData({
2131
+ account: from,
2132
+ chainId,
2133
+ deadline,
2134
+ tokenIds,
2135
+ quantities,
2136
+ safeTransferData: callArgument,
2137
+ to: import_protocol_deployments5.mintsEthUnwrapperAndCallerConfig.address[chainId],
2138
+ nonce
2139
+ });
2140
+ };
2141
+ var safeTransferAndUnwrapEthParams = ({
2142
+ chainId,
2143
+ tokenIds,
2144
+ quantities,
2145
+ from,
2146
+ addressToCall,
2147
+ functionToCall,
2148
+ valueToSend
2149
+ }) => {
2150
+ const callArgument = (0, import_viem7.encodeFunctionData)({
2151
+ abi: import_protocol_deployments5.iUnwrapAndForwardActionABI,
2152
+ functionName: "callWithEth",
2153
+ args: [addressToCall, functionToCall, valueToSend]
2154
+ });
2155
+ const result = {
2156
+ abi: import_protocol_deployments5.zoraMints1155Config.abi,
2157
+ functionName: "safeBatchTransferFrom",
2158
+ address: import_protocol_deployments5.zoraMints1155Config.address[chainId],
2159
+ args: [
2160
+ typeof from === "string" ? from : from.address,
2161
+ // the mints will be transferred to this address, which
2162
+ // will burn/redeem their eth value
2163
+ import_protocol_deployments5.mintsEthUnwrapperAndCallerConfig.address[chainId],
2164
+ // token ids to transfer/burn/unwrap - must be eth based tokens
2165
+ tokenIds,
2166
+ // quantities to transfer/burn/unwrap
2167
+ quantities,
2168
+ // this is the safeTransferData - which gets forwarded to the eth transferrer
2169
+ callArgument
2170
+ ],
2171
+ // the account whos mints will be transferred from
2172
+ account: from
2173
+ };
2174
+ return result;
2175
+ };
2176
+ function decodeCallFailedError(error) {
2177
+ if (error.data?.errorName !== "CallFailed")
2178
+ throw new Error("Not a CallFailed error");
2179
+ const internalErrorData = error.data?.args?.[0];
2180
+ return (0, import_viem7.decodeErrorResult)({
2181
+ abi: import_protocol_deployments5.zoraMintsManagerImplABI,
2182
+ data: internalErrorData
2183
+ });
2184
+ }
2023
2185
  // Annotate the CommonJS export names for ESM import in node:
2024
2186
  0 && (module.exports = {
2025
2187
  DEFAULT_SALE_SETTINGS,
@@ -2029,7 +2191,6 @@ var permitTransferBatchToManagerAndCallParams = ({
2029
2191
  PremintConfigVersion,
2030
2192
  PreminterDomain,
2031
2193
  ZORA_API_BASE,
2032
- accountNonceParams,
2033
2194
  applyUpdateToPremint,
2034
2195
  collectPremintV2WithMintsParams,
2035
2196
  collectPremintWithMintsTypedDataDefinition,
@@ -2042,12 +2203,14 @@ var permitTransferBatchToManagerAndCallParams = ({
2042
2203
  create1155TokenSetupArgs,
2043
2204
  createMintClient,
2044
2205
  createPremintClient,
2206
+ decodeCallFailedError,
2045
2207
  defaultTokenConfigV1MintArguments,
2046
2208
  defaultTokenConfigV2MintArguments,
2047
2209
  encodeCollectOnManager,
2048
2210
  encodePostSignatureInput,
2049
2211
  encodePremintForAPI,
2050
2212
  encodePremintOnManager,
2213
+ fixedPriceMinterMinterArguments,
2051
2214
  getApiNetworkConfigForChain,
2052
2215
  getDefaultFixedPriceMinterAddress,
2053
2216
  getMINTsBalance,
@@ -2068,11 +2231,15 @@ var permitTransferBatchToManagerAndCallParams = ({
2068
2231
  migratePremintConfigToV2,
2069
2232
  mintWithEthParams,
2070
2233
  mintsBalanceOfAccountParams,
2234
+ permitBatchTypedDataDefinition,
2071
2235
  permitTransferBatchToManagerAndCallParams,
2072
- permitTypedDataDefinition,
2236
+ permitTransferTypedDataDefinition,
2073
2237
  premintTypedDataDefinition,
2074
2238
  recoverCreatorFromCreatorAttribution,
2075
2239
  recoverPremintSigner,
2240
+ safeTransferAndUnwrapEthParams,
2241
+ safeTransferAndUnwrapTypedDataDefinition,
2242
+ safeTransferBatchAndUnwrapTypedDataDefinition,
2076
2243
  selectMintsToCollectWithFromQueryResult,
2077
2244
  sumBalances,
2078
2245
  supportedPremintVersions,