/
tld.js
120 lines (91 loc) · 3.3 KB
/
tld.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
var ethers = require('ethers')
var dotenv = require('dotenv')
// console.log(ethers.utils.keccak256(ethers.utils.toUtf8Bytes('attest')))
// console.log(ethers.utils.keccak256(ethers.utils.toUtf8Bytes('revoke')))
const ROOT =
'0x0000000000000000000000000000000000000000000000000000000000000000'
dotenv.config()
console.log(process.env.TLD)
console.log(
ethers.utils.solidityKeccak256(
['bytes32', 'bytes32'],
[ROOT, ethers.utils.keccak256(ethers.utils.toUtf8Bytes(process.env.TLD))],
),
)
console.log(ethers.utils.namehash(process.env.TLD))
console.log(ethers.utils.keccak256(ethers.utils.toUtf8Bytes(process.env.TLD)))
console.log(ethers.utils.keccak256(ethers.utils.toUtf8Bytes('register')))
console.log(ethers.utils.keccak256(ethers.utils.toUtf8Bytes('renew')))
console.log(ethers.utils.keccak256(ethers.utils.toUtf8Bytes('takeover')))
console.log('earth.838earth.bored')
let earth = ethers.utils.solidityKeccak256(
['bytes32', 'bytes32'],
[ROOT, ethers.utils.keccak256(ethers.utils.toUtf8Bytes('bored'))],
)
earth = ethers.utils.solidityKeccak256(
['bytes32', 'bytes32'],
[earth, ethers.utils.keccak256(ethers.utils.toUtf8Bytes('838earth'))],
)
earth = ethers.utils.solidityKeccak256(
['bytes32', 'bytes32'],
[earth, ethers.utils.keccak256(ethers.utils.toUtf8Bytes('earth'))],
)
console.log(earth)
console.log('addr.reverse')
let reverse = ethers.utils.solidityKeccak256(
['bytes32', 'bytes32'],
[ROOT, ethers.utils.keccak256(ethers.utils.toUtf8Bytes('reverse'))],
)
console.log(ethers.utils.keccak256(ethers.utils.toUtf8Bytes('reverse')))
console.log(reverse)
let addrReverse = ethers.utils.solidityKeccak256(
['bytes32', 'bytes32'],
[reverse, ethers.utils.keccak256(ethers.utils.toUtf8Bytes('addr'))],
)
console.log(ethers.utils.keccak256(ethers.utils.toUtf8Bytes('addr')))
console.log(addrReverse)
{
console.log('axl.axelar.op')
let op = ethers.utils.solidityKeccak256(
['bytes32', 'bytes32'],
[ROOT, ethers.utils.keccak256(ethers.utils.toUtf8Bytes('op'))],
)
console.log(op)
axelar = ethers.utils.solidityKeccak256(
['bytes32', 'bytes32'],
[op, ethers.utils.keccak256(ethers.utils.toUtf8Bytes('axelar'))],
)
console.log(axelar)
axl = ethers.utils.solidityKeccak256(
['bytes32', 'bytes32'],
[axelar, ethers.utils.keccak256(ethers.utils.toUtf8Bytes('axl'))],
)
console.log(axl)
gateway = ethers.utils.solidityKeccak256(
['bytes32', 'bytes32'],
[axelar, ethers.utils.keccak256(ethers.utils.toUtf8Bytes('gateway'))],
)
console.log(gateway)
gasservice = ethers.utils.solidityKeccak256(
['bytes32', 'bytes32'],
[axelar, ethers.utils.keccak256(ethers.utils.toUtf8Bytes('gasservice'))],
)
console.log(gasservice)
resolver = ethers.utils.solidityKeccak256(
['bytes32', 'bytes32'],
[axelar, ethers.utils.keccak256(ethers.utils.toUtf8Bytes('resolver'))],
)
console.log(resolver)
}
const ADDRESS_PROBLEM = '000000187c72ee4a4120a3e626425595a34f185b'
const xxx = ethers.utils.solidityKeccak256(
['bytes32', 'bytes32'],
[
addrReverse,
ethers.utils.keccak256(ethers.utils.toUtf8Bytes(ADDRESS_PROBLEM)),
],
)
console.log(xxx)
console.log(ethers.utils.namehash('addr.reverse'))
console.log(ethers.utils.keccak256(ethers.utils.toUtf8Bytes(ADDRESS_PROBLEM)))
console.log(ethers.utils.namehash(ADDRESS_PROBLEM + '.addr.reverse'))