@ensdomains/ensjs 3.0.0-alpha.25 → 3.0.0-alpha.26

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.
@@ -37,19 +37,19 @@ const addresses = {
37
37
  "1": "0x283af0b28c62c092c9727f1ee09c02ca627eb7f5",
38
38
  "3": "0xa5627AB7Ae47063B533622C34FEBDb52d3281dF8",
39
39
  "4": "0x283af0b28c62c092c9727f1ee09c02ca627eb7f5",
40
- "5": "0x4a16c6Bbee697b66706E7dc0101BfCA1d60cdE76"
40
+ "5": "0x9C51161bA2FB02Cc0a403332B607117685f34831"
41
41
  },
42
42
  Multicall: "0xcA11bde05977b3631167028862bE2a173976CA11",
43
43
  NameWrapper: {
44
44
  "1": "0x0000000000000000000000000000000000000000",
45
45
  "3": "0xF82155e2a43Be0871821E9654Fc8Ae894FB8307C",
46
46
  "4": "0x0000000000000000000000000000000000000000",
47
- "5": "0x9c4C40960B53e9A01af429D3f90aEf02Bd0c4c72"
47
+ "5": "0x582224b8d4534F4749EFA4f22eF7241E0C56D4B8"
48
48
  },
49
49
  PublicResolver: {
50
50
  "1": "0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41",
51
51
  "3": "0x13F0659Ee6bb7484C884FEeFb7F75C93951ef837",
52
- "5": "0x58e4627848223BF59F8Ce34265c426E7B05E8625"
52
+ "5": "0xE264d5bb84bA3b8061ADC38D3D76e6674aB91852"
53
53
  },
54
54
  ENSRegistryWithFallback: {
55
55
  "1": "0x00000000000c2e074ec69a0dfb2997ba6c7d2e1e",
@@ -25,11 +25,8 @@ var import_ethers = require("ethers");
25
25
  var import_normalise = require("../utils/normalise");
26
26
  async function deleteSubname_default({ contracts, signer }, name, { contract }) {
27
27
  const labels = name.split(".");
28
- if (labels.length !== 3) {
29
- throw new Error("ENS.js currently only supports deleting 2LDs, not TLDs");
30
- }
31
- if (labels[2] !== "eth") {
32
- throw new Error("ENS.js currently only supports deleting .eth 2LDs");
28
+ if (labels.length < 3) {
29
+ throw new Error(`${name} is not a valid subname`);
33
30
  }
34
31
  const label = labels.shift();
35
32
  const labelhash = import_ethers.ethers.utils.solidityKeccak256(["string"], [label]);
@@ -15,19 +15,19 @@ var addresses = {
15
15
  "1": "0x283af0b28c62c092c9727f1ee09c02ca627eb7f5",
16
16
  "3": "0xa5627AB7Ae47063B533622C34FEBDb52d3281dF8",
17
17
  "4": "0x283af0b28c62c092c9727f1ee09c02ca627eb7f5",
18
- "5": "0x4a16c6Bbee697b66706E7dc0101BfCA1d60cdE76"
18
+ "5": "0x9C51161bA2FB02Cc0a403332B607117685f34831"
19
19
  },
20
20
  Multicall: "0xcA11bde05977b3631167028862bE2a173976CA11",
21
21
  NameWrapper: {
22
22
  "1": "0x0000000000000000000000000000000000000000",
23
23
  "3": "0xF82155e2a43Be0871821E9654Fc8Ae894FB8307C",
24
24
  "4": "0x0000000000000000000000000000000000000000",
25
- "5": "0x9c4C40960B53e9A01af429D3f90aEf02Bd0c4c72"
25
+ "5": "0x582224b8d4534F4749EFA4f22eF7241E0C56D4B8"
26
26
  },
27
27
  PublicResolver: {
28
28
  "1": "0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41",
29
29
  "3": "0x13F0659Ee6bb7484C884FEeFb7F75C93951ef837",
30
- "5": "0x58e4627848223BF59F8Ce34265c426E7B05E8625"
30
+ "5": "0xE264d5bb84bA3b8061ADC38D3D76e6674aB91852"
31
31
  },
32
32
  ENSRegistryWithFallback: {
33
33
  "1": "0x00000000000c2e074ec69a0dfb2997ba6c7d2e1e",
@@ -3,11 +3,8 @@ import { ethers } from "ethers";
3
3
  import { namehash } from "../utils/normalise.mjs";
4
4
  async function deleteSubname_default({ contracts, signer }, name, { contract }) {
5
5
  const labels = name.split(".");
6
- if (labels.length !== 3) {
7
- throw new Error("ENS.js currently only supports deleting 2LDs, not TLDs");
8
- }
9
- if (labels[2] !== "eth") {
10
- throw new Error("ENS.js currently only supports deleting .eth 2LDs");
6
+ if (labels.length < 3) {
7
+ throw new Error(`${name} is not a valid subname`);
11
8
  }
12
9
  const label = labels.shift();
13
10
  const labelhash = ethers.utils.solidityKeccak256(["string"], [label]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ensdomains/ensjs",
3
- "version": "3.0.0-alpha.25",
3
+ "version": "3.0.0-alpha.26",
4
4
  "description": "ENS javascript library for contract interaction",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -20,19 +20,19 @@ const addresses: Record<
20
20
  '1': '0x283af0b28c62c092c9727f1ee09c02ca627eb7f5',
21
21
  '3': '0xa5627AB7Ae47063B533622C34FEBDb52d3281dF8',
22
22
  '4': '0x283af0b28c62c092c9727f1ee09c02ca627eb7f5',
23
- '5': '0x4a16c6Bbee697b66706E7dc0101BfCA1d60cdE76',
23
+ '5': '0x9C51161bA2FB02Cc0a403332B607117685f34831',
24
24
  },
25
25
  Multicall: '0xcA11bde05977b3631167028862bE2a173976CA11',
26
26
  NameWrapper: {
27
27
  '1': '0x0000000000000000000000000000000000000000',
28
28
  '3': '0xF82155e2a43Be0871821E9654Fc8Ae894FB8307C',
29
29
  '4': '0x0000000000000000000000000000000000000000',
30
- '5': '0x9c4C40960B53e9A01af429D3f90aEf02Bd0c4c72',
30
+ '5': '0x582224b8d4534F4749EFA4f22eF7241E0C56D4B8',
31
31
  },
32
32
  PublicResolver: {
33
33
  '1': '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41',
34
34
  '3': '0x13F0659Ee6bb7484C884FEeFb7F75C93951ef837',
35
- '5': '0x58e4627848223BF59F8Ce34265c426E7B05E8625',
35
+ '5': '0xE264d5bb84bA3b8061ADC38D3D76e6674aB91852',
36
36
  },
37
37
  ENSRegistryWithFallback: {
38
38
  '1': '0x00000000000c2e074ec69a0dfb2997ba6c7d2e1e',
@@ -29,7 +29,10 @@ describe('deleteSubname', () => {
29
29
  const result = await registry.owner(namehash('test.with-subnames.eth'))
30
30
  expect(result).toBe('0x0000000000000000000000000000000000000000')
31
31
  })
32
+
32
33
  it('should allow deleting a subname on the nameWrapper', async () => {
34
+ const nameWrapper = await ensInstance.contracts!.getNameWrapper()!
35
+
33
36
  const tx = await ensInstance.deleteSubname(
34
37
  'test.wrapped-with-subnames.eth',
35
38
  {
@@ -40,10 +43,27 @@ describe('deleteSubname', () => {
40
43
  expect(tx).toBeTruthy()
41
44
  await tx.wait()
42
45
 
43
- const nameWrapper = await ensInstance.contracts!.getNameWrapper()!
44
46
  const result = await nameWrapper.ownerOf(
45
47
  namehash('test.wrapped-with-subnames.eth'),
46
48
  )
47
49
  expect(result).toBe('0x0000000000000000000000000000000000000000')
48
50
  })
51
+
52
+ it('should not allow deleting 1LD', async () => {
53
+ await expect(
54
+ ensInstance.deleteSubname('eth', {
55
+ contract: 'nameWrapper',
56
+ addressOrIndex: 1,
57
+ }),
58
+ ).rejects.toThrow()
59
+ })
60
+
61
+ it('should not allow deleting 2LD', async () => {
62
+ await expect(
63
+ ensInstance.deleteSubname('test123.eth', {
64
+ contract: 'registry',
65
+ addressOrIndex: 1,
66
+ }),
67
+ ).rejects.toThrow()
68
+ })
49
69
  })
@@ -13,12 +13,8 @@ export default async function (
13
13
  ) {
14
14
  const labels = name.split('.')
15
15
 
16
- if (labels.length !== 3) {
17
- throw new Error('ENS.js currently only supports deleting 2LDs, not TLDs')
18
- }
19
-
20
- if (labels[2] !== 'eth') {
21
- throw new Error('ENS.js currently only supports deleting .eth 2LDs')
16
+ if (labels.length < 3) {
17
+ throw new Error(`${name} is not a valid subname`)
22
18
  }
23
19
 
24
20
  const label = labels.shift() as string