Skip to content

Commit

Permalink
refactor: upgrade to 0.1.0 (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Mar 11, 2022
1 parent 9010764 commit dc9d7b7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ ape console --network ethereum:goerli:infura

## Development

This project is in development and should be considered a beta.
Things might not be in their final state and breaking changes may occur.
Please see the [contributing guide](CONTRIBUTING.md) to learn more how to contribute to this project.
Comments, questions, criticisms and pull requests are welcomed.

## License
Expand Down
14 changes: 12 additions & 2 deletions ape_infura/providers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from typing import Dict

from ape.api import ReceiptAPI, TransactionAPI, UpstreamProvider, Web3Provider
from ape.exceptions import ContractLogicError, ProviderError, TransactionError, VirtualMachineError
Expand All @@ -24,7 +25,14 @@ def __init__(self):


class Infura(Web3Provider, UpstreamProvider):
def __post_init__(self):
network_uris: Dict[str, str] = {}

@property
def uri(self) -> str:
network_name = self.network.name
if network_name in self.network_uris:
return self.network_uris[network_name]

key = None
for env_var_name in _ENVIRONMENT_VARIABLE_NAMES:
env_var = os.environ.get(env_var_name)
Expand All @@ -35,7 +43,9 @@ def __post_init__(self):
if not key:
raise MissingProjectKeyError()

self.uri = f"https://{self.network.name}.infura.io/v3/{key}"
network_uri = f"https://{self.network.name}.infura.io/v3/{key}"
self.network_uris[network_name] = network_uri
return network_uri

@property
def connection_str(self) -> str:
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@
url="https://github.com/ApeWorX/ape-infura",
include_package_data=True,
install_requires=[
"eth-ape>=0.1.0b3",
"eth-ape>=0.1.0,<0.2.0",
"importlib-metadata ; python_version<'3.8'",
], # NOTE: Add 3rd party libraries here
python_requires=">=3.7,<4",
python_requires=">=3.7.2,<4",
extras_require=extras_require,
py_modules=["ape_infura"],
license="Apache-2.0",
Expand All @@ -72,7 +72,7 @@
packages=find_packages(exclude=["tests", "tests.*"]),
package_data={"ape_infura": ["py.typed"]},
classifiers=[
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
Expand All @@ -82,5 +82,6 @@
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
)
Empty file removed tests/.gitkeep
Empty file.

0 comments on commit dc9d7b7

Please sign in to comment.