Skip to content

feat: implements chainName - #10

Merged
0xItadaki merged 2 commits into
devfrom
feat/implements-chainName
Aug 20, 2025
Merged

feat: implements chainName#10
0xItadaki merged 2 commits into
devfrom
feat/implements-chainName

Conversation

@0xItadaki

@0xItadaki 0xItadaki commented Aug 20, 2025

Copy link
Copy Markdown
Collaborator

Closes EFI-429, EFI-438

@linear

linear Bot commented Aug 20, 2025

Copy link
Copy Markdown
EFI-429 chainName

  • function chainName(bytes calldata _chainIdBytes) external view returns (string memory)
    • Retrieves the primary human-readable ENS name string associated with a given EIP-7930 chain identifier (bytes, with AddressLength = 0).
    • Assumes the input chainIdBytes is a correctly formatted EIP-7930 sequence.
    • Off-chain tooling used to set reverse records should ensure canonical name formatting (e.g., lowercase, UTS#46 normalization) of the ENS name string.
    • Implementation:
      1. Hash the input: bytes32 identifierHash = keccak256(chainIdBytes);
      2. Convert hash to hex string (conceptual step, e.g., using an internal _bytes32ToHexString helper). Let this be hexIdentifierHash.
      3. Construct key: string memory key = string.concat(CHAIN_IDENTIFIER_EIP7930_KEY, hexIdentifierHash);
      4. Retrieves data: bytes memory data = this.getRecord(REVERSE_LOOKUP_NODE, key);
      5. Handles not found: if (data.length == 0) { return ""; }
      6. Decodes and returns: return abi.decode(data, (string)); (This will revert if data is not a valid ABI-encoded string).

@0xItadaki 0xItadaki self-assigned this Aug 20, 2025
@0xItadaki
0xItadaki requested a review from 0xAustrian August 20, 2025 13:20
@linear

linear Bot commented Aug 20, 2025

Copy link
Copy Markdown

EFI-438 chainName

Comment on lines +91 to +92
if (_data.length == 0) return '';
_chainName = abi.decode(_data, (string));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_chainName = _data.length == 0 ? '' : abi.decode(_data, (string));, wdyt?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a performance reason for doing that? I think two lines makes it easier to follow, but I don't have a strong preference

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if there is a gas improvement, just personal opinion, feel free to keep it as is.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep it. I think it makes the different branches more obvious

@0xItadaki
0xItadaki merged commit b9476c1 into dev Aug 20, 2025
4 checks passed
@0xItadaki
0xItadaki deleted the feat/implements-chainName branch August 20, 2025 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants