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

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 +52 -1
  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/functions/dns/{prepareDnsImport.js → getDnsImportData.js} +3 -3
  11. package/dist/cjs/functions/dns/{prepareDnsImport.js.map → getDnsImportData.js.map} +1 -1
  12. package/dist/cjs/functions/dns/importDnsName.js +7 -7
  13. package/dist/cjs/functions/dns/importDnsName.js.map +1 -1
  14. package/dist/cjs/functions/public/_getContentHash.js +1 -1
  15. package/dist/cjs/functions/public/getSupportedInterfaces.js +1 -1
  16. package/dist/cjs/functions/public/getSupportedInterfaces.js.map +1 -1
  17. package/dist/cjs/functions/public/getWrapperData.js.map +1 -1
  18. package/dist/cjs/functions/subgraph/filters.js +3 -0
  19. package/dist/cjs/functions/subgraph/filters.js.map +1 -0
  20. package/dist/cjs/functions/subgraph/getNameHistory.js +1 -1
  21. package/dist/cjs/functions/subgraph/getNamesForAddress.js +140 -182
  22. package/dist/cjs/functions/subgraph/getNamesForAddress.js.map +1 -1
  23. package/dist/cjs/functions/subgraph/getSubnames.js +95 -108
  24. package/dist/cjs/functions/subgraph/getSubnames.js.map +1 -1
  25. package/dist/cjs/functions/subgraph/types.js +3 -0
  26. package/dist/cjs/functions/subgraph/types.js.map +1 -0
  27. package/dist/cjs/functions/subgraph/utils.js.map +1 -1
  28. package/dist/cjs/functions/wallet/createSubname.js +1 -1
  29. package/dist/cjs/functions/wallet/createSubname.js.map +1 -1
  30. package/dist/cjs/functions/wallet/setChildFuses.js +1 -1
  31. package/dist/cjs/functions/wallet/setChildFuses.js.map +1 -1
  32. package/dist/cjs/functions/wallet/setFuses.js +1 -1
  33. package/dist/cjs/functions/wallet/setFuses.js.map +1 -1
  34. package/dist/cjs/functions/wallet/wrapName.js +3 -1
  35. package/dist/cjs/functions/wallet/wrapName.js.map +1 -1
  36. package/dist/cjs/index.js +1 -2
  37. package/dist/cjs/index.js.map +1 -1
  38. package/dist/cjs/utils/contentHash.js +54 -131
  39. package/dist/cjs/utils/contentHash.js.map +1 -1
  40. package/dist/cjs/utils/encoders/encodeSetContentHash.js +1 -4
  41. package/dist/cjs/utils/encoders/encodeSetContentHash.js.map +1 -1
  42. package/dist/cjs/utils/format.js +1 -5
  43. package/dist/cjs/utils/format.js.map +1 -1
  44. package/dist/cjs/utils/fuses.js +181 -200
  45. package/dist/cjs/utils/fuses.js.map +1 -1
  46. package/dist/cjs/utils/index.js +4 -7
  47. package/dist/cjs/utils/index.js.map +1 -1
  48. package/dist/cjs/utils/registerHelpers.js +3 -1
  49. package/dist/cjs/utils/registerHelpers.js.map +1 -1
  50. package/dist/esm/clients/decorators/subgraph.js.map +1 -1
  51. package/dist/esm/contracts/consts.js +52 -1
  52. package/dist/esm/contracts/consts.js.map +1 -1
  53. package/dist/esm/dns.js +1 -1
  54. package/dist/esm/dns.js.map +1 -1
  55. package/dist/esm/errors/subgraph.js.map +1 -1
  56. package/dist/esm/errors/utils.js +13 -16
  57. package/dist/esm/errors/utils.js.map +1 -1
  58. package/dist/esm/errors/version.js +1 -1
  59. package/dist/esm/functions/dns/{prepareDnsImport.js → getDnsImportData.js} +9 -10
  60. package/dist/esm/functions/dns/getDnsImportData.js.map +1 -0
  61. package/dist/esm/functions/dns/importDnsName.js +12 -12
  62. package/dist/esm/functions/dns/importDnsName.js.map +1 -1
  63. package/dist/esm/functions/public/_getContentHash.js +2 -2
  64. package/dist/esm/functions/public/getSupportedInterfaces.js +2 -2
  65. package/dist/esm/functions/public/getSupportedInterfaces.js.map +1 -1
  66. package/dist/esm/functions/public/getWrapperData.js.map +1 -1
  67. package/dist/esm/functions/subgraph/filters.js +2 -0
  68. package/dist/esm/functions/subgraph/filters.js.map +1 -0
  69. package/dist/esm/functions/subgraph/getNameHistory.js +2 -2
  70. package/dist/esm/functions/subgraph/getNamesForAddress.js +144 -183
  71. package/dist/esm/functions/subgraph/getNamesForAddress.js.map +1 -1
  72. package/dist/esm/functions/subgraph/getSubnames.js +101 -111
  73. package/dist/esm/functions/subgraph/getSubnames.js.map +1 -1
  74. package/dist/esm/functions/subgraph/types.js +2 -0
  75. package/dist/esm/functions/subgraph/types.js.map +1 -0
  76. package/dist/esm/functions/subgraph/utils.js.map +1 -1
  77. package/dist/esm/functions/wallet/createSubname.js +1 -1
  78. package/dist/esm/functions/wallet/createSubname.js.map +1 -1
  79. package/dist/esm/functions/wallet/setChildFuses.js +1 -1
  80. package/dist/esm/functions/wallet/setChildFuses.js.map +1 -1
  81. package/dist/esm/functions/wallet/setFuses.js +2 -2
  82. package/dist/esm/functions/wallet/setFuses.js.map +1 -1
  83. package/dist/esm/functions/wallet/wrapName.js +4 -2
  84. package/dist/esm/functions/wallet/wrapName.js.map +1 -1
  85. package/dist/esm/index.js +1 -1
  86. package/dist/esm/index.js.map +1 -1
  87. package/dist/esm/utils/contentHash.js +51 -128
  88. package/dist/esm/utils/contentHash.js.map +1 -1
  89. package/dist/esm/utils/encoders/encodeSetContentHash.js +2 -5
  90. package/dist/esm/utils/encoders/encodeSetContentHash.js.map +1 -1
  91. package/dist/esm/utils/format.js +0 -2
  92. package/dist/esm/utils/format.js.map +1 -1
  93. package/dist/esm/utils/fuses.js +180 -201
  94. package/dist/esm/utils/fuses.js.map +1 -1
  95. package/dist/esm/utils/index.js +2 -2
  96. package/dist/esm/utils/index.js.map +1 -1
  97. package/dist/esm/utils/registerHelpers.js +4 -2
  98. package/dist/esm/utils/registerHelpers.js.map +1 -1
  99. package/dist/types/clients/decorators/subgraph.d.ts +1 -1
  100. package/dist/types/clients/decorators/subgraph.d.ts.map +1 -1
  101. package/dist/types/clients/decorators/wallet.d.ts +12 -12
  102. package/dist/types/clients/public.d.ts +1 -1
  103. package/dist/types/clients/subgraph.d.ts +1 -1
  104. package/dist/types/clients/wallet.d.ts +43 -79
  105. package/dist/types/clients/wallet.d.ts.map +1 -1
  106. package/dist/types/contracts/consts.d.ts +51 -2
  107. package/dist/types/contracts/consts.d.ts.map +1 -1
  108. package/dist/types/dns.d.ts +1 -1
  109. package/dist/types/dns.d.ts.map +1 -1
  110. package/dist/types/errors/subgraph.d.ts +4 -4
  111. package/dist/types/errors/subgraph.d.ts.map +1 -1
  112. package/dist/types/errors/utils.d.ts +10 -13
  113. package/dist/types/errors/utils.d.ts.map +1 -1
  114. package/dist/types/errors/version.d.ts +1 -1
  115. package/dist/types/functions/dns/{prepareDnsImport.d.ts → getDnsImportData.d.ts} +11 -12
  116. package/dist/types/functions/dns/{prepareDnsImport.d.ts.map → getDnsImportData.d.ts.map} +1 -1
  117. package/dist/types/functions/dns/importDnsName.d.ts +36 -36
  118. package/dist/types/functions/dns/importDnsName.d.ts.map +1 -1
  119. package/dist/types/functions/public/getSupportedInterfaces.d.ts +19 -4
  120. package/dist/types/functions/public/getSupportedInterfaces.d.ts.map +1 -1
  121. package/dist/types/functions/public/getWrapperData.d.ts +2 -2
  122. package/dist/types/functions/public/getWrapperData.d.ts.map +1 -1
  123. package/dist/types/functions/subgraph/filters.d.ts +693 -0
  124. package/dist/types/functions/subgraph/filters.d.ts.map +1 -0
  125. package/dist/types/functions/subgraph/getNamesForAddress.d.ts +2 -0
  126. package/dist/types/functions/subgraph/getNamesForAddress.d.ts.map +1 -1
  127. package/dist/types/functions/subgraph/getSubnames.d.ts +3 -1
  128. package/dist/types/functions/subgraph/getSubnames.d.ts.map +1 -1
  129. package/dist/types/functions/subgraph/types.d.ts +13 -0
  130. package/dist/types/functions/subgraph/types.d.ts.map +1 -0
  131. package/dist/types/functions/subgraph/utils.d.ts +2 -2
  132. package/dist/types/functions/subgraph/utils.d.ts.map +1 -1
  133. package/dist/types/functions/wallet/commitName.d.ts +25 -25
  134. package/dist/types/functions/wallet/createSubname.d.ts +28 -28
  135. package/dist/types/functions/wallet/createSubname.d.ts.map +1 -1
  136. package/dist/types/functions/wallet/deleteSubname.d.ts +25 -25
  137. package/dist/types/functions/wallet/registerName.d.ts +24 -24
  138. package/dist/types/functions/wallet/renewNames.d.ts +24 -24
  139. package/dist/types/functions/wallet/setAbiRecord.d.ts +25 -25
  140. package/dist/types/functions/wallet/setAddressRecord.d.ts +25 -25
  141. package/dist/types/functions/wallet/setChildFuses.d.ts +27 -27
  142. package/dist/types/functions/wallet/setChildFuses.d.ts.map +1 -1
  143. package/dist/types/functions/wallet/setContentHashRecord.d.ts +25 -25
  144. package/dist/types/functions/wallet/setFuses.d.ts +27 -27
  145. package/dist/types/functions/wallet/setFuses.d.ts.map +1 -1
  146. package/dist/types/functions/wallet/setPrimaryName.d.ts +25 -25
  147. package/dist/types/functions/wallet/setRecords.d.ts +25 -25
  148. package/dist/types/functions/wallet/setResolver.d.ts +25 -25
  149. package/dist/types/functions/wallet/setTextRecord.d.ts +25 -25
  150. package/dist/types/functions/wallet/transferName.d.ts +25 -25
  151. package/dist/types/functions/wallet/unwrapName.d.ts +25 -25
  152. package/dist/types/functions/wallet/wrapName.d.ts +27 -27
  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 +57 -12
  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
@@ -1,79 +0,0 @@
1
- import { publicClient } from '../../tests/addTestContracts.js'
2
- import getWrapperData from './getWrapperData.js'
3
-
4
- describe('getWrapperData', () => {
5
- it('should return null for an unwrapped name', async () => {
6
- const result = await getWrapperData(publicClient, {
7
- name: 'with-profile.eth',
8
- })
9
- expect(result).toBeNull()
10
- })
11
- it('should return with CAN_DO_EVERYTHING set to true for a name with no fuses burned', async () => {
12
- const result = await getWrapperData(publicClient, {
13
- name: 'test.wrapped-with-subnames.eth',
14
- })
15
- expect(result).toBeTruthy()
16
- if (result) {
17
- expect(result.fuses.child.CAN_DO_EVERYTHING).toBe(true)
18
- expect(result.fuses.value).toBe(0)
19
- }
20
- })
21
- // it('should return with other correct fuses', async () => {
22
- // const tx = await ensInstance.setFuses('wrapped.eth', {
23
- // named: [
24
- // 'CANNOT_UNWRAP',
25
- // 'CANNOT_CREATE_SUBDOMAIN',
26
- // 'CANNOT_SET_TTL',
27
- // 'CANNOT_APPROVE',
28
- // ],
29
- // addressOrIndex: 1,
30
- // })
31
- // await tx.wait()
32
-
33
- // const result = await ensInstance.getWrapperData('wrapped.eth')
34
- // expect(result).toBeTruthy()
35
- // if (result) {
36
- // expect(result.child.CAN_DO_EVERYTHING).toBe(false)
37
- // expect(result.child.CANNOT_UNWRAP).toBe(true)
38
- // expect(result.child.CANNOT_CREATE_SUBDOMAIN).toBe(true)
39
- // expect(result.child.CANNOT_SET_TTL).toBe(true)
40
- // expect(result.child.CANNOT_APPROVE).toBe(true)
41
- // expect(result.parent.IS_DOT_ETH).toBe(true)
42
- // }
43
- // })
44
- it('should return correct expiry', async () => {
45
- const result = await getWrapperData(publicClient, {
46
- name: 'wrapped.eth',
47
- })
48
- expect(result).toBeTruthy()
49
- if (result) {
50
- expect(result.expiry!.date).toBeInstanceOf(Date)
51
- expect(typeof result.expiry!.value).toBe('bigint')
52
- expect(Number.isNaN(result.expiry!.date.getTime())).toBe(false)
53
- }
54
- })
55
- it('should return correct expiry for large expiry', async () => {
56
- const result = await getWrapperData(publicClient, {
57
- name: 'wrapped-big-duration.eth',
58
- })
59
- expect(result).toBeTruthy()
60
- if (result) {
61
- expect(result.expiry!.date).toBeInstanceOf(Date)
62
- expect(typeof result.expiry!.value).toBe('bigint')
63
- expect(result.expiry!.date.getFullYear()).toBe(275760)
64
- expect(Number.isNaN(result.expiry!.date.getTime())).toBe(false)
65
- }
66
- })
67
- it('should return correct max expiry for expiry larger than maximum for date', async () => {
68
- const result = await getWrapperData(publicClient, {
69
- name: 'wrapped-max-duration.eth',
70
- })
71
- expect(result).toBeTruthy()
72
- if (result) {
73
- expect(result.expiry!.date).toBeInstanceOf(Date)
74
- expect(typeof result.expiry!.value).toBe('bigint')
75
- expect(result.expiry!.date.getFullYear()).toBe(275760)
76
- expect(Number.isNaN(result.expiry!.date.getTime())).toBe(false)
77
- }
78
- })
79
- })
@@ -1,19 +0,0 @@
1
- import { publicClient } from '../../tests/addTestContracts.js'
2
- import getWrapperName from './getWrapperName.js'
3
-
4
- describe('getWrapperName()', () => {
5
- it('should return name for existing name', async () => {
6
- const result = await getWrapperName(publicClient, {
7
- // wrapped.eth
8
- name: '[4ca938ec1b323ca71c4fb47a712abb68cce1cabf39ea4d6789e42fbc1f95459b].eth',
9
- })
10
- expect(result).toBe('wrapped.eth')
11
- })
12
- it('should return null for non-existent name', async () => {
13
- const result = await getWrapperName(publicClient, {
14
- // test123.eth
15
- name: '[f81b517a242b218999ec8eec0ea6e2ddbef2a367a14e93f4a32a39e260f686ad].eth',
16
- })
17
- expect(result).toBeNull()
18
- })
19
- })
@@ -1,170 +0,0 @@
1
- import { namehash } from 'viem'
2
- import { requestMiddleware, responseMiddleware } from './client.js'
3
-
4
- const queryWithoutId = `
5
- query getNames($id: ID!, $expiryDate: Int) {
6
- account(id: $id) {
7
- registrations(first: 1000, where: { expiryDate_gt: $expiryDate }) {
8
- registrationDate
9
- expiryDate
10
- domain {
11
- labelName
12
- labelhash
13
- name
14
- isMigrated
15
- parent {
16
- name
17
- }
18
- }
19
- }
20
- domains(first: 1000) {
21
- labelName
22
- labelhash
23
- name
24
- isMigrated
25
- parent {
26
- name
27
- }
28
- createdAt
29
- }
30
- }
31
- }
32
- `
33
-
34
- const mockRequest = {
35
- method: 'POST',
36
- headers: {
37
- // eslint-disable-next-line @typescript-eslint/naming-convention
38
- 'Content-Type': 'application/json',
39
- },
40
- body: JSON.stringify({ query: queryWithoutId }),
41
- }
42
-
43
- const mockResponse = {
44
- data: {
45
- account: {
46
- registrations: [
47
- {
48
- registrationDate: '1659245504',
49
- expiryDate: '1690781504',
50
- domain: {
51
- id: '0xb1ccf7f6bb648f39ba48bf80f4a8a4522f474ee7d1edd6ea65f7fa51fe8b1612',
52
- labelName: 'randydandy',
53
- labelhash:
54
- '0x63fd5bfdd0b1eb9f4c33c209b7c3e7dcb87a761d926a65e267f7cb99ee313ddd',
55
- name: '0xde2551f43e950a2a4d4e6052f25edc450c48a5338faa27f09d1ee99ca9dc04fd',
56
- isMigrated: true,
57
- parent: {
58
- name: '0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae',
59
- invalidName: true,
60
- },
61
- invalidName: true,
62
- },
63
- },
64
- {
65
- registrationDate: '1635284756',
66
- expiryDate: '1666841708',
67
- domain: {
68
- id: '0xde2551f43e950a2a4d4e6052f25edc450c48a5338faa27f09d1ee99ca9dc04fd',
69
- labelName: 'randydandy',
70
- labelhash:
71
- '0x6a877a8d92ad83c8d044d0c5b69aa0da3050f4d653dcc149fca952d6439e4105',
72
- name: 'randydandy.eth',
73
- isMigrated: true,
74
- parent: {
75
- name: '0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae',
76
- invalidName: true,
77
- },
78
- },
79
- },
80
- {
81
- registrationDate: '1659250465',
82
- expiryDate: '1690786465',
83
- domain: {
84
- id: '0xaf119e72f050e5acad6b2d97826a7afb45afe9407376a2ab8240b62173b2d7c2',
85
- labelName: 'nullbyte',
86
- labelhash:
87
- '0xc8985f8323b3dc707003a6ef5b379d9e8a058b6d6bcc2cfb307c61ca36920e27',
88
- name: '0xb54c7c79c89d571f1fbf4c67f524e336a04441eeee4d76f156e835da99a46ddb',
89
- isMigrated: true,
90
- parent: {
91
- name: '0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae',
92
- invalidName: true,
93
- },
94
- invalidName: true,
95
- },
96
- },
97
- ],
98
- domains: [
99
- {
100
- id: '0xaf119e72f050e5acad6b2d97826a7afb45afe9407376a2ab8240b62173b2d7c2',
101
- labelName: 'nullbyte',
102
- labelhash:
103
- '0xc8985f8323b3dc707003a6ef5b379d9e8a058b6d6bcc2cfb307c61ca36920e27',
104
- name: '0xb54c7c79c89d571f1fbf4c67f524e336a04441eeee4d76f156e835da99a46ddb',
105
- isMigrated: true,
106
- parent: {
107
- name: '0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae',
108
- invalidName: true,
109
- },
110
- createdAt: '1659250465',
111
- invalidName: true,
112
- },
113
- {
114
- id: '0xb1ccf7f6bb648f39ba48bf80f4a8a4522f474ee7d1edd6ea65f7fa51fe8b1612',
115
- labelName: 'randydandy',
116
- labelhash:
117
- '0x63fd5bfdd0b1eb9f4c33c209b7c3e7dcb87a761d926a65e267f7cb99ee313ddd',
118
- name: '0xde2551f43e950a2a4d4e6052f25edc450c48a5338faa27f09d1ee99ca9dc04fd',
119
- isMigrated: true,
120
- parent: {
121
- name: '0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae',
122
- invalidName: true,
123
- },
124
- createdAt: '1659245504',
125
- invalidName: true,
126
- },
127
- {
128
- id: '0xde2551f43e950a2a4d4e6052f25edc450c48a5338faa27f09d1ee99ca9dc04fd',
129
- labelName: 'randydandy',
130
- labelhash:
131
- '0x6a877a8d92ad83c8d044d0c5b69aa0da3050f4d653dcc149fca952d6439e4105',
132
- name: 'randydandy.eth',
133
- isMigrated: true,
134
- parent: {
135
- name: '0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae',
136
- invalidName: true,
137
- },
138
- createdAt: '1635284756',
139
- },
140
- ],
141
- },
142
- },
143
- headers: {
144
- map: {
145
- // eslint-disable-next-line @typescript-eslint/naming-convention
146
- 'Content-Type': 'application/json',
147
- },
148
- },
149
- status: 200,
150
- }
151
-
152
- describe('requestMiddleware', () => {
153
- it('should add id to a SelectionSet if name is present and id is not', () => {
154
- const result = requestMiddleware(mockRequest as any)
155
- const body = (result as any).body as string
156
- expect(body.match(/domain.*id.*id.*domains.*id.*id/)?.length).toBe(1)
157
- })
158
- })
159
-
160
- describe('responseMiddleware', () => {
161
- it('should replace name with the namehash when there is an invalid name and id combo', () => {
162
- const response = { ...mockResponse }
163
- responseMiddleware(response as any)
164
- expect(response.data.account.domains[0].name).toBe(
165
- namehash(
166
- '0xb54c7c79c89d571f1fbf4c67f524e336a04441eeee4d76f156e835da99a46ddb',
167
- ),
168
- )
169
- })
170
- })
@@ -1,31 +0,0 @@
1
- import { publicClient } from '../../tests/addTestContracts.js'
2
- import getDecodedName from './getDecodedName.js'
3
-
4
- it('should decode a name via namehash lookup', async () => {
5
- const result = await getDecodedName(publicClient, {
6
- name: '[9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658].wrapped-with-subnames.eth',
7
- })
8
- expect(result).toBe('test.wrapped-with-subnames.eth')
9
- })
10
- it('should decode a name via labelhash lookup', async () => {
11
- const result = await getDecodedName(publicClient, {
12
- name: '[f81b517a242b218999ec8eec0ea6e2ddbef2a367a14e93f4a32a39e260f686ad].eth',
13
- })
14
- expect(result).toBe('test123.eth')
15
- })
16
- it('should partially decode a name when allowIncomplete is true', async () => {
17
- const result = await getDecodedName(publicClient, {
18
- name: '[7bffb6e3ebf801bbc438fea5c11d957ba49978bdc8d52b71cba974139d22edea].[6c14e1739568670447af1d5af8a571008f7a582068af18bcd7ac2dbc13bb37c1].eth',
19
- allowIncomplete: true,
20
- })
21
- expect(result).toBe(
22
- '[7bffb6e3ebf801bbc438fea5c11d957ba49978bdc8d52b71cba974139d22edea].with-unknown-subnames.eth',
23
- )
24
- })
25
- it('should not partially decode a name when allowIncomplete is false', async () => {
26
- const result = await getDecodedName(publicClient, {
27
- name: '[7bffb6e3ebf801bbc438fea5c11d957ba49978bdc8d52b71cba974139d22edea].[6c14e1739568670447af1d5af8a571008f7a582068af18bcd7ac2dbc13bb37c1].eth',
28
- allowIncomplete: false,
29
- })
30
- expect(result).toBeNull()
31
- })
@@ -1,39 +0,0 @@
1
- import { publicClient } from '../../tests/addTestContracts.js'
2
- import getNameHistory from './getNameHistory.js'
3
-
4
- it('returns null for a non-existent name', async () => {
5
- const result = await getNameHistory(publicClient, {
6
- name: 'test123123cool.eth',
7
- })
8
- expect(result).toBeNull()
9
- })
10
-
11
- it('returns the history of a name', async () => {
12
- const result = await getNameHistory(publicClient, {
13
- name: 'with-profile.eth',
14
- })
15
- if (!result) throw new Error('No result')
16
- expect(result.domainEvents.length).toBeGreaterThan(0)
17
- expect(result.registrationEvents!.length).toBeGreaterThan(0)
18
- expect(result.resolverEvents!.length).toBeGreaterThan(0)
19
- })
20
-
21
- it('returns the history of a wrapped name', async () => {
22
- const result = await getNameHistory(publicClient, {
23
- name: 'wrapped.eth',
24
- })
25
- if (!result) throw new Error('No result')
26
- expect(result.domainEvents.length).toBeGreaterThan(0)
27
- expect(result.registrationEvents!.length).toBeGreaterThan(0)
28
- expect(result.resolverEvents).not.toBeNull()
29
- })
30
-
31
- it('returns the history of a subname', async () => {
32
- const result = await getNameHistory(publicClient, {
33
- name: 'test.wrapped-with-subnames.eth',
34
- })
35
- if (!result) throw new Error('No result')
36
- expect(result.domainEvents.length).toBeGreaterThan(0)
37
- expect(result.registrationEvents).toBeNull()
38
- expect(result.resolverEvents).not.toBeNull()
39
- })
@@ -1,244 +0,0 @@
1
- /* eslint-disable no-await-in-loop */
2
-
3
- import type { Address } from 'viem'
4
- import { publicClient, walletClient } from '../../tests/addTestContracts.js'
5
- import getNamesForAddress, {
6
- type NameWithRelation,
7
- } from './getNamesForAddress.js'
8
-
9
- let accounts: Address[]
10
-
11
- beforeAll(async () => {
12
- accounts = await walletClient.getAddresses()
13
- })
14
-
15
- it('returns with default values', async () => {
16
- const result = await getNamesForAddress(publicClient, {
17
- address: accounts[1],
18
- })
19
-
20
- expect(result).toBeTruthy()
21
- // arbitrary number, just to make sure we get some results
22
- expect(result.length).toBeGreaterThan(10)
23
- })
24
-
25
- it('has registration date on .eth names', async () => {
26
- const result = await getNamesForAddress(publicClient, {
27
- address: accounts[1],
28
- })
29
- if (!result.length) throw new Error('No names found')
30
- for (const name of result) {
31
- if (name.parentName === 'eth') {
32
- expect(name.registrationDate).toBeTruthy()
33
- }
34
- }
35
- })
36
- describe('filter', () => {
37
- it('filters by owner', async () => {
38
- const result = await getNamesForAddress(publicClient, {
39
- address: accounts[1],
40
- filter: {
41
- owner: true,
42
- registrant: false,
43
- resolvedAddress: false,
44
- wrappedOwner: false,
45
- },
46
- })
47
- if (!result.length) throw new Error('No names found')
48
- for (const name of result) {
49
- expect(name.owner).toBe(accounts[1])
50
- expect(name.relation.owner).toBe(true)
51
- }
52
- })
53
- it('filters by registrant', async () => {
54
- const result = await getNamesForAddress(publicClient, {
55
- address: accounts[1],
56
- filter: {
57
- owner: false,
58
- registrant: true,
59
- resolvedAddress: false,
60
- wrappedOwner: false,
61
- },
62
- })
63
- if (!result.length) throw new Error('No names found')
64
- for (const name of result) {
65
- expect(name.registrant).toBe(accounts[1])
66
- expect(name.relation.registrant).toBe(true)
67
- }
68
- })
69
- it('filters by resolved address', async () => {
70
- const result = await getNamesForAddress(publicClient, {
71
- address: accounts[1],
72
- filter: {
73
- owner: false,
74
- registrant: false,
75
- resolvedAddress: true,
76
- wrappedOwner: false,
77
- },
78
- })
79
- if (!result.length) throw new Error('No names found')
80
- for (const name of result) {
81
- expect(name.resolvedAddress).toBe(accounts[1])
82
- expect(name.relation.resolvedAddress).toBe(true)
83
- }
84
- })
85
- it('filters by wrapped owner', async () => {
86
- const result = await getNamesForAddress(publicClient, {
87
- address: accounts[1],
88
- filter: {
89
- owner: false,
90
- registrant: false,
91
- resolvedAddress: false,
92
- wrappedOwner: true,
93
- },
94
- })
95
- if (!result.length) throw new Error('No names found')
96
- for (const name of result) {
97
- expect(name.wrappedOwner).toBe(accounts[1])
98
- expect(name.relation.wrappedOwner).toBe(true)
99
- }
100
- })
101
- it('allows including expired names', async () => {
102
- const result = await getNamesForAddress(publicClient, {
103
- address: accounts[1],
104
- filter: {
105
- owner: true,
106
- registrant: true,
107
- resolvedAddress: true,
108
- wrappedOwner: true,
109
- allowExpired: true,
110
- },
111
- })
112
- if (!result.length) throw new Error('No names found')
113
- const expiredNames = result.filter(
114
- (x) => x.expiryDate?.date && x.expiryDate.date < new Date(),
115
- )
116
- expect(expiredNames.length).toBeGreaterThan(0)
117
- })
118
- it('allows including reverse record', async () => {
119
- const result = await getNamesForAddress(publicClient, {
120
- address: accounts[2],
121
- filter: {
122
- owner: true,
123
- registrant: true,
124
- resolvedAddress: true,
125
- wrappedOwner: true,
126
- allowReverseRecord: true,
127
- },
128
- })
129
- if (!result.length) throw new Error('No names found')
130
- const reverseRecordNames = result.filter(
131
- (x) => x.parentName === 'addr.reverse',
132
- )
133
- expect(reverseRecordNames.length).toBeGreaterThan(0)
134
- })
135
- })
136
-
137
- describe.each([
138
- {
139
- orderBy: 'name',
140
- orderDirection: 'asc',
141
- compareFn: (a: NameWithRelation, b: NameWithRelation) =>
142
- (a.name || '').localeCompare(b.name || ''),
143
- },
144
- {
145
- orderBy: 'name',
146
- orderDirection: 'desc',
147
- compareFn: (a: NameWithRelation, b: NameWithRelation) =>
148
- (b.name || '').localeCompare(a.name || ''),
149
- },
150
- {
151
- orderBy: 'labelName',
152
- orderDirection: 'asc',
153
- compareFn: (a: NameWithRelation, b: NameWithRelation) => {
154
- const aLabelName = a.labelName || ''
155
- const bLabelName = b.labelName || ''
156
- return aLabelName.localeCompare(bLabelName)
157
- },
158
- },
159
- {
160
- orderBy: 'labelName',
161
- orderDirection: 'desc',
162
- compareFn: (a: NameWithRelation, b: NameWithRelation) => {
163
- const aLabelName = a.labelName || ''
164
- const bLabelName = b.labelName || ''
165
- return bLabelName.localeCompare(aLabelName)
166
- },
167
- },
168
- {
169
- orderBy: 'expiryDate',
170
- orderDirection: 'asc',
171
- compareFn: (a: NameWithRelation, b: NameWithRelation) => {
172
- const aExpiryDate = a.expiryDate?.value || Infinity
173
- const bExpiryDate = b.expiryDate?.value || Infinity
174
- return aExpiryDate - bExpiryDate
175
- },
176
- },
177
- {
178
- orderBy: 'expiryDate',
179
- orderDirection: 'desc',
180
- compareFn: (a: NameWithRelation, b: NameWithRelation) => {
181
- const aExpiryDate = a.expiryDate?.value || Infinity
182
- const bExpiryDate = b.expiryDate?.value || Infinity
183
- return bExpiryDate - aExpiryDate
184
- },
185
- },
186
- {
187
- orderBy: 'createdAt',
188
- orderDirection: 'asc',
189
- compareFn: (a: NameWithRelation, b: NameWithRelation) => {
190
- const aCreatedAt = a.createdAt.value
191
- const bCreatedAt = b.createdAt.value
192
- return aCreatedAt - bCreatedAt
193
- },
194
- },
195
- {
196
- orderBy: 'createdAt',
197
- orderDirection: 'desc',
198
- compareFn: (a: NameWithRelation, b: NameWithRelation) => {
199
- const aCreatedAt = a.createdAt.value
200
- const bCreatedAt = b.createdAt.value
201
- return bCreatedAt - aCreatedAt
202
- },
203
- },
204
- ])(
205
- 'filters by $orderBy $orderDirection',
206
- ({ orderBy, orderDirection, compareFn }) => {
207
- it('is consistent between full result and paginated results', async () => {
208
- const fullResult = await getNamesForAddress(publicClient, {
209
- address: accounts[1],
210
- orderBy: orderBy as any,
211
- orderDirection: orderDirection as any,
212
- pageSize: 1000,
213
- })
214
- if (!fullResult.length) throw new Error('No names found')
215
- const paginatedResults = []
216
- let lastResult: NameWithRelation[] = []
217
- do {
218
- const result = await getNamesForAddress(publicClient, {
219
- address: accounts[1],
220
- orderBy: orderBy as any,
221
- orderDirection: orderDirection as any,
222
- previousPage: lastResult,
223
- pageSize: 5,
224
- })
225
- paginatedResults.push(...result)
226
- lastResult = result
227
- } while (lastResult.length)
228
-
229
- expect(paginatedResults.length).toBe(fullResult.length)
230
- expect(paginatedResults).toStrictEqual(fullResult)
231
- })
232
- it('is sorted correctly', async () => {
233
- const fullResult = await getNamesForAddress(publicClient, {
234
- address: accounts[1],
235
- orderBy: orderBy as any,
236
- orderDirection: orderDirection as any,
237
- pageSize: 1000,
238
- })
239
- if (!fullResult.length) throw new Error('No names found')
240
- const sortedResult = [...fullResult].sort(compareFn)
241
- expect(fullResult).toEqual(sortedResult)
242
- })
243
- },
244
- )
@@ -1,74 +0,0 @@
1
- import {
2
- deploymentAddresses,
3
- publicClient,
4
- } from '../../tests/addTestContracts.js'
5
- import getSubgraphRecords from './getSubgraphRecords.js'
6
-
7
- it('gets basic records', async () => {
8
- const result = await getSubgraphRecords(publicClient, {
9
- name: 'with-profile.eth',
10
- })
11
- expect(result).toBeTruthy()
12
- const { createdAt, ...snapshot } = result!
13
- expect(createdAt.date).toBeInstanceOf(Date)
14
- expect(createdAt.value).toBe(createdAt.date.getTime())
15
- expect(snapshot).toMatchInlineSnapshot(`
16
- {
17
- "coins": [
18
- "60",
19
- "61",
20
- "0",
21
- "2",
22
- ],
23
- "isMigrated": true,
24
- "texts": [
25
- "description",
26
- "url",
27
- "blankrecord",
28
- "email",
29
- ],
30
- }
31
- `)
32
- })
33
- it('gets records for custom resolver address', async () => {
34
- const result = await getSubgraphRecords(publicClient, {
35
- name: 'with-legacy-resolver.eth',
36
- resolverAddress: deploymentAddresses.LegacyPublicResolver,
37
- })
38
- expect(result).toBeTruthy()
39
- const { createdAt, ...snapshot } = result!
40
- expect(createdAt.date).toBeInstanceOf(Date)
41
- expect(createdAt.value).toBe(createdAt.date.getTime())
42
- expect(snapshot).toMatchInlineSnapshot(`
43
- {
44
- "coins": [
45
- "60",
46
- ],
47
- "isMigrated": true,
48
- "texts": [],
49
- }
50
- `)
51
- })
52
- it('returns null for nonexistent name', async () => {
53
- const result = await getSubgraphRecords(publicClient, {
54
- name: 'nonexistent.eth',
55
- })
56
- expect(result).toBeNull()
57
- })
58
- it('returns empty texts/coins for nonexistent resolver', async () => {
59
- const result = await getSubgraphRecords(publicClient, {
60
- name: 'with-profile.eth',
61
- resolverAddress: '0xb794F5eA0ba39494cE839613fffBA74279579268',
62
- })
63
- expect(result).toBeTruthy()
64
- const { createdAt, ...snapshot } = result!
65
- expect(createdAt.date).toBeInstanceOf(Date)
66
- expect(createdAt.value).toBe(createdAt.date.getTime())
67
- expect(snapshot).toMatchInlineSnapshot(`
68
- {
69
- "coins": [],
70
- "isMigrated": true,
71
- "texts": [],
72
- }
73
- `)
74
- })
@@ -1,34 +0,0 @@
1
- import { getVersion } from '../../errors/error-utils.js'
2
- import {
3
- deploymentAddresses,
4
- publicClient,
5
- } from '../../tests/addTestContracts.js'
6
- import getSubgraphRegistrant from './getSubgraphRegistrant.js'
7
-
8
- it('gets the registrant for a 2ld .eth name', async () => {
9
- const result = await getSubgraphRegistrant(publicClient, {
10
- name: 'wrapped.eth',
11
- })
12
- expect(result).toBe(deploymentAddresses.NameWrapper)
13
- })
14
- it('returns null for nonexistent name', async () => {
15
- const result = await getSubgraphRegistrant(publicClient, {
16
- name: 'unregistered.eth',
17
- })
18
- expect(result).toBeNull()
19
- })
20
- it('throws an error for other name', async () => {
21
- await expect(
22
- getSubgraphRegistrant(publicClient, {
23
- name: 'test123.com',
24
- }),
25
- ).rejects.toThrowErrorMatchingInlineSnapshot(`
26
- "Unsupported name type: other-2ld
27
-
28
- - Supported name types: eth-2ld
29
-
30
- Details: Registrant can only be fetched for eth-2ld names
31
-
32
- Version: ${getVersion()}"
33
- `)
34
- })