@enscribe/hardhat-enscribe 0.1.3 → 0.1.5

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.
@@ -5,6 +5,7 @@ export declare const ENS_CONTRACTS: {
5
5
  readonly NAME_WRAPPER: "0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401";
6
6
  readonly REVERSE_REGISTRAR: "0xa58E81fe9b61B5c3fE2AFD33CF304c454AbFc7Cb";
7
7
  readonly L2_REVERSE_REGISTRAR: "";
8
+ readonly COIN_TYPE: 60;
8
9
  };
9
10
  readonly sepolia: {
10
11
  readonly ENS_REGISTRY: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
@@ -12,6 +13,7 @@ export declare const ENS_CONTRACTS: {
12
13
  readonly NAME_WRAPPER: "0x0635513f179D50A207757E05759CbD106d7dFcE8";
13
14
  readonly REVERSE_REGISTRAR: "0xA0a1AbcDAe1a2a4A2EF8e9113Ff0e02DD81DC0C6";
14
15
  readonly L2_REVERSE_REGISTRAR: "";
16
+ readonly COIN_TYPE: 60;
15
17
  };
16
18
  readonly linea: {
17
19
  readonly ENS_REGISTRY: "0x50130b669B28C339991d8676FA73CF122a121267";
@@ -19,6 +21,7 @@ export declare const ENS_CONTRACTS: {
19
21
  readonly NAME_WRAPPER: "0xA53cca02F98D590819141Aa85C891e2Af713C223";
20
22
  readonly REVERSE_REGISTRAR: "0x08D3fF6E65f680844fd2465393ff6f0d742b67D5";
21
23
  readonly L2_REVERSE_REGISTRAR: "0x0000000000D8e504002cC26E3Ec46D81971C1664";
24
+ readonly COIN_TYPE: 2147542792;
22
25
  };
23
26
  readonly "linea-sepolia": {
24
27
  readonly ENS_REGISTRY: "0x5B2636F0f2137B4aE722C01dd5122D7d3e9541f7";
@@ -26,6 +29,7 @@ export declare const ENS_CONTRACTS: {
26
29
  readonly NAME_WRAPPER: "0xF127De9E039a789806fEd4C6b1C0f3aFfeA9425e";
27
30
  readonly REVERSE_REGISTRAR: "0x4aAA964D8EB65508ca3DA3b0A3C060c16059E613";
28
31
  readonly L2_REVERSE_REGISTRAR: "0x00000BeEF055f7934784D6d81b6BC86665630dbA";
32
+ readonly COIN_TYPE: 2147542789;
29
33
  };
30
34
  readonly base: {
31
35
  readonly ENS_REGISTRY: "0xB94704422c2a1E396835A571837Aa5AE53285a95";
@@ -33,6 +37,7 @@ export declare const ENS_CONTRACTS: {
33
37
  readonly NAME_WRAPPER: "";
34
38
  readonly REVERSE_REGISTRAR: "0x79EA96012eEa67A83431F1701B3dFf7e37F9E282";
35
39
  readonly L2_REVERSE_REGISTRAR: "0x0000000000D8e504002cC26E3Ec46D81971C1664";
40
+ readonly COIN_TYPE: 2147492101;
36
41
  };
37
42
  readonly "base-sepolia": {
38
43
  readonly ENS_REGISTRY: "0x1493b2567056c2181630115660963E13A8E32735";
@@ -40,6 +45,7 @@ export declare const ENS_CONTRACTS: {
40
45
  readonly NAME_WRAPPER: "";
41
46
  readonly REVERSE_REGISTRAR: "0xa0A8401ECF248a9375a0a71C4dedc263dA18dCd7";
42
47
  readonly L2_REVERSE_REGISTRAR: "0x00000BeEF055f7934784D6d81b6BC86665630dbA";
48
+ readonly COIN_TYPE: 2147568180;
43
49
  };
44
50
  readonly optimism: {
45
51
  readonly ENS_REGISTRY: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
@@ -47,6 +53,7 @@ export declare const ENS_CONTRACTS: {
47
53
  readonly NAME_WRAPPER: "";
48
54
  readonly REVERSE_REGISTRAR: "";
49
55
  readonly L2_REVERSE_REGISTRAR: "0x0000000000D8e504002cC26E3Ec46D81971C1664";
56
+ readonly COIN_TYPE: 2147483658;
50
57
  };
51
58
  readonly "optimism-sepolia": {
52
59
  readonly ENS_REGISTRY: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
@@ -54,6 +61,7 @@ export declare const ENS_CONTRACTS: {
54
61
  readonly NAME_WRAPPER: "";
55
62
  readonly REVERSE_REGISTRAR: "";
56
63
  readonly L2_REVERSE_REGISTRAR: "0x00000BeEF055f7934784D6d81b6BC86665630dbA";
64
+ readonly COIN_TYPE: 2158639068;
57
65
  };
58
66
  readonly arbitrum: {
59
67
  readonly ENS_REGISTRY: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
@@ -61,6 +69,7 @@ export declare const ENS_CONTRACTS: {
61
69
  readonly NAME_WRAPPER: "";
62
70
  readonly REVERSE_REGISTRAR: "";
63
71
  readonly L2_REVERSE_REGISTRAR: "0x0000000000D8e504002cC26E3Ec46D81971C1664";
72
+ readonly COIN_TYPE: 2147525809;
64
73
  };
65
74
  readonly "arbitrum-sepolia": {
66
75
  readonly ENS_REGISTRY: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
@@ -68,6 +77,7 @@ export declare const ENS_CONTRACTS: {
68
77
  readonly NAME_WRAPPER: "";
69
78
  readonly REVERSE_REGISTRAR: "";
70
79
  readonly L2_REVERSE_REGISTRAR: "0x00000BeEF055f7934784D6d81b6BC86665630dbA";
80
+ readonly COIN_TYPE: 2147905262;
71
81
  };
72
82
  readonly scroll: {
73
83
  readonly ENS_REGISTRY: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
@@ -75,6 +85,7 @@ export declare const ENS_CONTRACTS: {
75
85
  readonly NAME_WRAPPER: "";
76
86
  readonly REVERSE_REGISTRAR: "";
77
87
  readonly L2_REVERSE_REGISTRAR: "0x0000000000D8e504002cC26E3Ec46D81971C1664";
88
+ readonly COIN_TYPE: 2148018000;
78
89
  };
79
90
  readonly "scroll-sepolia": {
80
91
  readonly ENS_REGISTRY: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
@@ -82,6 +93,7 @@ export declare const ENS_CONTRACTS: {
82
93
  readonly NAME_WRAPPER: "";
83
94
  readonly REVERSE_REGISTRAR: "";
84
95
  readonly L2_REVERSE_REGISTRAR: "0x00000BeEF055f7934784D6d81b6BC86665630dbA";
96
+ readonly COIN_TYPE: 2148017999;
85
97
  };
86
98
  readonly localhost: {
87
99
  readonly ENS_REGISTRY: "0x0000000000000000000000000000000000000000";
@@ -89,6 +101,7 @@ export declare const ENS_CONTRACTS: {
89
101
  readonly NAME_WRAPPER: "";
90
102
  readonly REVERSE_REGISTRAR: "";
91
103
  readonly L2_REVERSE_REGISTRAR: "";
104
+ readonly COIN_TYPE: 60;
92
105
  };
93
106
  };
94
107
  export type NetworkName = keyof typeof ENS_CONTRACTS;
@@ -98,78 +111,91 @@ export declare function getContractAddresses(networkName: NetworkName): {
98
111
  readonly NAME_WRAPPER: "0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401";
99
112
  readonly REVERSE_REGISTRAR: "0xa58E81fe9b61B5c3fE2AFD33CF304c454AbFc7Cb";
100
113
  readonly L2_REVERSE_REGISTRAR: "";
114
+ readonly COIN_TYPE: 60;
101
115
  } | {
102
116
  readonly ENS_REGISTRY: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
103
117
  readonly PUBLIC_RESOLVER: "0xE99638b40E4Fff0129D56f03b55b6bbC4BBE49b5";
104
118
  readonly NAME_WRAPPER: "0x0635513f179D50A207757E05759CbD106d7dFcE8";
105
119
  readonly REVERSE_REGISTRAR: "0xA0a1AbcDAe1a2a4A2EF8e9113Ff0e02DD81DC0C6";
106
120
  readonly L2_REVERSE_REGISTRAR: "";
121
+ readonly COIN_TYPE: 60;
107
122
  } | {
108
123
  readonly ENS_REGISTRY: "0x50130b669B28C339991d8676FA73CF122a121267";
109
124
  readonly PUBLIC_RESOLVER: "0x86c5AED9F27837074612288610fB98ccC1733126";
110
125
  readonly NAME_WRAPPER: "0xA53cca02F98D590819141Aa85C891e2Af713C223";
111
126
  readonly REVERSE_REGISTRAR: "0x08D3fF6E65f680844fd2465393ff6f0d742b67D5";
112
127
  readonly L2_REVERSE_REGISTRAR: "0x0000000000D8e504002cC26E3Ec46D81971C1664";
128
+ readonly COIN_TYPE: 2147542792;
113
129
  } | {
114
130
  readonly ENS_REGISTRY: "0x5B2636F0f2137B4aE722C01dd5122D7d3e9541f7";
115
131
  readonly PUBLIC_RESOLVER: "0xA2008916Ed2d7ED0Ecd747a8a5309267e42cf1f1";
116
132
  readonly NAME_WRAPPER: "0xF127De9E039a789806fEd4C6b1C0f3aFfeA9425e";
117
133
  readonly REVERSE_REGISTRAR: "0x4aAA964D8EB65508ca3DA3b0A3C060c16059E613";
118
134
  readonly L2_REVERSE_REGISTRAR: "0x00000BeEF055f7934784D6d81b6BC86665630dbA";
135
+ readonly COIN_TYPE: 2147542789;
119
136
  } | {
120
137
  readonly ENS_REGISTRY: "0xB94704422c2a1E396835A571837Aa5AE53285a95";
121
138
  readonly PUBLIC_RESOLVER: "0xC6d566A56A1aFf6508b41f6c90ff131615583BCD";
122
139
  readonly NAME_WRAPPER: "";
123
140
  readonly REVERSE_REGISTRAR: "0x79EA96012eEa67A83431F1701B3dFf7e37F9E282";
124
141
  readonly L2_REVERSE_REGISTRAR: "0x0000000000D8e504002cC26E3Ec46D81971C1664";
142
+ readonly COIN_TYPE: 2147492101;
125
143
  } | {
126
144
  readonly ENS_REGISTRY: "0x1493b2567056c2181630115660963E13A8E32735";
127
145
  readonly PUBLIC_RESOLVER: "0x6533C94869D28fAA8dF77cc63f9e2b2D6Cf77eBA";
128
146
  readonly NAME_WRAPPER: "";
129
147
  readonly REVERSE_REGISTRAR: "0xa0A8401ECF248a9375a0a71C4dedc263dA18dCd7";
130
148
  readonly L2_REVERSE_REGISTRAR: "0x00000BeEF055f7934784D6d81b6BC86665630dbA";
149
+ readonly COIN_TYPE: 2147568180;
131
150
  } | {
132
151
  readonly ENS_REGISTRY: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
133
152
  readonly PUBLIC_RESOLVER: "";
134
153
  readonly NAME_WRAPPER: "";
135
154
  readonly REVERSE_REGISTRAR: "";
136
155
  readonly L2_REVERSE_REGISTRAR: "0x0000000000D8e504002cC26E3Ec46D81971C1664";
156
+ readonly COIN_TYPE: 2147483658;
137
157
  } | {
138
158
  readonly ENS_REGISTRY: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
139
159
  readonly PUBLIC_RESOLVER: "";
140
160
  readonly NAME_WRAPPER: "";
141
161
  readonly REVERSE_REGISTRAR: "";
142
162
  readonly L2_REVERSE_REGISTRAR: "0x00000BeEF055f7934784D6d81b6BC86665630dbA";
163
+ readonly COIN_TYPE: 2158639068;
143
164
  } | {
144
165
  readonly ENS_REGISTRY: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
145
166
  readonly PUBLIC_RESOLVER: "";
146
167
  readonly NAME_WRAPPER: "";
147
168
  readonly REVERSE_REGISTRAR: "";
148
169
  readonly L2_REVERSE_REGISTRAR: "0x0000000000D8e504002cC26E3Ec46D81971C1664";
170
+ readonly COIN_TYPE: 2147525809;
149
171
  } | {
150
172
  readonly ENS_REGISTRY: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
151
173
  readonly PUBLIC_RESOLVER: "";
152
174
  readonly NAME_WRAPPER: "";
153
175
  readonly REVERSE_REGISTRAR: "";
154
176
  readonly L2_REVERSE_REGISTRAR: "0x00000BeEF055f7934784D6d81b6BC86665630dbA";
177
+ readonly COIN_TYPE: 2147905262;
155
178
  } | {
156
179
  readonly ENS_REGISTRY: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
157
180
  readonly PUBLIC_RESOLVER: "";
158
181
  readonly NAME_WRAPPER: "";
159
182
  readonly REVERSE_REGISTRAR: "";
160
183
  readonly L2_REVERSE_REGISTRAR: "0x0000000000D8e504002cC26E3Ec46D81971C1664";
184
+ readonly COIN_TYPE: 2148018000;
161
185
  } | {
162
186
  readonly ENS_REGISTRY: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
163
187
  readonly PUBLIC_RESOLVER: "";
164
188
  readonly NAME_WRAPPER: "";
165
189
  readonly REVERSE_REGISTRAR: "";
166
190
  readonly L2_REVERSE_REGISTRAR: "0x00000BeEF055f7934784D6d81b6BC86665630dbA";
191
+ readonly COIN_TYPE: 2148017999;
167
192
  } | {
168
193
  readonly ENS_REGISTRY: "0x0000000000000000000000000000000000000000";
169
194
  readonly PUBLIC_RESOLVER: "";
170
195
  readonly NAME_WRAPPER: "";
171
196
  readonly REVERSE_REGISTRAR: "";
172
197
  readonly L2_REVERSE_REGISTRAR: "";
198
+ readonly COIN_TYPE: 60;
173
199
  };
174
200
  export declare function getNetworkNameFromChainId(chainId: number): NetworkName;
175
201
  export declare function validateContractAddresses(addresses: Record<string, string>): void;
@@ -7,6 +7,7 @@ export const ENS_CONTRACTS = {
7
7
  NAME_WRAPPER: "0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401",
8
8
  REVERSE_REGISTRAR: "0xa58E81fe9b61B5c3fE2AFD33CF304c454AbFc7Cb",
9
9
  L2_REVERSE_REGISTRAR: "",
10
+ COIN_TYPE: 60,
10
11
  },
11
12
  // Sepolia testnet addresses
12
13
  sepolia: {
@@ -15,6 +16,7 @@ export const ENS_CONTRACTS = {
15
16
  NAME_WRAPPER: "0x0635513f179D50A207757E05759CbD106d7dFcE8",
16
17
  REVERSE_REGISTRAR: "0xA0a1AbcDAe1a2a4A2EF8e9113Ff0e02DD81DC0C6",
17
18
  L2_REVERSE_REGISTRAR: "",
19
+ COIN_TYPE: 60,
18
20
  },
19
21
  // Linea mainnet addresses
20
22
  linea: {
@@ -23,6 +25,7 @@ export const ENS_CONTRACTS = {
23
25
  NAME_WRAPPER: "0xA53cca02F98D590819141Aa85C891e2Af713C223",
24
26
  REVERSE_REGISTRAR: "0x08D3fF6E65f680844fd2465393ff6f0d742b67D5",
25
27
  L2_REVERSE_REGISTRAR: "0x0000000000D8e504002cC26E3Ec46D81971C1664",
28
+ COIN_TYPE: 2147542792,
26
29
  },
27
30
  // Linea Sepolia testnet addresses
28
31
  "linea-sepolia": {
@@ -31,6 +34,7 @@ export const ENS_CONTRACTS = {
31
34
  NAME_WRAPPER: "0xF127De9E039a789806fEd4C6b1C0f3aFfeA9425e",
32
35
  REVERSE_REGISTRAR: "0x4aAA964D8EB65508ca3DA3b0A3C060c16059E613",
33
36
  L2_REVERSE_REGISTRAR: "0x00000BeEF055f7934784D6d81b6BC86665630dbA",
37
+ COIN_TYPE: 2147542789,
34
38
  },
35
39
  // Base mainnet addresses
36
40
  base: {
@@ -39,6 +43,7 @@ export const ENS_CONTRACTS = {
39
43
  NAME_WRAPPER: "",
40
44
  REVERSE_REGISTRAR: "0x79EA96012eEa67A83431F1701B3dFf7e37F9E282",
41
45
  L2_REVERSE_REGISTRAR: "0x0000000000D8e504002cC26E3Ec46D81971C1664",
46
+ COIN_TYPE: 2147492101,
42
47
  },
43
48
  // Base Sepolia testnet addresses
44
49
  "base-sepolia": {
@@ -47,6 +52,7 @@ export const ENS_CONTRACTS = {
47
52
  NAME_WRAPPER: "",
48
53
  REVERSE_REGISTRAR: "0xa0A8401ECF248a9375a0a71C4dedc263dA18dCd7",
49
54
  L2_REVERSE_REGISTRAR: "0x00000BeEF055f7934784D6d81b6BC86665630dbA",
55
+ COIN_TYPE: 2147568180,
50
56
  },
51
57
  // Optimism mainnet addresses
52
58
  optimism: {
@@ -55,6 +61,7 @@ export const ENS_CONTRACTS = {
55
61
  NAME_WRAPPER: "",
56
62
  REVERSE_REGISTRAR: "",
57
63
  L2_REVERSE_REGISTRAR: "0x0000000000D8e504002cC26E3Ec46D81971C1664",
64
+ COIN_TYPE: 2147483658,
58
65
  },
59
66
  // Optimism Sepolia testnet addresses
60
67
  "optimism-sepolia": {
@@ -63,6 +70,7 @@ export const ENS_CONTRACTS = {
63
70
  NAME_WRAPPER: "",
64
71
  REVERSE_REGISTRAR: "",
65
72
  L2_REVERSE_REGISTRAR: "0x00000BeEF055f7934784D6d81b6BC86665630dbA",
73
+ COIN_TYPE: 2158639068,
66
74
  },
67
75
  // Arbitrum mainnet addresses
68
76
  arbitrum: {
@@ -71,6 +79,7 @@ export const ENS_CONTRACTS = {
71
79
  NAME_WRAPPER: "",
72
80
  REVERSE_REGISTRAR: "",
73
81
  L2_REVERSE_REGISTRAR: "0x0000000000D8e504002cC26E3Ec46D81971C1664",
82
+ COIN_TYPE: 2147525809,
74
83
  },
75
84
  // Arbitrum Sepolia testnet addresses
76
85
  "arbitrum-sepolia": {
@@ -79,6 +88,7 @@ export const ENS_CONTRACTS = {
79
88
  NAME_WRAPPER: "",
80
89
  REVERSE_REGISTRAR: "",
81
90
  L2_REVERSE_REGISTRAR: "0x00000BeEF055f7934784D6d81b6BC86665630dbA",
91
+ COIN_TYPE: 2147905262,
82
92
  },
83
93
  // Scroll mainnet addresses
84
94
  scroll: {
@@ -87,6 +97,7 @@ export const ENS_CONTRACTS = {
87
97
  NAME_WRAPPER: "",
88
98
  REVERSE_REGISTRAR: "",
89
99
  L2_REVERSE_REGISTRAR: "0x0000000000D8e504002cC26E3Ec46D81971C1664",
100
+ COIN_TYPE: 2148018000,
90
101
  },
91
102
  // Scroll Sepolia testnet addresses
92
103
  "scroll-sepolia": {
@@ -95,6 +106,7 @@ export const ENS_CONTRACTS = {
95
106
  NAME_WRAPPER: "",
96
107
  REVERSE_REGISTRAR: "",
97
108
  L2_REVERSE_REGISTRAR: "0x00000BeEF055f7934784D6d81b6BC86665630dbA",
109
+ COIN_TYPE: 2148017999,
98
110
  },
99
111
  // Local development addresses (will be set during deployment)
100
112
  localhost: {
@@ -103,6 +115,7 @@ export const ENS_CONTRACTS = {
103
115
  NAME_WRAPPER: "",
104
116
  REVERSE_REGISTRAR: "",
105
117
  L2_REVERSE_REGISTRAR: "",
118
+ COIN_TYPE: 60,
106
119
  },
107
120
  };
108
121
  // Helper function to get contract addresses for a given network
@@ -3,7 +3,6 @@ import "@nomicfoundation/hardhat-viem";
3
3
  interface TaskNameArguments {
4
4
  name: string;
5
5
  contract?: string;
6
- chain?: string;
7
6
  }
8
7
  declare const taskName: NewTaskActionFunction<TaskNameArguments>;
9
8
  export default taskName;
@@ -1,265 +1,33 @@
1
1
  import "@nomicfoundation/hardhat-viem";
2
- import { namehash, normalize } from "viem/ens";
3
- import { readContract, writeContract, waitForTransactionReceipt } from "viem/actions";
4
- import { keccak256, toBytes } from "viem";
5
- import ensRegistryABI from "../abi/ENSRegistry.js";
6
- import ownableContractABI from "../abi/Ownable.js";
7
- import nameWrapperABI from "../abi/NameWrapper.js";
8
- import publicResolverABI from "../abi/PublicResolver.js";
9
- import reverseRegistrarABI from "../abi/ReverseRegistrar.js";
10
- import { isAddressEmpty, isAddressValid, parseNormalizedName, logMetric, } from "../utils.js";
11
- import { getContractAddresses } from "../config/contracts.js";
12
- import { randomUUID } from "crypto";
13
- // Global contracts object - will be initialized based on chain
14
- let contracts = {};
15
- const opType = 'hh-enscribe-nameexisting';
16
- const corelationId = randomUUID();
2
+ import { normalize } from "viem/ens";
3
+ import { nameContract } from "@enscribe/enscribe";
17
4
  const taskName = async (args, hre) => {
18
- // console.log(args);
19
5
  if (args.contract == null) {
20
6
  console.log("need to pass a contract address");
21
7
  return;
22
8
  }
23
- // Determine network from chain parameter or default to sepolia
24
- const networkName = args.chain || "sepolia";
25
- // Initialize global contracts object based on network
26
- contracts = getContractAddresses(networkName);
27
- const { viem } = await hre.network.connect(networkName);
28
- // console.log(hre.userConfig.networks);
29
- const [senderClient, recvrClient] = await viem.getWalletClients();
30
- // console.log(senderClient.account);
9
+ const networkConnection = await hre.network.connect();
10
+ const [walletClient] = await networkConnection.viem.getWalletClients();
31
11
  const nameNormalized = normalize(args.name);
32
12
  console.log(`normalized name is ${nameNormalized}`);
33
- await setPrimaryName(nameNormalized, args.contract, senderClient);
34
- };
35
- const isOwnable = async (address, walletClient) => {
36
- if (isAddressEmpty(address) || !isAddressValid(address)) {
37
- return false;
38
- }
39
- try {
40
- const _ = (await readContract(walletClient, {
41
- address: address,
42
- abi: ownableContractABI,
43
- functionName: "owner",
44
- args: [],
45
- }));
46
- console.log("contract implements Ownable");
47
- }
48
- catch (err) {
49
- return false;
50
- }
51
- return true;
52
- };
53
- const isReverseClaimable = async (address, walletClient) => {
54
- if (isAddressEmpty(address) || !isAddressValid(address)) {
55
- return;
56
- }
13
+ // Use the library API
57
14
  try {
58
- const addrLabel = address.slice(2).toLowerCase();
59
- const reversedNode = namehash(addrLabel + '.' + 'addr.reverse');
60
- const resolvedAddr = (await readContract(walletClient, {
61
- address: contracts.ENS_REGISTRY,
62
- abi: ensRegistryABI,
63
- functionName: 'owner',
64
- args: [reversedNode],
65
- }));
66
- console.log('resolvedaddr is ' + resolvedAddr);
67
- if (resolvedAddr.toLowerCase() === walletClient.account?.address.toLowerCase()) {
68
- console.log('contract implements Reverseclaimable');
69
- return true;
70
- }
71
- else {
72
- console.log('contract does not implement reverseclaimable');
73
- return false;
74
- }
75
- }
76
- catch (err) {
77
- console.log('there was an error checking if the contract was reverse claimer');
78
- return false;
79
- }
80
- };
81
- const isContractOwner = async (address, walletClient) => {
82
- if (isAddressEmpty(address) || !isAddressValid(address) || !walletClient) {
83
- return false;
84
- }
85
- try {
86
- const ownerAddress = (await readContract(walletClient, {
87
- address: address,
88
- abi: ownableContractABI,
89
- functionName: 'owner',
90
- args: [],
91
- }));
92
- return ownerAddress.toLowerCase() == walletClient.account?.address.toLowerCase();
93
- }
94
- catch (err) {
95
- // console.log('err ' + err);
96
- const addrLabel = address.slice(2).toLowerCase();
97
- const reversedNode = namehash(addrLabel + '.' + 'addr.reverse');
98
- const resolvedAddr = (await readContract(walletClient, {
99
- address: contracts.ENS_REGISTRY,
100
- abi: ensRegistryABI,
101
- functionName: 'owner',
102
- args: [reversedNode],
103
- }));
104
- return resolvedAddr.toLowerCase() == walletClient.account?.address.toLowerCase();
105
- }
106
- };
107
- const setPrimaryName = async (normalizedName, contractAddress, walletClient) => {
108
- const { label, parent } = parseNormalizedName(normalizedName);
109
- const parentNode = namehash(parent);
110
- const labelHash = keccak256(toBytes(label));
111
- const fullNameNode = namehash(normalizedName);
112
- const nameExists = (await readContract(walletClient, {
113
- address: contracts.ENS_REGISTRY,
114
- abi: ensRegistryABI,
115
- functionName: "recordExists",
116
- args: [fullNameNode],
117
- }));
118
- let contractType = 'Unknown';
119
- if (await isReverseClaimable(contractAddress, walletClient)) {
120
- contractType = 'ReverseClaimer';
121
- }
122
- if (await isOwnable(contractAddress, walletClient)) {
123
- contractType = 'Ownable';
124
- }
125
- // create subname
126
- if (!nameExists) {
127
- process.stdout.write(`creating subname ... `);
128
- let txn;
129
- const isWrapped = await readContract(walletClient, {
130
- address: contracts.NAME_WRAPPER,
131
- abi: nameWrapperABI,
132
- functionName: "isWrapped",
133
- args: [parentNode],
15
+ console.log(`\Setting name for contract ${args.contract} on chain ${networkConnection.networkName} ...`);
16
+ const result = await nameContract({
17
+ name: nameNormalized,
18
+ contractAddress: args.contract,
19
+ walletClient: walletClient,
20
+ chainName: networkConnection.networkName,
21
+ opType: "hh-enscribe-nameexisting",
22
+ enableMetrics: true, // Enable metrics logging for plugin usage
134
23
  });
135
- if (isWrapped) {
136
- // console.log(
137
- // "create subname::writeContract calling setSubnodeRecord on NAME_WRAPPER",
138
- // );
139
- txn = await writeContract(walletClient, {
140
- address: contracts.NAME_WRAPPER,
141
- abi: nameWrapperABI,
142
- functionName: "setSubnodeRecord",
143
- args: [
144
- parentNode,
145
- label,
146
- walletClient.account?.address,
147
- contracts.PUBLIC_RESOLVER,
148
- 0,
149
- 0,
150
- 0,
151
- ],
152
- account: walletClient.account,
153
- chain: walletClient.chain,
154
- });
155
- // console.log(`create subname txn: ${txn}`);
156
- await waitForTransactionReceipt(walletClient, { hash: txn });
157
- process.stdout.write(`done with txn: ${txn}\n`);
158
- await logMetric(corelationId, Date.now(), walletClient.chain?.id, contractAddress, walletClient.account?.address, normalizedName, 'subname::setSubnodeRecord', txn, contractType, opType);
159
- }
160
- else {
161
- // console.log(
162
- // "create subname::writeContract calling setSubnodeRecord on ENS_REGISTRY",
163
- // );
164
- txn = await writeContract(walletClient, {
165
- address: contracts.ENS_REGISTRY,
166
- abi: ensRegistryABI,
167
- functionName: "setSubnodeRecord",
168
- args: [
169
- parentNode,
170
- labelHash,
171
- walletClient.account?.address,
172
- contracts.PUBLIC_RESOLVER,
173
- 0,
174
- ],
175
- account: walletClient.account,
176
- chain: walletClient.chain,
177
- });
178
- // console.log(`create subname txn: ${txn}`);
179
- await waitForTransactionReceipt(walletClient, { hash: txn });
180
- process.stdout.write(`done with txn: ${txn}\n`);
181
- await logMetric(corelationId, Date.now(), walletClient.chain?.id, contractAddress, walletClient.account?.address, normalizedName, 'subname::setSubnodeRecord', txn, contractType, opType);
182
- }
183
- }
184
- else {
185
- process.stdout.write(`${normalizedName} already exists. skipping subname creation.\n`);
186
- }
187
- // Wait for subname creation to be confirmed before proceeding
188
- // set fwd res
189
- process.stdout.write(`setting forward resolution ... `);
190
- const currentAddr = (await readContract(walletClient, {
191
- address: contracts.PUBLIC_RESOLVER,
192
- abi: publicResolverABI,
193
- functionName: "addr",
194
- args: [fullNameNode],
195
- }));
196
- if (currentAddr.toLowerCase() !== contractAddress.toLowerCase()) {
197
- // console.log("set fwdres::writeContract calling setAddr on PUBLIC_RESOLVER");
198
- let txn = await writeContract(walletClient, {
199
- address: contracts.PUBLIC_RESOLVER,
200
- abi: publicResolverABI,
201
- functionName: "setAddr",
202
- args: [fullNameNode, contractAddress],
203
- account: walletClient.account,
204
- chain: walletClient.chain,
205
- });
206
- await waitForTransactionReceipt(walletClient, { hash: txn });
207
- process.stdout.write(`done with txn: ${txn}\n`);
208
- await logMetric(corelationId, Date.now(), walletClient.chain?.id, contractAddress, walletClient.account?.address, normalizedName, 'fwdres::setAddr', txn, contractType, opType);
209
- }
210
- else {
211
- process.stdout.write("forward resolution already set.\n");
212
- }
213
- // set rev res
214
- process.stdout.write(`setting reverse resolution ... `);
215
- if (await isContractOwner(contractAddress, walletClient)) {
216
- let txn;
217
- if (contractType === 'ReverseClaimer') {
218
- const addrLabel = contractAddress.slice(2).toLowerCase();
219
- const reversedNode = namehash(addrLabel + '.' + 'addr.reverse');
220
- // console.log('reversedNode is ' + reversedNode + '\n');
221
- // console.log('pub res is ' + contracts.PUBLIC_RESOLVER + '\n');
222
- txn = await writeContract(walletClient, {
223
- address: contracts.PUBLIC_RESOLVER,
224
- abi: publicResolverABI,
225
- functionName: 'setName',
226
- args: [
227
- reversedNode,
228
- normalizedName,
229
- ],
230
- account: walletClient.account,
231
- chain: walletClient.chain,
232
- });
233
- await waitForTransactionReceipt(walletClient, { hash: txn });
234
- process.stdout.write(`done with txn: ${txn}\n`);
235
- await logMetric(corelationId, Date.now(), walletClient.chain?.id, contractAddress, walletClient.account?.address, normalizedName, 'revres::setName', txn, 'ReverseClaimer', opType);
236
- }
237
- else if (contractType === 'Ownable') {
238
- txn = await writeContract(walletClient, {
239
- address: contracts.REVERSE_REGISTRAR,
240
- abi: reverseRegistrarABI,
241
- functionName: "setNameForAddr",
242
- args: [
243
- contractAddress,
244
- walletClient.account?.address,
245
- contracts.PUBLIC_RESOLVER,
246
- normalizedName,
247
- ],
248
- account: walletClient.account,
249
- chain: walletClient.chain,
250
- });
251
- await waitForTransactionReceipt(walletClient, { hash: txn });
252
- process.stdout.write(`done with txn: ${txn}\n`);
253
- await logMetric(corelationId, Date.now(), walletClient.chain?.id, contractAddress, walletClient.account?.address, normalizedName, 'revres::setNameForAddr', txn, 'Ownable', opType);
254
- }
255
- else {
256
- console.log(`Only Ownable, ERC173 and ReverseClaimer contracts can be named.`);
257
- return;
258
- }
24
+ console.log(`\nNaming completed successfully!`);
25
+ console.log(`Contract Type: ${result.contractType}`);
26
+ console.log(`Transactions:`, result.transactions);
27
+ console.log(`You can check your contract at:`, result.explorerUrl);
259
28
  }
260
- else {
261
- console.log(`You are not the owner of this contract. Skipping reverse resolution.\n`);
29
+ catch (error) {
30
+ console.error("Error naming contract:", error);
262
31
  }
263
- console.log(`✨ Contract named: https://app.enscribe.xyz/explore/${walletClient.chain?.id}/${normalizedName}`);
264
32
  };
265
33
  export default taskName;
@@ -38,17 +38,14 @@ describe("name task integration", () => {
38
38
  const mockArgs = {
39
39
  name: "test.example.eth",
40
40
  contract: "0x1234567890123456789012345678901234567890",
41
- chain: "sepolia",
42
41
  };
43
42
  expect(mockArgs.name).toBe("test.example.eth");
44
43
  expect(mockArgs.contract).toBe("0x1234567890123456789012345678901234567890");
45
- expect(mockArgs.chain).toBe("sepolia");
46
44
  });
47
45
  it("should handle missing contract address gracefully", () => {
48
46
  const mockArgs = {
49
47
  name: "test.example.eth",
50
48
  contract: null,
51
- chain: "sepolia",
52
49
  };
53
50
  expect(mockArgs.contract).toBeNull();
54
51
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enscribe/hardhat-enscribe",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "A Hardhat v3 plugin to name smart contracts",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -22,14 +22,15 @@
22
22
  "node": ">=18.0.0"
23
23
  },
24
24
  "dependencies": {
25
- "viem": "^2.37.8"
25
+ "@enscribe/enscribe": "^0.1.2",
26
+ "viem": "^2.38.0"
26
27
  },
27
28
  "peerDependencies": {
28
29
  "hardhat": "^3.0.0"
29
30
  },
30
31
  "devDependencies": {
31
- "@nomicfoundation/hardhat-viem": "^3.0.0",
32
32
  "@nomicfoundation/hardhat-network-helpers": "^1.0.0",
33
+ "@nomicfoundation/hardhat-viem": "^3.0.0",
33
34
  "@types/chai": "^4.3.11",
34
35
  "@types/mocha": "^10.0.6",
35
36
  "@types/node": "^20.0.0",
@@ -39,7 +40,7 @@
39
40
  "prettier": "^3.0.0",
40
41
  "rimraf": "^6.0.0",
41
42
  "ts-node": "^10.9.2",
42
- "typescript": "^5.0.0",
43
+ "typescript": "5.9.2",
43
44
  "vitest": "^1.6.0"
44
45
  },
45
46
  "publishConfig": {