mm-sol 0.3.2__py3-none-any.whl → 0.3.4__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_sol/cli/cli.py +3 -2
- mm_sol/cli/cmd/balances_cmd.py +20 -10
- mm_sol/cli/cmd/wallet/mnemonic_cmd.py +2 -2
- mm_sol/cli/examples/balances.toml +1 -0
- mm_sol/converters.py +4 -0
- {mm_sol-0.3.2.dist-info → mm_sol-0.3.4.dist-info}/METADATA +1 -1
- {mm_sol-0.3.2.dist-info → mm_sol-0.3.4.dist-info}/RECORD +9 -9
- {mm_sol-0.3.2.dist-info → mm_sol-0.3.4.dist-info}/WHEEL +0 -0
- {mm_sol-0.3.2.dist-info → mm_sol-0.3.4.dist-info}/entry_points.txt +0 -0
mm_sol/cli/cli.py
CHANGED
|
@@ -110,9 +110,10 @@ def wallet_mnemonic_command( # nosec
|
|
|
110
110
|
mnemonic: Annotated[str, typer.Option("--mnemonic", "-m")] = "",
|
|
111
111
|
passphrase: Annotated[str, typer.Option("--passphrase", "-p")] = "",
|
|
112
112
|
derivation_path: Annotated[str, typer.Option("--path")] = PHANTOM_DERIVATION_PATH,
|
|
113
|
-
|
|
113
|
+
words: int = typer.Option(12, "--words", "-w", help="Number of mnemonic words"),
|
|
114
|
+
limit: int = typer.Option(5, "--limit", "-l"),
|
|
114
115
|
) -> None:
|
|
115
|
-
mnemonic_cmd.run(mnemonic, passphrase, derivation_path, limit)
|
|
116
|
+
mnemonic_cmd.run(mnemonic, passphrase, words, derivation_path, limit)
|
|
116
117
|
|
|
117
118
|
|
|
118
119
|
@wallet_app.command(name="keypair", help="Print public, private_base58, private_arr by a private key")
|
mm_sol/cli/cmd/balances_cmd.py
CHANGED
|
@@ -4,13 +4,14 @@ from pathlib import Path
|
|
|
4
4
|
from typing import Annotated, Any
|
|
5
5
|
|
|
6
6
|
from mm_crypto_utils import ConfigValidators
|
|
7
|
-
from mm_std import BaseConfig, print_json
|
|
7
|
+
from mm_std import BaseConfig, Err, fatal, print_json
|
|
8
8
|
from pydantic import BeforeValidator
|
|
9
9
|
|
|
10
10
|
import mm_sol.converters
|
|
11
11
|
from mm_sol import balance
|
|
12
12
|
from mm_sol.balance import get_token_balance_with_retries
|
|
13
13
|
from mm_sol.cli.validators import Validators
|
|
14
|
+
from mm_sol.token import get_decimals_with_retries
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
class Config(BaseConfig):
|
|
@@ -34,22 +35,31 @@ def run(config_path: Path, print_config: bool) -> None:
|
|
|
34
35
|
|
|
35
36
|
if config.tokens:
|
|
36
37
|
for token in config.tokens:
|
|
37
|
-
|
|
38
|
+
token_decimals_res = get_decimals_with_retries(config.nodes, token, retries=3, proxies=config.proxies)
|
|
39
|
+
if isinstance(token_decimals_res, Err):
|
|
40
|
+
fatal(f"Failed to get decimals for token {token}: {token_decimals_res.unwrap_err()}")
|
|
41
|
+
token_decimals = token_decimals_res.unwrap()
|
|
42
|
+
result[token] = _get_token_balances(token, token_decimals, config.accounts, config)
|
|
43
|
+
result[token + "_decimals"] = token_decimals
|
|
38
44
|
result[token + "_sum"] = sum([v for v in result[token].values() if v is not None])
|
|
39
45
|
|
|
40
46
|
print_json(result)
|
|
41
47
|
|
|
42
48
|
|
|
43
|
-
def _get_token_balances(token: str, accounts: list[str], config: Config) -> dict[str,
|
|
49
|
+
def _get_token_balances(token: str, token_decimals: int, accounts: list[str], config: Config) -> dict[str, Decimal | None]:
|
|
44
50
|
result = {}
|
|
45
51
|
for account in accounts:
|
|
46
|
-
result[account] =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
result[account] = (
|
|
53
|
+
get_token_balance_with_retries(
|
|
54
|
+
nodes=config.nodes,
|
|
55
|
+
owner_address=account,
|
|
56
|
+
token_mint_address=token,
|
|
57
|
+
retries=3,
|
|
58
|
+
proxies=config.proxies,
|
|
59
|
+
)
|
|
60
|
+
.map(lambda v: mm_sol.converters.to_token(v, token_decimals))
|
|
61
|
+
.unwrap_or(None)
|
|
62
|
+
)
|
|
53
63
|
return result
|
|
54
64
|
|
|
55
65
|
|
|
@@ -6,10 +6,10 @@ from mm_std import print_json
|
|
|
6
6
|
from mm_sol.account import derive_accounts, generate_mnemonic
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
def run(mnemonic: str, passphrase: str, derivation_path: str, limit: int) -> None: # nosec
|
|
9
|
+
def run(mnemonic: str, passphrase: str, words: int, derivation_path: str, limit: int) -> None: # nosec
|
|
10
10
|
result: dict[str, Any] = {}
|
|
11
11
|
if not mnemonic:
|
|
12
|
-
mnemonic = generate_mnemonic()
|
|
12
|
+
mnemonic = generate_mnemonic(words)
|
|
13
13
|
result["mnemonic"] = mnemonic
|
|
14
14
|
if passphrase:
|
|
15
15
|
result["passphrase"] = passphrase
|
mm_sol/converters.py
CHANGED
|
@@ -2,10 +2,14 @@ from decimal import Decimal
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
def lamports_to_sol(lamports: int, ndigits: int = 4) -> Decimal:
|
|
5
|
+
if lamports == 0:
|
|
6
|
+
return Decimal(0)
|
|
5
7
|
return Decimal(str(round(lamports / 10**9, ndigits=ndigits)))
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
def to_token(smallest_unit_value: int, decimals: int, ndigits: int = 4) -> Decimal:
|
|
11
|
+
if smallest_unit_value == 0:
|
|
12
|
+
return Decimal(0)
|
|
9
13
|
return Decimal(str(round(smallest_unit_value / 10**decimals, ndigits=ndigits)))
|
|
10
14
|
|
|
11
15
|
|
|
@@ -3,7 +3,7 @@ mm_sol/account.py,sha256=0pjvNxwhpmDHoXY3oTY2fNlQHoWPmlS77r8JcP8lAy4,4545
|
|
|
3
3
|
mm_sol/balance.py,sha256=Idx7h9yhRLbrIEDFCBI5QSHE7OT2pYWEZrbHj9XFrkM,3147
|
|
4
4
|
mm_sol/block.py,sha256=4Lc4TANgpGvPflVumC9MR-3vIl1dedGyci3cgzczuds,1794
|
|
5
5
|
mm_sol/constants.py,sha256=WSpfz5_cq_8XbIrNFJGu9okwbfPTL00zsyR_k9-7O0o,29
|
|
6
|
-
mm_sol/converters.py,sha256=
|
|
6
|
+
mm_sol/converters.py,sha256=rBxe3SIADZS8hG7TYl4FgjmvKH-ykaTmNbnWWQDiFZ4,1430
|
|
7
7
|
mm_sol/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
mm_sol/rpc.py,sha256=TspD_KZQp_KJDQzRknxaT8DR03okok26UWDQWF7Zflg,8031
|
|
9
9
|
mm_sol/solana_cli.py,sha256=ig3OoTvmkrl7MFQSZjRHIraLSmtse0_9kn5Nsw8_zb0,8258
|
|
@@ -12,23 +12,23 @@ mm_sol/transfer.py,sha256=Gu6UYEjY5OECSusKJO-VA8C3B7W6ZJGjegUv67EQdfs,5809
|
|
|
12
12
|
mm_sol/utils.py,sha256=NE0G564GiT9d7rW_lPPxUb1eq62WiXh28xtvtzNQIqw,556
|
|
13
13
|
mm_sol/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
mm_sol/cli/calcs.py,sha256=-r9RlsQyOziTDf84uIsvTgZmsUdNrVeazu3vTj9hhNA,1887
|
|
15
|
-
mm_sol/cli/cli.py,sha256=
|
|
15
|
+
mm_sol/cli/cli.py,sha256=OlgBas-dWWZJ_WCbHJGLX6GxfILvIy7Q0VhgRo_nytE,4945
|
|
16
16
|
mm_sol/cli/cli_utils.py,sha256=Skj0SCHPWMHGr2ag-em1JtIK9Qdh7xeJafMzvCgChnc,2254
|
|
17
17
|
mm_sol/cli/validators.py,sha256=HLCFRrBOdyAMj_ibdAkkP36y9Zm2Dt3gMKoyPOcaiQE,1164
|
|
18
18
|
mm_sol/cli/cmd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
19
|
mm_sol/cli/cmd/balance_cmd.py,sha256=DfUZY3-Hr-F7Y0xp1faol0yLnPu6iDU3b839VhdwAbw,2587
|
|
20
|
-
mm_sol/cli/cmd/balances_cmd.py,sha256=
|
|
20
|
+
mm_sol/cli/cmd/balances_cmd.py,sha256=AMeO8vESO7ytQ-clChl4mRfaBiRBAiFAV_DWuv5Kn0c,2840
|
|
21
21
|
mm_sol/cli/cmd/example_cmd.py,sha256=M5dvRg9jvpVUwxvMRiRnO77aKR7c57bMY9booxMAswM,222
|
|
22
22
|
mm_sol/cli/cmd/node_cmd.py,sha256=2AEAjq2M9f8-RZiI0rif6wITdns9QUb4Kr34QPsI2CA,238
|
|
23
23
|
mm_sol/cli/cmd/transfer_sol_cmd.py,sha256=ZBdkb7YrR88foT3zobMZGnDYAHWgx8ljkxRKpkWyM0w,5313
|
|
24
24
|
mm_sol/cli/cmd/transfer_token_cmd.py,sha256=NCaSdO-eud-ef7SdWyTwWdSLiBegYAHySvKz22_j1cg,5911
|
|
25
25
|
mm_sol/cli/cmd/wallet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
26
|
mm_sol/cli/cmd/wallet/keypair_cmd.py,sha256=cRHVVTs9zNYmUozZ8ZlJoutn9V6r8I1AEHBrszR7dTE,538
|
|
27
|
-
mm_sol/cli/cmd/wallet/mnemonic_cmd.py,sha256=
|
|
28
|
-
mm_sol/cli/examples/balances.toml,sha256=
|
|
27
|
+
mm_sol/cli/cmd/wallet/mnemonic_cmd.py,sha256=IiON_fJT5AFfIr_E1LR6_iDYZ3c_jWCFc-wSYqk61V8,648
|
|
28
|
+
mm_sol/cli/examples/balances.toml,sha256=1PWtcYyfBsaHeMsQNiNqnoiYyXMescfOrl80FGKp25o,303
|
|
29
29
|
mm_sol/cli/examples/transfer-sol.toml,sha256=1LdkhSBC0y5oMJXjm8MVIMyZruIrYSIm3LBDGmcS5Iw,353
|
|
30
30
|
mm_sol/cli/examples/transfer-token.toml,sha256=I_Wof-APv-h6xeYVq0zbWfLbpDny2kz9U0xJifVNEtU,401
|
|
31
|
-
mm_sol-0.3.
|
|
32
|
-
mm_sol-0.3.
|
|
33
|
-
mm_sol-0.3.
|
|
34
|
-
mm_sol-0.3.
|
|
31
|
+
mm_sol-0.3.4.dist-info/METADATA,sha256=eQsce4amDDYDbgPehfMLKVaBkGXdXUY7LIhnwC1pu4Q,259
|
|
32
|
+
mm_sol-0.3.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
33
|
+
mm_sol-0.3.4.dist-info/entry_points.txt,sha256=MrYnosumy9nsITSAw5TiR3WXDwsdoF0YvUIlZ38TLLs,46
|
|
34
|
+
mm_sol-0.3.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|