vyperlang / titanoboa

a vyper interpreter
https://titanoboa.readthedocs.io
Other
247 stars 49 forks source link

Add `nickname` to `NetworkEnv` and `Env` class #264

Closed PatrickAlphaC closed 1 week ago

PatrickAlphaC commented 1 month ago

And add tests

In network.py

def __init__(
        self,
        rpc: str | RPC,
        nickname: str = None,
        accounts: dict[str, Account] = None,
        fork_try_prefetch_state=True,
        **kwargs,
    ):
        super().__init__(fork_try_prefetch_state, **kwargs)

        if isinstance(rpc, str):
            warnings.warn(
                "NetworkEnv(url) is deprecated. Use boa.set_network_env(url) instead.",
                stacklevel=2,
            )
            rpc = EthereumRPC(rpc)

        self._rpc: RPC = rpc

        self.nickname = nickname or rpc.identifier

and in environment.py

# wrapper class around py-evm which provides a "contract-centric" API
class Env:
    _singleton = None
    _random = random.Random("titanoboa")  # something reproducible
    _coverage_enabled = False

    def __init__(self, fork_try_prefetch_state=False, fast_mode_enabled=False):
        self._gas_price = None

        self._aliases = {}

        # TODO differentiate between origin and sender
        self.eoa = self.generate_address("eoa")

        self._contracts = {}
        self._code_registry = {}

        self.sha3_trace: dict = {}
        self.sstore_trace: dict = {}

        self._profiled_contracts = {}
        self._cached_call_profiles = {}
        self._cached_line_profiles = {}
        self._coverage_data = {}

        self._gas_tracker = 0

        self.evm = PyEVM(self, fast_mode_enabled, fork_try_prefetch_state)
DanielSchiavini commented 1 week ago

Fixed via https://github.com/vyperlang/titanoboa/pull/266?

charles-cooper commented 1 week ago

Fixed via #266?

yes