@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
@@ -1,156 +0,0 @@
1
- import type { Address, Hex } from 'viem'
2
- import {
3
- publicClient,
4
- testClient,
5
- waitForTransaction,
6
- walletClient,
7
- } from '../../tests/addTestContracts.js'
8
- import { encodeAbi } from '../../utils/encoders/encodeAbi.js'
9
- import getAbiRecord from '../public/getAbiRecord.js'
10
- import getResolver from '../public/getResolver.js'
11
- import setAbiRecord from './setAbiRecord.js'
12
-
13
- let snapshot: Hex
14
- let accounts: Address[]
15
-
16
- beforeAll(async () => {
17
- accounts = await walletClient.getAddresses()
18
- })
19
-
20
- beforeEach(async () => {
21
- snapshot = await testClient.snapshot()
22
- })
23
-
24
- afterEach(async () => {
25
- await testClient.revert({ id: snapshot })
26
- })
27
-
28
- const dummyABI = [
29
- {
30
- type: 'function',
31
- name: 'supportsInterface',
32
- constant: true,
33
- stateMutability: 'view',
34
- payable: false,
35
- inputs: [
36
- {
37
- type: 'bytes4',
38
- },
39
- ],
40
- outputs: [
41
- {
42
- type: 'bool',
43
- },
44
- ],
45
- },
46
- ]
47
-
48
- it('should allow an abi record to be set with json content type', async () => {
49
- const encodedAbi = await encodeAbi({ encodeAs: 'json', data: dummyABI })
50
- const tx = await setAbiRecord(walletClient, {
51
- name: 'test123.eth',
52
- encodedAbi,
53
- resolverAddress: (await getResolver(publicClient, {
54
- name: 'test123.eth',
55
- }))!,
56
- account: accounts[1],
57
- })
58
- expect(tx).toBeTruthy()
59
- const receipt = await waitForTransaction(tx)
60
- expect(receipt.status).toBe('success')
61
-
62
- const response = await getAbiRecord(publicClient, {
63
- name: 'test123.eth',
64
- })
65
- expect(response!.abi).toEqual(dummyABI)
66
- expect(response!.contentType).toEqual(1)
67
- expect(response!.decoded).toBe(true)
68
- })
69
-
70
- it('should allow an abi record to be set with zlib content type', async () => {
71
- const encodedAbi = await encodeAbi({ encodeAs: 'zlib', data: dummyABI })
72
- const tx = await setAbiRecord(walletClient, {
73
- name: 'test123.eth',
74
- encodedAbi,
75
- resolverAddress: (await getResolver(publicClient, {
76
- name: 'test123.eth',
77
- }))!,
78
- account: accounts[1],
79
- })
80
- expect(tx).toBeTruthy()
81
- const receipt = await waitForTransaction(tx)
82
- expect(receipt.status).toBe('success')
83
-
84
- const response = await getAbiRecord(publicClient, {
85
- name: 'test123.eth',
86
- })
87
- expect(response!.abi).toEqual(dummyABI)
88
- expect(response!.contentType).toEqual(2)
89
- expect(response!.decoded).toBe(true)
90
- })
91
-
92
- it('should allow an abi record to be set with cbor content type', async () => {
93
- const encodedAbi = await encodeAbi({ encodeAs: 'cbor', data: dummyABI })
94
- const tx = await setAbiRecord(walletClient, {
95
- name: 'test123.eth',
96
- encodedAbi,
97
- resolverAddress: (await getResolver(publicClient, {
98
- name: 'test123.eth',
99
- }))!,
100
- account: accounts[1],
101
- })
102
- expect(tx).toBeTruthy()
103
- const receipt = await waitForTransaction(tx)
104
- expect(receipt.status).toBe('success')
105
-
106
- const response = await getAbiRecord(publicClient, {
107
- name: 'test123.eth',
108
- })
109
- expect(response!.abi).toEqual(dummyABI)
110
- expect(response!.contentType).toEqual(4)
111
- expect(response!.decoded).toBe(true)
112
- })
113
-
114
- it('should allow an abi record to be set with uri content type', async () => {
115
- const encodedAbi = await encodeAbi({
116
- encodeAs: 'uri',
117
- data: 'https://example.com',
118
- })
119
- const tx = await setAbiRecord(walletClient, {
120
- name: 'test123.eth',
121
- encodedAbi,
122
- resolverAddress: (await getResolver(publicClient, {
123
- name: 'test123.eth',
124
- }))!,
125
- account: accounts[1],
126
- })
127
- expect(tx).toBeTruthy()
128
- const receipt = await waitForTransaction(tx)
129
- expect(receipt.status).toBe('success')
130
-
131
- const response = await getAbiRecord(publicClient, {
132
- name: 'test123.eth',
133
- })
134
- expect(response!.abi).toEqual('https://example.com')
135
- expect(response!.contentType).toEqual(8)
136
- expect(response!.decoded).toBe(true)
137
- })
138
-
139
- it('should allow an abi record to be set to blank', async () => {
140
- const tx = await setAbiRecord(walletClient, {
141
- name: 'with-type-1-abi.eth',
142
- encodedAbi: null,
143
- resolverAddress: (await getResolver(publicClient, {
144
- name: 'test123.eth',
145
- }))!,
146
- account: accounts[1],
147
- })
148
- expect(tx).toBeTruthy()
149
- const receipt = await waitForTransaction(tx)
150
- expect(receipt.status).toBe('success')
151
-
152
- const response = await getAbiRecord(publicClient, {
153
- name: 'test123.eth',
154
- })
155
- expect(response).toBeNull()
156
- })
@@ -1,121 +0,0 @@
1
- import type { Address, Hex } from 'viem'
2
- import {
3
- publicClient,
4
- testClient,
5
- waitForTransaction,
6
- walletClient,
7
- } from '../../tests/addTestContracts.js'
8
- import getAddressRecord from '../public/getAddressRecord.js'
9
- import getResolver from '../public/getResolver.js'
10
- import setAddressRecord from './setAddressRecord.js'
11
-
12
- let snapshot: Hex
13
- let accounts: Address[]
14
-
15
- beforeAll(async () => {
16
- accounts = await walletClient.getAddresses()
17
- })
18
-
19
- beforeEach(async () => {
20
- snapshot = await testClient.snapshot()
21
- })
22
-
23
- afterEach(async () => {
24
- await testClient.revert({ id: snapshot })
25
- })
26
-
27
- it('should allow an eth address record to be set', async () => {
28
- const tx = await setAddressRecord(walletClient, {
29
- name: 'test123.eth',
30
- coin: 'ETH',
31
- value: '0x42D63ae25990889E35F215bC95884039Ba354115',
32
- resolverAddress: (await getResolver(publicClient, {
33
- name: 'test123.eth',
34
- }))!,
35
- account: accounts[1],
36
- })
37
- expect(tx).toBeTruthy()
38
- const receipt = await waitForTransaction(tx)
39
- expect(receipt.status).toBe('success')
40
-
41
- const response = await getAddressRecord(publicClient, {
42
- name: 'test123.eth',
43
- coin: 'ETH',
44
- })
45
- expect(response).toMatchInlineSnapshot(`
46
- {
47
- "id": 60,
48
- "name": "ETH",
49
- "value": "0x42D63ae25990889E35F215bC95884039Ba354115",
50
- }
51
- `)
52
- })
53
-
54
- it('should allow a multicoin address record to be set', async () => {
55
- const tx = await setAddressRecord(walletClient, {
56
- name: 'test123.eth',
57
- coin: 'ETC_LEGACY',
58
- value: '0x42D63ae25990889E35F215bC95884039Ba354115',
59
- resolverAddress: (await getResolver(publicClient, {
60
- name: 'test123.eth',
61
- }))!,
62
- account: accounts[1],
63
- })
64
- expect(tx).toBeTruthy()
65
- const receipt = await waitForTransaction(tx)
66
- expect(receipt.status).toBe('success')
67
-
68
- const response = await getAddressRecord(publicClient, {
69
- name: 'test123.eth',
70
- coin: 'ETC_LEGACY',
71
- })
72
- expect(response).toMatchInlineSnapshot(`
73
- {
74
- "id": 61,
75
- "name": "ETC_LEGACY",
76
- "value": "0x42D63ae25990889E35F215bC95884039Ba354115",
77
- }
78
- `)
79
- })
80
-
81
- it('should allow an eth record to be set to blank', async () => {
82
- const tx = await setAddressRecord(walletClient, {
83
- name: 'test123.eth',
84
- coin: 'ETH',
85
- value: null,
86
- resolverAddress: (await getResolver(publicClient, {
87
- name: 'test123.eth',
88
- }))!,
89
- account: accounts[1],
90
- })
91
- expect(tx).toBeTruthy()
92
- const receipt = await waitForTransaction(tx)
93
- expect(receipt.status).toBe('success')
94
-
95
- const response = await getAddressRecord(publicClient, {
96
- name: 'test123.eth',
97
- coin: 'ETH',
98
- })
99
- expect(response).toBeNull()
100
- })
101
-
102
- it('should allow a multicoin record to be set to blank', async () => {
103
- const tx = await setAddressRecord(walletClient, {
104
- name: 'with-profile.eth',
105
- coin: 'BTC',
106
- value: null,
107
- resolverAddress: (await getResolver(publicClient, {
108
- name: 'with-profile.eth',
109
- }))!,
110
- account: accounts[2],
111
- })
112
- expect(tx).toBeTruthy()
113
- const receipt = await waitForTransaction(tx)
114
- expect(receipt.status).toBe('success')
115
-
116
- const response = await getAddressRecord(publicClient, {
117
- name: 'with-profile.eth',
118
- coin: 'BTC',
119
- })
120
- expect(response).toBeNull()
121
- })
@@ -1,97 +0,0 @@
1
- import type { Address, Hex } from 'viem'
2
- import { getChainContractAddress } from '../../contracts/getChainContractAddress.js'
3
- import { nameWrapperGetDataSnippet } from '../../contracts/nameWrapper.js'
4
- import {
5
- publicClient,
6
- testClient,
7
- waitForTransaction,
8
- walletClient,
9
- } from '../../tests/addTestContracts.js'
10
- import { userSettableFuseEnum } from '../../utils/fuses.js'
11
- import { namehash } from '../../utils/normalise.js'
12
- import setChildFuses from './setChildFuses.js'
13
- import setFuses from './setFuses.js'
14
-
15
- let snapshot: Hex
16
- let accounts: Address[]
17
-
18
- beforeAll(async () => {
19
- accounts = await walletClient.getAddresses()
20
- })
21
-
22
- beforeEach(async () => {
23
- snapshot = await testClient.snapshot()
24
- })
25
-
26
- afterEach(async () => {
27
- await testClient.revert({ id: snapshot })
28
- })
29
-
30
- const checkFuses = (
31
- fuses: number,
32
- expected: (keyof typeof userSettableFuseEnum)[],
33
- ) => {
34
- // eslint-disable-next-line guard-for-in
35
- for (const fuse in userSettableFuseEnum) {
36
- const active =
37
- (fuses &
38
- userSettableFuseEnum[fuse as keyof typeof userSettableFuseEnum]) >
39
- 0
40
- if (expected.includes(fuse as keyof typeof userSettableFuseEnum)) {
41
- try {
42
- expect(active).toBeTruthy()
43
- } catch {
44
- throw new Error(`${fuse} should be true but is false`)
45
- }
46
- } else if (active) {
47
- try {
48
- expect(active).toBeFalsy()
49
- } catch {
50
- throw new Error(`${fuse} should be false but is true`)
51
- }
52
- }
53
- }
54
- }
55
-
56
- const getFuses = async (name: string) => {
57
- const [, fuses] = await publicClient.readContract({
58
- abi: nameWrapperGetDataSnippet,
59
- address: getChainContractAddress({
60
- client: publicClient,
61
- contract: 'ensNameWrapper',
62
- }),
63
- functionName: 'getData',
64
- args: [BigInt(namehash(name))],
65
- })
66
- return fuses
67
- }
68
-
69
- it('should return a setChildFuses transaction and succeed', async () => {
70
- const setParentTx = await setFuses(walletClient, {
71
- name: 'wrapped-with-subnames.eth',
72
- fuses: {
73
- named: ['CANNOT_UNWRAP'],
74
- },
75
- account: accounts[1],
76
- })
77
- expect(setParentTx).toBeTruthy()
78
- const setParentTxReceipt = await waitForTransaction(setParentTx)
79
- expect(setParentTxReceipt.status).toBe('success')
80
-
81
- const tx = await setChildFuses(walletClient, {
82
- name: 'test.wrapped-with-subnames.eth',
83
- fuses: 65537 + 64,
84
- account: accounts[1],
85
- })
86
- expect(tx).toBeTruthy()
87
- const receipt = await waitForTransaction(tx)
88
- expect(receipt.status).toBe('success')
89
-
90
- const fuses = await getFuses('test.wrapped-with-subnames.eth')
91
-
92
- checkFuses(fuses, [
93
- 'CANNOT_UNWRAP',
94
- 'PARENT_CANNOT_CONTROL',
95
- 'CANNOT_APPROVE',
96
- ])
97
- })
@@ -1,69 +0,0 @@
1
- import type { Address, Hex } from 'viem'
2
- import {
3
- publicClient,
4
- testClient,
5
- waitForTransaction,
6
- walletClient,
7
- } from '../../tests/addTestContracts.js'
8
- import getContentHashRecord from '../public/getContentHashRecord.js'
9
- import getResolver from '../public/getResolver.js'
10
- import setContentHashRecord from './setContentHashRecord.js'
11
-
12
- let snapshot: Hex
13
- let accounts: Address[]
14
-
15
- beforeAll(async () => {
16
- accounts = await walletClient.getAddresses()
17
- })
18
-
19
- beforeEach(async () => {
20
- snapshot = await testClient.snapshot()
21
- })
22
-
23
- afterEach(async () => {
24
- await testClient.revert({ id: snapshot })
25
- })
26
-
27
- it('should allow a contenthash record to be set', async () => {
28
- const tx = await setContentHashRecord(walletClient, {
29
- name: 'test123.eth',
30
- contentHash:
31
- 'ipns://k51qzi5uqu5dgox2z23r6e99oqency055a6xt92xzmyvpz8mwz5ycjavm0u150',
32
- resolverAddress: (await getResolver(publicClient, {
33
- name: 'test123.eth',
34
- }))!,
35
- account: accounts[1],
36
- })
37
- expect(tx).toBeTruthy()
38
- const receipt = await waitForTransaction(tx)
39
- expect(receipt.status).toBe('success')
40
-
41
- const response = await getContentHashRecord(publicClient, {
42
- name: 'test123.eth',
43
- })
44
- expect(response).toMatchInlineSnapshot(`
45
- {
46
- "decoded": "k51qzi5uqu5dgox2z23r6e99oqency055a6xt92xzmyvpz8mwz5ycjavm0u150",
47
- "protocolType": "ipns",
48
- }
49
- `)
50
- })
51
-
52
- it('should allow a contenthash record to be set to blank', async () => {
53
- const tx = await setContentHashRecord(walletClient, {
54
- name: 'with-contenthash.eth',
55
- contentHash: null,
56
- resolverAddress: (await getResolver(publicClient, {
57
- name: 'test123.eth',
58
- }))!,
59
- account: accounts[1],
60
- })
61
- expect(tx).toBeTruthy()
62
- const receipt = await waitForTransaction(tx)
63
- expect(receipt.status).toBe('success')
64
-
65
- const response = await getContentHashRecord(publicClient, {
66
- name: 'test123.eth',
67
- })
68
- expect(response).toBeNull()
69
- })