generated from ApeWorX/project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
89 additions
and
11 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from ape import plugins | ||
|
||
from ape_subsquid.query import SubsquidQueryEngine | ||
|
||
|
||
@plugins.register(plugins.QueryPlugin) | ||
def query_engines(): | ||
yield SubsquidQueryEngine |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from typing import Iterator, Optional | ||
|
||
from ape.api.query import ( | ||
AccountTransactionQuery, | ||
BlockQuery, | ||
BlockTransactionQuery, | ||
ContractCreationQuery, | ||
ContractEventQuery, | ||
QueryAPI, | ||
QueryType, | ||
) | ||
from ape.exceptions import QueryEngineError | ||
from ape.utils import singledispatchmethod | ||
|
||
|
||
class SubsquidQueryEngine(QueryAPI): | ||
@singledispatchmethod | ||
def estimate_query(self, query: QueryType) -> Optional[int]: | ||
return None | ||
|
||
@estimate_query.register | ||
def estimate_block_query(self, query: BlockQuery) -> int: | ||
router_ms = 400 | ||
query_ms = 300 | ||
return router_ms + query_ms | ||
|
||
@estimate_query.register | ||
def estimate_block_transaction_query(self, query: BlockTransactionQuery) -> int: | ||
router_ms = 400 | ||
query_ms = 1500 | ||
return router_ms + query_ms | ||
|
||
@estimate_query.register | ||
def estimate_account_transaction_query(self, query: AccountTransactionQuery) -> int: | ||
return 0 | ||
|
||
@estimate_query.register | ||
def estimate_contract_creation_query(self, query: ContractCreationQuery) -> int: | ||
return 0 | ||
|
||
@estimate_query.register | ||
def estimate_contract_event_query(self, query: ContractEventQuery) -> int: | ||
router_ms = 400 | ||
query_ms = 400 + (1 + query.stop_block - query.start_block) * 1.4 | ||
return router_ms + query_ms | ||
|
||
@singledispatchmethod | ||
def perform_query(self, query: QueryType) -> Iterator: | ||
raise QueryEngineError( | ||
f"{self.__class__.__name__} cannot handle {query.__class__.__name__} queries." | ||
) | ||
|
||
@perform_query.register | ||
def perform_block_query(self, query: BlockQuery): | ||
return None | ||
|
||
@perform_query.register | ||
def perform_block_transaction_query(self, query: BlockTransactionQuery): | ||
return None | ||
|
||
@perform_query.register | ||
def perform_account_transaction_query(self, query: AccountTransactionQuery): | ||
return None | ||
|
||
@perform_query.register | ||
def perform_contract_creation_query(self, query: ContractCreationQuery): | ||
return None | ||
|
||
@perform_query.register | ||
def perform_contract_event_query(self, query: ContractEventQuery): | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,25 +50,25 @@ | |
|
||
|
||
setup( | ||
name="<PYPI_NAME>", | ||
name="ape-subsquid", | ||
use_scm_version=True, | ||
setup_requires=["setuptools_scm"], | ||
description="""<PYPI_NAME>: <SHORT_DESCRIPTION>""", | ||
description="""ape-subsquid: <SHORT_DESCRIPTION>""", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
author="ApeWorX Ltd.", | ||
author_email="[email protected]", | ||
url="https://github.com/ApeWorX/<REPO_NAME>", | ||
include_package_data=True, | ||
install_requires=[], | ||
install_requires=["eth-ape>=0.6.27,<0.7"], | ||
python_requires=">=3.8,<4", | ||
extras_require=extras_require, | ||
py_modules=["<MODULE_NAME>"], | ||
py_modules=["ape_subsquid"], | ||
license="Apache-2.0", | ||
zip_safe=False, | ||
keywords="ethereum", | ||
packages=find_packages(exclude=["tests", "tests.*"]), | ||
package_data={"<MODULE_NAME>": ["py.typed"]}, | ||
package_data={"ape_subsquid": ["py.typed"]}, | ||
classifiers=[ | ||
"Development Status :: 5 - Production/Stable", | ||
"Intended Audience :: Developers", | ||
|