Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Switch to L2ReverseRegistrar #12

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
5 changes: 2 additions & 3 deletions crosschain-reverse-resolver/contracts/L1ReverseResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ contract L1ReverseResolver is EVMFetchTarget {
using EVMFetcher for EVMFetcher.EVMFetchRequest;
IEVMVerifier immutable verifier;
address immutable target;
uint256 constant COIN_TYPE_ETH = 60;
uint256 constant RECORD_VERSIONS_SLOT = 1;
uint256 constant VERSINABLE_NAME_SLOT = 9;
uint256 constant VERSINABLE_TEXTS_SLOT = 11;
uint256 constant VERSINABLE_TEXTS_SLOT = 3;
uint256 constant VERSINABLE_NAME_SLOT = 4;

constructor(IEVMVerifier _verifier, address _target) {
verifier = _verifier;
Expand Down
25 changes: 10 additions & 15 deletions crosschain-reverse-resolver/contracts/deps.sol
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import {L1Verifier} from '@ensdomains/l1-verifier/contracts/L1Verifier.sol';
import '@ensdomains/ens-contracts/contracts/resolvers/OwnedResolver.sol';
import '@ensdomains/ens-contracts/contracts/reverseRegistrar/L2ReverseRegistrar.sol';

// Storage slot
// ┌─────────────────────┬──────────────────────────────┬──────────────┬
// │ contract │ state_variable │ storage_slot │
// ├─────────────────────┼──────────────────────────────┼──────────────┼
// | OwnedResolver │ _owner │ 0 │
// │ OwnedResolver │ recordVersions │ 1 │
// │ OwnedResolver │ versionable_abis │ 2 │
// │ OwnedResolver │ versionable_addresses │ 3 │
// │ OwnedResolver │ versionable_hashes │ 4 │
// │ OwnedResolver │ versionable_zonehashes │ 5 │
// │ OwnedResolver │ versionable_records │ 6 │
// │ OwnedResolver │ versionable_nameEntriesCount │ 7 │
// │ OwnedResolver │ versionable_interfaces │ 8 │
// │ OwnedResolver │ versionable_names │ 9 │
// │ OwnedResolver │ versionable_pubkeys │ 10 │
// │ OwnedResolver │ versionable_texts │ 11 │
// ┌───────────────────────┬──────────────────────────────┬──────────────┬
// │ contract │ state_variable │ storage_slot │
// ├───────────────────────┼──────────────────────────────┼──────────────│
// │ L2ReverseRegistrar │ _owner │ 0 │
// │ L2ReverseRegistrar │ recordVersions │ 1 │
// │ L2ReverseRegistrar │ lastUpdated │ 2 │
// │ L2ReverseRegistrar │ versionable_texts │ 3 │
// │ L2ReverseRegistrar │ versionable_names │ 4 │
// │ L2ReverseResolverBase │ recordVersions │ 0 │
6 changes: 3 additions & 3 deletions crosschain-reverse-resolver/deploy_l1/10_l1resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployer} = await getNamedAccounts();

const OP_VERIFIER_ADDRESS = process.env.OP_VERIFIER_ADDRESS
const OwnedResolver = await hre.companionNetworks['l2'].deployments.get('OwnedResolver');
const L2ReverseRegistrar = await hre.companionNetworks['l2'].deployments.get('L2ReverseRegistrar');
if(!OP_VERIFIER_ADDRESS) throw ('Set $OP_VERIFIER_ADDRESS')
console.log({OP_VERIFIER_ADDRESS, OWNED_RESOLVER_ADDRESS:OwnedResolver.address})
console.log({OP_VERIFIER_ADDRESS, L2_RESOLVER_ADDRESS:L2ReverseRegistrar.address})
await deploy('L1ReverseResolver', {
from: deployer,
args: [OP_VERIFIER_ADDRESS, OwnedResolver.address],
args: [OP_VERIFIER_ADDRESS, L2ReverseRegistrar.address],
log: true,
});
};
Expand Down
4 changes: 2 additions & 2 deletions crosschain-reverse-resolver/deploy_l2/01_l2resolver .ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

const {deployer} = await getNamedAccounts();
console.log({deployer})
await deploy('OwnedResolver', {
await deploy('L2ReverseRegistrar', {
from: deployer,
args: [],
log: true,
});
};
export default func;
func.tags = ['OwnedResolver'];
func.tags = ['L2ReverseRegistrar'];
2 changes: 1 addition & 1 deletion crosschain-reverse-resolver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"typescript": "^5.2.2"
},
"dependencies": {
"@ensdomains/ens-contracts": "^0.0.22",
"@ensdomains/ens-contracts": "ensdomains/ens-contracts#l2-reverse-registrar",
"@ensdomains/evm-verifier": "^0.1.0",
"@eth-optimism/contracts": "^0.6.0"
}
Expand Down
21 changes: 11 additions & 10 deletions crosschain-reverse-resolver/test/testReverseResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { FetchRequest } from 'ethers';
import { ethers } from 'hardhat';
import { EthereumProvider } from 'hardhat/types';
import request from 'supertest';
const node = '0x80ee077a908dffcf32972ba13c2df16b42688e1de21bcf17d3469a8507895eae'
const NAMESPACE = 2147483658 // OP

type ethersObj = typeof ethersT &
Omit<HardhatEthersHelpers, 'provider'> & {
Expand Down Expand Up @@ -72,37 +72,38 @@ describe('Crosschain Reverse Resolver', () => {
signer
);
verifier = await l1VerifierFactory.deploy(['test:']);

const testL2Factory = await ethers.getContractFactory(
'OwnedResolver',
'L2ReverseRegistrar',
signer
);
l2contract = await testL2Factory.deploy();

l2contract = await testL2Factory.deploy(ethers.namehash(`${NAMESPACE}.reverse`));
const testL1Factory = await ethers.getContractFactory(
'L1ReverseResolver',
signer
);
target = await testL1Factory.deploy(await verifier.getAddress(), await l2contract.getAddress());

// Mine an empty block so we have something to prove against
await provider.send('evm_mine', []);
});

it("should test name", async() => {
const name = 'vitalik.eth'
await l2contract.clearRecords(node)
await l2contract.setName(node, name)
const node = await l2contract.node(
await signer.getAddress(),
)
await l2contract.setName(name)
await provider.send("evm_mine", []);
const result2 = await target.name(node, { enableCcipRead: true })
expect(result2).to.equal(name);
})

it("should test text record", async() => {
const node = await l2contract.node(
await signer.getAddress(),
)
const key = 'name'
const value = 'nick.eth'
await l2contract.clearRecords(node)
await l2contract.setText(node, key, value)
await l2contract.setText(key, value)
await provider.send("evm_mine", []);
const result = await l2contract.text(node, key)
expect(result).to.equal(value);
Expand Down
Loading