@ensdomains/ensjs 3.0.0-beta.1 → 3.0.0-beta.2

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.
Files changed (248) hide show
  1. package/dist/cjs/clients/decorators/subgraph.js.map +1 -1
  2. package/dist/cjs/contracts/consts.js +6 -0
  3. package/dist/cjs/contracts/consts.js.map +1 -1
  4. package/dist/cjs/dns.js +3 -3
  5. package/dist/cjs/dns.js.map +1 -1
  6. package/dist/cjs/errors/subgraph.js.map +1 -1
  7. package/dist/cjs/errors/utils.js +15 -18
  8. package/dist/cjs/errors/utils.js.map +1 -1
  9. package/dist/cjs/errors/version.js +1 -1
  10. package/dist/cjs/errors/version.js.map +1 -1
  11. package/dist/cjs/functions/dns/{prepareDnsImport.js → getDnsImportData.js} +3 -3
  12. package/dist/cjs/functions/dns/{prepareDnsImport.js.map → getDnsImportData.js.map} +1 -1
  13. package/dist/cjs/functions/dns/importDnsName.js +7 -7
  14. package/dist/cjs/functions/dns/importDnsName.js.map +1 -1
  15. package/dist/cjs/functions/public/_getContentHash.js +1 -1
  16. package/dist/cjs/functions/public/getSupportedInterfaces.js +1 -1
  17. package/dist/cjs/functions/public/getSupportedInterfaces.js.map +1 -1
  18. package/dist/cjs/functions/public/getWrapperData.js.map +1 -1
  19. package/dist/cjs/functions/subgraph/filters.js +3 -0
  20. package/dist/cjs/functions/subgraph/filters.js.map +1 -0
  21. package/dist/cjs/functions/subgraph/getNameHistory.js +1 -1
  22. package/dist/cjs/functions/subgraph/getNamesForAddress.js +140 -182
  23. package/dist/cjs/functions/subgraph/getNamesForAddress.js.map +1 -1
  24. package/dist/cjs/functions/subgraph/getSubnames.js +95 -108
  25. package/dist/cjs/functions/subgraph/getSubnames.js.map +1 -1
  26. package/dist/cjs/functions/subgraph/types.js +3 -0
  27. package/dist/cjs/functions/subgraph/types.js.map +1 -0
  28. package/dist/cjs/functions/subgraph/utils.js.map +1 -1
  29. package/dist/cjs/functions/wallet/createSubname.js +1 -1
  30. package/dist/cjs/functions/wallet/createSubname.js.map +1 -1
  31. package/dist/cjs/functions/wallet/setChildFuses.js +1 -1
  32. package/dist/cjs/functions/wallet/setChildFuses.js.map +1 -1
  33. package/dist/cjs/functions/wallet/setFuses.js +1 -1
  34. package/dist/cjs/functions/wallet/setFuses.js.map +1 -1
  35. package/dist/cjs/functions/wallet/wrapName.js +3 -1
  36. package/dist/cjs/functions/wallet/wrapName.js.map +1 -1
  37. package/dist/cjs/index.js +1 -2
  38. package/dist/cjs/index.js.map +1 -1
  39. package/dist/cjs/utils/contentHash.js +54 -131
  40. package/dist/cjs/utils/contentHash.js.map +1 -1
  41. package/dist/cjs/utils/encoders/encodeSetContentHash.js +1 -4
  42. package/dist/cjs/utils/encoders/encodeSetContentHash.js.map +1 -1
  43. package/dist/cjs/utils/format.js +1 -5
  44. package/dist/cjs/utils/format.js.map +1 -1
  45. package/dist/cjs/utils/fuses.js +181 -200
  46. package/dist/cjs/utils/fuses.js.map +1 -1
  47. package/dist/cjs/utils/index.js +4 -7
  48. package/dist/cjs/utils/index.js.map +1 -1
  49. package/dist/cjs/utils/registerHelpers.js +3 -1
  50. package/dist/cjs/utils/registerHelpers.js.map +1 -1
  51. package/dist/esm/clients/decorators/subgraph.js.map +1 -1
  52. package/dist/esm/contracts/consts.js +6 -0
  53. package/dist/esm/contracts/consts.js.map +1 -1
  54. package/dist/esm/dns.js +1 -1
  55. package/dist/esm/dns.js.map +1 -1
  56. package/dist/esm/errors/subgraph.js.map +1 -1
  57. package/dist/esm/errors/utils.js +13 -16
  58. package/dist/esm/errors/utils.js.map +1 -1
  59. package/dist/esm/errors/version.js +1 -1
  60. package/dist/esm/errors/version.js.map +1 -1
  61. package/dist/esm/functions/dns/{prepareDnsImport.js → getDnsImportData.js} +9 -10
  62. package/dist/esm/functions/dns/getDnsImportData.js.map +1 -0
  63. package/dist/esm/functions/dns/importDnsName.js +12 -12
  64. package/dist/esm/functions/dns/importDnsName.js.map +1 -1
  65. package/dist/esm/functions/public/_getContentHash.js +2 -2
  66. package/dist/esm/functions/public/getSupportedInterfaces.js +2 -2
  67. package/dist/esm/functions/public/getSupportedInterfaces.js.map +1 -1
  68. package/dist/esm/functions/public/getWrapperData.js.map +1 -1
  69. package/dist/esm/functions/subgraph/filters.js +2 -0
  70. package/dist/esm/functions/subgraph/filters.js.map +1 -0
  71. package/dist/esm/functions/subgraph/getNameHistory.js +2 -2
  72. package/dist/esm/functions/subgraph/getNamesForAddress.js +144 -183
  73. package/dist/esm/functions/subgraph/getNamesForAddress.js.map +1 -1
  74. package/dist/esm/functions/subgraph/getSubnames.js +101 -111
  75. package/dist/esm/functions/subgraph/getSubnames.js.map +1 -1
  76. package/dist/esm/functions/subgraph/types.js +2 -0
  77. package/dist/esm/functions/subgraph/types.js.map +1 -0
  78. package/dist/esm/functions/subgraph/utils.js.map +1 -1
  79. package/dist/esm/functions/wallet/createSubname.js +1 -1
  80. package/dist/esm/functions/wallet/createSubname.js.map +1 -1
  81. package/dist/esm/functions/wallet/setChildFuses.js +1 -1
  82. package/dist/esm/functions/wallet/setChildFuses.js.map +1 -1
  83. package/dist/esm/functions/wallet/setFuses.js +2 -2
  84. package/dist/esm/functions/wallet/setFuses.js.map +1 -1
  85. package/dist/esm/functions/wallet/wrapName.js +4 -2
  86. package/dist/esm/functions/wallet/wrapName.js.map +1 -1
  87. package/dist/esm/index.js +1 -1
  88. package/dist/esm/index.js.map +1 -1
  89. package/dist/esm/utils/contentHash.js +51 -128
  90. package/dist/esm/utils/contentHash.js.map +1 -1
  91. package/dist/esm/utils/encoders/encodeSetContentHash.js +2 -5
  92. package/dist/esm/utils/encoders/encodeSetContentHash.js.map +1 -1
  93. package/dist/esm/utils/format.js +0 -2
  94. package/dist/esm/utils/format.js.map +1 -1
  95. package/dist/esm/utils/fuses.js +180 -201
  96. package/dist/esm/utils/fuses.js.map +1 -1
  97. package/dist/esm/utils/index.js +2 -2
  98. package/dist/esm/utils/index.js.map +1 -1
  99. package/dist/esm/utils/registerHelpers.js +4 -2
  100. package/dist/esm/utils/registerHelpers.js.map +1 -1
  101. package/dist/types/clients/decorators/subgraph.d.ts +1 -1
  102. package/dist/types/clients/decorators/subgraph.d.ts.map +1 -1
  103. package/dist/types/clients/public.d.ts +1 -1
  104. package/dist/types/clients/subgraph.d.ts +1 -1
  105. package/dist/types/clients/wallet.d.ts +31 -67
  106. package/dist/types/clients/wallet.d.ts.map +1 -1
  107. package/dist/types/contracts/consts.d.ts +6 -0
  108. package/dist/types/contracts/consts.d.ts.map +1 -1
  109. package/dist/types/dns.d.ts +1 -1
  110. package/dist/types/dns.d.ts.map +1 -1
  111. package/dist/types/errors/subgraph.d.ts +4 -4
  112. package/dist/types/errors/subgraph.d.ts.map +1 -1
  113. package/dist/types/errors/utils.d.ts +10 -13
  114. package/dist/types/errors/utils.d.ts.map +1 -1
  115. package/dist/types/errors/version.d.ts +1 -1
  116. package/dist/types/errors/version.d.ts.map +1 -1
  117. package/dist/types/functions/dns/{prepareDnsImport.d.ts → getDnsImportData.d.ts} +11 -12
  118. package/dist/types/functions/dns/{prepareDnsImport.d.ts.map → getDnsImportData.d.ts.map} +1 -1
  119. package/dist/types/functions/dns/importDnsName.d.ts +12 -12
  120. package/dist/types/functions/dns/importDnsName.d.ts.map +1 -1
  121. package/dist/types/functions/public/getSupportedInterfaces.d.ts +19 -4
  122. package/dist/types/functions/public/getSupportedInterfaces.d.ts.map +1 -1
  123. package/dist/types/functions/public/getWrapperData.d.ts +2 -2
  124. package/dist/types/functions/public/getWrapperData.d.ts.map +1 -1
  125. package/dist/types/functions/subgraph/filters.d.ts +693 -0
  126. package/dist/types/functions/subgraph/filters.d.ts.map +1 -0
  127. package/dist/types/functions/subgraph/getNamesForAddress.d.ts +2 -0
  128. package/dist/types/functions/subgraph/getNamesForAddress.d.ts.map +1 -1
  129. package/dist/types/functions/subgraph/getSubnames.d.ts +3 -1
  130. package/dist/types/functions/subgraph/getSubnames.d.ts.map +1 -1
  131. package/dist/types/functions/subgraph/types.d.ts +13 -0
  132. package/dist/types/functions/subgraph/types.d.ts.map +1 -0
  133. package/dist/types/functions/subgraph/utils.d.ts +2 -2
  134. package/dist/types/functions/subgraph/utils.d.ts.map +1 -1
  135. package/dist/types/functions/wallet/commitName.d.ts +1 -1
  136. package/dist/types/functions/wallet/createSubname.d.ts +4 -4
  137. package/dist/types/functions/wallet/createSubname.d.ts.map +1 -1
  138. package/dist/types/functions/wallet/deleteSubname.d.ts +1 -1
  139. package/dist/types/functions/wallet/setAbiRecord.d.ts +1 -1
  140. package/dist/types/functions/wallet/setAddressRecord.d.ts +1 -1
  141. package/dist/types/functions/wallet/setChildFuses.d.ts +3 -3
  142. package/dist/types/functions/wallet/setChildFuses.d.ts.map +1 -1
  143. package/dist/types/functions/wallet/setContentHashRecord.d.ts +1 -1
  144. package/dist/types/functions/wallet/setFuses.d.ts +3 -3
  145. package/dist/types/functions/wallet/setFuses.d.ts.map +1 -1
  146. package/dist/types/functions/wallet/setPrimaryName.d.ts +1 -1
  147. package/dist/types/functions/wallet/setRecords.d.ts +1 -1
  148. package/dist/types/functions/wallet/setResolver.d.ts +1 -1
  149. package/dist/types/functions/wallet/setTextRecord.d.ts +1 -1
  150. package/dist/types/functions/wallet/transferName.d.ts +1 -1
  151. package/dist/types/functions/wallet/unwrapName.d.ts +1 -1
  152. package/dist/types/functions/wallet/wrapName.d.ts +3 -3
  153. package/dist/types/functions/wallet/wrapName.d.ts.map +1 -1
  154. package/dist/types/index.d.ts +1 -1
  155. package/dist/types/index.d.ts.map +1 -1
  156. package/dist/types/utils/contentHash.d.ts +7 -11
  157. package/dist/types/utils/contentHash.d.ts.map +1 -1
  158. package/dist/types/utils/encoders/encodeSetContentHash.d.ts.map +1 -1
  159. package/dist/types/utils/format.d.ts +0 -2
  160. package/dist/types/utils/format.d.ts.map +1 -1
  161. package/dist/types/utils/fuses.d.ts +164 -125
  162. package/dist/types/utils/fuses.d.ts.map +1 -1
  163. package/dist/types/utils/index.d.ts +2 -2
  164. package/dist/types/utils/index.d.ts.map +1 -1
  165. package/dist/types/utils/registerHelpers.d.ts +2 -2
  166. package/dist/types/utils/registerHelpers.d.ts.map +1 -1
  167. package/package.json +4 -3
  168. package/src/clients/decorators/subgraph.ts +1 -0
  169. package/src/contracts/consts.ts +6 -0
  170. package/src/dns.ts +5 -5
  171. package/src/errors/subgraph.ts +4 -4
  172. package/src/errors/utils.ts +21 -18
  173. package/src/errors/version.ts +1 -1
  174. package/src/functions/dns/{prepareDnsImport.ts → getDnsImportData.ts} +12 -13
  175. package/src/functions/dns/importDnsName.ts +20 -15
  176. package/src/functions/public/_getContentHash.ts +2 -2
  177. package/src/functions/public/getSupportedInterfaces.ts +48 -10
  178. package/src/functions/public/getWrapperData.ts +2 -2
  179. package/src/functions/subgraph/filters.ts +702 -0
  180. package/src/functions/subgraph/getNameHistory.ts +2 -2
  181. package/src/functions/subgraph/getNamesForAddress.ts +170 -186
  182. package/src/functions/subgraph/getSubnames.ts +121 -113
  183. package/src/functions/subgraph/types.ts +13 -0
  184. package/src/functions/subgraph/utils.ts +2 -2
  185. package/src/functions/wallet/createSubname.ts +4 -4
  186. package/src/functions/wallet/setChildFuses.ts +3 -3
  187. package/src/functions/wallet/setFuses.ts +6 -3
  188. package/src/functions/wallet/wrapName.ts +8 -3
  189. package/src/index.ts +0 -1
  190. package/src/utils/contentHash.ts +59 -113
  191. package/src/utils/encoders/encodeSetContentHash.ts +2 -4
  192. package/src/utils/format.ts +0 -6
  193. package/src/utils/fuses.ts +308 -308
  194. package/src/utils/index.ts +4 -5
  195. package/src/utils/registerHelpers.ts +5 -3
  196. package/dist/esm/functions/dns/prepareDnsImport.js.map +0 -1
  197. package/src/@types/@ensdomains/content-hash.d.ts +0 -1
  198. package/src/functions/dns/getDnsOwner.test.ts +0 -195
  199. package/src/functions/dns/importDnsName.test.ts +0 -117
  200. package/src/functions/dns/prepareDnsImport.test.ts +0 -115
  201. package/src/functions/public/batch.test.ts +0 -67
  202. package/src/functions/public/ccip.test.ts +0 -78
  203. package/src/functions/public/getAbiRecord.test.ts +0 -174
  204. package/src/functions/public/getAddressRecord.test.ts +0 -83
  205. package/src/functions/public/getAvailable.test.ts +0 -17
  206. package/src/functions/public/getContentHashRecord.test.ts +0 -28
  207. package/src/functions/public/getExpiry.test.ts +0 -48
  208. package/src/functions/public/getName.test.ts +0 -66
  209. package/src/functions/public/getOwner.test.ts +0 -87
  210. package/src/functions/public/getPrice.test.ts +0 -45
  211. package/src/functions/public/getRecords.test.ts +0 -49
  212. package/src/functions/public/getResolver.test.ts +0 -12
  213. package/src/functions/public/getTextRecord.test.ts +0 -20
  214. package/src/functions/public/getWrapperData.test.ts +0 -79
  215. package/src/functions/public/getWrapperName.test.ts +0 -19
  216. package/src/functions/subgraph/client.test.ts +0 -170
  217. package/src/functions/subgraph/getDecodedName.test.ts +0 -31
  218. package/src/functions/subgraph/getNameHistory.test.ts +0 -39
  219. package/src/functions/subgraph/getNamesForAddress.test.ts +0 -244
  220. package/src/functions/subgraph/getSubgraphRecords.test.ts +0 -74
  221. package/src/functions/subgraph/getSubgraphRegistrant.test.ts +0 -34
  222. package/src/functions/subgraph/getSubnames.test.ts +0 -202
  223. package/src/functions/wallet/commitName.test.ts +0 -58
  224. package/src/functions/wallet/createSubname.test.ts +0 -73
  225. package/src/functions/wallet/deleteSubname.test.ts +0 -150
  226. package/src/functions/wallet/registerName.test.ts +0 -81
  227. package/src/functions/wallet/renewNames.test.ts +0 -92
  228. package/src/functions/wallet/setAbiRecord.test.ts +0 -156
  229. package/src/functions/wallet/setAddressRecord.test.ts +0 -121
  230. package/src/functions/wallet/setChildFuses.test.ts +0 -97
  231. package/src/functions/wallet/setContentHashRecord.test.ts +0 -69
  232. package/src/functions/wallet/setFuses.test.ts +0 -287
  233. package/src/functions/wallet/setPrimaryName.test.ts +0 -71
  234. package/src/functions/wallet/setRecords.test.ts +0 -127
  235. package/src/functions/wallet/setResolver.test.ts +0 -114
  236. package/src/functions/wallet/setTextRecord.test.ts +0 -67
  237. package/src/functions/wallet/transferName.test.ts +0 -201
  238. package/src/functions/wallet/unwrapName.test.ts +0 -93
  239. package/src/functions/wallet/wrapName.test.ts +0 -195
  240. package/src/utils/generateRecordCallArray.test.ts +0 -84
  241. package/src/utils/labels.test.ts +0 -163
  242. package/src/utils/makeLabelNodeAndParent.test.ts +0 -11
  243. package/src/utils/makeSafeSecondsDate.test.ts +0 -14
  244. package/src/utils/normalise.test.ts +0 -35
  245. package/src/utils/ownerFromContract.test.ts +0 -52
  246. package/src/utils/registerHelpers.test.ts +0 -159
  247. package/src/utils/validation.test.ts +0 -170
  248. package/src/utils/wrapper.test.ts +0 -46
@@ -21,13 +21,13 @@ import type {
21
21
  WriteTransactionParameters,
22
22
  } from '../../types.js'
23
23
  import { packetToBytes } from '../../utils/hexEncodedName.js'
24
- import type { PrepareDnsImportReturnType } from './prepareDnsImport.js'
24
+ import type { GetDnsImportDataReturnType } from './getDnsImportData.js'
25
25
 
26
26
  type BaseImportDnsNameDataParameters = {
27
27
  /** Name to import */
28
28
  name: string
29
- /** Data returned from `prepareDnsImport()` */
30
- preparedData: PrepareDnsImportReturnType
29
+ /** Data returned from `getDnsImportData()` */
30
+ dnsImportData: GetDnsImportDataReturnType
31
31
  /** Address to claim the name for */
32
32
  address?: Address
33
33
  /** Address of the resolver to use (default: `ensPublicResolver`) */
@@ -65,9 +65,14 @@ export const makeFunctionData = <
65
65
  TAccount extends Account | undefined,
66
66
  >(
67
67
  wallet: WalletWithEns<Transport, TChain, TAccount>,
68
- { name, preparedData, address, resolverAddress }: ImportDnsNameDataParameters,
68
+ {
69
+ name,
70
+ dnsImportData,
71
+ address,
72
+ resolverAddress,
73
+ }: ImportDnsNameDataParameters,
69
74
  ): ImportDnsNameDataReturnType => {
70
- const data = preparedData.rrsets.map((rrset) => ({
75
+ const data = dnsImportData.rrsets.map((rrset) => ({
71
76
  rrset: bytesToHex(rrset.rrset),
72
77
  sig: bytesToHex(rrset.sig),
73
78
  }))
@@ -81,7 +86,7 @@ export const makeFunctionData = <
81
86
  if (resolverAddress)
82
87
  throw new AdditionalParameterSpecifiedError({
83
88
  parameter: 'resolverAddress',
84
- allowedParameters: ['name', 'preparedData'],
89
+ allowedParameters: ['name', 'dnsImportData'],
85
90
  details:
86
91
  'resolverAddress cannot be specified when claiming without an address',
87
92
  })
@@ -90,7 +95,7 @@ export const makeFunctionData = <
90
95
  data: encodeFunctionData({
91
96
  abi: dnsRegistrarProveAndClaimSnippet,
92
97
  functionName: 'proveAndClaim',
93
- args: [hexEncodedName, data, bytesToHex(preparedData.proof)],
98
+ args: [hexEncodedName, data, bytesToHex(dnsImportData.proof)],
94
99
  }),
95
100
  }
96
101
  }
@@ -107,7 +112,7 @@ export const makeFunctionData = <
107
112
  args: [
108
113
  hexEncodedName,
109
114
  data,
110
- bytesToHex(preparedData.proof),
115
+ bytesToHex(dnsImportData.proof),
111
116
  resolverAddress_,
112
117
  address,
113
118
  ],
@@ -124,9 +129,9 @@ export const makeFunctionData = <
124
129
  * @example
125
130
  * import { createPublicClient, createWalletClient, http, custom } from 'viem'
126
131
  * import { mainnet } from 'viem/chains'
127
- * import { addContracts, prepareDnsImport, importDnsName } from '@ensdomains/ensjs'
132
+ * import { addEnsContracts, getDnsImportData, importDnsName } from '@ensdomains/ensjs'
128
133
  *
129
- * const [mainnetWithEns] = addContracts([mainnet])
134
+ * const mainnetWithEns = addEnsContracts(mainnet)
130
135
  * const client = createPublicClient({
131
136
  * chain: mainnetWithEns,
132
137
  * transport: http(),
@@ -135,12 +140,12 @@ export const makeFunctionData = <
135
140
  * chain: mainnetWithEns,
136
141
  * transport: custom(window.ethereum),
137
142
  * })
138
- * const preparedData = await prepareDnsImport(client, {
143
+ * const dnsImportData = await getDnsImportData(client, {
139
144
  * name: 'example.com',
140
145
  * })
141
- * const hash = await importDnsName(client, {
146
+ * const hash = await importDnsName(wallet, {
142
147
  * name: 'example.com',
143
- * preparedData,
148
+ * dnsImportData,
144
149
  * })
145
150
  */
146
151
  async function importDnsName<
@@ -152,7 +157,7 @@ async function importDnsName<
152
157
  {
153
158
  name,
154
159
  address,
155
- preparedData,
160
+ dnsImportData,
156
161
  resolverAddress,
157
162
  ...txArgs
158
163
  }: ImportDnsNameParameters<TChain, TAccount, TChainOverride>,
@@ -160,7 +165,7 @@ async function importDnsName<
160
165
  const data = makeFunctionData(wallet, {
161
166
  name,
162
167
  address,
163
- preparedData,
168
+ dnsImportData,
164
169
  resolverAddress,
165
170
  } as ImportDnsNameDataParameters)
166
171
  const writeArgs = {
@@ -4,7 +4,7 @@ import { publicResolverContenthashSnippet } from '../../contracts/publicResolver
4
4
  import type { Prettify, SimpleTransactionRequest } from '../../types.js'
5
5
  import { EMPTY_ADDRESS } from '../../utils/consts.js'
6
6
  import {
7
- decodeContenthash,
7
+ decodeContentHash,
8
8
  type DecodedContentHash,
9
9
  } from '../../utils/contentHash.js'
10
10
  import { generateFunction } from '../../utils/generateFunction.js'
@@ -44,7 +44,7 @@ const decode = async (
44
44
  data,
45
45
  })
46
46
 
47
- return decodeContenthash(response)
47
+ return decodeContentHash(response)
48
48
  }
49
49
 
50
50
  const _getContentHash = generateFunction({ encode, decode })
@@ -1,4 +1,10 @@
1
- import { BaseError, encodeFunctionData, type Address, type Hex } from 'viem'
1
+ import {
2
+ BaseError,
3
+ encodeFunctionData,
4
+ padHex,
5
+ type Address,
6
+ type Hex,
7
+ } from 'viem'
2
8
  import type { ClientWithEns } from '../../contracts/consts.js'
3
9
  import { erc165SupportsInterfaceSnippet } from '../../contracts/erc165.js'
4
10
  import type {
@@ -8,12 +14,18 @@ import type {
8
14
  import { generateFunction } from '../../utils/generateFunction.js'
9
15
  import multicallWrapper from './multicallWrapper.js'
10
16
 
11
- export type GetSupportedInterfacesParameters = {
17
+ export type GetSupportedInterfacesParameters<
18
+ TInterfaces extends readonly Hex[],
19
+ > = {
12
20
  address: Address
13
- interfaces: Hex[]
21
+ interfaces: TInterfaces
14
22
  }
15
23
 
16
- export type GetSupportedInterfacesReturnType = boolean[]
24
+ export type GetSupportedInterfacesReturnType<
25
+ TInterfaces extends readonly Hex[],
26
+ > = {
27
+ -readonly [K in keyof TInterfaces]: boolean
28
+ }
17
29
 
18
30
  const encodeInterface = (interfaceId: Hex): Hex =>
19
31
  encodeFunctionData({
@@ -22,9 +34,9 @@ const encodeInterface = (interfaceId: Hex): Hex =>
22
34
  args: [interfaceId],
23
35
  })
24
36
 
25
- const encode = (
37
+ const encode = <TInterfaces extends Hex[]>(
26
38
  client: ClientWithEns,
27
- { address, interfaces }: GetSupportedInterfacesParameters,
39
+ { address, interfaces }: GetSupportedInterfacesParameters<TInterfaces>,
28
40
  ): TransactionRequestWithPassthrough => {
29
41
  const calls = interfaces.map((interfaceId) => ({
30
42
  to: address,
@@ -39,16 +51,42 @@ const encode = (
39
51
  }
40
52
  }
41
53
 
42
- const decode = async (
54
+ const decode = async <const TInterfaces extends readonly Hex[]>(
43
55
  client: ClientWithEns,
44
56
  data: Hex | BaseError,
45
57
  passthrough: SimpleTransactionRequest[],
46
- ): Promise<GetSupportedInterfacesReturnType> => {
58
+ ): Promise<GetSupportedInterfacesReturnType<TInterfaces>> => {
47
59
  if (typeof data === 'object') throw data
48
60
  const result = await multicallWrapper.decode(client, data, passthrough)
49
- return result.map((r) => r.success && r.returnData === '0x01')
61
+ return result.map(
62
+ (r) => r.success && r.returnData === padHex('0x01'),
63
+ ) as GetSupportedInterfacesReturnType<TInterfaces>
64
+ }
65
+
66
+ type EncoderFunction = typeof encode
67
+ type DecoderFunction = typeof decode
68
+
69
+ type BatchableFunctionObject = {
70
+ encode: EncoderFunction
71
+ decode: DecoderFunction
72
+ batch: <
73
+ const TInterfaces extends readonly Hex[],
74
+ TParams extends GetSupportedInterfacesParameters<TInterfaces>,
75
+ >(
76
+ args: TParams,
77
+ ) => {
78
+ args: [TParams]
79
+ encode: EncoderFunction
80
+ decode: typeof decode<TInterfaces>
81
+ }
50
82
  }
51
83
 
52
- const getSupportedInterfaces = generateFunction({ encode, decode })
84
+ const getSupportedInterfaces = generateFunction({ encode, decode }) as (<
85
+ const TInterfaces extends readonly Hex[],
86
+ >(
87
+ client: ClientWithEns,
88
+ { address, interfaces }: GetSupportedInterfacesParameters<TInterfaces>,
89
+ ) => Promise<GetSupportedInterfacesReturnType<TInterfaces>>) &
90
+ BatchableFunctionObject
53
91
 
54
92
  export default getSupportedInterfaces
@@ -16,7 +16,7 @@ import type {
16
16
  TransactionRequestWithPassthrough,
17
17
  } from '../../types.js'
18
18
  import { EMPTY_ADDRESS } from '../../utils/consts.js'
19
- import { decodeFuses } from '../../utils/fuses.js'
19
+ import { decodeFuses, type DecodedFuses } from '../../utils/fuses.js'
20
20
  import {
21
21
  generateFunction,
22
22
  type GeneratedFunction,
@@ -31,7 +31,7 @@ export type GetWrapperDataParameters = {
31
31
 
32
32
  export type GetWrapperDataReturnType = Prettify<{
33
33
  /** Fuse object */
34
- fuses: ReturnType<typeof decodeFuses> & {
34
+ fuses: DecodedFuses & {
35
35
  value: number
36
36
  }
37
37
  /** Expiry of the name */