diff --git a/crosschain-resolver/contracts/L1Resolver.sol b/crosschain-resolver/contracts/L1Resolver.sol index 726319a8..b4882e73 100644 --- a/crosschain-resolver/contracts/L1Resolver.sol +++ b/crosschain-resolver/contracts/L1Resolver.sol @@ -30,7 +30,7 @@ contract L1Resolver is EVMFetchTarget, ITargetResolver, IMetadataResolver, IExte uint256 constant VERSIONABLE_HASHES_SLOT = 3; uint256 constant VERSIONABLE_TEXTS_SLOT = 10; string public graphqlUrl; - uint256 public l2ResolverCoinType; + uint256 public l2ChainId; event TargetSet(bytes name, address target); function isAuthorised(bytes32 node) internal view returns (bool) { @@ -61,14 +61,14 @@ contract L1Resolver is EVMFetchTarget, ITargetResolver, IMetadataResolver, IExte * @param _ens The ENS registry address * @param _nameWrapper The ENS name wrapper address * @param _graphqlUrl The offchain/l2 graphql endpoint url - * @param _l2ResolverCoinType The chainId at which the resolver resolves data from. 0 if storageLocation is offChain + * @param _l2ChainId The chainId at which the resolver resolves data from */ constructor( IEVMVerifier _verifier, ENS _ens, INameWrapper _nameWrapper, string memory _graphqlUrl, - uint256 _l2ResolverCoinType + uint256 _l2ChainId ){ require(address(_nameWrapper) != address(0), "Name Wrapper address must be set"); require(address(_verifier) != address(0), "Verifier address must be set"); @@ -77,7 +77,7 @@ contract L1Resolver is EVMFetchTarget, ITargetResolver, IMetadataResolver, IExte ens = _ens; nameWrapper = _nameWrapper; graphqlUrl = _graphqlUrl; - l2ResolverCoinType = _l2ResolverCoinType; + l2ChainId = _l2ChainId; } /** @@ -283,13 +283,9 @@ contract L1Resolver is EVMFetchTarget, ITargetResolver, IMetadataResolver, IExte super.supportsInterface(interfaceId); } - function convertCoinTypeToEVMChainId(uint256 coinType) private pure returns (uint256) { - return (0x7fffffff & coinType) >> 0; - } - function _writeDeferral(address target) internal view { revert StorageHandledByL2( - convertCoinTypeToEVMChainId(l2ResolverCoinType), + l2ChainId, target ); } diff --git a/crosschain-resolver/deploy_l1/10_l1resolver.ts b/crosschain-resolver/deploy_l1/10_l1resolver.ts index 84398ae0..584f0c15 100644 --- a/crosschain-resolver/deploy_l1/10_l1resolver.ts +++ b/crosschain-resolver/deploy_l1/10_l1resolver.ts @@ -22,12 +22,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const CHAIN_NAME = process.env.CHAIN_NAME if(!['Op', 'Base', 'Arb'].includes(CHAIN_NAME)) throw ('Set $CHAIN_NAME to Op, Base, or Arb') - const L2_COINTYPE = convertEVMChainIdToCoinType(parseInt(L2_CHAIN_ID)) - console.log({VERIFIER_ADDRESS,ENS_ADDRESS, WRAPPER_ADDRESS,L2_GRAPHQL_URL,L2_COINTYPE}) + console.log({VERIFIER_ADDRESS,ENS_ADDRESS, WRAPPER_ADDRESS,L2_GRAPHQL_URL,L2_CHAIN_ID}) await deploy(`${CHAIN_NAME}L1Resolver`, { from: deployer, contract: 'L1Resolver', - args: [VERIFIER_ADDRESS,ENS_ADDRESS,WRAPPER_ADDRESS,L2_GRAPHQL_URL,L2_COINTYPE], + args: [VERIFIER_ADDRESS,ENS_ADDRESS,WRAPPER_ADDRESS,L2_GRAPHQL_URL,parseInt(L2_CHAIN_ID)], log: true, }); }; diff --git a/crosschain-resolver/test/testResolver.ts b/crosschain-resolver/test/testResolver.ts index d0b716be..612acd92 100644 --- a/crosschain-resolver/test/testResolver.ts +++ b/crosschain-resolver/test/testResolver.ts @@ -15,13 +15,12 @@ import { ethers } from 'hardhat'; import { EthereumProvider } from 'hardhat/types'; import request from 'supertest'; import packet from 'dns-packet'; -import {convertEVMChainIdToCoinType} from '@ensdomains/address-encoder' +import { L2ChainID } from '@eth-optimism/sdk'; const labelhash = (label) => ethers.keccak256(ethers.toUtf8Bytes(label)) const encodeName = (name) => '0x' + packet.name.encode(name).toString('hex') const l2graphqlUrl = 'http://graphql' -const l2ResolverChainId = 420 -const l2ResolverCoinType = convertEVMChainIdToCoinType(l2ResolverChainId) // Optimism Goerli +const chainId = L2ChainID.OPTIMISM_SEPOLIA const name = 'foo.eth' const node = ethers.namehash(name) @@ -155,7 +154,7 @@ describe('Crosschain Resolver', () => { signer ); const verifierAddress = await verifier.getAddress() - target = await testL1Factory.deploy(verifierAddress, ensAddress, wrapperAddress, l2graphqlUrl, l2ResolverCoinType); + target = await testL1Factory.deploy(verifierAddress, ensAddress, wrapperAddress, l2graphqlUrl, chainId); // Mine an empty block so we have something to prove against await provider.send('evm_mine', []); @@ -328,7 +327,7 @@ describe('Crosschain Resolver', () => { const calldata = i.encodeFunctionData("setAddr", [node, EMPTY_ADDRESS]) await expect(target.resolveDeferral(encodedname, calldata)).to.be .revertedWithCustomError(target, 'StorageHandledByL2') - .withArgs(l2ResolverChainId, resolverAddress) + .withArgs(chainId, resolverAddress) }); });