Skip to content

Commit

Permalink
New Contract Added
Browse files Browse the repository at this point in the history
  • Loading branch information
saransh committed Oct 30, 2021
1 parent 32607a1 commit 64221ec
Show file tree
Hide file tree
Showing 14 changed files with 2,296 additions and 0 deletions.
33 changes: 33 additions & 0 deletions deploy/basregistrar/00_deploy_base_registrar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const { ethers } = require("hardhat");
const ZERO_HASH = "0x0000000000000000000000000000000000000000000000000000000000000000";

const ethernal = require('hardhat-ethernal');

const namehash = require('eth-ens-namehash');
const sha3 = require('web3-utils').sha3;

module.exports = async ({getNamedAccounts, deployments, network}) => {
const {deploy} = deployments;
const {deployer, owner} = await getNamedAccounts();

const ens = await ethers.getContract('ENSRegistry')

await deploy('BaseRegistrarImplementation', {
from: deployer,
args: [ens.address, namehash.hash('avax')],
log: true
})

const base = await ethers.getContract('BaseRegistrarImplementation');

const transactions = []
transactions.push(await base.addController(deployer))
transactions.push(await ens.setSubnodeOwner(ZERO_HASH, sha3('avax'), base.address))

console.log(`Waiting on ${transactions.length} transactions setting base registrar`);
await Promise.all(transactions.map((tx) => tx.wait()));
}


module.exports.tags = ['baseregistrar'];
module.exports.dependencies = ['registry']
26 changes: 26 additions & 0 deletions deploy/basregistrar/10_deploy_reverse_registrar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { ethers } = require("hardhat");
const ZERO_HASH = "0x0000000000000000000000000000000000000000000000000000000000000000";
const sha3 = require('web3-utils').sha3;
const namehash = require('eth-ens-namehash');
module.exports = async ({getNamedAccounts, deployments, network}) => {
const {deploy} = deployments;
const {deployer, owner} = await getNamedAccounts();

const ens = await ethers.getContract('ENSRegistry');
const resolver = await ethers.getContract('PublicResolver');

await deploy('ReverseRegistrar', {
from: deployer,
args:[ens.address, resolver.address]
})
const reverseRegistrar = await ethers.getContract('ReverseRegistrar');

const transactions = []
transactions.push(await ens.setSubnodeOwner(ZERO_HASH, sha3('reverse'), deployer))
transactions.push(await ens.setSubnodeOwner(namehash.hash('reverse'),sha3('addr'),reverseRegistrar.address))
console.log(`Waiting on settings to take place of reverse registrar ${transactions.length}`)
await Promise.all(transactions.map((tx) => tx.wait()));
}

module.exports.tags = ['reverse-registrar'];
module.exports.dependencies = ['registry', 'public-resolver']
33 changes: 33 additions & 0 deletions deploy/ethregistrar/00_deploy_eth_registrar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const { ethers } = require("hardhat");


module.exports = async ({getNamedAccounts, deployments, network}) => {
const {deploy} = deployments;
const {deployer, owner} = await getNamedAccounts();

const baseRegistrar = await ethers.getContract('BaseRegistrarImplementation');

const priceOracle = await ethers.getContract('StablePriceOracle')

await deploy('ETHRegistrarController', {
from: deployer,
args: [baseRegistrar.address, priceOracle.address, 600, 86400],
log: true
})

const controller = await ethers.getContract('ETHRegistrarController')
const transactions = []
transactions.push(await baseRegistrar.addController(controller.address, {from: deployer}))
// ESTIMATE GAS -->
transactions.push(await controller.setPriceOracle(priceOracle.address, {from: deployer}));
console.log(`Waiting on settings to take place ${transactions.length}`)
await Promise.all(transactions.map((tx) => tx.wait()));





}

module.exports.tags = ['eth-registrar'];
module.exports.dependencies = ['registry', 'oracles']
22 changes: 22 additions & 0 deletions deploy/oracles/00_deploy_oracles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { ethers } = require("hardhat");

module.exports = async ({getNamedAccounts, deployments, network}) => {
const {deploy} = deployments;
const {deployer, owner} = await getNamedAccounts();
const oracle = await deploy('DummyOracle', {
from: deployer,
args:[1000],
log:true
})

await deploy('StablePriceOracle', {
from: deployer,
args:[oracle.address,[1]],
log:true
})


}

module.exports.tags = ['oracles'];
module.exports.dependencies = ['registry']
21 changes: 21 additions & 0 deletions deploy/registry/00_deploy_reverse_resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { ethers } = require("hardhat");


module.exports = async ({getNamedAccounts, deployments, network}) => {
const {deploy} = deployments;
const {deployer, owner} = await getNamedAccounts();

const ens = await ethers.getContract('ENSRegistry')

const publicResolver = await deploy('DefaultReverseResolver', {
from: deployer,
args: [ens.address],
log: true
})



}

module.exports.tags = ['reverse-resolver'];
module.exports.dependencies = ['registry']
49 changes: 49 additions & 0 deletions deploy/registry/10_deploy_public_resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const { ethers } = require("hardhat");
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
const ZERO_HASH = "0x0000000000000000000000000000000000000000000000000000000000000000"
const sha3 = require('web3-utils').sha3;

module.exports = async ({getNamedAccounts, deployments, network}) => {
const {deploy} = deployments;
const {deployer, owner} = await getNamedAccounts();

const ens = await ethers.getContract('ENSRegistry')

await deploy('PublicResolver', {
from: deployer,
args: [ens.address, ZERO_ADDRESS],
log: true
})

const resolver = await ethers.getContract('PublicResolver')

const transactions = []
transactions.push(await ens.setSubnodeOwner(ZERO_HASH, sha3('avax'), deployer))
transactions.push(await ens.setResolver(namehash.hash('avax'), resolver.address))
transactions.push(await resolver['setAddr(bytes32,address)'](namehash.hash('avax'), resolver.address))
console.log(`Waiting on settings to take place on resolvers ${transactions.length}`)
await Promise.all(transactions.map((tx) => tx.wait()));

// const rootOwner = await ens.owner(ZERO_HASH);
// switch(rootOwner) {
// case deployer:
// // const tx = await base.addController(owner, {from: deployer});
// // console.log("Setting Controller on base (tx:${tx.hash})...");
// // await tx.wait();
// break;
// case owner:
// console.log('e')
// const tx = await ens.setSubnodeOwner(ZERO_HASH, sha3('avax'), owner, {from: deployer});
// console.log("Setting Controller on base (tx:${tx.hash})...");
// await tx.wait();
// break;
// default:
// console.log(`WARNING: ENS registry root is owned by ${rootOwner}; cannot transfer to owner`);
// }



}

module.exports.tags = ['public-resolver'];
module.exports.dependencies = ['registry']
1 change: 1 addition & 0 deletions deployments/avash/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
43112
3 changes: 3 additions & 0 deletions deployments/avash/.migrations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ens": 1635592240
}
Loading

0 comments on commit 64221ec

Please sign in to comment.