Skip to content

feat: add OP Stack address alias utilities#201

Closed
dieutx wants to merge 1 commit into
base:mainfrom
dieutx:feat/add-address-alias-utils
Closed

feat: add OP Stack address alias utilities#201
dieutx wants to merge 1 commit into
base:mainfrom
dieutx:feat/add-address-alias-utils

Conversation

@dieutx
Copy link
Copy Markdown

@dieutx dieutx commented May 11, 2026

Summary

  • add applyL1ToL2Alias, undoL1ToL2Alias, and L1_TO_L2_ALIAS_OFFSET utility exports
  • expose the new alias helpers from both the root package entrypoint and op-viem/utils
  • add regression tests that compare the implementation against @eth-optimism/core-utils

Problem

Issue #117 asks for helpers that compute the aliased L2 msg.sender for L1 contract callers.

Today op-viem mentions address aliasing in deposit docs and runtime errors, but it does not provide a first-class helper for users who want to predict or reverse the aliased address.

Solution

This PR adds utility functions that mirror the OP Stack aliasing scheme:

  • applyL1ToL2Alias(address)
  • undoL1ToL2Alias(address)
  • L1_TO_L2_ALIAS_OFFSET

The implementation follows the same offset-based scheme used in the OP Stack reference utilities and validates addresses before transforming them.

Verification

  • ./node_modules/.bin/vitest run src/utils/addressAlias.test.ts
  • ./node_modules/.bin/dprint fmt src/utils/addressAlias.ts src/utils/addressAlias.test.ts src/utils/index.ts src/index.ts
  • ./node_modules/.bin/biome check src/utils/addressAlias.ts src/utils/addressAlias.test.ts src/utils/index.ts src/index.ts

Closes #117

@dieutx dieutx closed this by deleting the head repository May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alias functions

1 participant