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:
object
The base plugin class in ape. There are several types of plugins available in ape, such as the
Config
orEcosystemPlugin
. 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:
PluginType
An account-related plugin. The plugin must register both an
ape.api.accounts.AccountContainerAPI
as 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:
PluginType
A 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:
PluginType
A registered config item. Plugins register config implementations when they allow additional user-configuration, set in the
ape-config.yaml
. See theConfigManager
documentation for more information on theape-config.yaml
.- config_class() type[PluginConfig]
A hook that returns a
PluginConfig
parser 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:
PluginType
A 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
ConverterAPI
subclass.Usage example:
@plugins.register(plugins.ConversionPlugin) def converters(): yield int, MweiConversions
- Returns:
Iterator[tuple[str, type[
ConverterAPI
]]]
Network
- class ape.plugins.network.EcosystemPlugin
Bases:
PluginType
An ecosystem plugin, such as
ape-ethereum
. See theape.api.networks.EcosystemAPI
for 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.EcosystemAPI
subclasses.Usage example:
@plugins.register(plugins.EcosystemPlugin) def ecosystems(): yield Ethereum
- Returns:
Iterator[type[
EcosystemAPI
]]
- class ape.plugins.network.ExplorerPlugin
Bases:
PluginType
A 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
ExplorerAPI
subclass
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:
PluginType
A network plugin, such as
mainnet
orropsten
. 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.NetworkAPI
subclass
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:
PluginType
A 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.ProviderAPI
subclass
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:
PluginType
A plugin for downloading packages and creating
ProjectPlugin
implementations.- dependencies() dict[str, type[DependencyAPI]]
A hook that returns a
DependencyAPI
mapped to itsape-config.yaml
file dependencies special key. For example, when configuring GitHub dependencies, you set thegithub
key in thedependencies:
block of yourape-config.yaml
file and it will automatically use thisDependencyAPI
implementation.- Returns:
type[
DependencyAPI
]
- class ape.plugins.project.ProjectPlugin
Bases:
PluginType
A 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
ProjectAPI
subclass type.- Returns:
type[
ProjectAPI
]
Query
- class ape.plugins.query.QueryPlugin
Bases:
PluginType
A plugin for querying chains.