meshtensor-cli 9.18.1__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.
- meshtensor_cli/__init__.py +22 -0
- meshtensor_cli/cli.py +10742 -0
- meshtensor_cli/doc_generation_helper.py +4 -0
- meshtensor_cli/src/__init__.py +1085 -0
- meshtensor_cli/src/commands/__init__.py +0 -0
- meshtensor_cli/src/commands/axon/__init__.py +0 -0
- meshtensor_cli/src/commands/axon/axon.py +132 -0
- meshtensor_cli/src/commands/crowd/__init__.py +0 -0
- meshtensor_cli/src/commands/crowd/contribute.py +621 -0
- meshtensor_cli/src/commands/crowd/contributors.py +200 -0
- meshtensor_cli/src/commands/crowd/create.py +783 -0
- meshtensor_cli/src/commands/crowd/dissolve.py +219 -0
- meshtensor_cli/src/commands/crowd/refund.py +233 -0
- meshtensor_cli/src/commands/crowd/update.py +418 -0
- meshtensor_cli/src/commands/crowd/utils.py +124 -0
- meshtensor_cli/src/commands/crowd/view.py +991 -0
- meshtensor_cli/src/commands/governance/__init__.py +0 -0
- meshtensor_cli/src/commands/governance/governance.py +794 -0
- meshtensor_cli/src/commands/liquidity/__init__.py +0 -0
- meshtensor_cli/src/commands/liquidity/liquidity.py +699 -0
- meshtensor_cli/src/commands/liquidity/utils.py +202 -0
- meshtensor_cli/src/commands/proxy.py +700 -0
- meshtensor_cli/src/commands/stake/__init__.py +0 -0
- meshtensor_cli/src/commands/stake/add.py +799 -0
- meshtensor_cli/src/commands/stake/auto_staking.py +306 -0
- meshtensor_cli/src/commands/stake/children_hotkeys.py +865 -0
- meshtensor_cli/src/commands/stake/claim.py +770 -0
- meshtensor_cli/src/commands/stake/list.py +738 -0
- meshtensor_cli/src/commands/stake/move.py +1211 -0
- meshtensor_cli/src/commands/stake/remove.py +1466 -0
- meshtensor_cli/src/commands/stake/wizard.py +323 -0
- meshtensor_cli/src/commands/subnets/__init__.py +0 -0
- meshtensor_cli/src/commands/subnets/mechanisms.py +515 -0
- meshtensor_cli/src/commands/subnets/price.py +733 -0
- meshtensor_cli/src/commands/subnets/subnets.py +2908 -0
- meshtensor_cli/src/commands/sudo.py +1294 -0
- meshtensor_cli/src/commands/tc/__init__.py +0 -0
- meshtensor_cli/src/commands/tc/tc.py +190 -0
- meshtensor_cli/src/commands/treasury/__init__.py +0 -0
- meshtensor_cli/src/commands/treasury/treasury.py +194 -0
- meshtensor_cli/src/commands/view.py +354 -0
- meshtensor_cli/src/commands/wallets.py +2311 -0
- meshtensor_cli/src/commands/weights.py +467 -0
- meshtensor_cli/src/meshtensor/__init__.py +0 -0
- meshtensor_cli/src/meshtensor/balances.py +313 -0
- meshtensor_cli/src/meshtensor/chain_data.py +1263 -0
- meshtensor_cli/src/meshtensor/extrinsics/__init__.py +0 -0
- meshtensor_cli/src/meshtensor/extrinsics/mev_shield.py +174 -0
- meshtensor_cli/src/meshtensor/extrinsics/registration.py +1861 -0
- meshtensor_cli/src/meshtensor/extrinsics/root.py +550 -0
- meshtensor_cli/src/meshtensor/extrinsics/serving.py +255 -0
- meshtensor_cli/src/meshtensor/extrinsics/transfer.py +239 -0
- meshtensor_cli/src/meshtensor/meshtensor_interface.py +2598 -0
- meshtensor_cli/src/meshtensor/minigraph.py +254 -0
- meshtensor_cli/src/meshtensor/networking.py +12 -0
- meshtensor_cli/src/meshtensor/templates/main-filters.j2 +24 -0
- meshtensor_cli/src/meshtensor/templates/main-header.j2 +36 -0
- meshtensor_cli/src/meshtensor/templates/neuron-details.j2 +111 -0
- meshtensor_cli/src/meshtensor/templates/price-multi.j2 +113 -0
- meshtensor_cli/src/meshtensor/templates/price-single.j2 +99 -0
- meshtensor_cli/src/meshtensor/templates/subnet-details-header.j2 +49 -0
- meshtensor_cli/src/meshtensor/templates/subnet-details.j2 +32 -0
- meshtensor_cli/src/meshtensor/templates/subnet-metrics.j2 +57 -0
- meshtensor_cli/src/meshtensor/templates/subnets-table.j2 +28 -0
- meshtensor_cli/src/meshtensor/templates/table.j2 +267 -0
- meshtensor_cli/src/meshtensor/templates/view.css +1058 -0
- meshtensor_cli/src/meshtensor/templates/view.j2 +43 -0
- meshtensor_cli/src/meshtensor/templates/view.js +1053 -0
- meshtensor_cli/src/meshtensor/utils.py +2007 -0
- meshtensor_cli/version.py +23 -0
- meshtensor_cli-9.18.1.dist-info/METADATA +261 -0
- meshtensor_cli-9.18.1.dist-info/RECORD +74 -0
- meshtensor_cli-9.18.1.dist-info/WHEEL +4 -0
- meshtensor_cli-9.18.1.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
import json
|
|
3
|
+
from rich.table import Table
|
|
4
|
+
import asyncio
|
|
5
|
+
|
|
6
|
+
from meshtensor_cli.src import COLORS
|
|
7
|
+
from meshtensor_cli.src.meshtensor.balances import Balance
|
|
8
|
+
from meshtensor_cli.src.meshtensor.meshtensor_interface import MeshtensorInterface
|
|
9
|
+
from meshtensor_cli.src.meshtensor.utils import (
|
|
10
|
+
console,
|
|
11
|
+
json_console,
|
|
12
|
+
print_error,
|
|
13
|
+
millify_tao,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _shorten(account: Optional[str]) -> str:
|
|
18
|
+
"""Shorten an account address for display."""
|
|
19
|
+
if not account:
|
|
20
|
+
return "-"
|
|
21
|
+
return f"{account[:6]}…{account[-6:]}"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
async def list_contributors(
|
|
25
|
+
meshtensor: MeshtensorInterface,
|
|
26
|
+
crowdloan_id: int,
|
|
27
|
+
verbose: bool = False,
|
|
28
|
+
json_output: bool = False,
|
|
29
|
+
) -> bool:
|
|
30
|
+
"""List all contributors to a specific crowdloan.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
meshtensor: MeshtensorInterface object for chain interaction
|
|
34
|
+
crowdloan_id: ID of the crowdloan to list contributors for
|
|
35
|
+
verbose: Show full addresses and precise amounts
|
|
36
|
+
json_output: Output as JSON
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
bool: True if successful, False otherwise
|
|
40
|
+
"""
|
|
41
|
+
with console.status(":satellite: Fetching crowdloan details..."):
|
|
42
|
+
crowdloan = await meshtensor.get_single_crowdloan(crowdloan_id)
|
|
43
|
+
if not crowdloan:
|
|
44
|
+
error_msg = f"Crowdloan #{crowdloan_id} not found."
|
|
45
|
+
if json_output:
|
|
46
|
+
json_console.print(json.dumps({"success": False, "error": error_msg}))
|
|
47
|
+
else:
|
|
48
|
+
print_error(f"{error_msg}")
|
|
49
|
+
return False
|
|
50
|
+
|
|
51
|
+
with console.status(":satellite: Fetching contributors and identities..."):
|
|
52
|
+
contributor_contributions, all_identities = await asyncio.gather(
|
|
53
|
+
meshtensor.get_crowdloan_contributors(crowdloan_id),
|
|
54
|
+
meshtensor.query_all_identities(),
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
if not contributor_contributions:
|
|
58
|
+
if json_output:
|
|
59
|
+
json_console.print(
|
|
60
|
+
json.dumps(
|
|
61
|
+
{
|
|
62
|
+
"success": True,
|
|
63
|
+
"error": None,
|
|
64
|
+
"data": {
|
|
65
|
+
"crowdloan_id": crowdloan_id,
|
|
66
|
+
"contributors": [],
|
|
67
|
+
"total_count": 0,
|
|
68
|
+
"total_contributed": 0,
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
)
|
|
73
|
+
else:
|
|
74
|
+
console.print(
|
|
75
|
+
f"[yellow]No contributors found for crowdloan #{crowdloan_id}.[/yellow]"
|
|
76
|
+
)
|
|
77
|
+
return True
|
|
78
|
+
|
|
79
|
+
total_contributed = sum(
|
|
80
|
+
contributor_contributions.values(), start=Balance.from_tao(0)
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
contributor_data = []
|
|
84
|
+
for address, amount in sorted(
|
|
85
|
+
contributor_contributions.items(), key=lambda x: x[1].meshlet, reverse=True
|
|
86
|
+
):
|
|
87
|
+
identity = all_identities.get(address)
|
|
88
|
+
identity_name = (
|
|
89
|
+
identity.get("name") or identity.get("display") if identity else None
|
|
90
|
+
)
|
|
91
|
+
percentage = (
|
|
92
|
+
(amount.meshlet / total_contributed.meshlet * 100)
|
|
93
|
+
if total_contributed.meshlet > 0
|
|
94
|
+
else 0.0
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
contributor_data.append(
|
|
98
|
+
{
|
|
99
|
+
"address": address,
|
|
100
|
+
"identity": identity_name,
|
|
101
|
+
"contribution": amount,
|
|
102
|
+
"percentage": percentage,
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
if json_output:
|
|
107
|
+
contributors_json = [
|
|
108
|
+
{
|
|
109
|
+
"rank": rank,
|
|
110
|
+
"address": data["address"],
|
|
111
|
+
"identity": data["identity"],
|
|
112
|
+
"contribution_tao": data["contribution"].tao,
|
|
113
|
+
"contribution_meshlet": data["contribution"].meshlet,
|
|
114
|
+
"percentage": data["percentage"],
|
|
115
|
+
}
|
|
116
|
+
for rank, data in enumerate(contributor_data, start=1)
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
output_dict = {
|
|
120
|
+
"success": True,
|
|
121
|
+
"error": None,
|
|
122
|
+
"data": {
|
|
123
|
+
"crowdloan_id": crowdloan_id,
|
|
124
|
+
"contributors": contributors_json,
|
|
125
|
+
"total_count": len(contributor_data),
|
|
126
|
+
"total_contributed_tao": total_contributed.tao,
|
|
127
|
+
"total_contributed_meshlet": total_contributed.meshlet,
|
|
128
|
+
"network": meshtensor.network,
|
|
129
|
+
},
|
|
130
|
+
}
|
|
131
|
+
json_console.print(json.dumps(output_dict))
|
|
132
|
+
return True
|
|
133
|
+
|
|
134
|
+
# Display table
|
|
135
|
+
table = Table(
|
|
136
|
+
title=f"\n[{COLORS.G.HEADER}]Contributors for Crowdloan #{crowdloan_id}"
|
|
137
|
+
f"\nNetwork: [{COLORS.G.SUBHEAD}]{meshtensor.network}\n\n",
|
|
138
|
+
show_footer=True,
|
|
139
|
+
show_edge=False,
|
|
140
|
+
header_style="bold white",
|
|
141
|
+
border_style="bright_black",
|
|
142
|
+
style="bold",
|
|
143
|
+
title_justify="center",
|
|
144
|
+
show_lines=False,
|
|
145
|
+
pad_edge=True,
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
table.add_column(
|
|
149
|
+
"[bold white]Rank",
|
|
150
|
+
style="grey89",
|
|
151
|
+
justify="center",
|
|
152
|
+
footer=str(len(contributor_data)),
|
|
153
|
+
)
|
|
154
|
+
table.add_column(
|
|
155
|
+
"[bold white]Contributor Address",
|
|
156
|
+
style=COLORS.G.TEMPO,
|
|
157
|
+
justify="left",
|
|
158
|
+
overflow="fold",
|
|
159
|
+
)
|
|
160
|
+
table.add_column(
|
|
161
|
+
"[bold white]Identity Name",
|
|
162
|
+
style=COLORS.G.SUBHEAD,
|
|
163
|
+
justify="left",
|
|
164
|
+
overflow="fold",
|
|
165
|
+
)
|
|
166
|
+
table.add_column(
|
|
167
|
+
f"[bold white]Contribution\n({Balance.get_unit(0)})",
|
|
168
|
+
style="dark_sea_green2",
|
|
169
|
+
justify="right",
|
|
170
|
+
footer=f"τ {millify_tao(total_contributed.tao)}"
|
|
171
|
+
if not verbose
|
|
172
|
+
else f"τ {total_contributed.tao:,.4f}",
|
|
173
|
+
)
|
|
174
|
+
table.add_column(
|
|
175
|
+
"[bold white]Percentage",
|
|
176
|
+
style=COLORS.P.EMISSION,
|
|
177
|
+
justify="right",
|
|
178
|
+
footer="100.00%",
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
for rank, data in enumerate(contributor_data, start=1):
|
|
182
|
+
address_cell = data["address"] if verbose else _shorten(data["address"])
|
|
183
|
+
identity_cell = data["identity"] if data["identity"] else "[dim]-[/dim]"
|
|
184
|
+
contribution_cell = (
|
|
185
|
+
f"τ {data['contribution'].tao:,.4f}"
|
|
186
|
+
if verbose
|
|
187
|
+
else f"τ {millify_tao(data['contribution'].tao)}"
|
|
188
|
+
)
|
|
189
|
+
percentage_cell = f"{data['percentage']:.2f}%"
|
|
190
|
+
|
|
191
|
+
table.add_row(
|
|
192
|
+
str(rank),
|
|
193
|
+
address_cell,
|
|
194
|
+
identity_cell,
|
|
195
|
+
contribution_cell,
|
|
196
|
+
percentage_cell,
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
console.print(table)
|
|
200
|
+
return True
|