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 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 chain_id(self) -> int:
"""
The blockchain ID.
See `ChainList <https://chainlist.org/>`__ for a comprehensive list of IDs.
"""
network_name = self.provider.network.name
if network_name not in self._chain_id_map:
self._chain_id_map[network_name] = self.provi... |
The blockchain ID.
See `ChainList <https://chainlist.org/>`__ for a comprehensive list of IDs.
| chain_id | 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 |
def get_dependency_api(self, package_id: str, version: Optional[str] = None) -> DependencyAPI:
"""
Get a dependency API. If not given version and there are multiple,
returns the latest.
Args:
package_id (str): The package ID or name of the dependency.
version (st... |
Get a dependency API. If not given version and there are multiple,
returns the latest.
Args:
package_id (str): The package ID or name of the dependency.
version (str): The version of the dependency.
Returns:
:class:`~ape.api.projects.DependencyAPI`
... | get_dependency_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 get_versions(self, name: str, allow_install: bool = True) -> Iterator[Dependency]:
"""
Get all installed versions of a dependency.
Args:
name (str): The name of the dependency.
allow_install (bool): Set to ``False`` to not allow installing.
Returns:
... |
Get all installed versions of a dependency.
Args:
name (str): The name of the dependency.
allow_install (bool): Set to ``False`` to not allow installing.
Returns:
Iterator[:class:`~ape.managers.project.Dependency`]
| get_versions | 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_dependency(
self, dependency_id: str, version: str, allow_install: bool = True
) -> Dependency:
"""
Get a dependency.
Args:
dependency_id (str): The package ID of the dependency. You can also
provide the short-name of the dependency.
ver... |
Get a dependency.
Args:
dependency_id (str): The package ID of the dependency. You can also
provide the short-name of the dependency.
version (str): The version identifier.
allow_install (bool): If the dependency API is known but the
proj... | get_dependency | python | ApeWorX/ape | src/ape/managers/project.py | https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py | Apache-2.0 |
def decode_dependency(self, **item: Any) -> DependencyAPI:
"""
Decode data into a :class:`~ape.api.projects.DependencyAPI`.
Args:
**item: The same data you put in your ``dependencies:`` config.
Raises:
:class:`~ape.exceptions.ProjectError`: When unable to handle... |
Decode data into a :class:`~ape.api.projects.DependencyAPI`.
Args:
**item: The same data you put in your ``dependencies:`` config.
Raises:
:class:`~ape.exceptions.ProjectError`: When unable to handle the
given API data.
Returns:
:clas... | decode_dependency | python | ApeWorX/ape | src/ape/managers/project.py | https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py | Apache-2.0 |
def add(self, dependency: Union[dict, DependencyAPI]) -> Dependency:
"""
Add the dependency API data. This sets up a dependency such that
it can be fetched.
Args:
dependency (dict | :class:`~ape.api.projects.DependencyAPI`): The
API data necessary for fetching ... |
Add the dependency API data. This sets up a dependency such that
it can be fetched.
Args:
dependency (dict | :class:`~ape.api.projects.DependencyAPI`): The
API data necessary for fetching the dependency.
Returns:
class:`~ape.managers.project.Depen... | add | 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, **dependency: Any) -> Union[Dependency, list[Dependency]]:
"""
Install dependencies.
Args:
**dependency: Dependency data, same to what you put in `dependencies:` config.
When excluded, installs all project-specified dependencies. Also, use
... |
Install dependencies.
Args:
**dependency: Dependency data, same to what you put in `dependencies:` config.
When excluded, installs all project-specified dependencies. Also, use
``use_cache=False`` to force re-installing and ``recurse=False`` to avoid
... | 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 unpack(self, base_path: Path, cache_name: str = ".cache"):
"""
Move dependencies into a .cache folder.
Ideal for isolated, temporary projects.
Args:
base_path (Path): The target path.
cache_name (str): The cache folder name to create
at the targ... |
Move dependencies into a .cache folder.
Ideal for isolated, temporary projects.
Args:
base_path (Path): The target path.
cache_name (str): The cache folder name to create
at the target path. Defaults to ``.cache`` because
that is what ``ape-s... | unpack | python | ApeWorX/ape | src/ape/managers/project.py | https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py | Apache-2.0 |
def from_manifest(
cls, manifest: Union[PackageManifest, Path, str], config_override: Optional[dict] = None
) -> "Project":
"""
Create an Ape project using only a manifest.
Args:
manifest (Union[PackageManifest, Path, str]): Either a manifest or a
path to a... |
Create an Ape project using only a manifest.
Args:
manifest (Union[PackageManifest, Path, str]): Either a manifest or a
path to a manifest file.
config_override (Optional[Dict]): Optionally provide a config override.
Returns:
:class:`~ape.mana... | from_manifest | python | ApeWorX/ape | src/ape/managers/project.py | https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py | Apache-2.0 |
def from_python_library(
cls, package_name: str, config_override: Optional[dict] = None
) -> "LocalProject":
"""
Create an Ape project instance from an installed Python package.
This is useful for when Ape or Vyper projects are published to
pypi.
Args:
pa... |
Create an Ape project instance from an installed Python package.
This is useful for when Ape or Vyper projects are published to
pypi.
Args:
package_name (str): The name of the package's folder that would
appear in site-packages.
config_override (di... | from_python_library | 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_in_tempdir(self, **config_override) -> Iterator["LocalProject"]:
"""
Clone this project to a temporary directory and return
its project.
"""
config_override = config_override or {}
name = config_override.get("name", self.name)
chdir = config_override.p... |
Clone this project to a temporary directory and return
its project.
| isolate_in_tempdir | python | ApeWorX/ape | src/ape/managers/project.py | https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py | Apache-2.0 |
def unpack(self, destination: Path, config_override: Optional[dict] = None) -> "LocalProject":
"""
Unpack the project to a location using the information
from the manifest. Converts a manifest-based project
to a local one.
"""
config_override = {**self._config_override, *... |
Unpack the project to a location using the information
from the manifest. Converts a manifest-based project
to a local one.
| unpack | python | ApeWorX/ape | src/ape/managers/project.py | https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py | Apache-2.0 |
def update_manifest(self, **kwargs):
"""
Change manifest values. Overwrites.
Args:
**kwargs: Top-level manifest attributes.
"""
for k, v in kwargs.items():
setattr(self._manifest, k, v) |
Change manifest values. Overwrites.
Args:
**kwargs: Top-level manifest attributes.
| update_manifest | python | ApeWorX/ape | src/ape/managers/project.py | https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py | Apache-2.0 |
def add_compiler_data(self, compiler_data: Iterable[Compiler]) -> list[Compiler]:
"""
Add compiler data to the existing cached manifest.
Args:
compiler_data (Iterable[``ethpm_types.Compiler``]): Compilers to add.
Returns:
List[``ethpm_types.source.Compiler``]: T... |
Add compiler data to the existing cached manifest.
Args:
compiler_data (Iterable[``ethpm_types.Compiler``]): Compilers to add.
Returns:
List[``ethpm_types.source.Compiler``]: The full list of compilers.
| add_compiler_data | python | ApeWorX/ape | src/ape/managers/project.py | https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py | Apache-2.0 |
def reconfigure(self, **overrides):
"""
Change a project's config.
Args:
**overrides: Config key-value pairs. Completely overrides
existing.
"""
if "config" in self.__dict__:
# Delete cached property.
del self.__dict__["config"]... |
Change a project's config.
Args:
**overrides: Config key-value pairs. Completely overrides
existing.
| reconfigure | python | ApeWorX/ape | src/ape/managers/project.py | https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py | Apache-2.0 |
def instance_map(self) -> dict[str, dict[str, EthPMContractInstance]]:
"""
The mapping needed for deployments publishing in an ethpm manifest.
"""
result: dict[str, dict[str, EthPMContractInstance]] = {}
if not self.cache_folder.is_dir():
return result
for ec... |
The mapping needed for deployments publishing in an ethpm manifest.
| instance_map | python | ApeWorX/ape | src/ape/managers/project.py | https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py | Apache-2.0 |
def track(self, contract: ContractInstance, allow_dev: bool = False):
"""
Indicate that a contract deployment should be included in the package manifest
upon publication.
**NOTE**: Deployments are automatically tracked for contracts. However, only
deployments passed to this meth... |
Indicate that a contract deployment should be included in the package manifest
upon publication.
**NOTE**: Deployments are automatically tracked for contracts. However, only
deployments passed to this method are included in the final, publishable manifest.
Args:
co... | track | python | ApeWorX/ape | src/ape/managers/project.py | https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py | Apache-2.0 |
def __iter__(self) -> Iterator[EthPMContractInstance]:
"""
Get project deployments.
Returns:
Iterator[ethpm_types.ContractInstance]
"""
if not self.cache_folder.is_dir():
return
for ecosystem_path in self.cache_folder.iterdir():
if no... |
Get project deployments.
Returns:
Iterator[ethpm_types.ContractInstance]
| __iter__ | python | ApeWorX/ape | src/ape/managers/project.py | https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py | Apache-2.0 |
def project_api(self) -> ProjectAPI:
"""
The 'type' of project this is, such as an Ape project
or a Brownie project (or something else).
"""
default_project = self._get_ape_project_api()
valid_apis: list[ProjectAPI] = [default_project] if default_project else []
... |
The 'type' of project this is, such as an Ape project
or a Brownie project (or something else).
| project_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 config(self) -> ApeConfig:
"""
The project configuration (including global defaults).
"""
# NOTE: Accessing the config this way allows us
# to be a different project than the cwd project.
project_config = self.project_api.extract_config(**self._config_override)
... |
The project configuration (including global defaults).
| config | python | ApeWorX/ape | src/ape/managers/project.py | https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py | Apache-2.0 |
def in_tempdir(self) -> bool:
"""
``True`` when this project is in the temporary directory,
meaning existing only in the temporary directory
namespace.
"""
if not self.path:
return False
return in_tempdir(self.path) |
``True`` when this project is in the temporary directory,
meaning existing only in the temporary directory
namespace.
| in_tempdir | python | ApeWorX/ape | src/ape/managers/project.py | https://github.com/ApeWorX/ape/blob/master/src/ape/managers/project.py | Apache-2.0 |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.