Skip to content

Commit

Permalink
feat: added l1Resolver deployment scripts + health check in the gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
Julink-eth committed May 7, 2024
1 parent 72c2843 commit 8a6cd8d
Show file tree
Hide file tree
Showing 11 changed files with 1,295 additions and 6 deletions.
1 change: 0 additions & 1 deletion packages/ens-app-v3/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export const formatFullExpiry = (expiryDate?: Date) =>
expiryDate ? `${formatExpiry(expiryDate)}, ${formatDateTime(expiryDate)}` : ''

export const makeEtherscanLink = (data: string, network?: string, route: string = 'tx') => {
console.log({ network })
switch (network) {
case 'mainnet':
case '':
Expand Down
15 changes: 15 additions & 0 deletions packages/gateway/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ const server = new Server();
gateway.add(server);
const app = server.makeApp("/");

// Add a health check page
app.get("/health", async (_req, res, _next) => {
const healthcheck = {
uptime: process.uptime(),
message: "OK",
timestamp: Date.now(),
};
try {
res.send(healthcheck);
} catch (error) {
healthcheck.message = error;
res.status(503).send();
}
});

(async () => {
app.listen(port, function () {
console.log(`Listening on ${port}`);
Expand Down
23 changes: 22 additions & 1 deletion packages/l1-contracts/deploy/01_deploy_verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,38 @@ import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, deployments } = hre;
const { getNamedAccounts, deployments, network } = hre;
const { deploy, get } = deployments;
const { deployer } = await getNamedAccounts();

const args: any[] = [];

switch (network.name) {
case "sepolia":
args.push(
["https://linea-ens-gateway.devnet.linea.build"],
"0xB218f8A4Bc926cF1cA7b3423c154a0D627Bdb7E5"
);
break;
case "mainnet":
// TODO add when deployed on mainnet
// args.push(PohVerifierSepoliaAddr,ENSRegistryMainnetAddr, NameWrapperMainnetAddr);
// break;
console.log("Mainnet deployment not ready");
return;
default:
console.log(`Network ${network.name} not supported`);
return;
}

const sparseMerkleProof = await get("SparseMerkleProof");

const lineaSparseProofVerifier = await deploy("LineaSparseProofVerifier", {
from: deployer,
libraries: {
SparseMerkleProof: sparseMerkleProof.address,
},
args,
log: true,
});
console.log(
Expand Down
25 changes: 21 additions & 4 deletions packages/l1-contracts/deploy/02_deploy_l1Resolver.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { ethers } from "hardhat";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { address as ENSRegistrySepoliaAddr } from "../../l2-contracts/deployments/sepolia/ENSRegistry.json";
import { address as NameWrapperSepoliaAddr } from "../../l2-contracts/deployments/sepolia/NameWrapper.json";
import { address as PublicResolverLineaSepoliaAddr } from "../../l2-contracts/deployments/lineaSepolia/PublicResolver.json";
import { address as ENSRegistryMainnetAddr } from "../../l2-contracts/deployments/mainnet/ENSRegistry.json";
import { address as NameWrapperMainnetAddr } from "../../l2-contracts/deployments/mainnet/NameWrapper.json";
import { address as PublicResolverMainnetAddr } from "../../l2-contracts/deployments/mainnet/PublicResolver.json";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, deployments, network } = hre;
const { getNamedAccounts, deployments, network, ethers } = hre;
const { deploy, get } = deployments;
const { deployer } = await getNamedAccounts();

const lineaSparseProofVerifier = await get("LineaSparseProofVerifier");
// ens namehash of linea-sepolia.eth
let node =
"0x1944d8f922dbda424d5bb8181be5344d513cd0210312d2dcccd37d54c11a17de";
let target = PublicResolverLineaSepoliaAddr;

const args: string[] = [];
switch (network.name) {
Expand All @@ -24,6 +28,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
);
break;
case "mainnet":
// ens namehash of linea.eth
node =
"0x527aac89ac1d1de5dd84cff89ec92c69b028ce9ce3fa3d654882474ab4402ec3";
target = PublicResolverMainnetAddr;
// TODO add when deployed on mainnet
// args.push(PohVerifierSepoliaAddr,ENSRegistryMainnetAddr, NameWrapperMainnetAddr);
// break;
Expand All @@ -34,12 +42,21 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
return;
}

const l1Resolver = await deploy("L1Resolver", {
const l1ResolverDeploy = await deploy("L1Resolver", {
from: deployer,
args,
log: true,
});
console.log(`Deployed L1Resolver to ${l1Resolver.address}`);
console.log(`Deployed L1Resolver to ${l1ResolverDeploy.address}`);

const l1Resolver = await ethers.getContractAt(
"L1Resolver",
l1ResolverDeploy.address
);
const tx = await l1Resolver.setTarget(node, target);
await tx.wait();

console.log(`Set target on L1Resolver for ${node} to ${target}`);
};

func.tags = ["l1Resolver"];
Expand Down
1 change: 1 addition & 0 deletions packages/l1-contracts/deployments/sepolia/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11155111
Loading

0 comments on commit 8a6cd8d

Please sign in to comment.