Skip to content

Commit

Permalink
reverse resolver with migration
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed Oct 6, 2024
1 parent 3d5f389 commit 5ed8774
Show file tree
Hide file tree
Showing 19 changed files with 4,086 additions and 76 deletions.
Binary file modified bun.lockb
Binary file not shown.
28 changes: 28 additions & 0 deletions contracts/reverseRegistrar/L2ReverseResolverWithMigration.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

import {L2ReverseResolver} from "./L2ReverseResolver.sol";
import {INameResolver} from "../resolvers/profiles/INameResolver.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

contract L2ReverseResolverWithMigration is L2ReverseResolver, Ownable {
INameResolver immutable oldReverseResolver;

constructor(
bytes32 _L2ReverseNode,
uint256 _coinType,
INameResolver _oldReverseResolver
) L2ReverseResolver(_L2ReverseNode, _coinType) {
oldReverseResolver = _oldReverseResolver;
}

function batchSetName(address[] calldata addresses) external onlyOwner {
for (uint256 i = 0; i < addresses.length; i++) {
bytes32 node = _getNamehash(addresses[i]);
string memory name = oldReverseResolver.name(node);
_setName(node, name);
emit ReverseClaimed(addresses[i], node);
}
}
}
2 changes: 1 addition & 1 deletion contracts/reverseRegistrar/SignatureReverseResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ contract SignatureReverseResolver is ISignatureReverseResolver, ERC165 {
return node;
}

function _setName(bytes32 node, string calldata newName) internal virtual {
function _setName(bytes32 node, string memory newName) internal virtual {
names[node] = newName;
emit NameChanged(node, newName);
}
Expand Down
5 changes: 3 additions & 2 deletions deploy/l2/03_l2reverse_registrar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ const func: DeployFunction = async function (hre) {

const chainId = hre.network.config.chainId!
const coinType = evmChainIdToCoinType(chainId) as bigint
const coinTypeHex = coinType.toString(16)

const REVERSE_NAMESPACE = `${coinType}.reverse`
const REVERSE_NAMESPACE = `${coinTypeHex}.reverse`
const REVERSENODE = namehash(REVERSE_NAMESPACE)

console.log(
`REVERSE_NAMESPACE for chainId ${chainId} is ${REVERSE_NAMESPACE}`,
)
console.log(
`Deploying L2ReverseResolver with REVERSENODE ${REVERSENODE} and coinType ${coinType}`,
`Deploying L2ReverseResolver with REVERSENODE ${REVERSENODE} and coinType ${coinTypeHex}`,
)

await viem.deploy('L2ReverseResolver', [REVERSENODE, coinType])
Expand Down
Loading

0 comments on commit 5ed8774

Please sign in to comment.