mm-strk 0.4.3__tar.gz → 0.5.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.
Files changed (29) hide show
  1. {mm_strk-0.4.3 → mm_strk-0.5.0}/.claude/settings.local.json +2 -1
  2. mm_strk-0.5.0/CLAUDE.md +24 -0
  3. {mm_strk-0.4.3 → mm_strk-0.5.0}/PKG-INFO +3 -3
  4. {mm_strk-0.4.3 → mm_strk-0.5.0}/pyproject.toml +9 -8
  5. mm_strk-0.5.0/src/mm_strk/__init__.py +1 -0
  6. {mm_strk-0.4.3 → mm_strk-0.5.0}/src/mm_strk/account.py +5 -4
  7. {mm_strk-0.4.3 → mm_strk-0.5.0}/src/mm_strk/balance.py +3 -0
  8. mm_strk-0.5.0/src/mm_strk/cli/__init__.py +1 -0
  9. {mm_strk-0.4.3 → mm_strk-0.5.0}/src/mm_strk/cli/cli.py +7 -3
  10. {mm_strk-0.4.3 → mm_strk-0.5.0}/src/mm_strk/cli/cli_utils.py +3 -0
  11. {mm_strk-0.4.3 → mm_strk-0.5.0}/src/mm_strk/cli/commands/__init__.py +2 -0
  12. {mm_strk-0.4.3 → mm_strk-0.5.0}/src/mm_strk/cli/commands/node.py +5 -2
  13. {mm_strk-0.4.3 → mm_strk-0.5.0}/src/mm_strk/domain.py +6 -3
  14. mm_strk-0.5.0/tests/__init__.py +1 -0
  15. {mm_strk-0.4.3 → mm_strk-0.5.0}/tests/conftest.py +5 -0
  16. {mm_strk-0.4.3 → mm_strk-0.5.0}/tests/test_account.py +4 -0
  17. {mm_strk-0.4.3 → mm_strk-0.5.0}/tests/test_balance.py +3 -0
  18. {mm_strk-0.4.3 → mm_strk-0.5.0}/tests/test_domain.py +4 -0
  19. {mm_strk-0.4.3 → mm_strk-0.5.0}/uv.lock +50 -342
  20. mm_strk-0.4.3/CLAUDE.md +0 -19
  21. mm_strk-0.4.3/src/mm_strk/__init__.py +0 -0
  22. mm_strk-0.4.3/src/mm_strk/cli/__init__.py +0 -0
  23. mm_strk-0.4.3/tests/__init__.py +0 -0
  24. {mm_strk-0.4.3 → mm_strk-0.5.0}/.gitignore +0 -0
  25. {mm_strk-0.4.3 → mm_strk-0.5.0}/ADR.md +0 -0
  26. {mm_strk-0.4.3 → mm_strk-0.5.0}/README.md +0 -0
  27. {mm_strk-0.4.3 → mm_strk-0.5.0}/dict.dic +0 -0
  28. {mm_strk-0.4.3 → mm_strk-0.5.0}/justfile +0 -0
  29. {mm_strk-0.4.3 → mm_strk-0.5.0}/src/mm_strk/py.typed +0 -0
@@ -8,7 +8,8 @@
8
8
  "WebFetch(domain:www.starknet.io)",
9
9
  "WebFetch(domain:www.comparenodes.com)",
10
10
  "WebFetch(domain:starknetpy.readthedocs.io)",
11
- "WebFetch(domain:pypi.org)"
11
+ "WebFetch(domain:pypi.org)",
12
+ "WebFetch(domain:drpc.org)"
12
13
  ]
13
14
  }
14
15
  }
@@ -0,0 +1,24 @@
1
+ # AI Agent Start Guide
2
+
3
+ ## Critical: Language
4
+ RESPOND IN ENGLISH. Always. No exceptions.
5
+ User's language does NOT determine your response language.
6
+ Only switch if user EXPLICITLY requests it (e.g., "respond in {language}").
7
+ Language switching applies ONLY to chat. All code, comments, commit messages, and files must ALWAYS be in English — no exceptions.
8
+
9
+ ## Mandatory Rules (external)
10
+ These files are REQUIRED. Read them fully and follow all rules.
11
+ - `~/.claude/shared-rules/general.md`
12
+ - `~/.claude/shared-rules/python.md`
13
+
14
+ ## Project Reading (context)
15
+ These files are REQUIRED for project understanding.
16
+ - `README.md`
17
+
18
+ ## Preflight (mandatory)
19
+ Before your first response:
20
+ 1. Read all files listed above.
21
+ 2. Do not answer until all are read.
22
+ 3. In your first reply, list every file you have read from this document.
23
+
24
+ Failure to follow this protocol is considered an error.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mm-strk
3
- Version: 0.4.3
4
- Requires-Python: >=3.13
5
- Requires-Dist: mm-web3~=0.5.7
3
+ Version: 0.5.0
4
+ Requires-Python: >=3.14
5
+ Requires-Dist: mm-web3~=0.6.2
6
6
  Requires-Dist: starknet-py~=0.29.0
7
7
  Requires-Dist: typer~=0.21.1
@@ -1,9 +1,9 @@
1
1
  [project]
2
2
  name = "mm-strk"
3
- version = "0.4.3"
3
+ version = "0.5.0"
4
4
  description = ""
5
- requires-python = ">=3.13"
6
- dependencies = ["mm-web3~=0.5.7", "starknet-py~=0.29.0", "typer~=0.21.1"]
5
+ requires-python = ">=3.14"
6
+ dependencies = ["mm-web3~=0.6.2", "starknet-py~=0.29.0", "typer~=0.21.1"]
7
7
  [project.scripts]
8
8
  mm-strk = "mm_strk.cli.cli:app"
9
9
 
@@ -15,14 +15,14 @@ build-backend = "hatchling.build"
15
15
 
16
16
  [dependency-groups]
17
17
  dev = [
18
- "bandit~=1.9.2",
18
+ "bandit~=1.9.3",
19
19
  "mypy~=1.19.1",
20
20
  "pip-audit~=2.10.0",
21
21
  "pre-commit~=4.5.1",
22
22
  "pytest~=9.0.2",
23
23
  "pytest-asyncio~=1.3.0",
24
24
  "pytest-xdist~=3.8.0",
25
- "ruff~=0.14.13",
25
+ "ruff~=0.15.0",
26
26
  "python-dotenv~=1.2.0",
27
27
  ]
28
28
 
@@ -31,14 +31,14 @@ override-dependencies = ["pywin32 ; sys_platform == 'win32'"]
31
31
 
32
32
 
33
33
  [tool.mypy]
34
- python_version = "3.13"
34
+ python_version = "3.14"
35
35
  warn_no_return = false
36
36
  strict = true
37
37
  exclude = ["^tests/", "^tmp/"]
38
38
 
39
39
  [tool.ruff]
40
40
  line-length = 130
41
- target-version = "py313"
41
+ target-version = "py314"
42
42
  [tool.ruff.lint]
43
43
  select = ["ALL"]
44
44
  ignore = [
@@ -46,7 +46,6 @@ ignore = [
46
46
  "A005", # flake8-builtins: stdlib-module-shadowing
47
47
  "ERA001", # eradicate: commented-out-code
48
48
  "PT", # flake8-pytest-style
49
- "D", # pydocstyle
50
49
  "FIX", # flake8-fixme
51
50
  "PLR0911", # pylint: too-many-return-statements
52
51
  "PLR0912", # pylint: too-many-branches
@@ -64,6 +63,8 @@ ignore = [
64
63
  "RET503", # flake8-return: implicit-return
65
64
  "COM812", # it's used in ruff formatter
66
65
  "ASYNC109", # flake8-async: async-function-with-timeout
66
+ "D203", # pydocstyle: one-blank-line-before-class (conflicts with D211)
67
+ "D213", # pydocstyle: multi-line-summary-second-line (conflicts with D212)
67
68
  ]
68
69
  [tool.ruff.lint.pep8-naming]
69
70
  classmethod-decorators = ["field_validator"]
@@ -0,0 +1 @@
1
+ """Starknet utilities library."""
@@ -1,3 +1,5 @@
1
+ """Starknet address validation."""
2
+
1
3
  import re
2
4
 
3
5
  # Maximum allowable value for a StarkNet address (251 bits)
@@ -5,15 +7,14 @@ MAX_STARKNET_ADDRESS = 2**251
5
7
 
6
8
 
7
9
  def is_address(address: str) -> bool:
8
- """
9
- Validates a StarkNet address.
10
+ """Validate a Starknet address.
10
11
 
11
12
  - Must be a string starting with '0x'.
12
13
  - Hex part 1-64 chars.
13
14
  - Integer value < 2**251.
14
15
  - Accepts either:
15
- Full 64-hex-character padded form.
16
- Minimal form without leading zeros (canonical).
16
+ * Full 64-hex-character padded form.
17
+ * Minimal form without leading zeros (canonical).
17
18
  """
18
19
  # Type and prefix
19
20
  if not isinstance(address, str) or not address.startswith("0x"):
@@ -1,3 +1,5 @@
1
+ """Token balance querying on Starknet."""
2
+
1
3
  import aiohttp
2
4
  from aiohttp_socks import ProxyConnector
3
5
  from mm_result import Result
@@ -19,6 +21,7 @@ STRK_DECIMALS = 18
19
21
 
20
22
 
21
23
  async def get_balance(rpc_url: str, address: str, token: str, timeout: float = 5, proxy: str | None = None) -> Result[int]:
24
+ """Get token balance for a Starknet address."""
22
25
  try:
23
26
  timeout_config = aiohttp.ClientTimeout(total=timeout)
24
27
  connector = ProxyConnector.from_url(proxy) if proxy else None
@@ -0,0 +1 @@
1
+ """CLI package for mm-strk."""
@@ -1,7 +1,9 @@
1
+ """CLI entry point for mm-strk."""
2
+
1
3
  from typing import Annotated
2
4
 
3
- import mm_print
4
5
  import typer
6
+ from mm_print import print_plain
5
7
 
6
8
  from mm_strk.cli import cli_utils, commands
7
9
 
@@ -9,14 +11,15 @@ app = typer.Typer(no_args_is_help=True, pretty_exceptions_enable=False, add_comp
9
11
 
10
12
 
11
13
  def version_callback(value: bool) -> None:
14
+ """Print version and exit when --version is passed."""
12
15
  if value:
13
- mm_print.plain(f"mm-strk: {cli_utils.get_version()}")
16
+ print_plain(f"mm-strk: {cli_utils.get_version()}")
14
17
  raise typer.Exit
15
18
 
16
19
 
17
20
  @app.callback()
18
21
  def main(_version: bool = typer.Option(None, "--version", callback=version_callback, is_eager=True)) -> None:
19
- pass
22
+ """Starknet utilities CLI."""
20
23
 
21
24
 
22
25
  @app.command(name="node", help="Checks RPC URLs for availability and status")
@@ -24,4 +27,5 @@ def node_command(
24
27
  urls: Annotated[list[str], typer.Argument()],
25
28
  proxy: Annotated[str | None, typer.Option("--proxy", "-p", help="Proxy")] = None,
26
29
  ) -> None:
30
+ """Check RPC node availability and status."""
27
31
  commands.node.run(urls, proxy)
@@ -1,5 +1,8 @@
1
+ """CLI utility functions."""
2
+
1
3
  import importlib.metadata
2
4
 
3
5
 
4
6
  def get_version() -> str:
7
+ """Return the installed version of mm-strk."""
5
8
  return importlib.metadata.version("mm-strk")
@@ -1,3 +1,5 @@
1
+ """CLI commands for mm-strk."""
2
+
1
3
  from . import node
2
4
 
3
5
  __all__ = ["node"]
@@ -1,7 +1,9 @@
1
+ """Starknet node status checking."""
2
+
1
3
  import asyncio
2
4
 
3
- import mm_print
4
5
  import typer
6
+ from mm_print import print_json
5
7
  from pydantic import BaseModel
6
8
  from starknet_py.net.client_models import SyncStatus
7
9
  from starknet_py.net.full_node_client import FullNodeClient
@@ -25,11 +27,12 @@ def run(urls: list[str], proxy: str | None) -> None:
25
27
 
26
28
 
27
29
  async def _run(urls: list[str]) -> None:
30
+ """Fetch and print status for all given node URLs."""
28
31
  result = {}
29
32
  for url in urls:
30
33
  result[url] = (await _node_status(url)).model_dump()
31
34
 
32
- mm_print.json(result)
35
+ print_json(result)
33
36
 
34
37
 
35
38
  async def _node_status(url: str) -> NodeStatus:
@@ -1,9 +1,12 @@
1
+ """Starknet domain resolution via starknet.id API."""
2
+
1
3
  from mm_http import http_request
2
4
  from mm_result import Result
3
5
  from mm_std import str_contains_any
4
6
 
5
7
 
6
8
  async def address_to_domain(address: str, timeout: float = 5.0, proxy: str | None = None) -> Result[str | None]:
9
+ """Resolve a Starknet address to its .stark domain name."""
7
10
  url = "https://api.starknet.id/addr_to_domain"
8
11
  res = await http_request(url, params={"addr": address}, proxy=proxy, timeout=timeout)
9
12
  if (
@@ -14,7 +17,7 @@ async def address_to_domain(address: str, timeout: float = 5.0, proxy: str | Non
14
17
  return res.to_result_ok(None)
15
18
  if res.is_err():
16
19
  return res.to_result_err()
17
- domain = res.parse_json("domain")
18
- if domain:
19
- return res.to_result_ok(domain)
20
+ domain_res = res.json_body("domain")
21
+ if domain_res.is_ok():
22
+ return res.to_result_ok(domain_res.unwrap())
20
23
  return res.to_result_err("unknown_response")
@@ -0,0 +1 @@
1
+ """Tests for mm-strk."""
@@ -1,3 +1,5 @@
1
+ """Shared test fixtures."""
2
+
1
3
  import os
2
4
 
3
5
  import pytest
@@ -10,16 +12,19 @@ MAINNET_URL = os.getenv("MAINNET_URL")
10
12
 
11
13
  @pytest.fixture
12
14
  def anyio_backend() -> str:
15
+ """Use asyncio as the async backend."""
13
16
  return "asyncio"
14
17
 
15
18
 
16
19
  @pytest.fixture
17
20
  def zklend_market_address() -> str:
21
+ """Return the zkLend market contract address."""
18
22
  return "0x04c0a5193d58f74fbace4b74dcf65481e734ed1714121bdc571da345540efa05"
19
23
 
20
24
 
21
25
  @pytest.fixture
22
26
  def mainnet_rpc_url() -> str:
27
+ """Return the mainnet RPC URL from environment."""
23
28
  if not MAINNET_URL:
24
29
  raise ValueError("MAINNET_URL environment variable is not set.")
25
30
  return MAINNET_URL
@@ -1,9 +1,12 @@
1
+ """Tests for address validation."""
2
+
1
3
  from starknet_py.hash.address import get_checksum_address
2
4
 
3
5
  from mm_strk.account import is_address
4
6
 
5
7
 
6
8
  def test_valid_addresses():
9
+ """Test that valid Starknet addresses are accepted."""
7
10
  # Compact lower-case and mixed-case hex strings
8
11
  assert is_address("0x1") is True
9
12
  assert is_address("0x123abc") is True
@@ -17,6 +20,7 @@ def test_valid_addresses():
17
20
 
18
21
 
19
22
  def test_invalid_addresses():
23
+ """Test that invalid Starknet addresses are rejected."""
20
24
  # Missing prefix or empty
21
25
  assert is_address("123abc") is False
22
26
  assert is_address("0x") is False
@@ -1,7 +1,10 @@
1
+ """Tests for token balance querying."""
2
+
1
3
  from mm_strk import balance
2
4
 
3
5
 
4
6
  async def test_get_balance(mainnet_rpc_url):
7
+ """Test fetching ETH and STRK balances for a known address."""
5
8
  address = "0x076601136372fcdbbd914eea797082f7504f828e122288ad45748b0c8b0c9696" # Bybit: Hot Wallet
6
9
  assert (await balance.get_balance(mainnet_rpc_url, address, balance.ETH_ADDRESS_MAINNET)).unwrap() > 1
7
10
  assert (await balance.get_balance(mainnet_rpc_url, address, balance.STRK_ADDRESS_MAINNET)).unwrap() > 1
@@ -1,13 +1,17 @@
1
+ """Tests for Starknet domain resolution."""
2
+
1
3
  from mm_strk import domain
2
4
 
3
5
 
4
6
  async def test_address_to_domain_exist():
7
+ """Test resolving an address that has a .stark domain."""
5
8
  res = await domain.address_to_domain("0x0060b56b67e1b4dd1909376496b0e867f165f31c5eac7902d9ff48112f16ef9b")
6
9
  assert res.is_ok()
7
10
  assert res.unwrap() == "abc.stark"
8
11
 
9
12
 
10
13
  async def test_address_to_domain_async_not_exist():
14
+ """Test resolving an address that has no .stark domain."""
11
15
  res = await domain.address_to_domain("0x0060b56b67e1b4dd1909376496b0e867f165f31c5eac7902d9ff48112f16ef9a") # not existed
12
16
  assert res.is_ok()
13
17
  assert res.unwrap() is None