Skip to content

chore: Make contract check EIP-7702 aware #1074

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

chore: Make contract check EIP-7702 aware #1074

wants to merge 2 commits into from

Conversation

pxrl
Copy link
Contributor

@pxrl pxrl commented Jun 4, 2025

isContractDeployedToAddress() currently mistakes EIP-7702 delegations for contracts. For most/all purposes in Across, 7702 delegation is preferred to be treated as an EOA. This change permits the caller to specify whether EIP-7702 delegations should be considered as contract code. EIP-7702 delegation is considered as a contract by default, so this is backwards compatible with the existing implementation and must requires opt-in.

pxrl added 2 commits June 4, 2025 10:05
isContractDeployedToAddress() currently mistakes EIP-7702 delegations
for contracts. For most/all purposes in Across, 7702 delegation is
preferred to be treated as an EOA. This change permits the caller to
specify whether EIP-7702 delegations should be considered as contract
code. EIP-7702 delegation is considered as a contract by default, so
this is backwards compatible with the existing implementation and must
requires opt-in.
*/
export function is7702Delegate(code: string): boolean {
// Sample 7702 delegation bytecode: 0xef010063c0c19a282a1b52b07dd5a65b58948a07dae32b
return code.length === 48 && code.startsWith("0xef0100") && isAddress(`0x${code.slice(8)}`);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nb. an EOA revokes delegation by setting the delegated address to address(0x0). From what I've understood, this removes the code at the EOA and resets the code hash to keccak256(""). I haven't verified this with any test yet, though.

@pxrl pxrl marked this pull request as ready for review June 10, 2025 09:35
@pxrl pxrl requested review from bmzig and dohaki June 10, 2025 09:35
@@ -1,23 +1,47 @@
import { isAddress } from "viem";
Copy link
Member

Choose a reason for hiding this comment

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

Why not reuse utils.isAddress?

Copy link
Member

@nicholaspai nicholaspai left a comment

Choose a reason for hiding this comment

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

One q on dependencies

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.

2 participants