-
Notifications
You must be signed in to change notification settings - Fork 22
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
base: master
Are you sure you want to change the base?
Conversation
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)}`); |
There was a problem hiding this comment.
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.
@@ -1,23 +1,47 @@ | |||
import { isAddress } from "viem"; |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked; we don't export isAddress
from src/utils
.
In terms of viem vs. ethers, I prefer the viem
variant because it doesn't throw exceptions. It's debatable whether it's good to throw exceptions on (for example) an all-caps address, but in practice it's not something we need to worry about, so it's nice to slip for the hassle.
In general isAddress
should be much less useful now that we tend to pass Address
classes around, so I'm also not sure whether we really need to export it.
There was a problem hiding this 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
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.