ape.plugins
- ape.plugins.register(plugin_type: type[PluginType], **hookimpl_kwargs) Callable
Register your plugin to ape. You must call this decorator to get your plugins included in ape’s plugin ecosystem.
Usage example:
@plugins.register(plugins.AccountPlugin) # 'register()' example def account_types(): return AccountContainer, KeyfileAccount
- Parameters:
plugin_type (type[
PluginType]) – The plugin type to register.hookimpl_kwargs – Return-values required by the plugin type.
- Returns:
Callable
Base
- class ape.plugins.pluggy_patch.PluginType
Bases:
objectThe base plugin class in ape. There are several types of plugins available in ape, such as the
ConfigorEcosystemPlugin. Each one of them subclass this class. It is used to namespace the plugin hooks for the registration process, and to ensure overall conformance to type interfaces as much as possible.
- ape.plugins.pluggy_patch.plugin_manager = <pluggy._manager.PluginManager object>
A manager responsible for registering and accessing plugins (singleton).
Accounts
- class ape.plugins.account.AccountPlugin
Bases:
PluginTypeAn account-related plugin. The plugin must register both an
ape.api.accounts.AccountContainerAPIas well as anape.api.accounts.AccountAPI.- account_types() tuple[type[AccountContainerAPI], type[AccountAPI]]
A hook for returning a tuple of an account container and an account type. Each account-base plugin defines and returns their own types here.
Usage example:
@plugins.register(plugins.AccountPlugin) def account_types(): return AccountContainer, KeyfileAccount
- Returns:
tuple[type[
AccountContainerAPI], type[AccountAPI]]
Compiler
- class ape.plugins.compiler.CompilerPlugin
Bases:
PluginTypeA plugin that implements the
ape.api.CompilerAPI, such as the ape-solidity plugin or the ape-vyper plugin.- register_compiler() tuple[tuple[str], type[CompilerAPI]]
A hook for returning the set of file extensions the plugin handles and the compiler class that can be used to compile them.
Usage example:
@plugins.register(plugins.CompilerPlugin) def register_compiler(): return (".json",), InterfaceCompiler
- Returns:
tuple[tuple[str], type[
CompilerAPI]]
Config
- class ape.plugins.config.Config
Bases:
PluginTypeA registered config item. Plugins register config implementations when they allow additional user-configuration, set in the
ape-config.yaml. See theConfigManagerdocumentation for more information on theape-config.yaml.- config_class() type[PluginConfig]
A hook that returns a
PluginConfigparser class that can be used to deconstruct the user config options for this plugins.NOTE: If none are specified, all injected
ape.api.config.PluginConfig’s are empty.Usage example:
@plugins.register(plugins.Config) def config_class(): return MyPluginConfig
- Returns:
type[
PluginConfig]
Converter
- class ape.plugins.converter.ConversionPlugin
Bases:
PluginTypeA plugin for converting values. The ape-ens plugin is an example of a conversion-plugin.
- converters() Iterator[tuple[str, type[ConverterAPI]]]
A hook that returns an iterator of tuples of a string ABI type and a
ConverterAPIsubclass.Usage example:
@plugins.register(plugins.ConversionPlugin) def converters(): yield int, MweiConversions
- Returns:
Iterator[tuple[str, type[
ConverterAPI]]]
Network
- class ape.plugins.network.EcosystemPlugin
Bases:
PluginTypeAn ecosystem plugin, such as
ape-ethereum. See theape.api.networks.EcosystemAPIfor more information on what is required to implement an ecosystem plugin.- ecosystems() Iterator[type[EcosystemAPI]]
A hook that must return an iterator of
ape.api.networks.EcosystemAPIsubclasses.Usage example:
@plugins.register(plugins.EcosystemPlugin) def ecosystems(): yield Ethereum
- Returns:
Iterator[type[
EcosystemAPI]]
- class ape.plugins.network.ExplorerPlugin
Bases:
PluginTypeA plugin for a blockchain explorer, such as ape-etherscan.
- explorers() Iterator[tuple[str, str, type[ExplorerAPI]]]
A hook that must return an iterator of tuples of:
the target ecosystem plugin’s name
the network it works with (which must be valid network in the ecosystem)
a
ExplorerAPIsubclass
Usage example:
@plugins.register(plugins.ExplorerPlugin) def explorers(): yield "ethereum", "mainnet", MyBlockExplorer
- Returns:
Iterator[tuple[str, str, type[
ape.api.explorers.ExplorerAPI]]]
- class ape.plugins.network.NetworkPlugin
Bases:
PluginTypeA network plugin, such as
mainnetorropsten. Likely, registering networks will happen soon after registering the ecosystem, as an ecosystem requires networks.- networks() Iterator[tuple[str, str, type[NetworkAPI]]]
A hook that must return an iterator of tuples of:
the target ecosystem plugin’s name
the network name
a
ape.api.networks.NetworkAPIsubclass
Usage example:
@plugins.register(plugins.NetworkPlugin) def networks(): yield "ethereum", "ShibaChain", ShibaNetwork
- Returns:
Iterator[tuple[str, str, type[
NetworkAPI]]]
- class ape.plugins.network.ProviderPlugin
Bases:
PluginTypeA plugin representing a network provider, which is the main API responsible for making requests against a blockchain. Example provider plugins projects include ape-infura as well as ape-alchemy.
- providers() Iterator[tuple[str, str, type[ProviderAPI]]]
A hook that must return an iterator of tuples of:
the target ecosystem plugin’s name
the network it works with (which must be valid network in the ecosystem)
a
ape.api.providers.ProviderAPIsubclass
Usage example:
@plugins.register(plugins.ProviderPlugin) def providers(): yield "ethereum", "local", MyProvider
- Returns:
Iterator[tuple[str, str, type[
ProviderAPI]]]
Project
- class ape.plugins.project.DependencyPlugin
Bases:
PluginTypeA plugin for downloading packages and creating
ProjectPluginimplementations.- dependencies() dict[str, type[DependencyAPI]]
A hook that returns a
DependencyAPImapped to itsape-config.yamlfile dependencies special key. For example, when configuring GitHub dependencies, you set thegithubkey in thedependencies:block of yourape-config.yamlfile and it will automatically use thisDependencyAPIimplementation.- Returns:
type[
DependencyAPI]
- class ape.plugins.project.ProjectPlugin
Bases:
PluginTypeA plugin for converting files to a
PackageManifest. The default project plugin is theApeProject. Otherwise, you can define your own project implementation for converting a set of files to aPackageManifest, such as one that resolves dependencies via.gitmodules.- projects() Iterator[type[ProjectAPI]]
A hook that returns a
ProjectAPIsubclass type.- Returns:
type[
ProjectAPI]
Query
- class ape.plugins.query.QueryPlugin
Bases:
PluginTypeA plugin for querying chains.