Skip to content

Commit

Permalink
feat: small updates from latest ens-gateway repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Julink-eth committed May 10, 2024
1 parent 0e4296c commit 1975e98
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 51 deletions.
22 changes: 10 additions & 12 deletions packages/l1-contracts/contracts/L1Resolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ contract L1Resolver is
{
using EVMFetcher for EVMFetcher.EVMFetchRequest;
using BytesUtils for bytes;
IEVMVerifier immutable verifier;
ENS immutable ens;
INameWrapper immutable nameWrapper;
IEVMVerifier public immutable verifier;
ENS public immutable ens;
INameWrapper public immutable nameWrapper;
mapping(bytes32 => address) targets;
uint256 constant COIN_TYPE_ETH = 60;
uint256 constant RECORD_VERSIONS_SLOT = 0;
Expand All @@ -40,7 +40,7 @@ contract L1Resolver is
string public graphqlUrl;
uint256 public l2ChainId;

event TargetSet(bytes32 indexed node, address target);
event TargetSet(bytes name, address target);

function isAuthorised(bytes32 node) internal view returns (bool) {
// TODO: Add support for
Expand All @@ -62,11 +62,6 @@ contract L1Resolver is
*/
error StorageHandledByL2(uint256 chainId, address contractAddress);

modifier authorised(bytes32 node) {
require(isAuthorised(node));
_;
}

/**
* @param _verifier The chain verifier address
* @param _ens The ENS registry address
Expand Down Expand Up @@ -99,12 +94,15 @@ contract L1Resolver is

/**
* Set target address to verify aagainst
* @param node The ENS node to query.
* @param name The encoded name to query.
* @param target The L2 resolver address to verify against.
*/
function setTarget(bytes32 node, address target) public authorised(node) {
function setTarget(bytes calldata name, address target) public {
(bytes32 node, ) = getTarget(name);
require(isAuthorised(node));
targets[node] = target;
emit TargetSet(node, target);
emit TargetSet(name, target);
emit MetadataChanged(name, graphqlUrl);
}

/**
Expand Down
9 changes: 5 additions & 4 deletions packages/l1-contracts/deploy/02_deploy_l1Resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { address as PublicResolverLineaSepoliaAddr } from "../../l2-contracts/de
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";
import packet from "dns-packet";

const encodeName = (name) => "0x" + packet.name.encode(name).toString("hex");

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, deployments, network, ethers } = hre;
Expand All @@ -14,8 +17,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

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

const args: any[] = [];
Expand All @@ -31,8 +33,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
break;
case "mainnet":
// ens namehash of linea.eth
node =
"0x527aac89ac1d1de5dd84cff89ec92c69b028ce9ce3fa3d654882474ab4402ec3";
node = encodeName("linea.eth");
target = PublicResolverMainnetAddr;
// TODO add when deployed on mainnet
// args.push(PohVerifierSepoliaAddr,ENSRegistryMainnetAddr, NameWrapperMainnetAddr);
Expand Down
87 changes: 63 additions & 24 deletions packages/l1-contracts/deployments/sepolia/L1Resolver.json

Large diffs are not rendered by default.

Loading

0 comments on commit 1975e98

Please sign in to comment.