Skip to content

Commit

Permalink
Merge pull request #3 from subsquid/fix-ecosystems
Browse files Browse the repository at this point in the history
fix: handle ecosystems and networks that have incompatible naming to …
  • Loading branch information
abernatskiy authored Feb 5, 2024
2 parents 09c5a0a + 6d78212 commit 3bd88e4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
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}"

0 comments on commit 3bd88e4

Please sign in to comment.