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_interpolate_layout_GPOS_only_LookupType_3_same_val_ttf(self):
"""Only GPOS; LookupType 3; same values in all masters."""
suffix = ".ttf"
ds_path = self.get_test_input("InterpolateLayout.designspace")
ufo_dir = self.get_test_input("master_ufo")
ttx_dir = self.get_t... | Only GPOS; LookupType 3; same values in all masters. | test_varlib_interpolate_layout_GPOS_only_LookupType_3_same_val_ttf | python | fonttools/fonttools | Tests/varLib/interpolate_layout_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py | MIT |
def test_varlib_interpolate_layout_GPOS_only_LookupType_3_diff_val_ttf(self):
"""Only GPOS; LookupType 3; different values in each master."""
suffix = ".ttf"
ds_path = self.get_test_input("InterpolateLayout.designspace")
ufo_dir = self.get_test_input("master_ufo")
ttx_dir = self.... | Only GPOS; LookupType 3; different values in each master. | test_varlib_interpolate_layout_GPOS_only_LookupType_3_diff_val_ttf | python | fonttools/fonttools | Tests/varLib/interpolate_layout_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py | MIT |
def test_varlib_interpolate_layout_GPOS_only_LookupType_4_same_val_ttf(self):
"""Only GPOS; LookupType 4; same values in all masters."""
suffix = ".ttf"
ds_path = self.get_test_input("InterpolateLayout.designspace")
ufo_dir = self.get_test_input("master_ufo")
ttx_dir = self.get_t... | Only GPOS; LookupType 4; same values in all masters. | test_varlib_interpolate_layout_GPOS_only_LookupType_4_same_val_ttf | python | fonttools/fonttools | Tests/varLib/interpolate_layout_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py | MIT |
def test_varlib_interpolate_layout_GPOS_only_LookupType_4_diff_val_ttf(self):
"""Only GPOS; LookupType 4; different values in each master."""
suffix = ".ttf"
ds_path = self.get_test_input("InterpolateLayout.designspace")
ufo_dir = self.get_test_input("master_ufo")
ttx_dir = self.... | Only GPOS; LookupType 4; different values in each master. | test_varlib_interpolate_layout_GPOS_only_LookupType_4_diff_val_ttf | python | fonttools/fonttools | Tests/varLib/interpolate_layout_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py | MIT |
def test_varlib_interpolate_layout_GPOS_only_LookupType_5_same_val_ttf(self):
"""Only GPOS; LookupType 5; same values in all masters."""
suffix = ".ttf"
ds_path = self.get_test_input("InterpolateLayout.designspace")
ufo_dir = self.get_test_input("master_ufo")
ttx_dir = self.get_t... | Only GPOS; LookupType 5; same values in all masters. | test_varlib_interpolate_layout_GPOS_only_LookupType_5_same_val_ttf | python | fonttools/fonttools | Tests/varLib/interpolate_layout_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py | MIT |
def test_varlib_interpolate_layout_GPOS_only_LookupType_5_diff_val_ttf(self):
"""Only GPOS; LookupType 5; different values in each master."""
suffix = ".ttf"
ds_path = self.get_test_input("InterpolateLayout.designspace")
ufo_dir = self.get_test_input("master_ufo")
ttx_dir = self.... | Only GPOS; LookupType 5; different values in each master. | test_varlib_interpolate_layout_GPOS_only_LookupType_5_diff_val_ttf | python | fonttools/fonttools | Tests/varLib/interpolate_layout_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py | MIT |
def test_varlib_interpolate_layout_GPOS_only_LookupType_6_same_val_ttf(self):
"""Only GPOS; LookupType 6; same values in all masters."""
suffix = ".ttf"
ds_path = self.get_test_input("InterpolateLayout.designspace")
ufo_dir = self.get_test_input("master_ufo")
ttx_dir = self.get_t... | Only GPOS; LookupType 6; same values in all masters. | test_varlib_interpolate_layout_GPOS_only_LookupType_6_same_val_ttf | python | fonttools/fonttools | Tests/varLib/interpolate_layout_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py | MIT |
def test_varlib_interpolate_layout_GPOS_only_LookupType_6_diff_val_ttf(self):
"""Only GPOS; LookupType 6; different values in each master."""
suffix = ".ttf"
ds_path = self.get_test_input("InterpolateLayout.designspace")
ufo_dir = self.get_test_input("master_ufo")
ttx_dir = self.... | Only GPOS; LookupType 6; different values in each master. | test_varlib_interpolate_layout_GPOS_only_LookupType_6_diff_val_ttf | python | fonttools/fonttools | Tests/varLib/interpolate_layout_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py | MIT |
def test_varlib_interpolate_layout_GPOS_only_LookupType_7_same_val_ttf(self):
"""Only GPOS; LookupType 7; same values in all masters."""
suffix = ".ttf"
ds_path = self.get_test_input("InterpolateLayout.designspace")
ufo_dir = self.get_test_input("master_ufo")
ttx_dir = self.get_t... | Only GPOS; LookupType 7; same values in all masters. | test_varlib_interpolate_layout_GPOS_only_LookupType_7_same_val_ttf | python | fonttools/fonttools | Tests/varLib/interpolate_layout_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py | MIT |
def test_varlib_interpolate_layout_GPOS_only_LookupType_7_diff_val_ttf(self):
"""Only GPOS; LookupType 7; different values in each master."""
suffix = ".ttf"
ds_path = self.get_test_input("InterpolateLayout.designspace")
ufo_dir = self.get_test_input("master_ufo")
ttx_dir = self.... | Only GPOS; LookupType 7; different values in each master. | test_varlib_interpolate_layout_GPOS_only_LookupType_7_diff_val_ttf | python | fonttools/fonttools | Tests/varLib/interpolate_layout_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py | MIT |
def test_varlib_interpolate_layout_GPOS_only_LookupType_8_same_val_ttf(self):
"""Only GPOS; LookupType 8; same values in all masters."""
suffix = ".ttf"
ds_path = self.get_test_input("InterpolateLayout.designspace")
ufo_dir = self.get_test_input("master_ufo")
ttx_dir = self.get_t... | Only GPOS; LookupType 8; same values in all masters. | test_varlib_interpolate_layout_GPOS_only_LookupType_8_same_val_ttf | python | fonttools/fonttools | Tests/varLib/interpolate_layout_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py | MIT |
def test_varlib_interpolate_layout_GPOS_only_LookupType_8_diff_val_ttf(self):
"""Only GPOS; LookupType 8; different values in each master."""
suffix = ".ttf"
ds_path = self.get_test_input("InterpolateLayout.designspace")
ufo_dir = self.get_test_input("master_ufo")
ttx_dir = self.... | Only GPOS; LookupType 8; different values in each master. | test_varlib_interpolate_layout_GPOS_only_LookupType_8_diff_val_ttf | python | fonttools/fonttools | Tests/varLib/interpolate_layout_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py | MIT |
def reload_font(font):
"""(De)serialize to get final binary layout."""
buf = BytesIO()
font.save(buf)
# Close the font to release filesystem resources so that on Windows the tearDown
# method can successfully remove the temporary directory created during setUp.
font.close()
buf.seek(0)
r... | (De)serialize to get final binary layout. | reload_font | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_build_ttf_reuse_nameid_2(self):
"""Instances at the default location can reuse name ID 2 or 17."""
self._run_varlib_build_test(
designspace_name="BuildReuseNameId2",
font_name="TestFamily",
tables=["fvar"],
expected_ttx_name="BuildReuseName... | Instances at the default location can reuse name ID 2 or 17. | test_varlib_build_ttf_reuse_nameid_2 | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_build_no_axes_ttf(self):
"""Designspace file does not contain an <axes> element."""
ds_path = self.get_test_input("InterpolateLayout3.designspace")
with self.assertRaisesRegex(DesignSpaceDocumentError, "No axes defined"):
build(ds_path) | Designspace file does not contain an <axes> element. | test_varlib_build_no_axes_ttf | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_avar_single_axis(self):
"""Designspace file contains a 'weight' axis with <map> elements
modifying the normalization mapping. An 'avar' table is generated.
"""
test_name = "BuildAvarSingleAxis"
self._run_varlib_build_test(
designspace_name=test_name,
... | Designspace file contains a 'weight' axis with <map> elements
modifying the normalization mapping. An 'avar' table is generated.
| test_varlib_avar_single_axis | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_avar_with_identity_maps(self):
"""Designspace file contains two 'weight' and 'width' axes both with
<map> elements.
The 'width' axis only contains identity mappings, however the resulting
avar segment will not be empty but will contain the default axis value
maps... | Designspace file contains two 'weight' and 'width' axes both with
<map> elements.
The 'width' axis only contains identity mappings, however the resulting
avar segment will not be empty but will contain the default axis value
maps: {-1.0: -1.0, 0.0: 0.0, 1.0: 1.0}.
This is to wo... | test_varlib_avar_with_identity_maps | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_avar_empty_axis(self):
"""Designspace file contains two 'weight' and 'width' axes, but
only one axis ('weight') has some <map> elements.
Even if no <map> elements are defined for the 'width' axis, the
resulting avar segment still contains the default axis value maps:
... | Designspace file contains two 'weight' and 'width' axes, but
only one axis ('weight') has some <map> elements.
Even if no <map> elements are defined for the 'width' axis, the
resulting avar segment still contains the default axis value maps:
{-1.0: -1.0, 0.0: 0.0, 1.0: 1.0}.
Th... | test_varlib_avar_empty_axis | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_avar2(self):
"""Designspace file contains a 'weight' axis with <map> elements
modifying the normalization mapping as well as <mappings> element
modifying it post-normalization. An 'avar' table is generated.
"""
test_name = "BuildAvar2"
self._run_varlib_bui... | Designspace file contains a 'weight' axis with <map> elements
modifying the normalization mapping as well as <mappings> element
modifying it post-normalization. An 'avar' table is generated.
| test_varlib_avar2 | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_build_feature_variations(self):
"""Designspace file contains <rules> element, used to build
GSUB FeatureVariations table.
"""
self._run_varlib_build_test(
designspace_name="FeatureVars",
font_name="TestFamily",
tables=["fvar", "GSUB"],
... | Designspace file contains <rules> element, used to build
GSUB FeatureVariations table.
| test_varlib_build_feature_variations | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_build_feature_variations_whole_range(self):
"""Designspace file contains <rules> element specifying the entire design
space, used to build GSUB FeatureVariations table.
"""
self._run_varlib_build_test(
designspace_name="FeatureVarsWholeRange",
font... | Designspace file contains <rules> element specifying the entire design
space, used to build GSUB FeatureVariations table.
| test_varlib_build_feature_variations_whole_range | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_build_feature_variations_whole_range_empty(self):
"""Designspace file contains <rules> element without a condition, specifying
the entire design space, used to build GSUB FeatureVariations table.
"""
self._run_varlib_build_test(
designspace_name="FeatureVarsWh... | Designspace file contains <rules> element without a condition, specifying
the entire design space, used to build GSUB FeatureVariations table.
| test_varlib_build_feature_variations_whole_range_empty | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_build_feature_variations_with_existing_rclt(self):
"""Designspace file contains <rules> element, used to build GSUB
FeatureVariations table. <rules> is specified to do its OT processing
"last", so a 'rclt' feature will be used or created. This test covers
the case when a ... | Designspace file contains <rules> element, used to build GSUB
FeatureVariations table. <rules> is specified to do its OT processing
"last", so a 'rclt' feature will be used or created. This test covers
the case when a 'rclt' already exists in the masters.
We dynamically add a 'rclt' fea... | test_varlib_build_feature_variations_with_existing_rclt | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_build_feature_variations_without_latn_dflt_feature(self):
"""Test that when a script does not have a dflt language, it gets one
when we later add variations, we can attach them to it."""
def add_features(font, savepath):
features = """
languagesystem DFLT... | Test that when a script does not have a dflt language, it gets one
when we later add variations, we can attach them to it. | test_varlib_build_feature_variations_without_latn_dflt_feature | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.