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 test_varlib_gvar_explicit_delta(self):
"""The variable font contains a composite glyph odieresis which does not
need a gvar entry.
"""
test_name = "BuildGvarCompositeExplicitDelta"
self._run_varlib_build_test(
designspace_name=test_name,
font_name="Tes... | The variable font contains a composite glyph odieresis which does not
need a gvar entry.
| test_varlib_gvar_explicit_delta | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_kerning_merging(self):
"""Test the correct merging of class-based pair kerning.
Problem description at https://github.com/fonttools/fonttools/pull/1638.
Test font and Designspace generated by
https://gist.github.com/madig/183d0440c9f7d05f04bd1280b9664bd1.
"""
ds... | Test the correct merging of class-based pair kerning.
Problem description at https://github.com/fonttools/fonttools/pull/1638.
Test font and Designspace generated by
https://gist.github.com/madig/183d0440c9f7d05f04bd1280b9664bd1.
| test_kerning_merging | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_composite_glyph_not_in_gvar(self, varfont):
"""The 'minus' glyph is a composite glyph, which references 'hyphen' as a
component, but has no tuple variations in gvar table, so the component offset
and the phantom points do not change; however the sidebearings and bounding box
do ... | The 'minus' glyph is a composite glyph, which references 'hyphen' as a
component, but has no tuple variations in gvar table, so the component offset
and the phantom points do not change; however the sidebearings and bounding box
do change as a result of the parent glyph 'hyphen' changing.
... | test_composite_glyph_not_in_gvar | python | fonttools/fonttools | Tests/varLib/instancer/instancer_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/instancer/instancer_test.py | MIT |
def test_rounds_before_iup():
"""Regression test for fonttools/fonttools#3634, with TTX based on
reproduction process there."""
varfont = ttLib.TTFont()
varfont.importXML(os.path.join(TESTDATA, "3634-VF.ttx"))
# Instantiate at a new default position, sufficient to cause differences
# when unro... | Regression test for fonttools/fonttools#3634, with TTX based on
reproduction process there. | test_rounds_before_iup | python | fonttools/fonttools | Tests/varLib/instancer/instancer_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/instancer/instancer_test.py | MIT |
def handle_ape_exception(err: ApeException, base_paths: Iterable[Union[Path, str]]) -> bool:
"""
Handle a transaction error by showing relevant stack frames,
including custom contract frames added to the exception.
This method must be called within an ``except`` block or with
an exception on the exc... |
Handle a transaction error by showing relevant stack frames,
including custom contract frames added to the exception.
This method must be called within an ``except`` block or with
an exception on the exc-stack.
Args:
err (:class:`~ape.exceptions.TransactionError`): The transaction error
... | handle_ape_exception | python | ApeWorX/ape | src/ape/exceptions.py | https://github.com/ApeWorX/ape/blob/master/src/ape/exceptions.py | Apache-2.0 |
def success(self, message, *args, **kws):
"""This method gets injected into python's `logging` module
to handle logging at this level."""
if self.isEnabledFor(LogLevel.SUCCESS.value):
# Yes, logger takes its '*args' as 'args'.
self._log(LogLevel.SUCCESS.value, message, args, **kws) | This method gets injected into python's `logging` module
to handle logging at this level. | success | python | ApeWorX/ape | src/ape/logging.py | https://github.com/ApeWorX/ape/blob/master/src/ape/logging.py | Apache-2.0 |
def _isatty(stream: IO) -> bool:
"""Returns ``True`` if the stream is part of a tty.
Borrowed from ``click._compat``."""
# noinspection PyBroadException
try:
return stream.isatty()
except Exception:
return False | Returns ``True`` if the stream is part of a tty.
Borrowed from ``click._compat``. | _isatty | python | ApeWorX/ape | src/ape/logging.py | https://github.com/ApeWorX/ape/blob/master/src/ape/logging.py | Apache-2.0 |
def _load_from_sys_argv(self, default: Optional[Union[str, int, LogLevel]] = None):
"""
Load from sys.argv to beat race condition with `click`.
"""
if self._did_parse_sys_argv:
# Already parsed.
return
log_level = _get_level(level=default)
level_n... |
Load from sys.argv to beat race condition with `click`.
| _load_from_sys_argv | python | ApeWorX/ape | src/ape/logging.py | https://github.com/ApeWorX/ape/blob/master/src/ape/logging.py | Apache-2.0 |
def set_level(self, level: Union[str, int, LogLevel]):
"""
Change the global ape logger log-level.
Args:
level (str): The name of the level or the value of the log-level.
"""
if level == self._logger.level:
return
elif isinstance(level, LogLevel):... |
Change the global ape logger log-level.
Args:
level (str): The name of the level or the value of the log-level.
| set_level | python | ApeWorX/ape | src/ape/logging.py | https://github.com/ApeWorX/ape/blob/master/src/ape/logging.py | Apache-2.0 |
def at_level(self, level: Union[str, int, LogLevel]) -> Iterator:
"""
Change the log-level in a context.
Args:
level (Union[str, int, LogLevel]): The level to use.
Returns:
Iterator
"""
initial_level = self.level
self.set_level(level)
... |
Change the log-level in a context.
Args:
level (Union[str, int, LogLevel]): The level to use.
Returns:
Iterator
| at_level | python | ApeWorX/ape | src/ape/logging.py | https://github.com/ApeWorX/ape/blob/master/src/ape/logging.py | Apache-2.0 |
def get_logger(
name: str,
fmt: Optional[str] = None,
handlers: Optional[Sequence[Callable[[str], str]]] = None,
) -> logging.Logger:
"""
Get a logger with the given ``name`` and configure it for usage with Ape.
Args:
name (str): The name of the logger.
fmt (Optional[str]): The ... |
Get a logger with the given ``name`` and configure it for usage with Ape.
Args:
name (str): The name of the logger.
fmt (Optional[str]): The format of the logger. Defaults to the Ape
logger's default format: ``"%(levelname)s%(plugin)s: %(message)s"``.
handlers (Optional[Seque... | get_logger | python | ApeWorX/ape | src/ape/logging.py | https://github.com/ApeWorX/ape/blob/master/src/ape/logging.py | Apache-2.0 |
def sanitize_url(url: str) -> str:
"""Removes sensitive information from given URL"""
parsed = urlparse(url)
new_netloc = parsed.hostname or ""
if parsed.port:
new_netloc += f":{parsed.port}"
new_url = urlunparse(parsed._replace(netloc=new_netloc, path=""))
return f"{new_url}/{HIDDEN_M... | Removes sensitive information from given URL | sanitize_url | python | ApeWorX/ape | src/ape/logging.py | https://github.com/ApeWorX/ape/blob/master/src/ape/logging.py | Apache-2.0 |
def silenced(func: Callable):
"""
A decorator for ensuring a function does not output any logs.
Args:
func (Callable): The function to call silently.
"""
def wrapper(*args, **kwargs):
with logger.disabled():
return func(*args, **kwargs)
return wrapper |
A decorator for ensuring a function does not output any logs.
Args:
func (Callable): The function to call silently.
| silenced | python | ApeWorX/ape | src/ape/logging.py | https://github.com/ApeWorX/ape/blob/master/src/ape/logging.py | Apache-2.0 |
def __dir__(self) -> list[str]:
"""
Display methods to IPython on ``a.[TAB]`` tab completion.
Returns:
list[str]: Method names that IPython uses for tab completion.
"""
base_value_excludes = ("code", "codesize", "is_contract") # Not needed for accounts
base_... |
Display methods to IPython on ``a.[TAB]`` tab completion.
Returns:
list[str]: Method names that IPython uses for tab completion.
| __dir__ | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def sign_raw_msghash(self, msghash: "HexBytes") -> Optional[MessageSignature]:
"""
Sign a raw message hash.
Args:
msghash (:class:`~eth_pydantic_types.HexBytes`):
The message hash to sign. Plugins may or may not support this operation.
Default implementation is... |
Sign a raw message hash.
Args:
msghash (:class:`~eth_pydantic_types.HexBytes`):
The message hash to sign. Plugins may or may not support this operation.
Default implementation is to raise ``APINotImplementedError``.
Returns:
:class:`~ape.types.signa... | sign_raw_msghash | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def sign_authorization(
self,
address: Any,
chain_id: Optional[int] = None,
nonce: Optional[int] = None,
) -> Optional[MessageSignature]:
"""
Sign an `EIP-7702 <https://eips.ethereum.org/EIPS/eip-7702>`__ Authorization.
Args:
address (Any): A delega... |
Sign an `EIP-7702 <https://eips.ethereum.org/EIPS/eip-7702>`__ Authorization.
Args:
address (Any): A delegate address to sign the authorization for.
chain_id (Optional[int]):
The chain ID that the authorization should be valid for.
A value of ``0`` means tha... | sign_authorization | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def sign_message(self, msg: Any, **signer_options) -> Optional[MessageSignature]:
"""
Sign a message.
Args:
msg (Any): The message to sign. Account plugins can handle various types of messages.
For example, :class:`~ape_accounts.accounts.KeyfileAccount` can handle
... |
Sign a message.
Args:
msg (Any): The message to sign. Account plugins can handle various types of messages.
For example, :class:`~ape_accounts.accounts.KeyfileAccount` can handle
:class:`~ape.types.signatures.SignableMessage`, str, int, and bytes.
See thes... | sign_message | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def sign_transaction(self, txn: TransactionAPI, **signer_options) -> Optional[TransactionAPI]:
"""
Sign a transaction.
Args:
txn (:class:`~ape.api.transactions.TransactionAPI`): The transaction to sign.
**signer_options: Additional kwargs given to the signer to modify the si... |
Sign a transaction.
Args:
txn (:class:`~ape.api.transactions.TransactionAPI`): The transaction to sign.
**signer_options: Additional kwargs given to the signer to modify the signing operation.
Returns:
:class:`~ape.api.transactions.TransactionAPI` (optional): A s... | sign_transaction | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def call(
self,
txn: TransactionAPI,
send_everything: bool = False,
private: bool = False,
sign: bool = True,
**signer_options,
) -> ReceiptAPI:
"""
Make a transaction call.
Raises:
:class:`~ape.exceptions.AccountsError`: When the ... |
Make a transaction call.
Raises:
:class:`~ape.exceptions.AccountsError`: When the nonce is invalid or the sender does
not have enough funds.
:class:`~ape.exceptions.TransactionError`: When the required confirmations are negative.
:class:`~ape.exception... | call | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def transfer(
self,
account: Union[str, AddressType, BaseAddress],
value: Optional[Union[str, int]] = None,
data: Optional[Union[bytes, str]] = None,
private: bool = False,
**kwargs,
) -> ReceiptAPI:
"""
Send funds to an account.
Raises:
... |
Send funds to an account.
Raises:
:class:`~ape.exceptions.APINotImplementedError`: When setting ``private=True``
and using a provider that does not support private transactions.
Args:
account (Union[str, AddressType, BaseAddress]): The receiver of the fun... | transfer | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def deploy(
self, contract: "ContractContainer", *args, publish: bool = False, **kwargs
) -> "ContractInstance":
"""
Create a smart contract on the blockchain. The smart contract must compile before
deploying and a provider must be active.
Args:
contract (:class:... |
Create a smart contract on the blockchain. The smart contract must compile before
deploying and a provider must be active.
Args:
contract (:class:`~ape.contracts.base.ContractContainer`): The type of contract to
deploy.
publish (bool): Set to ``True`` to a... | deploy | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def declare(self, contract: "ContractContainer", *args, **kwargs) -> ReceiptAPI:
"""
Deploy the "blueprint" of a contract type. For EVM providers, this likely means
using `EIP-5202 <https://eips.ethereum.org/EIPS/eip-5202>`__, which is implemented
in the core ``ape-ethereum`` plugin.
... |
Deploy the "blueprint" of a contract type. For EVM providers, this likely means
using `EIP-5202 <https://eips.ethereum.org/EIPS/eip-5202>`__, which is implemented
in the core ``ape-ethereum`` plugin.
Args:
contract (:class:`~ape.contracts.base.ContractContainer`): The contr... | declare | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def check_signature(
self,
data: Union[SignableMessage, TransactionAPI, str, EIP712Message, int, bytes],
signature: Optional[MessageSignature] = None, # TransactionAPI doesn't need it
recover_using_eip191: bool = True,
) -> bool:
"""
Verify a message or transaction w... |
Verify a message or transaction was signed by this account.
Args:
data (Union[:class:`~ape.types.signatures.SignableMessage`, :class:`~ape.api.transactions.TransactionAPI`]): # noqa: E501
The message or transaction to verify.
signature (Optional[:class:`~ape.type... | check_signature | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def get_deployment_address(self, nonce: Optional[int] = None) -> AddressType:
"""
Get a contract address before it is deployed. This is useful
when you need to pass the contract address to another contract
before deploying it.
Args:
nonce (int | None): Optionally pro... |
Get a contract address before it is deployed. This is useful
when you need to pass the contract address to another contract
before deploying it.
Args:
nonce (int | None): Optionally provide a nonce. Defaults
the account's current nonce.
Returns:
... | get_deployment_address | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def delegate_to(
self,
new_delegate: Union[BaseAddress, AddressType, str],
set_txn_kwargs: Optional[dict] = None,
reset_txn_kwargs: Optional[dict] = None,
**txn_kwargs,
) -> Iterator[BaseAddress]:
"""
Temporarily override the value of ``delegate`` for the acco... |
Temporarily override the value of ``delegate`` for the account inside of a context manager,
and yields a contract instance object whose interface matches that of ``new_delegate``.
This is useful for ensuring that delegation is only temporarily extended to an account when
doing a critica... | delegate_to | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def aliases(self) -> Iterator[str]:
"""
All available aliases.
Returns:
Iterator[str]
""" |
All available aliases.
Returns:
Iterator[str]
| aliases | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def accounts(self) -> Iterator[AccountAPI]:
"""
All accounts.
Returns:
Iterator[:class:`~ape.api.accounts.AccountAPI`]
""" |
All accounts.
Returns:
Iterator[:class:`~ape.api.accounts.AccountAPI`]
| accounts | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def data_folder(self) -> Path:
"""
The path to the account data files.
Defaults to ``$HOME/.ape/<plugin_name>`` unless overridden.
"""
path = self.config_manager.DATA_FOLDER / self.name
path.mkdir(parents=True, exist_ok=True)
return path |
The path to the account data files.
Defaults to ``$HOME/.ape/<plugin_name>`` unless overridden.
| data_folder | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def __getitem__(self, address: AddressType) -> AccountAPI:
"""
Get an account by address.
Args:
address (:class:`~ape.types.address.AddressType`): The address to get. The type is an alias to
`ChecksumAddress <https://eth-typing.readthedocs.io/en/latest/types.html#check... |
Get an account by address.
Args:
address (:class:`~ape.types.address.AddressType`): The address to get. The type is an alias to
`ChecksumAddress <https://eth-typing.readthedocs.io/en/latest/types.html#checksumaddress>`__. # noqa: E501
Raises:
KeyError: W... | __getitem__ | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def append(self, account: AccountAPI):
"""
Add an account to the container.
Raises:
:class:`~ape.exceptions.AccountsError`: When the account is already in the container.
Args:
account (:class:`~ape.api.accounts.AccountAPI`): The account to add.
"""
... |
Add an account to the container.
Raises:
:class:`~ape.exceptions.AccountsError`: When the account is already in the container.
Args:
account (:class:`~ape.api.accounts.AccountAPI`): The account to add.
| append | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def remove(self, account: AccountAPI):
"""
Delete an account.
Raises:
:class:`~ape.exceptions.AccountsError`: When the account is not known to ``ape``.
Args:
account (:class:`~ape.accounts.AccountAPI`): The account to remove.
"""
self._verify_acc... |
Delete an account.
Raises:
:class:`~ape.exceptions.AccountsError`: When the account is not known to ``ape``.
Args:
account (:class:`~ape.accounts.AccountAPI`): The account to remove.
| remove | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def __contains__(self, address: AddressType) -> bool:
"""
Check if the address is an existing account in ``ape``.
Raises:
IndexError: When the given account address is not in this container.
Args:
address (:class:`~ape.types.address.AddressType`): An account add... |
Check if the address is an existing account in ``ape``.
Raises:
IndexError: When the given account address is not in this container.
Args:
address (:class:`~ape.types.address.AddressType`): An account address.
Returns:
bool: ``True`` if ``ape`` man... | __contains__ | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def get_test_account(self, index: int) -> "TestAccountAPI": # type: ignore[empty-body]
"""
Get the test account at the given index.
Args:
index (int): The index of the test account.
Returns:
:class:`~ape.api.accounts.TestAccountAPI`
""" |
Get the test account at the given index.
Args:
index (int): The index of the test account.
Returns:
:class:`~ape.api.accounts.TestAccountAPI`
| get_test_account | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def reset(self):
"""
Reset the account container to an original state.
""" |
Reset the account container to an original state.
| reset | python | ApeWorX/ape | src/ape/api/accounts.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/accounts.py | Apache-2.0 |
def _base_dir_values(self) -> list[str]:
"""
This exists because when you call ``dir(BaseAddress)``, you get the type's return
value and not the instances. This allows base-classes to make use of shared
``IPython`` ``__dir__`` values.
"""
# NOTE: mypy is confused by prop... |
This exists because when you call ``dir(BaseAddress)``, you get the type's return
value and not the instances. This allows base-classes to make use of shared
``IPython`` ``__dir__`` values.
| _base_dir_values | python | ApeWorX/ape | src/ape/api/address.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/address.py | Apache-2.0 |
def address(self) -> AddressType:
"""
The address of this account. Subclasses must override and provide this value.
""" |
The address of this account. Subclasses must override and provide this value.
| address | python | ApeWorX/ape | src/ape/api/address.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/address.py | Apache-2.0 |
def __eq__(self, other: object) -> bool:
"""
Compares :class:`~ape.api.BaseAddress` or ``str`` objects by converting to
:class:`~ape.types.address.AddressType`.
Returns:
bool: comparison result
"""
convert = self.conversion_manager.convert
try:
... |
Compares :class:`~ape.api.BaseAddress` or ``str`` objects by converting to
:class:`~ape.types.address.AddressType`.
Returns:
bool: comparison result
| __eq__ | python | ApeWorX/ape | src/ape/api/address.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/address.py | Apache-2.0 |
def __call__(self, **kwargs) -> "ReceiptAPI":
"""
Call this address directly. For contracts, this may mean invoking their
default handler.
Args:
**kwargs: Transaction arguments, such as ``sender`` or ``data``.
Returns:
:class:`~ape.api.transactions.Recei... |
Call this address directly. For contracts, this may mean invoking their
default handler.
Args:
**kwargs: Transaction arguments, such as ``sender`` or ``data``.
Returns:
:class:`~ape.api.transactions.ReceiptAPI`
| __call__ | python | ApeWorX/ape | src/ape/api/address.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/address.py | Apache-2.0 |
def balance(self) -> int:
"""
The total balance of the account.
"""
bal = self.provider.get_balance(self.address)
# By using CurrencyValue, we can compare with
# strings like "1 ether".
return CurrencyValue(bal) |
The total balance of the account.
| balance | python | ApeWorX/ape | src/ape/api/address.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/address.py | Apache-2.0 |
def codesize(self) -> int:
"""
The number of bytes in the smart contract.
"""
code = self.code
return len(code) if isinstance(code, bytes) else len(bytes.fromhex(code.lstrip("0x"))) |
The number of bytes in the smart contract.
| codesize | python | ApeWorX/ape | src/ape/api/address.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/address.py | Apache-2.0 |
def prepare_transaction(self, txn: "TransactionAPI", **kwargs) -> "TransactionAPI":
"""
Set default values on a transaction.
Raises:
:class:`~ape.exceptions.AccountsError`: When the account cannot afford the transaction
or the nonce is invalid.
:class:`~ape... |
Set default values on a transaction.
Raises:
:class:`~ape.exceptions.AccountsError`: When the account cannot afford the transaction
or the nonce is invalid.
:class:`~ape.exceptions.TransactionError`: When given negative required confirmations.
Args:
... | prepare_transaction | python | ApeWorX/ape | src/ape/api/address.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/address.py | Apache-2.0 |
def get_config(self, project: Optional["ProjectManager"] = None) -> "PluginConfig":
"""
The combination of settings from ``ape-config.yaml`` and ``.compiler_settings``.
Args:
project (Optional[:class:`~ape.managers.project.ProjectManager`]): Optionally provide
the proj... |
The combination of settings from ``ape-config.yaml`` and ``.compiler_settings``.
Args:
project (Optional[:class:`~ape.managers.project.ProjectManager`]): Optionally provide
the project containing the base paths and full source set. Defaults to the local
project.... | get_config | python | ApeWorX/ape | src/ape/api/compiler.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/compiler.py | Apache-2.0 |
def get_versions(self, all_paths: Iterable[Path]) -> set[str]: # type: ignore[empty-body]
"""
Retrieve the set of available compiler versions for this plugin to compile ``all_paths``.
Args:
all_paths (Iterable[pathlib.Path]): The list of paths.
Returns:
set[str... |
Retrieve the set of available compiler versions for this plugin to compile ``all_paths``.
Args:
all_paths (Iterable[pathlib.Path]): The list of paths.
Returns:
set[str]: A set of available compiler versions.
| get_versions | python | ApeWorX/ape | src/ape/api/compiler.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/compiler.py | Apache-2.0 |
def get_compiler_settings( # type: ignore[empty-body]
self,
contract_filepaths: Iterable[Path],
project: Optional["ProjectManager"] = None,
**overrides,
) -> dict["Version", dict]:
"""
Get a mapping of the settings that would be used to compile each of the sources
... |
Get a mapping of the settings that would be used to compile each of the sources
by the compiler version number.
Args:
contract_filepaths (Iterable[pathlib.Path]): The list of paths.
project (Optional[:class:`~ape.managers.project.ProjectManager`]): Optionally provide
... | get_compiler_settings | python | ApeWorX/ape | src/ape/api/compiler.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/compiler.py | Apache-2.0 |
def compile(
self,
contract_filepaths: Iterable[Path],
project: Optional["ProjectManager"],
settings: Optional[dict] = None,
) -> Iterator["ContractType"]:
"""
Compile the given source files. All compiler plugins must implement this function.
Args:
... |
Compile the given source files. All compiler plugins must implement this function.
Args:
contract_filepaths (Iterable[pathlib.Path]): A list of source file paths to compile.
project (Optional[:class:`~ape.managers.project.ProjectManager`]): Optionally provide
the ... | compile | python | ApeWorX/ape | src/ape/api/compiler.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/compiler.py | Apache-2.0 |
def compile_code( # type: ignore[empty-body]
self,
code: str,
project: Optional["ProjectManager"],
settings: Optional[dict] = None,
**kwargs,
) -> "ContractType":
"""
Compile a program.
Args:
code (str): The code to compile.
p... |
Compile a program.
Args:
code (str): The code to compile.
project (Optional[:class:`~ape.managers.project.ProjectManager`]): Optionally provide
the project containing the base paths and full source set. Defaults to the local
project. Dependencies wil... | compile_code | python | ApeWorX/ape | src/ape/api/compiler.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/compiler.py | Apache-2.0 |
def get_imports( # type: ignore[empty-body]
self, contract_filepaths: Iterable[Path], project: Optional["ProjectManager"]
) -> dict[str, list[str]]:
"""
Returns a list of imports as source_ids for each contract's source_id in a given
compiler.
Args:
contract_fil... |
Returns a list of imports as source_ids for each contract's source_id in a given
compiler.
Args:
contract_filepaths (Iterable[pathlib.Path]): A list of source file paths to compile.
project (Optional[:class:`~ape.managers.project.ProjectManager`]): Optionally provide
... | get_imports | python | ApeWorX/ape | src/ape/api/compiler.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/compiler.py | Apache-2.0 |
def get_version_map( # type: ignore[empty-body]
self,
contract_filepaths: Iterable[Path],
project: Optional["ProjectManager"] = None,
) -> dict["Version", set[Path]]:
"""
Get a map of versions to source paths.
Args:
contract_filepaths (Iterable[Path]): I... |
Get a map of versions to source paths.
Args:
contract_filepaths (Iterable[Path]): Input source paths. Defaults to all source paths
per compiler.
project (Optional[:class:`~ape.managers.project.ProjectManager`]): Optionally provide
the project contain... | get_version_map | python | ApeWorX/ape | src/ape/api/compiler.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/compiler.py | Apache-2.0 |
def supports_source_tracing(self) -> bool:
"""
Returns ``True`` if this compiler is able to provider a source
traceback for a given trace.
"""
try:
self.trace_source(None, None, None) # type: ignore
except APINotImplementedError:
return False
... |
Returns ``True`` if this compiler is able to provider a source
traceback for a given trace.
| supports_source_tracing | python | ApeWorX/ape | src/ape/api/compiler.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/compiler.py | Apache-2.0 |
def trace_source( # type: ignore[empty-body]
self, contract_source: "ContractSource", trace: "TraceAPI", calldata: "HexBytes"
) -> "SourceTraceback":
"""
Get a source-traceback for the given contract type.
The source traceback object contains all the control paths taken in the trans... |
Get a source-traceback for the given contract type.
The source traceback object contains all the control paths taken in the transaction.
When available, source-code location information is accessible from the object.
Args:
contract_source (``ContractSource``): A contract ty... | trace_source | python | ApeWorX/ape | src/ape/api/compiler.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/compiler.py | Apache-2.0 |
def flatten_contract( # type: ignore[empty-body]
self, path: Path, project: Optional["ProjectManager"] = None, **kwargs
) -> "Content":
"""
Get the content of a flattened contract via its source path.
Plugin implementations handle import resolution, SPDX de-duplication,
and ... |
Get the content of a flattened contract via its source path.
Plugin implementations handle import resolution, SPDX de-duplication,
and anything else needed.
Args:
path (``pathlib.Path``): The source path of the contract.
project (Optional[:class:`~ape.managers.p... | flatten_contract | python | ApeWorX/ape | src/ape/api/compiler.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/compiler.py | Apache-2.0 |
def init_coverage_profile(
self, source_coverage: "ContractSourceCoverage", contract_source: "ContractSource"
): # type: ignore[empty-body]
"""
Initialize an empty report for the given source ID. Modifies the given source
coverage in-place.
Args:
source_coverage... |
Initialize an empty report for the given source ID. Modifies the given source
coverage in-place.
Args:
source_coverage (:class:`~ape.types.coverage.SourceCoverage`): The source
to generate an empty coverage profile for.
contract_source (``ethpm_types.sourc... | init_coverage_profile | python | ApeWorX/ape | src/ape/api/compiler.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/compiler.py | Apache-2.0 |
def _find_config_yaml_files(base_path: Path) -> list[Path]:
"""
Find all ape config file in the given path.
"""
found: list[Path] = []
if (base_path / "ape-config.yaml").is_file():
found.append(base_path / "ape-config.yaml")
if (base_path / "ape-config.yml").is_file():
found.appe... |
Find all ape config file in the given path.
| _find_config_yaml_files | python | ApeWorX/ape | src/ape/api/config.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/config.py | Apache-2.0 |
def validate_file(cls, path: Path, **overrides) -> "ApeConfig":
"""
Create an ApeConfig class using the given path.
Supports both pyproject.toml and ape-config.[.yml|.yaml|.json] files.
Raises:
:class:`~ape.exceptions.ConfigError`: When given an unknown file type
... |
Create an ApeConfig class using the given path.
Supports both pyproject.toml and ape-config.[.yml|.yaml|.json] files.
Raises:
:class:`~ape.exceptions.ConfigError`: When given an unknown file type
or the data is invalid.
Args:
path (Path): The path... | validate_file | python | ApeWorX/ape | src/ape/api/config.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/config.py | Apache-2.0 |
def write_to_disk(self, destination: Path, replace: bool = False):
"""
Write this config to a file.
Args:
destination (Path): The path to write to.
replace (bool): Set to ``True`` to overwrite the file if it exists.
"""
if destination.exists() and not rep... |
Write this config to a file.
Args:
destination (Path): The path to write to.
replace (bool): Set to ``True`` to overwrite the file if it exists.
| write_to_disk | python | ApeWorX/ape | src/ape/api/config.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/config.py | Apache-2.0 |
def is_convertible(self, value: Any) -> bool:
"""
Returns ``True`` if string value provided by ``value`` is convertible using
:meth:`ape.api.convert.ConverterAPI.convert`.
Args:
value (Any): The value to check.
Returns:
bool: ``True`` when the given valu... |
Returns ``True`` if string value provided by ``value`` is convertible using
:meth:`ape.api.convert.ConverterAPI.convert`.
Args:
value (Any): The value to check.
Returns:
bool: ``True`` when the given value can be converted.
| is_convertible | python | ApeWorX/ape | src/ape/api/convert.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/convert.py | Apache-2.0 |
def convert(self, value: Any) -> ConvertedType:
"""
Convert the given value to the type specified as the generic for this class.
Implementations of this API must throw a :class:`~ape.exceptions.ConversionError`
when the item fails to convert properly.
Usage example::
... |
Convert the given value to the type specified as the generic for this class.
Implementations of this API must throw a :class:`~ape.exceptions.ConversionError`
when the item fails to convert properly.
Usage example::
from ape import convert
from ape.types import... | convert | python | ApeWorX/ape | src/ape/api/convert.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/convert.py | Apache-2.0 |
def name(self) -> str:
"""
The calculated name of the converter class.
Typically, it is the lowered prefix of the class without
the "Converter" or "Conversions" suffix.
"""
class_name = self.__class__.__name__
name = class_name.replace("Converter", "").replace("Co... |
The calculated name of the converter class.
Typically, it is the lowered prefix of the class without
the "Converter" or "Conversions" suffix.
| name | python | ApeWorX/ape | src/ape/api/convert.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/convert.py | Apache-2.0 |
def get_address_url(self, address: "AddressType") -> str:
"""
Get an address URL, such as for a transaction.
Args:
address (:class:`~ape.types.address.AddressType`): The address.
Returns:
str: The URL.
""" |
Get an address URL, such as for a transaction.
Args:
address (:class:`~ape.types.address.AddressType`): The address.
Returns:
str: The URL.
| get_address_url | python | ApeWorX/ape | src/ape/api/explorers.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/explorers.py | Apache-2.0 |
def get_transaction_url(self, transaction_hash: str) -> str:
"""
Get the transaction URL for the given transaction.
Args:
transaction_hash (str): The transaction hash.
Returns:
str: The URL.
""" |
Get the transaction URL for the given transaction.
Args:
transaction_hash (str): The transaction hash.
Returns:
str: The URL.
| get_transaction_url | python | ApeWorX/ape | src/ape/api/explorers.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/explorers.py | Apache-2.0 |
def get_contract_type(self, address: "AddressType") -> Optional["ContractType"]:
"""
Get the contract type for a given address if it has been published to this explorer.
Args:
address (:class:`~ape.types.address.AddressType`): The contract address.
Returns:
Opti... |
Get the contract type for a given address if it has been published to this explorer.
Args:
address (:class:`~ape.types.address.AddressType`): The contract address.
Returns:
Optional[``ContractType``]: If not published, returns ``None``.
| get_contract_type | python | ApeWorX/ape | src/ape/api/explorers.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/explorers.py | Apache-2.0 |
def publish_contract(self, address: "AddressType"):
"""
Publish a contract to the explorer.
Args:
address (:class:`~ape.types.address.AddressType`): The address of the deployed contract.
""" |
Publish a contract to the explorer.
Args:
address (:class:`~ape.types.address.AddressType`): The address of the deployed contract.
| publish_contract | python | ApeWorX/ape | src/ape/api/explorers.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/explorers.py | Apache-2.0 |
def custom_network(self) -> "NetworkAPI":
"""
A :class:`~ape.api.networks.NetworkAPI` for custom networks where the
network is either not known, unspecified, or does not have an Ape plugin.
"""
ethereum_class = None
for plugin_name, ecosystem_class in self.plugin_manager.... |
A :class:`~ape.api.networks.NetworkAPI` for custom networks where the
network is either not known, unspecified, or does not have an Ape plugin.
| custom_network | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def decode_address(cls, raw_address: "RawAddress") -> AddressType:
"""
Convert a raw address to the ecosystem's native address type.
Args:
raw_address (:class:`~ape.types.address.RawAddress`): The address to
convert.
Returns:
:class:`~ape.types.add... |
Convert a raw address to the ecosystem's native address type.
Args:
raw_address (:class:`~ape.types.address.RawAddress`): The address to
convert.
Returns:
:class:`~ape.types.address.AddressType`
| decode_address | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def encode_address(cls, address: AddressType) -> "RawAddress":
"""
Convert the ecosystem's native address type to a raw integer or str address.
Args:
address (:class:`~ape.types.address.AddressType`): The address to convert.
Returns:
:class:`~ape.types.address.R... |
Convert the ecosystem's native address type to a raw integer or str address.
Args:
address (:class:`~ape.types.address.AddressType`): The address to convert.
Returns:
:class:`~ape.types.address.RawAddress`
| encode_address | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def encode_contract_blueprint( # type: ignore[empty-body]
self, contract_type: "ContractType", *args, **kwargs
) -> "TransactionAPI":
"""
Encode a unique type of transaction that allows contracts to be created
from other contracts, such as
`EIP-5202 <https://eips.ethereum.or... |
Encode a unique type of transaction that allows contracts to be created
from other contracts, such as
`EIP-5202 <https://eips.ethereum.org/EIPS/eip-5202>`__
or Starknet's ``Declare`` transaction type.
Args:
contract_type (``ContractType``): The type of contract to c... | encode_contract_blueprint | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def decode_receipt(self, data: dict) -> "ReceiptAPI":
"""
Convert data to :class:`~ape.api.transactions.ReceiptAPI`.
Args:
data (Dict): A dictionary of Receipt properties.
Returns:
:class:`~ape.api.transactions.ReceiptAPI`
""" |
Convert data to :class:`~ape.api.transactions.ReceiptAPI`.
Args:
data (Dict): A dictionary of Receipt properties.
Returns:
:class:`~ape.api.transactions.ReceiptAPI`
| decode_receipt | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def decode_block(self, data: dict) -> "BlockAPI":
"""
Decode data to a :class:`~ape.api.providers.BlockAPI`.
Args:
data (Dict): A dictionary of data to decode.
Returns:
:class:`~ape.api.providers.BlockAPI`
""" |
Decode data to a :class:`~ape.api.providers.BlockAPI`.
Args:
data (Dict): A dictionary of data to decode.
Returns:
:class:`~ape.api.providers.BlockAPI`
| decode_block | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def networks(self) -> dict[str, "NetworkAPI"]:
"""
A dictionary of network names mapped to their API implementation.
Returns:
dict[str, :class:`~ape.api.networks.NetworkAPI`]
"""
return {
**self._networks_from_evmchains,
**self._networks_from_... |
A dictionary of network names mapped to their API implementation.
Returns:
dict[str, :class:`~ape.api.networks.NetworkAPI`]
| networks | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def add_network(self, network_name: str, network: "NetworkAPI"):
"""
Attach a new network to an ecosystem (e.g. L2 networks like Optimism).
Raises:
:class:`~ape.exceptions.NetworkError`: When the network already exists.
Args:
network_name (str): The name of the ... |
Attach a new network to an ecosystem (e.g. L2 networks like Optimism).
Raises:
:class:`~ape.exceptions.NetworkError`: When the network already exists.
Args:
network_name (str): The name of the network to add.
network (:class:`~ape.api.networks.NetworkAPI`):... | add_network | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def default_network_name(self) -> str:
"""
The name of the default network in this ecosystem.
Returns:
str
"""
if network := self._default_network:
# Was set programmatically.
return network
networks = self.networks
if network... |
The name of the default network in this ecosystem.
Returns:
str
| default_network_name | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def set_default_network(self, network_name: str):
"""
Change the default network.
Raises:
:class:`~ape.exceptions.NetworkError`: When the network does not exist.
Args:
network_name (str): The name of the default network to switch to.
"""
if netwo... |
Change the default network.
Raises:
:class:`~ape.exceptions.NetworkError`: When the network does not exist.
Args:
network_name (str): The name of the default network to switch to.
| set_default_network | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def encode_deployment(
self, deployment_bytecode: HexBytes, abi: "ConstructorABI", *args, **kwargs
) -> "TransactionAPI":
"""
Create a deployment transaction in the given ecosystem.
This may require connecting to other networks.
Args:
deployment_bytecode (HexByte... |
Create a deployment transaction in the given ecosystem.
This may require connecting to other networks.
Args:
deployment_bytecode (HexBytes): The bytecode to deploy.
abi (ConstructorABI): The constructor interface of the contract.
*args (Any): Constructor arg... | encode_deployment | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def encode_transaction(
self, address: AddressType, abi: "MethodABI", *args, **kwargs
) -> "TransactionAPI":
"""
Encode a transaction object from a contract function's ABI and call arguments.
Additionally, update the transaction arguments with the overrides in ``kwargs``.
Ar... |
Encode a transaction object from a contract function's ABI and call arguments.
Additionally, update the transaction arguments with the overrides in ``kwargs``.
Args:
address (:class:`~ape.types.address.AddressType`): The address of the contract.
abi (``MethodABI``): The... | encode_transaction | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def decode_logs(self, logs: Sequence[dict], *events: "EventABI") -> Iterator["ContractLog"]:
"""
Decode any contract logs that match the given event ABI from the raw log data.
Args:
logs (Sequence[dict]): A list of raw log data from the chain.
*events (EventABI): Event d... |
Decode any contract logs that match the given event ABI from the raw log data.
Args:
logs (Sequence[dict]): A list of raw log data from the chain.
*events (EventABI): Event definitions to decode.
Returns:
Iterator[:class:`~ape.types.ContractLog`]
| decode_logs | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def create_transaction(self, **kwargs) -> "TransactionAPI":
"""
Create a transaction using key-value arguments.
Args:
**kwargs: Everything the transaction needs initialize.
Returns:
class:`~ape.api.transactions.TransactionAPI`
""" |
Create a transaction using key-value arguments.
Args:
**kwargs: Everything the transaction needs initialize.
Returns:
class:`~ape.api.transactions.TransactionAPI`
| create_transaction | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def decode_calldata(self, abi: Union["ConstructorABI", "MethodABI"], calldata: bytes) -> dict:
"""
Decode method calldata.
Args:
abi (Union[ConstructorABI, MethodABI]): The method called.
calldata (bytes): The raw calldata bytes.
Returns:
Dict: A map... |
Decode method calldata.
Args:
abi (Union[ConstructorABI, MethodABI]): The method called.
calldata (bytes): The raw calldata bytes.
Returns:
Dict: A mapping of input names to decoded values.
If an input is anonymous, it should use the stringified... | decode_calldata | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def encode_calldata(self, abi: Union["ConstructorABI", "MethodABI"], *args: Any) -> HexBytes:
"""
Encode method calldata.
Args:
abi (Union[ConstructorABI, MethodABI]): The ABI of the method called.
*args (Any): The arguments given to the method.
Returns:
... |
Encode method calldata.
Args:
abi (Union[ConstructorABI, MethodABI]): The ABI of the method called.
*args (Any): The arguments given to the method.
Returns:
HexBytes: The encoded calldata of the arguments to the given method.
| encode_calldata | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def decode_returndata(self, abi: "MethodABI", raw_data: bytes) -> Any:
"""
Get the result of a contract call.
Arg:
abi (MethodABI): The method called.
raw_data (bytes): Raw returned data.
Returns:
Any: All of the values returned from the contract fun... |
Get the result of a contract call.
Arg:
abi (MethodABI): The method called.
raw_data (bytes): Raw returned data.
Returns:
Any: All of the values returned from the contract function.
| decode_returndata | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def get_deployment_address( # type: ignore[empty-body]
self,
address: AddressType,
nonce: int,
) -> AddressType:
"""
Calculate the deployment address of a contract before it is deployed.
This is useful if the address is an argument to another contract's deployment
... |
Calculate the deployment address of a contract before it is deployed.
This is useful if the address is an argument to another contract's deployment
and you have not yet deployed the first contract yet.
| get_deployment_address | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def get_network(self, network_name: str) -> "NetworkAPI":
"""
Get the network for the given name.
Args:
network_name (str): The name of the network to get.
Raises:
:class:`~ape.exceptions.NetworkNotFoundError`: When the network is not present.
Returns:
... |
Get the network for the given name.
Args:
network_name (str): The name of the network to get.
Raises:
:class:`~ape.exceptions.NetworkNotFoundError`: When the network is not present.
Returns:
:class:`~ape.api.networks.NetworkAPI`
| get_network | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def get_network_data(
self, network_name: str, provider_filter: Optional[Collection[str]] = None
) -> dict:
"""
Get a dictionary of data about providers in the network.
**NOTE**: The keys are added in an opinionated order for nicely
translating into ``yaml``.
Args:
... |
Get a dictionary of data about providers in the network.
**NOTE**: The keys are added in an opinionated order for nicely
translating into ``yaml``.
Args:
network_name (str): The name of the network to get provider data from.
provider_filter (Optional[Collection... | get_network_data | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def get_python_types( # type: ignore[empty-body]
self, abi_type: "ABIType"
) -> Union[type, Sequence]:
"""
Get the Python types for a given ABI type.
Args:
abi_type (``ABIType``): The ABI type to get the Python types for.
Returns:
Union[Type, Sequen... |
Get the Python types for a given ABI type.
Args:
abi_type (``ABIType``): The ABI type to get the Python types for.
Returns:
Union[Type, Sequence]: The Python types for the given ABI type.
| get_python_types | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def decode_custom_error(
self,
data: HexBytes,
address: AddressType,
**kwargs,
) -> Optional[CustomError]:
"""
Decode a custom error class from an ABI defined in a contract.
Args:
data (HexBytes): The error data containing the selector
... |
Decode a custom error class from an ABI defined in a contract.
Args:
data (HexBytes): The error data containing the selector
and input data.
address (AddressType): The address of the contract containing
the error.
**kwargs: Additional ini... | decode_custom_error | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def chain_id(self) -> int:
"""
The ID of the blockchain.
**NOTE**: Unless overridden, returns same as
:py:attr:`ape.api.providers.ProviderAPI.chain_id`.
"""
if (
self.provider.network.name == self.name
and self.provider.network.ecosystem.name == s... |
The ID of the blockchain.
**NOTE**: Unless overridden, returns same as
:py:attr:`ape.api.providers.ProviderAPI.chain_id`.
| chain_id | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def transaction_acceptance_timeout(self) -> int:
"""
The amount of time to wait for a transaction to be accepted on the network.
Does not include waiting for block-confirmations. Defaults to two minutes.
Local networks use smaller timeouts.
"""
return self.config.get(
... |
The amount of time to wait for a transaction to be accepted on the network.
Does not include waiting for block-confirmations. Defaults to two minutes.
Local networks use smaller timeouts.
| transaction_acceptance_timeout | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def explorer(self) -> Optional["ExplorerAPI"]:
"""
The block-explorer for the given network.
Returns:
:class:`ape.api.explorers.ExplorerAPI`, optional
"""
chain_id = None if self.network_manager.active_provider is None else self.provider.chain_id
for plugin_n... |
The block-explorer for the given network.
Returns:
:class:`ape.api.explorers.ExplorerAPI`, optional
| explorer | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def is_mainnet(self) -> bool:
"""
True when the network is the mainnet network for the ecosystem.
"""
cfg_is_mainnet: Optional[bool] = self.config.get("is_mainnet")
if cfg_is_mainnet is not None:
return cfg_is_mainnet
return self.name == "mainnet" |
True when the network is the mainnet network for the ecosystem.
| is_mainnet | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def providers(self): # -> dict[str, Partial[ProviderAPI]]
"""
The providers of the network, such as Infura, Alchemy, or Node.
Returns:
dict[str, partial[:class:`~ape.api.providers.ProviderAPI`]]
"""
providers = {}
for _, plugin_tuple in self._get_plugin_prov... |
The providers of the network, such as Infura, Alchemy, or Node.
Returns:
dict[str, partial[:class:`~ape.api.providers.ProviderAPI`]]
| providers | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def get_provider(
self,
provider_name: Optional[str] = None,
provider_settings: Optional[dict] = None,
connect: bool = False,
):
"""
Get a provider for the given name. If given ``None``, returns the default provider.
Args:
provider_name (str, opti... |
Get a provider for the given name. If given ``None``, returns the default provider.
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): Setting... | get_provider | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def use_provider(
self,
provider: Union[str, "ProviderAPI"],
provider_settings: Optional[dict] = None,
disconnect_after: bool = False,
disconnect_on_exit: bool = True,
) -> ProviderContextManager:
"""
Use and connect to a provider in a temporary context. When ... |
Use and connect to a provider in a temporary context. When entering the context, it calls
method :meth:`ape.api.providers.ProviderAPI.connect` and when exiting, it calls
method :meth:`ape.api.providers.ProviderAPI.disconnect`.
Usage example::
from ape import networks
... | use_provider | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def default_provider_name(self) -> Optional[str]:
"""
The name of the default provider or ``None``.
Returns:
Optional[str]
"""
provider_from_config: str
if provider := self._default_provider:
# Was set programmatically.
return provide... |
The name of the default provider or ``None``.
Returns:
Optional[str]
| default_provider_name | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def set_default_provider(self, provider_name: str):
"""
Change the default provider.
Raises:
:class:`~ape.exceptions.NetworkError`: When the given provider is not found.
Args:
provider_name (str): The name of the provider to switch to.
"""
if pr... |
Change the default provider.
Raises:
:class:`~ape.exceptions.NetworkError`: When the given provider is not found.
Args:
provider_name (str): The name of the provider to switch to.
| set_default_provider | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def use_default_provider(
self,
provider_settings: Optional[dict] = None,
disconnect_after: bool = False,
) -> ProviderContextManager:
"""
Temporarily connect and use the default provider. When entering the context, it calls
method :meth:`ape.api.providers.ProviderAPI... |
Temporarily connect and use the default provider. When entering the context, it calls
method :meth:`ape.api.providers.ProviderAPI.connect` and when exiting, it calls
method :meth:`ape.api.providers.ProviderAPI.disconnect`.
**NOTE**: If multiple providers exist, uses whatever was "first... | use_default_provider | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def publish_contract(self, address: AddressType):
"""
A convenience method to publish a contract to the explorer.
Raises:
:class:`~ape.exceptions.NetworkError`: When there is no explorer for this network.
Args:
address (:class:`~ape.types.address.AddressType`): ... |
A convenience method to publish a contract to the explorer.
Raises:
:class:`~ape.exceptions.NetworkError`: When there is no explorer for this network.
Args:
address (:class:`~ape.types.address.AddressType`): The address of the contract.
| publish_contract | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def verify_chain_id(self, chain_id: int):
"""
Verify a chain ID for this network.
Args:
chain_id (int): The chain ID to verify.
Raises:
:class:`~ape.exceptions.NetworkMismatchError`: When the network is
not local or adhoc and has a different hardco... |
Verify a chain ID for this network.
Args:
chain_id (int): The chain ID to verify.
Raises:
:class:`~ape.exceptions.NetworkMismatchError`: When the network is
not local or adhoc and has a different hardcoded chain ID than
the given one.
... | verify_chain_id | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def upstream_provider(self) -> "UpstreamProvider":
"""
The provider used when requesting data before the local fork.
Set this in your config under the network settings.
When not set, will attempt to use the default provider, if one
exists.
"""
config_choice: str =... |
The provider used when requesting data before the local fork.
Set this in your config under the network settings.
When not set, will attempt to use the default provider, if one
exists.
| upstream_provider | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def create_network_type(chain_id: int, network_id: int, is_fork: bool = False) -> type[NetworkAPI]:
"""
Easily create a :class:`~ape.api.networks.NetworkAPI` subclass.
"""
BaseNetwork = ForkedNetworkAPI if is_fork else NetworkAPI
class network_def(BaseNetwork): # type: ignore
@property
... |
Easily create a :class:`~ape.api.networks.NetworkAPI` subclass.
| create_network_type | python | ApeWorX/ape | src/ape/api/networks.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/networks.py | Apache-2.0 |
def package_id(self) -> str:
"""
The full name of the package, used for storage.
Example: ``OpenZeppelin/openzeppelin-contracts``.
""" |
The full name of the package, used for storage.
Example: ``OpenZeppelin/openzeppelin-contracts``.
| package_id | python | ApeWorX/ape | src/ape/api/projects.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/projects.py | Apache-2.0 |
def version_id(self) -> str:
"""
The ID to use as the sub-directory in the download cache.
Most often, this is either a version number or a branch name.
""" |
The ID to use as the sub-directory in the download cache.
Most often, this is either a version number or a branch name.
| version_id | python | ApeWorX/ape | src/ape/api/projects.py | https://github.com/ApeWorX/ape/blob/master/src/ape/api/projects.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.