chainhound 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.3
2
+ Name: chainhound
3
+ Version: 0.1.0
4
+ Summary: Add your description here
5
+ Author: spin3l
6
+ Author-email: spin3l <dev.christianlopezgarcia@gmail.com>
7
+ Requires-Dist: anyio>=4.13.0
8
+ Requires-Dist: pydantic-settings>=2.14.1
9
+ Requires-Dist: returns[compatible-mypy,mypy-compatible]>=0.28.0
10
+ Requires-Dist: web3>=7.16.0
11
+ Requires-Python: >=3.14
12
+ Description-Content-Type: text/markdown
13
+
File without changes
@@ -0,0 +1,28 @@
1
+ [project]
2
+ name = "chainhound"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "spin3l", email = "dev.christianlopezgarcia@gmail.com" }
8
+ ]
9
+ requires-python = ">=3.14"
10
+ dependencies = [
11
+ "anyio>=4.13.0",
12
+ "pydantic-settings>=2.14.1",
13
+ "returns[compatible-mypy,mypy-compatible]>=0.28.0",
14
+ "web3>=7.16.0",
15
+ ]
16
+
17
+ [project.scripts]
18
+ chainhound = "chainhound:main"
19
+
20
+ [build-system]
21
+ requires = ["uv_build>=0.9.18,<0.10.0"]
22
+ build-backend = "uv_build"
23
+
24
+ [dependency-groups]
25
+ dev = [
26
+ "mypy>=2.1.0",
27
+ "pytest>=9.0.3",
28
+ ]
@@ -0,0 +1,4 @@
1
+ from chainhound.entrypoint import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,46 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from logging import getLogger
5
+
6
+ from returns.result import Failure, Result, Success
7
+ from web3 import AsyncBaseProvider, AsyncHTTPProvider, AsyncWeb3
8
+
9
+ logger = getLogger(__name__)
10
+
11
+
12
+ class BlockchainError(Exception):
13
+ def __init__(self, message: str = "") -> None:
14
+ self.message = message
15
+
16
+
17
+ @dataclass(frozen=True, slots=True)
18
+ class Blockchain:
19
+ web3: AsyncWeb3[AsyncBaseProvider]
20
+
21
+ @classmethod
22
+ def build(cls, endpoint: str) -> Blockchain:
23
+ if not endpoint:
24
+ raise ValueError(f"Incorrect endpoint: {endpoint}")
25
+
26
+ return cls(web3=AsyncWeb3(AsyncHTTPProvider(endpoint)))
27
+
28
+
29
+ async def is_connected(blockchain: Blockchain) -> bool:
30
+ return await blockchain.web3.provider.is_connected()
31
+
32
+
33
+ async def close_connection(blockchain: Blockchain) -> None:
34
+ assert blockchain is not None, "Must pass a valid blockchain"
35
+
36
+ logger.info("Closing blockchain connection")
37
+ await blockchain.web3.provider.disconnect()
38
+
39
+
40
+ async def get_last_block_number(blockchain: Blockchain) -> Result[int, BlockchainError]:
41
+ if not await is_connected(blockchain):
42
+ return Failure(
43
+ BlockchainError("The given blockchain instance is not connected")
44
+ )
45
+
46
+ return Success(await blockchain.web3.eth.block_number)
@@ -0,0 +1,11 @@
1
+ from pydantic import AnyUrl
2
+ from pydantic_settings import BaseSettings
3
+
4
+
5
+ class RpcSettings(BaseSettings):
6
+ endpoint: AnyUrl
7
+ chunk_size: int
8
+
9
+
10
+ class Settings(BaseSettings):
11
+ rpc: RpcSettings = RpcSettings.model_construct()
@@ -0,0 +1,5 @@
1
+ from anyio import run
2
+
3
+
4
+ def main() -> None:
5
+ run()