@ensdomains/ensjs 3.0.0-alpha.33 → 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
|
-
|
|
45
|
-
|
|
46
|
-
newOwner
|
|
47
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
newOwner
|
|
25
|
-
|
|
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
|
@@ -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)
|