@ensdomains/ensjs 3.0.0-alpha.32 → 3.0.0-alpha.34

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.
@@ -25,7 +25,8 @@ var import_ethers = require("ethers");
25
25
  var import_normalise = require("../utils/normalise");
26
26
  async function transferName_default({ contracts, signer }, name, {
27
27
  newOwner,
28
- contract
28
+ contract,
29
+ reclaim
29
30
  }) {
30
31
  const address = await signer.getAddress();
31
32
  switch (contract) {
@@ -41,11 +42,11 @@ async function transferName_default({ contracts, signer }, name, {
41
42
  if (labels.length > 2 || labels[labels.length - 1] !== "eth") {
42
43
  throw new Error("Invalid name for baseRegistrar");
43
44
  }
44
- return baseRegistrar.populateTransaction["safeTransferFrom(address,address,uint256)"](
45
- address,
46
- newOwner,
47
- import_ethers.ethers.utils.solidityKeccak256(["string"], [labels[0]])
48
- );
45
+ const tokenId = import_ethers.ethers.utils.solidityKeccak256(["string"], [labels[0]]);
46
+ if (reclaim) {
47
+ return baseRegistrar.populateTransaction.reclaim(tokenId, newOwner);
48
+ }
49
+ return baseRegistrar.populateTransaction["safeTransferFrom(address,address,uint256)"](address, newOwner, tokenId);
49
50
  }
50
51
  case "nameWrapper": {
51
52
  const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
@@ -3,7 +3,8 @@ import { ethers } from "ethers";
3
3
  import { namehash } from "../utils/normalise.mjs";
4
4
  async function transferName_default({ contracts, signer }, name, {
5
5
  newOwner,
6
- contract
6
+ contract,
7
+ reclaim
7
8
  }) {
8
9
  const address = await signer.getAddress();
9
10
  switch (contract) {
@@ -19,11 +20,11 @@ async function transferName_default({ contracts, signer }, name, {
19
20
  if (labels.length > 2 || labels[labels.length - 1] !== "eth") {
20
21
  throw new Error("Invalid name for baseRegistrar");
21
22
  }
22
- return baseRegistrar.populateTransaction["safeTransferFrom(address,address,uint256)"](
23
- address,
24
- newOwner,
25
- ethers.utils.solidityKeccak256(["string"], [labels[0]])
26
- );
23
+ const tokenId = ethers.utils.solidityKeccak256(["string"], [labels[0]]);
24
+ if (reclaim) {
25
+ return baseRegistrar.populateTransaction.reclaim(tokenId, newOwner);
26
+ }
27
+ return baseRegistrar.populateTransaction["safeTransferFrom(address,address,uint256)"](address, newOwner, tokenId);
27
28
  }
28
29
  case "nameWrapper": {
29
30
  const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
@@ -1,6 +1,7 @@
1
1
  import { ethers } from 'ethers';
2
2
  import { ENSArgs } from '..';
3
- export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { newOwner, contract, }: {
3
+ export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { newOwner, contract, reclaim, }: {
4
4
  newOwner: string;
5
5
  contract: 'registry' | 'nameWrapper' | 'baseRegistrar';
6
+ reclaim?: boolean;
6
7
  }): Promise<ethers.PopulatedTransaction>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ensdomains/ensjs",
3
- "version": "3.0.0-alpha.32",
3
+ "version": "3.0.0-alpha.34",
4
4
  "description": "ENS javascript library for contract interaction",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -52,7 +52,7 @@
52
52
  "author": "TateB <yo@taytems.xyz>",
53
53
  "license": "MIT",
54
54
  "dependencies": {
55
- "@ensdomains/address-encoder": "0.2.16",
55
+ "@ensdomains/address-encoder": "^0.2.18",
56
56
  "@ensdomains/content-hash": "^2.5.7",
57
57
  "@ensdomains/dnsprovejs": "^0.4.1",
58
58
  "@ensdomains/dnssecoraclejs": "^0.2.7",
@@ -66,7 +66,7 @@
66
66
  "devDependencies": {
67
67
  "@ensdomains/buffer": "^0.0.13",
68
68
  "@ensdomains/ens-contracts": "^0.0.15",
69
- "@ensdomains/ens-test-env": "0.3.3",
69
+ "@ensdomains/ens-test-env": "0.3.5",
70
70
  "@ethersproject/abi": "^5.6.0",
71
71
  "@ethersproject/providers": "^5.6.2",
72
72
  "@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers",
@@ -52,7 +52,7 @@ describe('getProfile', () => {
52
52
  it('should return a profile object with specified records', async () => {
53
53
  const result = await ensInstance.getProfile(
54
54
  '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',
55
- { texts: ['description', 'url'], coinTypes: ['ETC', '0'] },
55
+ { texts: ['description', 'url'], coinTypes: ['ETC_LEGACY', '0'] },
56
56
  )
57
57
  expect(result).toBeDefined()
58
58
  if (result) {
@@ -86,7 +86,7 @@ describe('getProfile', () => {
86
86
  it('should return a profile object with specified records', async () => {
87
87
  const result = await ensInstance.getProfile('with-profile.eth', {
88
88
  texts: ['description', 'url'],
89
- coinTypes: ['ETC', '0'],
89
+ coinTypes: ['ETC_LEGACY', '0'],
90
90
  })
91
91
  expect((result as any).address).toBe(
92
92
  '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',
@@ -55,21 +55,21 @@ describe('getSpecificRecord', () => {
55
55
  expect((result as any).addr).toBe(
56
56
  '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',
57
57
  )
58
- expect((result as any).coin).toBe('ETC')
58
+ expect((result as any).coin).toBe('ETC_LEGACY')
59
59
  })
60
60
  it('should return the correct address based on a coin ID input as a string', async () => {
61
61
  const result = await ensInstance.getAddr('with-profile.eth', '61')
62
62
  expect((result as any).addr).toBe(
63
63
  '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',
64
64
  )
65
- expect((result as any).coin).toBe('ETC')
65
+ expect((result as any).coin).toBe('ETC_LEGACY')
66
66
  })
67
67
  it('should return the correct address based on a coin name', async () => {
68
- const result = await ensInstance.getAddr('with-profile.eth', 'ETC')
68
+ const result = await ensInstance.getAddr('with-profile.eth', 'ETC_LEGACY')
69
69
  expect((result as any).addr).toBe(
70
70
  '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',
71
71
  )
72
- expect((result as any).coin).toBe('ETC')
72
+ expect((result as any).coin).toBe('ETC_LEGACY')
73
73
  })
74
74
  it('should return null for a non-existent coin', async () => {
75
75
  const result = await ensInstance.getAddr('with-profile.eth', 'BNB')
@@ -45,7 +45,7 @@ describe('setRecord', () => {
45
45
  const tx = await ensInstance.setRecord('test123.eth', {
46
46
  type: 'addr',
47
47
  record: {
48
- key: 'ETC',
48
+ key: 'ETC_LEGACY',
49
49
  value: '0x42D63ae25990889E35F215bC95884039Ba354115',
50
50
  },
51
51
  addressOrIndex: 1,
@@ -19,7 +19,10 @@ describe('setRecords', () => {
19
19
  const tx = await ensInstance.setRecords('test123.eth', {
20
20
  records: {
21
21
  coinTypes: [
22
- { key: 'ETC', value: '0x42D63ae25990889E35F215bC95884039Ba354115' },
22
+ {
23
+ key: 'ETC_LEGACY',
24
+ value: '0x42D63ae25990889E35F215bC95884039Ba354115',
25
+ },
23
26
  ],
24
27
  texts: [{ key: 'foo', value: 'bar' }],
25
28
  },
@@ -8,9 +8,11 @@ export default async function (
8
8
  {
9
9
  newOwner,
10
10
  contract,
11
+ reclaim,
11
12
  }: {
12
13
  newOwner: string
13
14
  contract: 'registry' | 'nameWrapper' | 'baseRegistrar'
15
+ reclaim?: boolean
14
16
  },
15
17
  ) {
16
18
  const address = await signer.getAddress()
@@ -28,13 +30,16 @@ export default async function (
28
30
  if (labels.length > 2 || labels[labels.length - 1] !== 'eth') {
29
31
  throw new Error('Invalid name for baseRegistrar')
30
32
  }
33
+ const tokenId = ethers.utils.solidityKeccak256(['string'], [labels[0]])
34
+
35
+ // reclaim if sending manager on unwrapped name
36
+ if (reclaim) {
37
+ return baseRegistrar.populateTransaction.reclaim(tokenId, newOwner)
38
+ }
39
+
31
40
  return baseRegistrar.populateTransaction[
32
41
  'safeTransferFrom(address,address,uint256)'
33
- ](
34
- address,
35
- newOwner,
36
- ethers.utils.solidityKeccak256(['string'], [labels[0]]),
37
- )
42
+ ](address, newOwner, tokenId)
38
43
  }
39
44
  case 'nameWrapper': {
40
45
  const nameWrapper = (await contracts?.getNameWrapper())!.connect(signer)