code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def ape_cli_context( default_log_level: Optional[Union[str, int, LogLevel]] = None, obj_type: type = ApeCliContextObject, ) -> Callable: """ A ``click`` context object with helpful utilities. Use in your commands to get access to common utility features, such as logging or accessing managers. ...
A ``click`` context object with helpful utilities. Use in your commands to get access to common utility features, such as logging or accessing managers. Args: default_log_level (str | int | :class:`~ape.logging.LogLevel` | None): The log-level value to pass to :meth:`~ape.cli.option...
ape_cli_context
python
ApeWorX/ape
src/ape/cli/options.py
https://github.com/ApeWorX/ape/blob/master/src/ape/cli/options.py
Apache-2.0
def network_option( default: Optional[Union[str, Callable]] = "auto", ecosystem: Optional[Union[list[str], str]] = None, network: Optional[Union[list[str], str]] = None, provider: Optional[Union[list[str], str]] = None, required: bool = False, **kwargs, ) -> Callable: """ A ``click.optio...
A ``click.option`` for specifying a network. Args: default (Optional[str]): Optionally, change which network to use as the default. Defaults to how ``ape`` normally selects a default network unless ``required=True``, then defaults to ``None``. ecosystem (Optional[Union[list...
network_option
python
ApeWorX/ape
src/ape/cli/options.py
https://github.com/ApeWorX/ape/blob/master/src/ape/cli/options.py
Apache-2.0
def skip_confirmation_option(help="") -> Callable: """ A ``click.option`` for skipping confirmation (``--yes``). Args: help (str): CLI option help text. Defaults to ``""``. """ return click.option( "-y", "--yes", "skip_confirmation", default=False, i...
A ``click.option`` for skipping confirmation (``--yes``). Args: help (str): CLI option help text. Defaults to ``""``.
skip_confirmation_option
python
ApeWorX/ape
src/ape/cli/options.py
https://github.com/ApeWorX/ape/blob/master/src/ape/cli/options.py
Apache-2.0
def account_option(account_type: _ACCOUNT_TYPE_FILTER = None) -> Callable: """ A CLI option that accepts either the account alias or the account number. If not given anything, it will prompt the user to select an account. """ return click.option( "--account", type=AccountAliasPrompt...
A CLI option that accepts either the account alias or the account number. If not given anything, it will prompt the user to select an account.
account_option
python
ApeWorX/ape
src/ape/cli/options.py
https://github.com/ApeWorX/ape/blob/master/src/ape/cli/options.py
Apache-2.0
def contract_option(help=None, required=False, multiple=False) -> Callable: """ Contract(s) from the current project. If you pass ``multiple=True``, you will get a list of contract types from the callback. :class:`~ape.exceptions.ContractError`: In the callback when it fails to load the contracts....
Contract(s) from the current project. If you pass ``multiple=True``, you will get a list of contract types from the callback. :class:`~ape.exceptions.ContractError`: In the callback when it fails to load the contracts.
contract_option
python
ApeWorX/ape
src/ape/cli/options.py
https://github.com/ApeWorX/ape/blob/master/src/ape/cli/options.py
Apache-2.0
def output_format_option(default: OutputFormat = OutputFormat.TREE) -> Callable: """ A ``click.option`` for specifying a format to use when outputting data. Args: default (:class:`~ape.cli.choices.OutputFormat`): Defaults to ``TREE`` format. """ return click.option( "--format", ...
A ``click.option`` for specifying a format to use when outputting data. Args: default (:class:`~ape.cli.choices.OutputFormat`): Defaults to ``TREE`` format.
output_format_option
python
ApeWorX/ape
src/ape/cli/options.py
https://github.com/ApeWorX/ape/blob/master/src/ape/cli/options.py
Apache-2.0
def incompatible_with(incompatible_opts) -> type[click.Option]: """ Factory for creating custom ``click.Option`` subclasses that enforce incompatibility with the option strings passed to this function. Usage example:: import click @click.command() @click.option("--option", cls...
Factory for creating custom ``click.Option`` subclasses that enforce incompatibility with the option strings passed to this function. Usage example:: import click @click.command() @click.option("--option", cls=incompatible_with(["other_option"])) def cmd(option, other_opt...
incompatible_with
python
ApeWorX/ape
src/ape/cli/options.py
https://github.com/ApeWorX/ape/blob/master/src/ape/cli/options.py
Apache-2.0
def _repr_pretty_(self, printer, cycle): """ Show the NatSpec of a Method in any IPython console (including ``ape console``). """ console = get_rich_console() output = self._get_info(enrich=True) or "\n".join(abi.signature for abi in self.abis) console.print(output)
Show the NatSpec of a Method in any IPython console (including ``ape console``).
_repr_pretty_
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def estimate_gas_cost(self, *args, **kwargs) -> int: """ Get the estimated gas cost (according to the provider) for the contract method call (as if it were a transaction). Args: *args: The contract method invocation arguments. **kwargs: Transaction kwargs, such a...
Get the estimated gas cost (according to the provider) for the contract method call (as if it were a transaction). Args: *args: The contract method invocation arguments. **kwargs: Transaction kwargs, such as value or sender. Returns: i...
estimate_gas_cost
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def as_transaction(self, *args, **kwargs) -> "TransactionAPI": """ Get a :class:`~ape.api.transactions.TransactionAPI` for this contract method invocation. This is useful for simulations or estimating fees without sending the transaction. Args: *args: The con...
Get a :class:`~ape.api.transactions.TransactionAPI` for this contract method invocation. This is useful for simulations or estimating fees without sending the transaction. Args: *args: The contract method invocation arguments. **kwargs: Transaction kwarg...
as_transaction
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def as_transaction_bytes(self, *args, **txn_kwargs) -> HexBytes: """ Get a signed serialized transaction. Returns: HexBytes: The serialized transaction """ txn_kwargs["sign"] = True tx = self.as_transaction(*args, **txn_kwargs) return tx.serialize_tra...
Get a signed serialized transaction. Returns: HexBytes: The serialized transaction
as_transaction_bytes
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def estimate_gas_cost(self, *args, **kwargs) -> int: """ Get the estimated gas cost (according to the provider) for the contract method-invocation transaction. Args: *args: The contract method invocation arguments. **kwargs: Transaction kwargs, such as value or ...
Get the estimated gas cost (according to the provider) for the contract method-invocation transaction. Args: *args: The contract method invocation arguments. **kwargs: Transaction kwargs, such as value or sender. Returns: int: The esti...
estimate_gas_cost
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def __getitem_int(self, index: int) -> ContractLog: """ Access events on the contract by the index of when they occurred. Args: index (int): The index such that ``0`` is the first log to have occurred and ``-1`` is the last. Returns: :class:`~ape.c...
Access events on the contract by the index of when they occurred. Args: index (int): The index such that ``0`` is the first log to have occurred and ``-1`` is the last. Returns: :class:`~ape.contracts.base.ContractLog`
__getitem_int
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def __getitem_slice(self, value: slice) -> list[ContractLog]: """ Access a slice of logs from this event. Args: value (slice): The range of log to get, e.g. ``[5:10]``. Returns: Iterator[:class:`~ape.contracts.base.ContractLog`] """ logs = self.p...
Access a slice of logs from this event. Args: value (slice): The range of log to get, e.g. ``[5:10]``. Returns: Iterator[:class:`~ape.contracts.base.ContractLog`]
__getitem_slice
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def __call__(self, *args: Any, **kwargs: Any) -> MockContractLog: """ Create a mock-instance of a log using this event ABI and the contract address. Args: *args: Positional arguments for the event. **kwargs: Key-word arguments for the event. Returns: ...
Create a mock-instance of a log using this event ABI and the contract address. Args: *args: Positional arguments for the event. **kwargs: Key-word arguments for the event. Returns: :class:`~ape.types.events.MockContractLog`
__call__
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def query( self, *columns: str, start_block: int = 0, stop_block: Optional[int] = None, step: int = 1, engine_to_use: Optional[str] = None, ) -> "DataFrame": """ Iterate through blocks for log events Args: *columns (str): ``*``-bas...
Iterate through blocks for log events Args: *columns (str): ``*``-based argument for columns in the DataFrame to return. start_block (int): The first block, by number, to include in the query. Defaults to ``0``. stop_block (Optional[int])...
query
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def range( self, start_or_stop: int, stop: Optional[int] = None, search_topics: Optional[dict[str, Any]] = None, extra_addresses: Optional[list] = None, ) -> Iterator[ContractLog]: """ Search through the logs for this event using the given filter parameters. ...
Search through the logs for this event using the given filter parameters. Args: start_or_stop (int): When also given ``stop``, this is the earliest block number in the desired log set. Otherwise, it is the total amount of blocks to get starting from ``0``. ...
range
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def from_receipt(self, receipt: "ReceiptAPI") -> list[ContractLog]: """ Get all the events from the given receipt. Args: receipt (:class:`~ape.api.transactions.ReceiptAPI`): The receipt containing the logs. Returns: list[:class:`~ape.contracts.base.ContractLog`]...
Get all the events from the given receipt. Args: receipt (:class:`~ape.api.transactions.ReceiptAPI`): The receipt containing the logs. Returns: list[:class:`~ape.contracts.base.ContractLog`]
from_receipt
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def poll_logs( self, start_block: Optional[int] = None, stop_block: Optional[int] = None, required_confirmations: Optional[int] = None, new_block_timeout: Optional[int] = None, search_topics: Optional[dict[str, Any]] = None, **search_topic_kwargs: dict[str, Any], ...
Poll new logs for this event. Can specify topic filters to use when setting up the filter. Optionally set a start block to include historical blocks. **NOTE**: This is a daemon method; it does not terminate unless an exception occurs. Usage example:: for new_log in contra...
poll_logs
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def __call__(self, *args, **kwargs) -> MockContractLog: """ Create a mock contract log using the first working ABI. Args: *args: Positional arguments for the event. **kwargs: Key-word arguments for the event. Returns: :class:`~ape.types.events.MockCo...
Create a mock contract log using the first working ABI. Args: *args: Positional arguments for the event. **kwargs: Key-word arguments for the event. Returns: :class:`~ape.types.events.MockContractLog`
__call__
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def source_path(self) -> Optional[Path]: """ Returns the path to the local contract if determined that this container belongs to the active project by cross checking source_id. """ if not (source_id := self.contract_type.source_id): return None base = self.ba...
Returns the path to the local contract if determined that this container belongs to the active project by cross checking source_id.
source_path
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def decode_input(self, calldata: bytes) -> tuple[str, dict[str, Any]]: """ Decode the given calldata using this contract. If the calldata has a method ID prefix, Ape will detect it and find the corresponding method, else it will error. Args: calldata (bytes): The cal...
Decode the given calldata using this contract. If the calldata has a method ID prefix, Ape will detect it and find the corresponding method, else it will error. Args: calldata (bytes): The calldata to decode. Returns: tuple[str, dict[str, Any]]: A tuple...
decode_input
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def from_receipt( cls, receipt: "ReceiptAPI", contract_type: "ContractType" ) -> "ContractInstance": """ Create a contract instance from the contract deployment receipt. """ address = receipt.contract_address if not address: raise ChainError( ...
Create a contract instance from the contract deployment receipt.
from_receipt
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def call_view_method(self, method_name: str, *args, **kwargs) -> Any: """ Call a contract's view function directly using the method_name. This is helpful in the scenario where the contract has a method name matching an attribute of the :class:`~ape.api.address.BaseAddress` class,...
Call a contract's view function directly using the method_name. This is helpful in the scenario where the contract has a method name matching an attribute of the :class:`~ape.api.address.BaseAddress` class, such as ``nonce`` or ``balance`` Args: method_name ...
call_view_method
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def invoke_transaction(self, method_name: str, *args, **kwargs) -> "ReceiptAPI": """ Call a contract's function directly using the method_name. This function is for non-view function's which may change contract state and will execute a transaction. This is helpful in the scenario...
Call a contract's function directly using the method_name. This function is for non-view function's which may change contract state and will execute a transaction. This is helpful in the scenario where the contract has a method name matching an attribute of the :class:`~...
invoke_transaction
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def get_event_by_signature(self, signature: str) -> ContractEvent: """ Get an event by its signature. Most often, you can use the :meth:`~ape.contracts.base.ContractInstance.__getattr__` method on this class to access events. However, in the case when you have more than one event...
Get an event by its signature. Most often, you can use the :meth:`~ape.contracts.base.ContractInstance.__getattr__` method on this class to access events. However, in the case when you have more than one event with the same name, such as the case where one event is coming from a...
get_event_by_signature
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def get_error_by_signature(self, signature: str) -> type[CustomError]: """ Get an error by its signature, similar to :meth:`~ape.contracts.ContractInstance.get_event_by_signature`. Args: signature (str): The signature of the error. Returns: :class:`~ape....
Get an error by its signature, similar to :meth:`~ape.contracts.ContractInstance.get_event_by_signature`. Args: signature (str): The signature of the error. Returns: :class:`~ape.exceptions.CustomError`
get_error_by_signature
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def __dir__(self) -> list[str]: """ Display methods to IPython on ``c.[TAB]`` tab completion. Returns: list[str] """ # NOTE: Type ignores because of this issue: https://github.com/python/typing/issues/1112 # They can be removed after next `mypy` release con...
Display methods to IPython on ``c.[TAB]`` tab completion. Returns: list[str]
__dir__
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def __getattr__(self, attr_name: str) -> Any: """ Access a method, property, event, or error on the contract using ``.`` access. Usage example:: result = contract.vote() # Implies a method named "vote" exists on the contract. Args: attr_name (str): The name of...
Access a method, property, event, or error on the contract using ``.`` access. Usage example:: result = contract.vote() # Implies a method named "vote" exists on the contract. Args: attr_name (str): The name of the method or property to access. Returns: ...
__getattr__
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def at( self, address: "AddressType", txn_hash: Optional[Union[str, HexBytes]] = None, fetch_from_explorer: bool = True, proxy_info: Optional["ProxyInfoAPI"] = None, detect_proxy: bool = True, ) -> ContractInstance: """ Get a contract at the given addr...
Get a contract at the given address. Usage example:: from ape import project my_contract = project.MyContract.at("0xAbC1230001112223334445566611855443322111") Args: address (str): The address to initialize a contract. **NOTE**: Things will n...
at
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def deploy(self, *args, publish: bool = False, **kwargs) -> ContractInstance: """ Deploy a contract. Args: *args (Any): The contract's constructor arguments as Python types. publish (bool): Whether to also perform contract-verification. Defaults to ``False`...
Deploy a contract. Args: *args (Any): The contract's constructor arguments as Python types. publish (bool): Whether to also perform contract-verification. Defaults to ``False``. Returns: :class:`~ape.contracts.base.ContractInstance`
deploy
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def _cache_wrap(self, function: Callable) -> "ReceiptAPI": """ A helper method to ensure a contract type is cached as early on as possible to help enrich errors from ``deploy()`` transactions as well produce nicer tracebacks for these errors. It also helps make assertions about t...
A helper method to ensure a contract type is cached as early on as possible to help enrich errors from ``deploy()`` transactions as well produce nicer tracebacks for these errors. It also helps make assertions about these revert conditions in your tests.
_cache_wrap
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def __getattr__(self, item: str) -> Union[ContractContainer, "ContractNamespace"]: """ Access the next contract container or namespace. Args: item (str): The name of the next node. Returns: Union[:class:`~ape.contracts.base.ContractContainer`, :class...
Access the next contract container or namespace. Args: item (str): The name of the next node. Returns: Union[:class:`~ape.contracts.base.ContractContainer`, :class:`~ape.contracts.base.ContractNamespace`]
__getattr__
python
ApeWorX/ape
src/ape/contracts/base.py
https://github.com/ApeWorX/ape/blob/master/src/ape/contracts/base.py
Apache-2.0
def mnemonic(self, value: str): """ The seed phrase for generated test accounts. **WARNING**: Changing the test-mnemonic mid-session re-starts the provider (if connected to one). """ self.config_manager.test.mnemonic = value self.containers["test"].mnemonic = v...
The seed phrase for generated test accounts. **WARNING**: Changing the test-mnemonic mid-session re-starts the provider (if connected to one).
mnemonic
python
ApeWorX/ape
src/ape/managers/accounts.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/accounts.py
Apache-2.0
def impersonate_account(self, address: AddressType) -> ImpersonatedAccount: """ Impersonate an account for testing purposes. Args: address (AddressType): The address to impersonate. """ try: result = self.provider.unlock_account(address) except No...
Impersonate an account for testing purposes. Args: address (AddressType): The address to impersonate.
impersonate_account
python
ApeWorX/ape
src/ape/managers/accounts.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/accounts.py
Apache-2.0
def stop_impersonating(self, address: AddressType): """ End the impersonating of an account, if it is being impersonated. Args: address (AddressType): The address to stop impersonating. """ if address in self._impersonated_accounts: del self._impersonated...
End the impersonating of an account, if it is being impersonated. Args: address (AddressType): The address to stop impersonating.
stop_impersonating
python
ApeWorX/ape
src/ape/managers/accounts.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/accounts.py
Apache-2.0
def containers(self) -> dict[str, AccountContainerAPI]: """ A dict of all :class:`~ape.api.accounts.AccountContainerAPI` instances across all installed plugins. Returns: dict[str, :class:`~ape.api.accounts.AccountContainerAPI`] """ containers = {} dat...
A dict of all :class:`~ape.api.accounts.AccountContainerAPI` instances across all installed plugins. Returns: dict[str, :class:`~ape.api.accounts.AccountContainerAPI`]
containers
python
ApeWorX/ape
src/ape/managers/accounts.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/accounts.py
Apache-2.0
def aliases(self) -> Iterator[str]: """ All account aliases from every account-related plugin. The "alias" is part of the :class:`~ape.api.accounts.AccountAPI`. Use the account alias to load an account using method :meth:`~ape.managers.accounts.AccountManager.load`. Retu...
All account aliases from every account-related plugin. The "alias" is part of the :class:`~ape.api.accounts.AccountAPI`. Use the account alias to load an account using method :meth:`~ape.managers.accounts.AccountManager.load`. Returns: Iterator[str]
aliases
python
ApeWorX/ape
src/ape/managers/accounts.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/accounts.py
Apache-2.0
def load(self, alias: str) -> AccountAPI: """ Get an account by its alias. Raises: KeyError: When there is no local account with the given alias. Returns: :class:`~ape.api.accounts.AccountAPI` """ if alias == "": raise ValueError("Can...
Get an account by its alias. Raises: KeyError: When there is no local account with the given alias. Returns: :class:`~ape.api.accounts.AccountAPI`
load
python
ApeWorX/ape
src/ape/managers/accounts.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/accounts.py
Apache-2.0
def __getitem_int(self, account_id: int) -> AccountAPI: """ Get an account by index. For example, when you do the CLI command ``ape accounts list --all``, you will see a list of enumerated accounts by their indices. Use this method as a quicker, ad-hoc way to get an account from ...
Get an account by index. For example, when you do the CLI command ``ape accounts list --all``, you will see a list of enumerated accounts by their indices. Use this method as a quicker, ad-hoc way to get an account from that index. **NOTE**: It is generally preferred to use ...
__getitem_int
python
ApeWorX/ape
src/ape/managers/accounts.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/accounts.py
Apache-2.0
def __getitem_slice(self, account_id: slice): """ Get list of accounts by slice. For example, when you do the CLI command ``ape accounts list --all``, you will see a list of enumerated accounts by their indices. Use this method as a quicker, ad-hoc way to get an accounts from a s...
Get list of accounts by slice. For example, when you do the CLI command ``ape accounts list --all``, you will see a list of enumerated accounts by their indices. Use this method as a quicker, ad-hoc way to get an accounts from a slice. **NOTE**: It is generally preferred to use...
__getitem_slice
python
ApeWorX/ape
src/ape/managers/accounts.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/accounts.py
Apache-2.0
def __getitem_str(self, account_str: str) -> AccountAPI: """ Get an account by address. If we are using a provider that supports unlocking accounts, this method will return an impersonated account at that address. Raises: KeyError: When there is no local account with the giv...
Get an account by address. If we are using a provider that supports unlocking accounts, this method will return an impersonated account at that address. Raises: KeyError: When there is no local account with the given address. Returns: :class:`~ape.api.accounts....
__getitem_str
python
ApeWorX/ape
src/ape/managers/accounts.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/accounts.py
Apache-2.0
def __contains__(self, address: AddressType) -> bool: """ Determine if the given address matches an account in ``ape``. Args: address (:class:`~ape.types.address.AddressType`): The address to check. Returns: bool: ``True`` when the given address is found. ...
Determine if the given address matches an account in ``ape``. Args: address (:class:`~ape.types.address.AddressType`): The address to check. Returns: bool: ``True`` when the given address is found.
__contains__
python
ApeWorX/ape
src/ape/managers/accounts.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/accounts.py
Apache-2.0
def resolve_address( self, account_id: Union["BaseAddress", AddressType, str, int, bytes] ) -> Optional[AddressType]: """ Resolve the given input to an address. Args: account_id (:class:~ape.api.address.BaseAddress, str, int, bytes): The input to resolve. ...
Resolve the given input to an address. Args: account_id (:class:~ape.api.address.BaseAddress, str, int, bytes): The input to resolve. It handles anything that converts to an AddressType like an ENS or a BaseAddress. It also handles account aliases Ape is awa...
resolve_address
python
ApeWorX/ape
src/ape/managers/accounts.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/accounts.py
Apache-2.0
def __getitem__(self, block_number: int) -> BlockAPI: """ Get a block by number. Negative numbers start at the chain head and move backwards. For example, ``-1`` would be the latest block and ``-2`` would be the block prior to that one, and so on. Args: block_number ...
Get a block by number. Negative numbers start at the chain head and move backwards. For example, ``-1`` would be the latest block and ``-2`` would be the block prior to that one, and so on. Args: block_number (int): The number of the block to get. Returns: ...
__getitem__
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def query( self, *columns: str, start_block: int = 0, stop_block: Optional[int] = None, step: int = 1, engine_to_use: Optional[str] = None, ) -> pd.DataFrame: """ A method for querying blocks and returning an Iterator. If you do not provide a s...
A method for querying blocks and returning an Iterator. If you do not provide a starting block, the 0 block is assumed. If you do not provide a stopping block, the last block is assumed. You can pass ``engine_to_use`` to short-circuit engine selection. Raises: :clas...
query
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def range( self, start_or_stop: int, stop: Optional[int] = None, step: int = 1, engine_to_use: Optional[str] = None, ) -> Iterator[BlockAPI]: """ Iterate over blocks. Works similarly to python ``range()``. Raises: :class:`~ape.exceptions.C...
Iterate over blocks. Works similarly to python ``range()``. Raises: :class:`~ape.exceptions.ChainError`: When ``stop`` is greater than the chain length. :class:`~ape.exceptions.ChainError`: When ``stop`` is less than ``start_block``. ...
range
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def poll_blocks( self, start_block: Optional[int] = None, stop_block: Optional[int] = None, required_confirmations: Optional[int] = None, new_block_timeout: Optional[int] = None, ) -> Iterator[BlockAPI]: """ Poll new blocks. Optionally set a start block to inc...
Poll new blocks. Optionally set a start block to include historical blocks. **NOTE**: When a chain reorganization occurs, this method logs an error and yields the missed blocks, even if they were previously yielded with different block numbers. **NOTE**: This is a daemon metho...
poll_blocks
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def outgoing(self) -> Iterator[ReceiptAPI]: """ All outgoing transactions, from earliest to latest. """ start_nonce = 0 stop_nonce = len(self) - 1 # just to cache this value # TODO: Add ephemeral network sessional history to `ape-cache` instead, # and rem...
All outgoing transactions, from earliest to latest.
outgoing
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def query( self, *columns: str, start_nonce: int = 0, stop_nonce: Optional[int] = None, engine_to_use: Optional[str] = None, ) -> pd.DataFrame: """ A method for querying transactions made by an account and returning an Iterator. If you do not provide a...
A method for querying transactions made by an account and returning an Iterator. If you do not provide a starting nonce, the first transaction is assumed. If you do not provide a stopping block, the last transaction is assumed. You can pass ``engine_to_use`` to short-circuit engine sele...
query
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def __getitem_str(self, account_or_hash: str) -> Union[AccountHistory, ReceiptAPI]: """ Get a receipt from the history by its transaction hash. If the receipt is not currently cached, will use the provider to retrieve it. Args: account_or_hash (str): The hash of the ...
Get a receipt from the history by its transaction hash. If the receipt is not currently cached, will use the provider to retrieve it. Args: account_or_hash (str): The hash of the transaction. Returns: :class:`~ape.api.transactions.ReceiptAPI`: The recei...
__getitem_str
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def append(self, txn_receipt: ReceiptAPI): """ Add a transaction to the cache This is useful for sessional-transactions. Raises: :class:`~ape.exceptions.ChainError`: When trying to append a transaction receipt that is already in the list. Args: txn...
Add a transaction to the cache This is useful for sessional-transactions. Raises: :class:`~ape.exceptions.ChainError`: When trying to append a transaction receipt that is already in the list. Args: txn_receipt (:class:`~ape.api.transactions.ReceiptAPI`): ...
append
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def revert_to_block(self, block_number: int): """ Remove all receipts past the given block number. Args: block_number (int): The block number to revert to. """ self._hash_to_receipt_map = { h: r for h, r in self._hash_to_receipt_map.items() if r.block_nu...
Remove all receipts past the given block number. Args: block_number (int): The block number to revert to.
revert_to_block
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def blocks(self) -> BlockContainer: """ The list of blocks on the chain. """ if self.chain_id not in self._block_container_map: blocks = BlockContainer() self._block_container_map[self.chain_id] = blocks return self._block_container_map[self.chain_id]
The list of blocks on the chain.
blocks
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def history(self) -> TransactionHistory: """ A mapping of transactions from the active session to the account responsible. """ try: chain_id = self.chain_id except ProviderNotConnectedError: return TransactionHistory() # Empty list. if chain_id n...
A mapping of transactions from the active session to the account responsible.
history
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def snapshot(self) -> "SnapshotID": """ Record the current state of the blockchain with intent to later call the method :meth:`~ape.managers.chain.ChainManager.revert` to go back to this point. This method is for local networks only. Raises: NotImplementedError: When...
Record the current state of the blockchain with intent to later call the method :meth:`~ape.managers.chain.ChainManager.revert` to go back to this point. This method is for local networks only. Raises: NotImplementedError: When the active provider does not support ...
snapshot
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def restore(self, snapshot_id: Optional["SnapshotID"] = None): """ Regress the current call using the given snapshot ID. Allows developers to go back to a previous state. Raises: NotImplementedError: When the active provider does not support snapshotting. ...
Regress the current call using the given snapshot ID. Allows developers to go back to a previous state. Raises: NotImplementedError: When the active provider does not support snapshotting. :class:`~ape.exceptions.UnknownSnapshotError`: When the snapshot ID...
restore
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def isolate(self): """ Run code in an isolated context. Requires using a local provider that supports snapshotting. Usages example:: owner = accounts[0] with chain.isolate(): contract = owner.deploy(project.MyContract) receipt = c...
Run code in an isolated context. Requires using a local provider that supports snapshotting. Usages example:: owner = accounts[0] with chain.isolate(): contract = owner.deploy(project.MyContract) receipt = contract.fooBar(sender=owner) ...
isolate
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def mine( self, num_blocks: int = 1, timestamp: Optional[int] = None, deltatime: Optional[int] = None, ) -> None: """ Mine any given number of blocks. Raises: ValueError: When a timestamp AND a deltatime argument are both passed Args: ...
Mine any given number of blocks. Raises: ValueError: When a timestamp AND a deltatime argument are both passed Args: num_blocks (int): Choose the number of blocks to mine. Defaults to 1 block. timestamp (Optional[int]): Designate a time (in ...
mine
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def get_balance( self, address: Union[BaseAddress, AddressType, str], block_id: Optional["BlockID"] = None ) -> int: """ Get the balance of the given address. If ``ape-ens`` is installed, you can pass ENS names. Args: address (BaseAddress, AddressType | str): An ...
Get the balance of the given address. If ``ape-ens`` is installed, you can pass ENS names. Args: address (BaseAddress, AddressType | str): An address, ENS, or account/contract. block_id (:class:`~ape.types.BlockID` | None): The block ID. Defaults to latest. Ret...
get_balance
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def set_balance(self, account: Union[BaseAddress, AddressType, str], amount: Union[int, str]): """ Set an account balance, only works on development chains. Args: account (BaseAddress, AddressType | str): The account. amount (int | str): The new balance. """ ...
Set an account balance, only works on development chains. Args: account (BaseAddress, AddressType | str): The account. amount (int | str): The new balance.
set_balance
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def get_receipt(self, transaction_hash: str) -> ReceiptAPI: """ Get a transaction receipt from the chain. Args: transaction_hash (str): The hash of the transaction. Returns: :class:`~ape.apt.transactions.ReceiptAPI` """ receipt = self.chain_manag...
Get a transaction receipt from the chain. Args: transaction_hash (str): The hash of the transaction. Returns: :class:`~ape.apt.transactions.ReceiptAPI`
get_receipt
python
ApeWorX/ape
src/ape/managers/chain.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/chain.py
Apache-2.0
def registered_compilers(self) -> dict[str, "CompilerAPI"]: """ Each compile-able file extension mapped to its respective :class:`~ape.api.compiler.CompilerAPI` instance. Returns: dict[str, :class:`~ape.api.compiler.CompilerAPI`]: The mapping of file-extensions t...
Each compile-able file extension mapped to its respective :class:`~ape.api.compiler.CompilerAPI` instance. Returns: dict[str, :class:`~ape.api.compiler.CompilerAPI`]: The mapping of file-extensions to compiler API classes.
registered_compilers
python
ApeWorX/ape
src/ape/managers/compilers.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/compilers.py
Apache-2.0
def compile( self, contract_filepaths: Union[Path, str, Iterable[Union[Path, str]]], project: Optional["ProjectManager"] = None, settings: Optional[dict] = None, excluded_compilers: Optional[list[str]] = None, ) -> Iterator["ContractType"]: """ Invoke :meth:`a...
Invoke :meth:`ape.ape.compiler.CompilerAPI.compile` for each of the given files. For example, use the `ape-solidity plugin <https://github.com/ApeWorX/ape-solidity>`__ to compile ``'.sol'`` files. Raises: :class:`~ape.exceptions.CompilerError`: When there is no compiler fou...
compile
python
ApeWorX/ape
src/ape/managers/compilers.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/compilers.py
Apache-2.0
def compile_source( self, compiler_name: str, code: str, project: Optional["ProjectManager"] = None, settings: Optional[dict] = None, **kwargs, ) -> ContractContainer: """ Compile the given program. Usage example:: code = '[{"name...
Compile the given program. Usage example:: code = '[{"name":"foo","type":"fallback", "stateMutability":"nonpayable"}]' contract_container = compilers.compile_source( "ethpm", code, contractName="MyContract", ) ...
compile_source
python
ApeWorX/ape
src/ape/managers/compilers.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/compilers.py
Apache-2.0
def get_imports( self, contract_filepaths: Sequence[Path], project: Optional["ProjectManager"] = None, ) -> dict[str, list[str]]: """ Combine import dicts from all compilers, where the key is a contract's source_id and the value is a list of import source_ids. ...
Combine import dicts from all compilers, where the key is a contract's source_id and the value is a list of import source_ids. Args: contract_filepaths (Sequence[pathlib.Path]): A list of source file paths to compile. project (Optional[:class:`~ape.managers.project.Proj...
get_imports
python
ApeWorX/ape
src/ape/managers/compilers.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/compilers.py
Apache-2.0
def get_references(self, imports_dict: dict[str, list[str]]) -> dict[str, list[str]]: """ Provide a mapping containing all referenced source_ids for a given project. Each entry contains a source_id as a key and list of source_ids that reference a given contract. Args: ...
Provide a mapping containing all referenced source_ids for a given project. Each entry contains a source_id as a key and list of source_ids that reference a given contract. Args: imports_dict (dict[str, list[str]]): A dictionary of source_ids from all compilers. Re...
get_references
python
ApeWorX/ape
src/ape/managers/compilers.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/compilers.py
Apache-2.0
def enrich_error(self, err: ContractLogicError) -> ContractLogicError: """ Enrich a contract logic error using compiler information, such known PC locations for compiler runtime errors. Args: err (:class:`~ape.exceptions.ContractLogicError`): The exception to e...
Enrich a contract logic error using compiler information, such known PC locations for compiler runtime errors. Args: err (:class:`~ape.exceptions.ContractLogicError`): The exception to enrich. Returns: :class:`~ape.exceptions.ContractLogicError`: ...
enrich_error
python
ApeWorX/ape
src/ape/managers/compilers.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/compilers.py
Apache-2.0
def get_custom_error(self, err: ContractLogicError) -> Optional[CustomError]: """ Get a custom error for the given contract logic error using the contract-type found from address-data in the error. Returns ``None`` if the given error is not a custom-error, or it is not able to find the a...
Get a custom error for the given contract logic error using the contract-type found from address-data in the error. Returns ``None`` if the given error is not a custom-error, or it is not able to find the associated contract type or address. Args: err (:class:`~ape....
get_custom_error
python
ApeWorX/ape
src/ape/managers/compilers.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/compilers.py
Apache-2.0
def flatten_contract(self, path: Path, **kwargs) -> "Content": """ Get the flattened version of a contract via its source path. Delegates to the matching :class:`~ape.api.compilers.CompilerAPI`. Args: path (``pathlib.Path``): The source path of the contract. Returns...
Get the flattened version of a contract via its source path. Delegates to the matching :class:`~ape.api.compilers.CompilerAPI`. Args: path (``pathlib.Path``): The source path of the contract. Returns: ``ethpm_types.source.Content``: The flattened contract conte...
flatten_contract
python
ApeWorX/ape
src/ape/managers/compilers.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/compilers.py
Apache-2.0
def can_trace_source(self, filename: str) -> bool: """ Check if Ape is able trace the source lines for the given file. Checks that both the compiler is registered and that it supports the :meth:`~ape.api.compilers.CompilerAPI.trace_source` API method. Args: filename ...
Check if Ape is able trace the source lines for the given file. Checks that both the compiler is registered and that it supports the :meth:`~ape.api.compilers.CompilerAPI.trace_source` API method. Args: filename (str): The file to check. Returns: bool: ...
can_trace_source
python
ApeWorX/ape
src/ape/managers/compilers.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/compilers.py
Apache-2.0
def isolate_data_folder( self, keep: Optional[Union[Iterable[str], str]] = None ) -> Iterator[Path]: """ Change Ape's DATA_FOLDER to point a temporary path, in a context, for testing purposes. Any data cached to disk will not persist. Args: keep (Optional...
Change Ape's DATA_FOLDER to point a temporary path, in a context, for testing purposes. Any data cached to disk will not persist. Args: keep (Optional[Union[Iterable[str], str]]): Optionally, pass in a key of subdirectory names to include in the new isolated ...
isolate_data_folder
python
ApeWorX/ape
src/ape/managers/config.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/config.py
Apache-2.0
def convert(self, value: Any, to_type: Union[type, tuple, list]) -> Any: """ Convert the given value to the given type. This method accesses all :class:`~ape.api.convert.ConverterAPI` instances known to `ape`` and selects the appropriate one, so long that it exists. Raises: ...
Convert the given value to the given type. This method accesses all :class:`~ape.api.convert.ConverterAPI` instances known to `ape`` and selects the appropriate one, so long that it exists. Raises: :class:`~ape.exceptions.ConversionError`: When there is not a registered ...
convert
python
ApeWorX/ape
src/ape/managers/converters.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/converters.py
Apache-2.0
def get_converter(self, name: str) -> ConverterAPI: """ Get a converter plugin by name. Args: name (str): The name of the converter. Returns: :class:`~ape.api.converters.ConverterAPI`: The converter. """ for converter_ls in self._converters.value...
Get a converter plugin by name. Args: name (str): The name of the converter. Returns: :class:`~ape.api.converters.ConverterAPI`: The converter.
get_converter
python
ApeWorX/ape
src/ape/managers/converters.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/converters.py
Apache-2.0
def running_nodes(self) -> NodeProcessMap: """ All running development nodes managed by Ape. """ path = self.config_manager.DATA_FOLDER / "processes" / "nodes.json" try: return NodeProcessMap.model_validate_file(path) except ValidationError: path.u...
All running development nodes managed by Ape.
running_nodes
python
ApeWorX/ape
src/ape/managers/networks.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/networks.py
Apache-2.0
def get_running_node(self, pid: int) -> "SubprocessProvider": """ Get a running subprocess provider for the given ``pid``. Args: pid (int): The process ID. Returns: class:`~ape.api.providers.SubprocessProvider` """ if not (data := self.running_no...
Get a running subprocess provider for the given ``pid``. Args: pid (int): The process ID. Returns: class:`~ape.api.providers.SubprocessProvider`
get_running_node
python
ApeWorX/ape
src/ape/managers/networks.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/networks.py
Apache-2.0
def kill_node_process(self, *process_ids: int) -> dict[int, NodeProcessData]: """ Kill a node process managed by Ape. Args: *process_ids (int): The process ID to kill. Returns: dict[str, :class:`~ape.managers.networks.NodeProcessData`]: The process data ...
Kill a node process managed by Ape. Args: *process_ids (int): The process ID to kill. Returns: dict[str, :class:`~ape.managers.networks.NodeProcessData`]: The process data of all terminated processes.
kill_node_process
python
ApeWorX/ape
src/ape/managers/networks.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/networks.py
Apache-2.0
def get_request_headers( self, ecosystem_name: str, network_name: str, provider_name: str ) -> "RPCHeaders": """ All request headers to be used when connecting to this network. """ ecosystem = self.get_ecosystem(ecosystem_name) network = ecosystem.get_network(network_...
All request headers to be used when connecting to this network.
get_request_headers
python
ApeWorX/ape
src/ape/managers/networks.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/networks.py
Apache-2.0
def fork( self, provider_name: Optional[str] = None, provider_settings: Optional[dict] = None, block_number: Optional[int] = None, ) -> ProviderContextManager: """ Fork the currently connected network. Args: provider_name (str, optional): The name...
Fork the currently connected network. Args: provider_name (str, optional): The name of the provider to get. Defaults to ``None``. When ``None``, returns the default provider. provider_settings (dict, optional): Settings to apply to the provider. Defaults to ...
fork
python
ApeWorX/ape
src/ape/managers/networks.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/networks.py
Apache-2.0
def provider_names(self) -> set[str]: """ The set of all provider names in ``ape``. """ return set( provider for ecosystem in self.ecosystems.values() for network in ecosystem.networks.values() for provider in network.providers )
The set of all provider names in ``ape``.
provider_names
python
ApeWorX/ape
src/ape/managers/networks.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/networks.py
Apache-2.0
def ecosystems(self) -> dict[str, "EcosystemAPI"]: """ All the registered ecosystems in ``ape``, such as ``ethereum``. """ return { **self._evmchains_ecosystems, **self._plugin_ecosystems, **self._custom_ecosystems, }
All the registered ecosystems in ``ape``, such as ``ethereum``.
ecosystems
python
ApeWorX/ape
src/ape/managers/networks.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/networks.py
Apache-2.0
def create_custom_provider( self, connection_str: str, provider_cls: type["ProviderAPI"] = EthereumNodeProvider, provider_name: Optional[str] = None, ) -> "ProviderAPI": """ Create a custom connection to a URI using the EthereumNodeProvider provider. **NOTE**:...
Create a custom connection to a URI using the EthereumNodeProvider provider. **NOTE**: This provider will assume EVM-like behavior and this is generally not recommended. Use plugins when possible! Args: connection_str (str): The connection string of the node, such as its UR...
create_custom_provider
python
ApeWorX/ape
src/ape/managers/networks.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/networks.py
Apache-2.0
def get_network_choices( self, ecosystem_filter: Optional[Union[list[str], str]] = None, network_filter: Optional[Union[list[str], str]] = None, provider_filter: Optional[Union[list[str], str]] = None, ) -> Iterator[str]: """ The set of all possible network choices av...
The set of all possible network choices available as a "network selection" e.g. ``--network [ECOSYSTEM:NETWORK:PROVIDER]``. Each value is in the form ``ecosystem:network:provider`` and shortened options also appear in the list. For example, ``::node`` would default to ``:ethereum:local...
get_network_choices
python
ApeWorX/ape
src/ape/managers/networks.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/networks.py
Apache-2.0
def get_ecosystem(self, ecosystem_name: str) -> "EcosystemAPI": """ Get the ecosystem for the given name. Args: ecosystem_name (str): The name of the ecosystem to get. Raises: :class:`~ape.exceptions.NetworkError`: When the ecosystem is not found. Retur...
Get the ecosystem for the given name. Args: ecosystem_name (str): The name of the ecosystem to get. Raises: :class:`~ape.exceptions.NetworkError`: When the ecosystem is not found. Returns: :class:`~ape.api.networks.EcosystemAPI`
get_ecosystem
python
ApeWorX/ape
src/ape/managers/networks.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/networks.py
Apache-2.0
def get_provider_from_choice( self, network_choice: Optional[str] = None, provider_settings: Optional[dict] = None, ) -> "ProviderAPI": """ Get a :class:`~ape.api.providers.ProviderAPI` from a network choice. A network choice is any value returned from :meth:`...
Get a :class:`~ape.api.providers.ProviderAPI` from a network choice. A network choice is any value returned from :meth:`~ape.managers.networks.NetworkManager.get_network_choices`. Use the CLI command ``ape networks list`` to list all the possible network combinations. R...
get_provider_from_choice
python
ApeWorX/ape
src/ape/managers/networks.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/networks.py
Apache-2.0
def parse_network_choice( self, network_choice: Optional[str] = None, provider_settings: Optional[dict] = None, disconnect_after: bool = False, disconnect_on_exit: bool = True, ) -> ProviderContextManager: """ Parse a network choice into a context manager for ...
Parse a network choice into a context manager for managing a temporary connection to a provider. See :meth:`~ape.managers.networks.NetworkManager.get_network_choices` for all available choices (or use CLI command ``ape networks list``). Raises: :class:`~ape.exceptio...
parse_network_choice
python
ApeWorX/ape
src/ape/managers/networks.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/networks.py
Apache-2.0
def set_default_ecosystem(self, ecosystem_name: str): """ Change the default ecosystem. Raises: :class:`~ape.exceptions.NetworkError`: When the given ecosystem name is unknown. Args: ecosystem_name (str): The name of the ecosystem to set as the def...
Change the default ecosystem. Raises: :class:`~ape.exceptions.NetworkError`: When the given ecosystem name is unknown. Args: ecosystem_name (str): The name of the ecosystem to set as the default.
set_default_ecosystem
python
ApeWorX/ape
src/ape/managers/networks.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/networks.py
Apache-2.0
def valid_impl(api_class: Any) -> bool: """ Check if an API class is valid. The class must not have any unimplemented abstract methods. Args: api_class (any) Returns: bool """ if isinstance(api_class, tuple): return all(valid_impl(c) for c in api_class) # Is n...
Check if an API class is valid. The class must not have any unimplemented abstract methods. Args: api_class (any) Returns: bool
valid_impl
python
ApeWorX/ape
src/ape/managers/plugins.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/plugins.py
Apache-2.0
def get(self, source_id: str) -> Optional[Source]: """ Get a Source by source_id. Args: source_id (str): The source identifier. Returns: Source | None """ if source_id in self._sources: return self._sources[source_id] for pat...
Get a Source by source_id. Args: source_id (str): The source identifier. Returns: Source | None
get
python
ApeWorX/ape
src/ape/managers/project.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py
Apache-2.0
def is_excluded(self, path: Path) -> bool: """ Check if the given path is considered an "excluded" file based on the configured ignore-patterns. Args: path (Path): The path to check. Returns: bool """ source_id = self._get_source_id(path)...
Check if the given path is considered an "excluded" file based on the configured ignore-patterns. Args: path (Path): The path to check. Returns: bool
is_excluded
python
ApeWorX/ape
src/ape/managers/project.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py
Apache-2.0
def lookup(self, path_id: Union[str, Path]) -> Optional[Path]: """ Look-up a path by given a sub-path or a source ID. Args: path_id (Union[str, Path]): Either part of a path or a source ID. Returns: Path: The full path to the source file. "...
Look-up a path by given a sub-path or a source ID. Args: path_id (Union[str, Path]): Either part of a path or a source ID. Returns: Path: The full path to the source file.
lookup
python
ApeWorX/ape
src/ape/managers/project.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py
Apache-2.0
def refresh(self): """ Reset file-caches to handle session-changes. (Typically not needed to be called by users). """ (self.__dict__ or {}).pop("_all_files", None) self._path_to_source_id = {} self._path_cache = None
Reset file-caches to handle session-changes. (Typically not needed to be called by users).
refresh
python
ApeWorX/ape
src/ape/managers/project.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py
Apache-2.0
def get( self, name: str, compile_missing: bool = True, check_for_changes: bool = True ) -> Optional[ContractContainer]: """ Get a contract by name. Args: name (str): The name of the contract. compile_missing (bool): Set to ``False`` to not attempt compiling ...
Get a contract by name. Args: name (str): The name of the contract. compile_missing (bool): Set to ``False`` to not attempt compiling if the contract can't be found. Note: modified sources are re-compiled regardless of this flag. check_fo...
get
python
ApeWorX/ape
src/ape/managers/project.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py
Apache-2.0
def installed(self) -> bool: """ ``True`` when a project is available. Note: Installed does not mean the dependency is compiled! """ if self._installation is not None: return True try: project_path = self.project_path except ProjectError: ...
``True`` when a project is available. Note: Installed does not mean the dependency is compiled!
installed
python
ApeWorX/ape
src/ape/managers/project.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py
Apache-2.0
def install( self, use_cache: bool = True, config_override: Optional[dict] = None, recurse: bool = True, ) -> "ProjectManager": """ Install this dependency. Args: use_cache (bool): To force a reinstalling, like a refresh, set this to...
Install this dependency. Args: use_cache (bool): To force a reinstalling, like a refresh, set this to ``False``. config_override (dict): Optionally change the configuration during install. recurse (bool): Set to ``False`` to avoid installing dependency...
install
python
ApeWorX/ape
src/ape/managers/project.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py
Apache-2.0
def compile( self, use_cache: bool = True, config_override: Optional[dict] = None, allow_install: bool = False, ) -> dict[str, ContractContainer]: """ Compile a dependency. Args: use_cache (bool): Set to ``False`` to force a re-compile. ...
Compile a dependency. Args: use_cache (bool): Set to ``False`` to force a re-compile. config_override (Optional[dict]): Optionally override the configuration, which may be needed for compiling. allow_install (bool): Set to ``True`` to allow installing....
compile
python
ApeWorX/ape
src/ape/managers/project.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py
Apache-2.0
def cache_api(self, api: DependencyAPI) -> Path: """ Cache a dependency JSON for usage outside the project. """ api_file = self.get_api_path(api.package_id, api.version_id) api_file.parent.mkdir(parents=True, exist_ok=True) api_file.unlink(missing_ok=True) # NOTE...
Cache a dependency JSON for usage outside the project.
cache_api
python
ApeWorX/ape
src/ape/managers/project.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py
Apache-2.0
def isolate_changes(self): """ Allows you to make changes affecting the Ape packages cache in a context. For example, temporarily install local "dev" packages for testing purposes. """ with create_tempdir() as tmpdir: packages_cache = tmpdir / "packages" p...
Allows you to make changes affecting the Ape packages cache in a context. For example, temporarily install local "dev" packages for testing purposes.
isolate_changes
python
ApeWorX/ape
src/ape/managers/project.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py
Apache-2.0
def get_project_dependencies( self, use_cache: bool = True, config_override: Optional[dict] = None, name: Optional[str] = None, version: Optional[str] = None, allow_install: bool = True, strict: bool = False, recurse: bool = True, ) -> Iterator[Depende...
Get dependencies specified in the project's ``ape-config.yaml`` file. Args: use_cache (bool): Set to ``False`` to force-reinstall dependencies. Defaults to ``True``. Does not work with ``allow_install=False``. config_override (Optional[dict]): Override shared con...
get_project_dependencies
python
ApeWorX/ape
src/ape/managers/project.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py
Apache-2.0
def all(self) -> Iterator[Dependency]: """ All dependencies known by Ape, regardless of their project affiliation. NOTE: By "installed" here, we simply mean the API files are cached and known by Ape. However, it does not guarantee the project is installed. """ ...
All dependencies known by Ape, regardless of their project affiliation. NOTE: By "installed" here, we simply mean the API files are cached and known by Ape. However, it does not guarantee the project is installed.
all
python
ApeWorX/ape
src/ape/managers/project.py
https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py
Apache-2.0