1 | const ENS = artifacts.require("./ENSRegistry.sol");
|
2 | const FIFSRegistrar = artifacts.require('./FIFSRegistrar.sol');
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | const Registrar = artifacts.require('./HashRegistrar.sol');
|
9 | const web3 = new (require('web3'))();
|
10 | const namehash = require('eth-ens-namehash');
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | function getRootNodeFromTLD(tld) {
|
18 | return {
|
19 | namehash: namehash(tld),
|
20 | sha3: web3.sha3(tld)
|
21 | };
|
22 | }
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | function deployFIFSRegistrar(deployer, tld) {
|
31 | var rootNode = getRootNodeFromTLD(tld);
|
32 |
|
33 |
|
34 | deployer.deploy(ENS)
|
35 | .then(() => {
|
36 |
|
37 | return deployer.deploy(FIFSRegistrar, ENS.address, rootNode.namehash);
|
38 | })
|
39 | .then(function() {
|
40 |
|
41 | return ENS.at(ENS.address).then((c) => c.setSubnodeOwner('0x0', rootNode.sha3, FIFSRegistrar.address));
|
42 | });
|
43 | }
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | function deployAuctionRegistrar(deployer, tld) {
|
52 | var rootNode = getRootNodeFromTLD(tld);
|
53 |
|
54 |
|
55 | deployer.deploy(ENS)
|
56 | .then(() => {
|
57 |
|
58 |
|
59 | return deployer.deploy(Registrar, ENS.address, rootNode.namehash, 0);
|
60 | })
|
61 | .then(function() {
|
62 |
|
63 | return ENS.at(ENS.address).then((c) => c.setSubnodeOwner('0x0', rootNode.sha3, Registrar.address));
|
64 | });
|
65 | }
|
66 |
|
67 | module.exports = function(deployer, network) {
|
68 | var tld = 'eth';
|
69 |
|
70 | if (network === 'dev.fifs') {
|
71 | deployFIFSRegistrar(deployer, tld);
|
72 | }
|
73 | else if (network === 'dev.auction') {
|
74 | deployAuctionRegistrar(deployer, tld);
|
75 | }
|
76 |
|
77 | };
|