Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle ecosystems and networks that have incompatible naming to … #3

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ape_subsquid/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ def _retry(self, request: Callable[..., T], *args, **kwargs) -> T:
return response

def _is_retryable_error(self, error: HTTPError) -> bool:
assert error.response
assert error.response is not None
return error.response.status_code == 503

def _raise_error(self, error: HTTPError) -> ApeSubsquidError:
assert error.response
assert error.response is not None
text = error.response.text
if "not ready to serve block" in text:
raise NotReadyToServeError(text)
Expand Down
14 changes: 14 additions & 0 deletions ape_subsquid/networks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from ape.api.query import QueryAPI


def get_network(engine: QueryAPI) -> str:
ecosystem_name = engine.network_manager.ecosystem.name
network_name = engine.network_manager.network.name

if ecosystem_name == "bsc":
ecosystem_name = "binance"
elif ecosystem_name == "arbitrum":
if network_name == "mainnet":
network_name = "one"

return f"{ecosystem_name}-{network_name}"
7 changes: 1 addition & 6 deletions ape_subsquid/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
TxFieldSelection,
)
from ape_subsquid.mappings import map_header, map_log, map_receipt
from ape_subsquid.networks import get_network


class SubsquidQueryEngine(QueryAPI):
Expand Down Expand Up @@ -200,9 +201,3 @@ def archive_ingest(archive: Archive, network: str, query: Query) -> Iterator[lis
break

query["fromBlock"] = last_block["header"]["number"] + 1


def get_network(engine: QueryAPI) -> str:
ecosystem_name = engine.network_manager.ecosystem.name
network_name = engine.network_manager.network.name
return f"{ecosystem_name}-{network_name}"
Loading