htcli 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.
Files changed (140) hide show
  1. htcli-1.1.0.dist-info/METADATA +509 -0
  2. htcli-1.1.0.dist-info/RECORD +140 -0
  3. htcli-1.1.0.dist-info/WHEEL +4 -0
  4. htcli-1.1.0.dist-info/entry_points.txt +2 -0
  5. htcli-1.1.0.dist-info/licenses/LICENSE +21 -0
  6. src/__init__.py +0 -0
  7. src/htcli/__init__.py +5 -0
  8. src/htcli/client/__init__.py +338 -0
  9. src/htcli/client/extrinsics/__init__.py +26 -0
  10. src/htcli/client/extrinsics/base.py +487 -0
  11. src/htcli/client/extrinsics/consensus.py +79 -0
  12. src/htcli/client/extrinsics/governance.py +714 -0
  13. src/htcli/client/extrinsics/identity.py +490 -0
  14. src/htcli/client/extrinsics/node.py +1054 -0
  15. src/htcli/client/extrinsics/overwatch.py +401 -0
  16. src/htcli/client/extrinsics/staking.py +1504 -0
  17. src/htcli/client/extrinsics/subnet.py +2218 -0
  18. src/htcli/client/extrinsics/validator.py +203 -0
  19. src/htcli/client/extrinsics/wallet.py +323 -0
  20. src/htcli/client/offchain/__init__.py +10 -0
  21. src/htcli/client/offchain/backup.py +385 -0
  22. src/htcli/client/offchain/config.py +541 -0
  23. src/htcli/client/offchain/wallet.py +839 -0
  24. src/htcli/client/rpc/__init__.py +20 -0
  25. src/htcli/client/rpc/chain.py +568 -0
  26. src/htcli/client/rpc/node.py +783 -0
  27. src/htcli/client/rpc/overwatch.py +680 -0
  28. src/htcli/client/rpc/staking.py +216 -0
  29. src/htcli/client/rpc/subnet.py +2104 -0
  30. src/htcli/client/rpc/wallet.py +912 -0
  31. src/htcli/commands/__init__.py +31 -0
  32. src/htcli/commands/chain/__init__.py +66 -0
  33. src/htcli/commands/chain/display.py +204 -0
  34. src/htcli/commands/chain/handlers.py +260 -0
  35. src/htcli/commands/config/__init__.py +158 -0
  36. src/htcli/commands/config/display.py +353 -0
  37. src/htcli/commands/config/handlers.py +347 -0
  38. src/htcli/commands/config/prompts.py +357 -0
  39. src/htcli/commands/consensus/__init__.py +61 -0
  40. src/htcli/commands/consensus/handlers.py +100 -0
  41. src/htcli/commands/governance/__init__.py +49 -0
  42. src/htcli/commands/governance/handlers.py +81 -0
  43. src/htcli/commands/node/__init__.py +304 -0
  44. src/htcli/commands/node/display.py +749 -0
  45. src/htcli/commands/node/error_handling.py +470 -0
  46. src/htcli/commands/node/handlers.py +844 -0
  47. src/htcli/commands/node/prompts.py +346 -0
  48. src/htcli/commands/overwatch/__init__.py +219 -0
  49. src/htcli/commands/overwatch/display.py +396 -0
  50. src/htcli/commands/overwatch/error_handling.py +276 -0
  51. src/htcli/commands/overwatch/handlers.py +443 -0
  52. src/htcli/commands/overwatch/prompts.py +359 -0
  53. src/htcli/commands/stake/__init__.py +736 -0
  54. src/htcli/commands/stake/display.py +1103 -0
  55. src/htcli/commands/stake/error_handling.py +425 -0
  56. src/htcli/commands/stake/handlers.py +1902 -0
  57. src/htcli/commands/stake/prompts.py +1080 -0
  58. src/htcli/commands/subnet/__init__.py +639 -0
  59. src/htcli/commands/subnet/display.py +801 -0
  60. src/htcli/commands/subnet/error_handling.py +524 -0
  61. src/htcli/commands/subnet/handlers.py +2855 -0
  62. src/htcli/commands/subnet/prompts.py +1225 -0
  63. src/htcli/commands/validator/__init__.py +192 -0
  64. src/htcli/commands/validator/display.py +54 -0
  65. src/htcli/commands/validator/handlers.py +340 -0
  66. src/htcli/commands/wallet/__init__.py +546 -0
  67. src/htcli/commands/wallet/display.py +806 -0
  68. src/htcli/commands/wallet/error_handling.py +210 -0
  69. src/htcli/commands/wallet/handlers.py +3040 -0
  70. src/htcli/commands/wallet/prompts.py +1518 -0
  71. src/htcli/config.py +184 -0
  72. src/htcli/dependencies.py +186 -0
  73. src/htcli/errors/__init__.py +63 -0
  74. src/htcli/errors/base.py +141 -0
  75. src/htcli/errors/display.py +20 -0
  76. src/htcli/errors/handlers.py +710 -0
  77. src/htcli/main.py +343 -0
  78. src/htcli/models/__init__.py +21 -0
  79. src/htcli/models/enums/enum_types.py +35 -0
  80. src/htcli/models/errors.py +103 -0
  81. src/htcli/models/requests/__init__.py +197 -0
  82. src/htcli/models/requests/config.py +70 -0
  83. src/htcli/models/requests/consensus.py +19 -0
  84. src/htcli/models/requests/governance.py +38 -0
  85. src/htcli/models/requests/identity.py +51 -0
  86. src/htcli/models/requests/key.py +22 -0
  87. src/htcli/models/requests/node.py +91 -0
  88. src/htcli/models/requests/overwatch.py +64 -0
  89. src/htcli/models/requests/staking.py +580 -0
  90. src/htcli/models/requests/subnet.py +195 -0
  91. src/htcli/models/requests/validator.py +139 -0
  92. src/htcli/models/requests/wallet.py +118 -0
  93. src/htcli/models/responses/__init__.py +147 -0
  94. src/htcli/models/responses/base.py +18 -0
  95. src/htcli/models/responses/chain.py +39 -0
  96. src/htcli/models/responses/config.py +58 -0
  97. src/htcli/models/responses/identity.py +102 -0
  98. src/htcli/models/responses/overwatch.py +51 -0
  99. src/htcli/models/responses/staking.py +502 -0
  100. src/htcli/models/responses/subnet.py +856 -0
  101. src/htcli/models/responses/wallet.py +185 -0
  102. src/htcli/ui/__init__.py +87 -0
  103. src/htcli/ui/colors.py +309 -0
  104. src/htcli/ui/components/__init__.py +60 -0
  105. src/htcli/ui/components/panels.py +174 -0
  106. src/htcli/ui/components/progress.py +166 -0
  107. src/htcli/ui/components/spinners.py +92 -0
  108. src/htcli/ui/components/tables.py +809 -0
  109. src/htcli/ui/components/trees.py +721 -0
  110. src/htcli/ui/display.py +336 -0
  111. src/htcli/ui/prompts.py +870 -0
  112. src/htcli/utils/__init__.py +76 -0
  113. src/htcli/utils/blockchain/__init__.py +75 -0
  114. src/htcli/utils/blockchain/formatting.py +368 -0
  115. src/htcli/utils/blockchain/patches.py +286 -0
  116. src/htcli/utils/blockchain/peer_id.py +186 -0
  117. src/htcli/utils/blockchain/staking.py +448 -0
  118. src/htcli/utils/blockchain/type_registry.py +1373 -0
  119. src/htcli/utils/blockchain/validation.py +179 -0
  120. src/htcli/utils/cache.py +613 -0
  121. src/htcli/utils/constants.py +38 -0
  122. src/htcli/utils/legacy/__init__.py +12 -0
  123. src/htcli/utils/legacy/colors.py +311 -0
  124. src/htcli/utils/legacy/crypto.py +1176 -0
  125. src/htcli/utils/legacy/formatting.py +452 -0
  126. src/htcli/utils/legacy/interactive.py +306 -0
  127. src/htcli/utils/legacy/subnet_manifest.py +265 -0
  128. src/htcli/utils/legacy/validation.py +488 -0
  129. src/htcli/utils/logging.py +183 -0
  130. src/htcli/utils/network/__init__.py +20 -0
  131. src/htcli/utils/network/subnet.py +344 -0
  132. src/htcli/utils/prompts.py +27 -0
  133. src/htcli/utils/scale_codec.py +155 -0
  134. src/htcli/utils/validation/__init__.py +57 -0
  135. src/htcli/utils/validation/prompt_validators.py +267 -0
  136. src/htcli/utils/wallet/__init__.py +65 -0
  137. src/htcli/utils/wallet/auth.py +151 -0
  138. src/htcli/utils/wallet/core.py +1069 -0
  139. src/htcli/utils/wallet/crypto.py +1615 -0
  140. src/htcli/utils/wallet/migration.py +159 -0
@@ -0,0 +1,216 @@
1
+ """
2
+ RPC client for staking-related queries using scalecodec for decoding.
3
+ """
4
+
5
+ from typing import Optional
6
+
7
+ from substrateinterface import SubstrateInterface
8
+
9
+ from ...models.responses.staking import StakeInfo
10
+ from ...utils.logging import get_logger
11
+
12
+ logger = get_logger(__name__)
13
+
14
+
15
+ class StakingRpcClient:
16
+ """RPC client for staking-related queries."""
17
+
18
+ def __init__(self, substrate: Optional[SubstrateInterface] = None):
19
+ """Initialize the staking RPC client."""
20
+ self.substrate = substrate
21
+
22
+ def get_coldkey_stakes(self, coldkey: str) -> list[StakeInfo]:
23
+ """
24
+ Get stake information for a specific coldkey using custom RPC method with full SCALE decoding.
25
+
26
+ Args:
27
+ coldkey: The coldkey account ID (0x... format)
28
+
29
+ Returns:
30
+ List of StakeInfo objects with all fields decoded
31
+
32
+ Reference:
33
+ - mesh-template chain_functions.py lines 1690-1702, 2179-2194
34
+ - hypertensor-evm/pallets/network/src/lib.rs lines 1218-1223 (SubnetNodeStakeInfo)
35
+ """
36
+ try:
37
+ # Call RPC method
38
+ result = self.substrate.rpc_request(
39
+ method="network_getColdkeyStakes", params=[coldkey]
40
+ )
41
+
42
+ if not result or not result.get("result"):
43
+ return []
44
+
45
+ result_data = result["result"]
46
+
47
+ # Decode Vec<SubnetNodeStakeInfo> using custom type registry
48
+ from ...utils.blockchain.type_registry import (
49
+ decode_vec_subnet_node_stake_info,
50
+ )
51
+
52
+ decoded_list = decode_vec_subnet_node_stake_info(result_data)
53
+
54
+ if not decoded_list:
55
+ return []
56
+
57
+ # Convert decoded dicts to StakeInfo model objects
58
+ stakes = []
59
+ for decoded in decoded_list:
60
+ stake_info = StakeInfo(
61
+ account_id=coldkey,
62
+ subnet_id=decoded.get("subnet_id", 0),
63
+ direct_stake_balance=decoded.get("balance", 0),
64
+ delegate_stake_shares=0, # Not in SubnetNodeStakeInfo
65
+ delegate_stake_balance=0, # Not in SubnetNodeStakeInfo
66
+ )
67
+ stakes.append(stake_info)
68
+ return stakes
69
+
70
+ except Exception as e:
71
+ logger.error(f"Error getting coldkey stakes: {e}")
72
+ return []
73
+
74
+ def get_validator_stakes(self, validator_id: int) -> list[StakeInfo]:
75
+ """
76
+ Get direct node stake information for a validator.
77
+
78
+ Upstream validator ownership RPCs return NodeStakeInfo entries keyed by
79
+ validator_id instead of the legacy coldkey SubnetNodeStakeInfo payload.
80
+ """
81
+ try:
82
+ result = self.substrate.rpc_request(
83
+ method="network_getValidatorStakes", params=[validator_id]
84
+ )
85
+
86
+ if not result or not result.get("result"):
87
+ return []
88
+
89
+ result_data = result["result"]
90
+
91
+ from ...utils.blockchain.type_registry import decode_vec_node_stake_info
92
+
93
+ decoded_list = decode_vec_node_stake_info(result_data)
94
+
95
+ if not decoded_list:
96
+ return []
97
+
98
+ stakes = []
99
+ for decoded in decoded_list:
100
+ stake_info = StakeInfo(
101
+ account_id=f"validator:{validator_id}",
102
+ subnet_id=decoded.get("subnet_id", 0) or 0,
103
+ direct_stake_balance=decoded.get("balance", 0),
104
+ delegate_stake_shares=0,
105
+ delegate_stake_balance=0,
106
+ )
107
+ stakes.append(stake_info)
108
+ return stakes
109
+
110
+ except Exception as e:
111
+ logger.error(f"Error getting validator stakes: {e}")
112
+ return []
113
+
114
+ def get_delegate_stakes(self, coldkey: str) -> list[StakeInfo]:
115
+ """
116
+ Get delegate stake information for a specific coldkey using custom RPC method with full SCALE decoding.
117
+
118
+ Args:
119
+ coldkey: The coldkey account ID (0x... format)
120
+
121
+ Returns:
122
+ List of StakeInfo objects with all fields decoded
123
+
124
+ Reference:
125
+ - mesh-template chain_functions.py lines 1704-1716, 2196-2213
126
+ - hypertensor-evm/pallets/network/src/lib.rs lines 1238-1242 (DelegateStakeInfo)
127
+ """
128
+ try:
129
+ # Call RPC method
130
+ result = self.substrate.rpc_request(
131
+ method="network_getDelegateStakes", params=[coldkey]
132
+ )
133
+
134
+ if not result or not result.get("result"):
135
+ return []
136
+
137
+ result_data = result["result"]
138
+
139
+ # Decode Vec<DelegateStakeInfo> using custom type registry
140
+ from ...utils.blockchain.type_registry import decode_vec_delegate_stake_info
141
+
142
+ decoded_list = decode_vec_delegate_stake_info(result_data)
143
+
144
+ if not decoded_list:
145
+ return []
146
+
147
+ # Convert decoded dicts to StakeInfo model objects
148
+ # DelegateStakeInfo has: subnet_id, shares, balance
149
+ stakes = []
150
+ for decoded in decoded_list:
151
+ stake_info = StakeInfo(
152
+ account_id=coldkey,
153
+ subnet_id=decoded.get("subnet_id", 0),
154
+ delegate_stake_balance=decoded.get("balance", 0),
155
+ delegate_stake_shares=decoded.get("shares", 0), # Delegate shares
156
+ )
157
+ stakes.append(stake_info)
158
+ return stakes
159
+
160
+ except Exception as e:
161
+ logger.error(f"Error getting delegate stakes: {e}")
162
+ return []
163
+
164
+ def get_node_delegate_stakes(self, coldkey: str) -> list[StakeInfo]:
165
+ """
166
+ Get node delegate stake information for a specific coldkey using custom RPC method with full SCALE decoding.
167
+
168
+ Args:
169
+ coldkey: The coldkey account ID (0x... format)
170
+
171
+ Returns:
172
+ List of StakeInfo objects with all fields decoded
173
+
174
+ Reference:
175
+ - mesh-template chain_functions.py lines 1718-1730, 2215-2234
176
+ - hypertensor-evm/pallets/network/src/lib.rs lines 1257-1262 (NodeDelegateStakeInfo)
177
+ """
178
+ try:
179
+ # Call RPC method
180
+ result = self.substrate.rpc_request(
181
+ method="network_getNodeDelegateStakes", params=[coldkey]
182
+ )
183
+
184
+ if not result or not result.get("result"):
185
+ return []
186
+
187
+ result_data = result["result"]
188
+
189
+ # Decode Vec<NodeDelegateStakeInfo> using custom type registry
190
+ from ...utils.blockchain.type_registry import (
191
+ decode_vec_node_delegate_stake_info,
192
+ )
193
+
194
+ decoded_list = decode_vec_node_delegate_stake_info(result_data)
195
+
196
+ if not decoded_list:
197
+ return []
198
+
199
+ # Convert decoded dicts to StakeInfo model objects
200
+ # NodeDelegateStakeInfo has: subnet_id, subnet_node_id, shares, balance
201
+ stakes = []
202
+ for decoded in decoded_list:
203
+ stake_info = StakeInfo(
204
+ account_id=coldkey,
205
+ subnet_id=decoded.get("subnet_id", 0),
206
+ delegate_stake_balance=decoded.get("balance", 0),
207
+ delegate_stake_shares=decoded.get(
208
+ "shares", 0
209
+ ), # Node delegate shares
210
+ )
211
+ stakes.append(stake_info)
212
+ return stakes
213
+
214
+ except Exception as e:
215
+ logger.error(f"Error getting node delegate stakes: {e}")
216
+ return []