mm-balance 0.1.19__py3-none-any.whl → 0.1.20__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.
- mm_balance/config.py +10 -37
- mm_balance/rpc/btc.py +1 -3
- mm_balance/workers.py +1 -4
- {mm_balance-0.1.19.dist-info → mm_balance-0.1.20.dist-info}/METADATA +4 -3
- {mm_balance-0.1.19.dist-info → mm_balance-0.1.20.dist-info}/RECORD +7 -7
- {mm_balance-0.1.19.dist-info → mm_balance-0.1.20.dist-info}/WHEEL +0 -0
- {mm_balance-0.1.19.dist-info → mm_balance-0.1.20.dist-info}/entry_points.txt +0 -0
mm_balance/config.py
CHANGED
|
@@ -3,23 +3,25 @@ from __future__ import annotations
|
|
|
3
3
|
import os
|
|
4
4
|
from decimal import Decimal
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import Self, cast
|
|
6
|
+
from typing import Annotated, Self, cast
|
|
7
7
|
|
|
8
|
+
import mm_crypto_utils
|
|
8
9
|
import pydash
|
|
9
|
-
from
|
|
10
|
-
from
|
|
10
|
+
from mm_crypto_utils import ConfigValidators
|
|
11
|
+
from mm_std import BaseConfig, PrintFormat, fatal
|
|
12
|
+
from pydantic import BeforeValidator, Field, StringConstraints, model_validator
|
|
11
13
|
|
|
12
14
|
from mm_balance.constants import DEFAULT_NODES, TOKEN_ADDRESS, Network
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
class Group(BaseConfig):
|
|
16
18
|
comment: str = ""
|
|
17
|
-
ticker: str
|
|
19
|
+
ticker: Annotated[str, StringConstraints(to_upper=True)]
|
|
18
20
|
network: Network
|
|
19
21
|
token_address: str | None = None # If None, it's a native token, for example ETH
|
|
20
22
|
token_decimals: int | None = None
|
|
21
23
|
coingecko_id: str | None = None
|
|
22
|
-
addresses: list[str]
|
|
24
|
+
addresses: Annotated[list[str], BeforeValidator(ConfigValidators.addresses(unique=True))]
|
|
23
25
|
share: Decimal = Decimal(1)
|
|
24
26
|
|
|
25
27
|
@property
|
|
@@ -30,20 +32,6 @@ class Group(BaseConfig):
|
|
|
30
32
|
result += " / " + self.network
|
|
31
33
|
return result
|
|
32
34
|
|
|
33
|
-
@field_validator("ticker", mode="after")
|
|
34
|
-
def ticker_validator(cls, v: str) -> str:
|
|
35
|
-
return v.upper()
|
|
36
|
-
|
|
37
|
-
@field_validator("addresses", mode="before")
|
|
38
|
-
def to_list_validator(cls, v: str | list[str] | None) -> list[str]:
|
|
39
|
-
return cls.to_list_str_validator(v, unique=True, remove_comments=True, split_line=True)
|
|
40
|
-
|
|
41
|
-
# @model_validator(mode="before")
|
|
42
|
-
# def before_all(cls, data: Any) -> Any:
|
|
43
|
-
# if "network" not in data:
|
|
44
|
-
# data["network"] = detect_network(data["coin"])
|
|
45
|
-
# return data
|
|
46
|
-
|
|
47
35
|
@model_validator(mode="after")
|
|
48
36
|
def final_validator(self) -> Self:
|
|
49
37
|
if self.token_address is None:
|
|
@@ -65,11 +53,7 @@ class Group(BaseConfig):
|
|
|
65
53
|
|
|
66
54
|
class AddressGroup(BaseConfig):
|
|
67
55
|
name: str
|
|
68
|
-
addresses: list[str]
|
|
69
|
-
|
|
70
|
-
@field_validator("addresses", mode="before")
|
|
71
|
-
def to_list_validator(cls, v: str | list[str] | None) -> list[str]:
|
|
72
|
-
return cls.to_list_str_validator(v, unique=True, remove_comments=True, split_line=True)
|
|
56
|
+
addresses: Annotated[list[str], BeforeValidator(ConfigValidators.addresses(unique=True))]
|
|
73
57
|
|
|
74
58
|
|
|
75
59
|
class Config(BaseConfig):
|
|
@@ -97,9 +81,9 @@ class Config(BaseConfig):
|
|
|
97
81
|
def final_validator(self) -> Self:
|
|
98
82
|
# load from proxies_url
|
|
99
83
|
if self.proxies_url is not None:
|
|
100
|
-
self.proxies
|
|
84
|
+
self.proxies += mm_crypto_utils.fetch_proxies_or_fatal(self.proxies_url)
|
|
101
85
|
elif os.getenv("MM_BALANCE_PROXIES_URL"):
|
|
102
|
-
self.proxies
|
|
86
|
+
self.proxies += mm_crypto_utils.fetch_proxies_or_fatal(cast(str, os.getenv("MM_BALANCE_PROXIES_URL")))
|
|
103
87
|
|
|
104
88
|
# load addresses from address_group
|
|
105
89
|
for group in self.groups:
|
|
@@ -123,17 +107,6 @@ def detect_token_address(ticker: str, network: Network) -> str | None:
|
|
|
123
107
|
return TOKEN_ADDRESS[network].get(ticker)
|
|
124
108
|
|
|
125
109
|
|
|
126
|
-
def get_proxies(proxies_url: str) -> list[str]:
|
|
127
|
-
try:
|
|
128
|
-
res = hr(proxies_url)
|
|
129
|
-
if res.is_error():
|
|
130
|
-
fatal(f"Can't get proxies: {res.error}")
|
|
131
|
-
proxies = [p.strip() for p in res.body.splitlines() if p.strip()]
|
|
132
|
-
return pydash.uniq(proxies)
|
|
133
|
-
except Exception as err:
|
|
134
|
-
fatal(f"Can't get proxies: {err}")
|
|
135
|
-
|
|
136
|
-
|
|
137
110
|
def get_address_group_by_name(address_groups: list[AddressGroup], name: str) -> AddressGroup | None:
|
|
138
111
|
return pydash.find(address_groups, lambda g: g.name == name)
|
|
139
112
|
|
mm_balance/rpc/btc.py
CHANGED
|
@@ -10,7 +10,5 @@ def get_balance(address: str, proxies: list[str], round_ndigits: int) -> Result[
|
|
|
10
10
|
return (
|
|
11
11
|
BlockstreamClient(proxies=proxies, attempts=RETRIES_BALANCE)
|
|
12
12
|
.get_confirmed_balance(address)
|
|
13
|
-
.and_then(
|
|
14
|
-
lambda b: Ok(round(Decimal(b / 100_000_000), round_ndigits)),
|
|
15
|
-
)
|
|
13
|
+
.and_then(lambda b: Ok(round(Decimal(b / 100_000_000), round_ndigits)))
|
|
16
14
|
)
|
mm_balance/workers.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
2
|
from decimal import Decimal
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
4
3
|
|
|
5
4
|
from mm_std import ConcurrentTasks, PrintFormat, Result
|
|
5
|
+
from rich.progress import TaskID
|
|
6
6
|
|
|
7
7
|
from mm_balance.config import Config
|
|
8
8
|
from mm_balance.constants import NETWORK_APTOS, NETWORK_BITCOIN, NETWORK_SOLANA, Network
|
|
@@ -10,9 +10,6 @@ from mm_balance.output import utils
|
|
|
10
10
|
from mm_balance.rpc import aptos, btc, evm, solana
|
|
11
11
|
from mm_balance.token_decimals import TokenDecimals
|
|
12
12
|
|
|
13
|
-
if TYPE_CHECKING:
|
|
14
|
-
from rich.progress import TaskID
|
|
15
|
-
|
|
16
13
|
|
|
17
14
|
@dataclass
|
|
18
15
|
class Task:
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mm-balance
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.20
|
|
4
4
|
Requires-Python: >=3.12
|
|
5
5
|
Requires-Dist: mm-aptos==0.1.5
|
|
6
6
|
Requires-Dist: mm-btc==0.2.1
|
|
7
|
-
Requires-Dist: mm-
|
|
8
|
-
Requires-Dist: mm-
|
|
7
|
+
Requires-Dist: mm-crypto-utils==0.0.13
|
|
8
|
+
Requires-Dist: mm-eth==0.2.5
|
|
9
|
+
Requires-Dist: mm-solana==0.2.4
|
|
9
10
|
Requires-Dist: typer>=0.15.1
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
mm_balance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
mm_balance/cli.py,sha256=7yQ0DiSDVYeG9lFav-PJnVswncWIfpZsj1G7CZvMDmc,3119
|
|
3
|
-
mm_balance/config.py,sha256=
|
|
3
|
+
mm_balance/config.py,sha256=7dB_8MrefufIi32-ubgiUxjacmeKERGNIbc1yXNw4ec,4578
|
|
4
4
|
mm_balance/constants.py,sha256=kqG2zuwv0l-PzDHIrMJVQpfQWiXjr2DsqGPcKmqNJLo,2334
|
|
5
5
|
mm_balance/price.py,sha256=9pK2Iy44zTcHIlrja5wC_jV03Q7bJr-S8joNzEsyUl0,1485
|
|
6
6
|
mm_balance/result.py,sha256=rwCSnuyK-u4mz1QmQucFKLC2-vpkSoXfFxbu0MScp9g,4524
|
|
7
7
|
mm_balance/token_decimals.py,sha256=5VZyx29euGtE2KIStQjh6xCcVg1qQweFAykUZU6vkRU,2268
|
|
8
8
|
mm_balance/utils.py,sha256=bngYS2WFIakGZO31_ey4MPsllvDhgOxkAnGiXqom3J4,286
|
|
9
|
-
mm_balance/workers.py,sha256=
|
|
9
|
+
mm_balance/workers.py,sha256=U9oQOkYtg83tbzCdhs-RqrqeX9JAY1H_AW65gLytxMU,3739
|
|
10
10
|
mm_balance/config/example.yml,sha256=7n72tHsnUbZ64q856IeKHlmt-7PvtAgZlB8t4AS0NzI,1899
|
|
11
11
|
mm_balance/output/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
mm_balance/output/utils.py,sha256=WUFwshFMKZKdcwRtO21nhxqW78JeLAatDyHPZhdV96A,716
|
|
@@ -15,10 +15,10 @@ mm_balance/output/formats/json_format.py,sha256=yMkZTA6vOUpLSixF7H4H4lVZKShRs4B9
|
|
|
15
15
|
mm_balance/output/formats/table_format.py,sha256=qN1uMF1cyAVOH31Gohoc_a4l9-pWTSZ8WRxBBSAwj54,4539
|
|
16
16
|
mm_balance/rpc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
mm_balance/rpc/aptos.py,sha256=1JCYCqDim4tk1axXscaAJRXPd4J6vV1ABFbwMbPgrL0,641
|
|
18
|
-
mm_balance/rpc/btc.py,sha256=
|
|
18
|
+
mm_balance/rpc/btc.py,sha256=iGDoO7HXP6reLI0bWm0UhEl7-UFZTo5xCWNzFngbITw,458
|
|
19
19
|
mm_balance/rpc/evm.py,sha256=ewlMmRrcXKlky3DPNbnUBTVwnvyw7N9iCZLsCX2V14w,1007
|
|
20
20
|
mm_balance/rpc/solana.py,sha256=Lwl5Otqy48g4LWfz9uN7_rkICKUIYJvf88PbIAnfMdc,1051
|
|
21
|
-
mm_balance-0.1.
|
|
22
|
-
mm_balance-0.1.
|
|
23
|
-
mm_balance-0.1.
|
|
24
|
-
mm_balance-0.1.
|
|
21
|
+
mm_balance-0.1.20.dist-info/METADATA,sha256=rUfrIh7wO8EWYVsDHysHw0yX202FfCpmGHK9qm_R_nA,268
|
|
22
|
+
mm_balance-0.1.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
23
|
+
mm_balance-0.1.20.dist-info/entry_points.txt,sha256=rSnP0ZW1a3ACNwTWM7T53CmOycKbzhG43m2_wseENng,50
|
|
24
|
+
mm_balance-0.1.20.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|