nerva-py 1.0.1__py3-none-any.whl → 1.1.0__py3-none-any.whl

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.
nerva/__init__.py CHANGED
@@ -37,7 +37,7 @@ class VersionInfo(NamedTuple):
37
37
 
38
38
 
39
39
  version_info: VersionInfo = VersionInfo(
40
- major=1, minor=0, micro=1, releaselevel="final", serial=0
40
+ major=1, minor=1, micro=0, releaselevel="final", serial=0
41
41
  )
42
42
 
43
43
  __version__ = str(version_info)
nerva/__main__.py CHANGED
@@ -2,7 +2,7 @@ import sys
2
2
  import argparse
3
3
  import platform
4
4
 
5
- import aiohttp
5
+ import httpx
6
6
 
7
7
  import nerva
8
8
 
@@ -18,7 +18,7 @@ def show_version() -> None:
18
18
 
19
19
  entries.append(f"- nerva-py v{nerva.__version__}")
20
20
 
21
- entries.append(f"- aiohttp v{aiohttp.__version__}")
21
+ entries.append(f"- httpx v{httpx.__version__}")
22
22
 
23
23
  uname = platform.uname()
24
24
  entries.append(f"- System Info: {uname.system} {uname.release} {uname.version}")
nerva/daemon.py CHANGED
@@ -2,12 +2,12 @@ from __future__ import annotations
2
2
 
3
3
  from typing import Any, Dict, List, Optional
4
4
 
5
- import aiohttp
5
+ import httpx
6
6
 
7
- __all__ = ["DaemonRPC", "DaemonLegacy"]
7
+ __all__ = ["Daemon", "DaemonLegacy"]
8
8
 
9
9
 
10
- class DaemonRPC:
10
+ class Daemon:
11
11
  """
12
12
  A class to interact with the Nerva daemon's JSON-RPC interface.
13
13
 
@@ -32,7 +32,7 @@ class DaemonRPC:
32
32
  The headers for the request.
33
33
  """
34
34
 
35
- __slots__ = ["url", "timeout", "headers"]
35
+ __slots__ = ["url", "timeout", "headers", "auth"]
36
36
 
37
37
  def __init__(
38
38
  self,
@@ -40,20 +40,26 @@ class DaemonRPC:
40
40
  port: Optional[int] = 17566,
41
41
  ssl: Optional[bool] = False,
42
42
  timeout: Optional[float] = 10.0,
43
+ username: Optional[str] = None,
44
+ password: Optional[str] = None,
43
45
  ) -> None:
44
46
  self.url: str = f"{'https' if ssl else 'http'}://{host}:{port}"
45
47
  self.timeout: float = timeout
46
48
  self.headers: Dict[str, str] = {"Content-Type": "application/json"}
49
+ self.auth: Optional[httpx.DigestAuth] = (
50
+ httpx.DigestAuth(username, password) if username and password else None
51
+ )
47
52
 
48
53
  async def _request(self, method: str, params: Dict[str, Any]) -> Dict[str, Any]:
49
- async with aiohttp.ClientSession() as session:
50
- async with session.post(
54
+ async with httpx.AsyncClient() as client:
55
+ response = await client.post(
51
56
  f"{self.url}/json_rpc",
52
57
  json={"jsonrpc": "2.0", "id": 0, "method": method, "params": params},
53
58
  headers=self.headers,
54
59
  timeout=self.timeout,
55
- ) as response:
56
- return await response.json(content_type=None)
60
+ auth=self.auth,
61
+ )
62
+ return response.json()
57
63
 
58
64
  async def get_block_count(self) -> Dict[str, Any]:
59
65
  """
@@ -660,7 +666,7 @@ class DaemonLegacy:
660
666
 
661
667
  """
662
668
 
663
- __slots__ = ["url", "timeout", "headers"]
669
+ __slots__ = ["url", "timeout", "headers", "auth"]
664
670
 
665
671
  def __init__(
666
672
  self,
@@ -668,23 +674,28 @@ class DaemonLegacy:
668
674
  port: Optional[int] = 17566,
669
675
  ssl: Optional[bool] = False,
670
676
  timeout: Optional[float] = 10.0,
677
+ username: Optional[str] = None,
678
+ password: Optional[str] = None,
671
679
  ):
672
680
  self.url = f"{'https' if ssl else 'http'}://{host}:{port}"
673
681
  self.timeout = timeout
674
-
675
682
  self.headers = {"Content-Type": "application/json"}
683
+ self.auth = (
684
+ httpx.DigestAuth(username, password) if username and password else None
685
+ )
676
686
 
677
687
  async def _request(
678
688
  self, endpoint: str, params: Dict[str, Any]
679
689
  ) -> Dict[str, Any]:
680
- async with aiohttp.ClientSession() as session:
681
- async with session.post(
690
+ async with httpx.AsyncClient() as client:
691
+ response = await client.post(
682
692
  f"{self.url}/{endpoint}",
683
693
  json=params,
684
694
  headers=self.headers,
685
695
  timeout=self.timeout,
686
- ) as response:
687
- return await response.json(content_type=None)
696
+ auth=self.auth,
697
+ )
698
+ return response.json()
688
699
 
689
700
  async def get_height(self) -> Dict[str, Any]:
690
701
  """
nerva/wallet.py CHANGED
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import Any, Dict, List, Optional
4
4
 
5
- import aiohttp
5
+ import httpx
6
6
 
7
7
  __all__ = ["Wallet"]
8
8
 
@@ -56,23 +56,22 @@ class Wallet:
56
56
  password: str = "",
57
57
  ) -> None:
58
58
  self.url: str = f"http{'s' if ssl else ''}://{host}:{port}"
59
- self.auth: Optional[aiohttp.BasicAuth] = (
60
- aiohttp.BasicAuth(username, password) if username and password else None
61
- )
62
59
  self.timeout: float = timeout
63
-
64
60
  self.headers: Dict[str, str] = {"Content-Type": "application/json"}
61
+ self.auth: Optional[httpx.DigestAuth] = (
62
+ httpx.DigestAuth(username, password) if username and password else None
63
+ )
65
64
 
66
65
  async def _request(self, method: str, params: Dict[str, Any]) -> Dict[str, Any]:
67
- async with aiohttp.ClientSession() as session:
68
- async with session.post(
66
+ async with httpx.AsyncClient() as client:
67
+ response = await client.post(
69
68
  f"{self.url}/json_rpc",
70
69
  json={"jsonrpc": "2.0", "id": 0, "method": method, "params": params},
71
70
  headers=self.headers,
72
71
  auth=self.auth,
73
72
  timeout=self.timeout,
74
- ) as response:
75
- return await response.json(content_type=None)
73
+ )
74
+ return response.json()
76
75
 
77
76
  async def get_balance(
78
77
  self, account_index: int, address_indices: Optional[List[int]] = None
@@ -1,10 +1,9 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: nerva-py
3
- Version: 1.0.1
3
+ Version: 1.1.0
4
4
  Summary: Python bindings for the JSON RPC interface of the Nerva cryptocurrency.
5
5
  Author-email: Sayan Bhattacharyya <sayan@sn1f3rt.dev>
6
- License-Expression: MIT
7
- License-File: LICENSE
6
+ License: MIT
8
7
  Keywords: bindings,cryptocurrency,json-rpc,nerva,python
9
8
  Classifier: Development Status :: 5 - Production/Stable
10
9
  Classifier: Intended Audience :: Developers
@@ -19,7 +18,7 @@ Classifier: Programming Language :: Python :: 3.12
19
18
  Classifier: Programming Language :: Python :: 3.13
20
19
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
20
  Requires-Python: >=3.8
22
- Requires-Dist: aiohttp>=3.10.10
21
+ Requires-Dist: httpx>=0.27.2
23
22
  Description-Content-Type: text/markdown
24
23
 
25
24
  # Nerva Python Library
@@ -70,12 +69,16 @@ Here is a simple example to get you started:
70
69
  ```python
71
70
  import asyncio
72
71
 
73
- from nerva.daemon import DaemonJSONRPC
72
+ from nerva.daemon import Daemon
74
73
 
75
74
 
76
75
  async def main():
77
- daemon = DaemonJSONRPC(
78
- host="x.y.z.w",
76
+ daemon = Daemon(
77
+ host="localhost",
78
+ port=17566,
79
+ ssl=False,
80
+ username="rpcuser", # omit if daemon was not started with the rpc-login flag
81
+ password="rpcpassword" # omit if daemon was not started with the rpc-login flag
79
82
  )
80
83
 
81
84
  print(await daemon.get_info())
@@ -0,0 +1,9 @@
1
+ nerva/__init__.py,sha256=uuerw1FTJ5CGL7NvOwKsp_-oTmN87MfSsfI7LYqNCUU,1128
2
+ nerva/__main__.py,sha256=vcuFqUiFv6xclYd1ME59lNH_d_E429SwMV-ShxmXCsg,1219
3
+ nerva/daemon.py,sha256=zMq1LUuJ1tggvVHTZGVGRksrqnHjnCNZ2AVogG6Vi9s,33573
4
+ nerva/utils.py,sha256=UzyhRTE2w7_H2YCz50ospggApyFbTOnrB92fuED9laQ,999
5
+ nerva/wallet.py,sha256=aomyDwd-a2kadX3v9FKHvhswFjYZOnELX95wQhxGkUo,59289
6
+ nerva_py-1.1.0.dist-info/METADATA,sha256=v0_5mR_OVkmaU8RdjPFZFxqk2yYul1_jtQb4PcTfFgc,2873
7
+ nerva_py-1.1.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
8
+ nerva_py-1.1.0.dist-info/licenses/LICENSE,sha256=OB3n91B4pOwIG9kD-nL-INDB0A7ma5fL9q32FGyoIQ4,1086
9
+ nerva_py-1.1.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.25.0
2
+ Generator: hatchling 1.26.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,9 +0,0 @@
1
- nerva/__init__.py,sha256=ie6yjXkAEzgUdstvjvV_MHkYAaeVO-7Sbq5mxMcVLrw,1128
2
- nerva/__main__.py,sha256=Ro0JgLqHkRB_laQfYgdyLkiLfj5VMV0azK0K8UhorsM,1225
3
- nerva/daemon.py,sha256=xeX3Ei5nGosvqlHmTFQsbjPVoumuX574zRWUjnqrJAI,33162
4
- nerva/utils.py,sha256=UzyhRTE2w7_H2YCz50ospggApyFbTOnrB92fuED9laQ,999
5
- nerva/wallet.py,sha256=EhQBS9PNq9QZdiP5I8y_jTPr_PtRHCf81dNwRdblDZA,59334
6
- nerva_py-1.0.1.dist-info/METADATA,sha256=j_ZUNLAW7sccYDIGGytpZGc8YBoCSxc7AFWDl3QWXnM,2709
7
- nerva_py-1.0.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
8
- nerva_py-1.0.1.dist-info/licenses/LICENSE,sha256=OB3n91B4pOwIG9kD-nL-INDB0A7ma5fL9q32FGyoIQ4,1086
9
- nerva_py-1.0.1.dist-info/RECORD,,