add new built-in/stdlib function `is_eoa`
I think it would be beneficial to have a built-in or stdlib function is_eoa that can determine if an address is an EOA. With EIP-7702 we have now also (0xef0100 || address) as code for an EOA. So the function could check if the code length is either zero or the first 3 bytes is ef_01_00. I haven't thought this completely through, but dropping this as an idea here for now. A simple Vyper implementation for a stdlib called address looks like this:
_DELEGATION_PREFIX: constant(bytes3) = 0xef0100
@internal
def is_eoa(target: address) -> bool:
code: Bytes[3] = slice(target.code, 0, 3)
return (len(code) == 0 or convert(code, bytes3) == _DELEGATION_PREFIX)
The reason why I don't check for the length of 23 bytes is that you cannot deploy a contract starting with 0xef according to EIP-3541.
Big fan of stdlib approach personally, makes it easier to audit & add functions in the future as well. From what I've heard Vyper already has an stdlib somewhere? is that so?
Big fan of stdlib approach personally, makes it easier to audit & add functions in the future as well. From what I've heard Vyper already has an stdlib somewhere? is that so?
https://github.com/vyperlang/vyper/commit/1591a1229cf837ccca6cfcc32aed601ce19fad44
We could also have an additional stdlib function fetch_delegate; similar to here.
fwiw, I added a utility function to 🐍 snekmate that allows you to fetch the EIP-7702 delegation contract address: https://github.com/pcaversaccio/snekmate/pull/335.