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,210 @@
1
+ """
2
+ Error handling utilities for wallet extrinsics commands.
3
+ Provides user-friendly error messages for all wallet-related blockchain errors.
4
+ """
5
+
6
+ from typing import Optional
7
+
8
+ from ...ui.components import HTCLIPanel
9
+ from ...ui.display import HTCLIConsole
10
+
11
+
12
+ def handle_wallet_extrinsic_error(
13
+ error_msg: str,
14
+ operation: str = "operation",
15
+ client=None,
16
+ ) -> bool:
17
+ """
18
+ Handle wallet extrinsic-related errors with user-friendly messages.
19
+
20
+ Args:
21
+ error_msg: The error message from the blockchain
22
+ operation: Description of the operation being performed (e.g., "transfer", "update coldkey")
23
+ client: Optional client instance for fetching additional info
24
+
25
+ Returns:
26
+ bool: True if error was handled, False otherwise
27
+ """
28
+ console = HTCLIConsole()
29
+
30
+ # System-level errors (checked first)
31
+ if "Paused" in error_msg and "Subnet" not in error_msg:
32
+ error_panel = HTCLIPanel(
33
+ f"The network is currently paused.\n\n"
34
+ f"⏸️ All transactions are temporarily disabled on the network.\n\n"
35
+ f"💡 Please wait for the network to resume operations.\n"
36
+ f" Check network status or try again later.",
37
+ title="⏸️ Network Paused",
38
+ border_style="htcli.warning",
39
+ highlight=True,
40
+ )
41
+ error_panel.render(console.console)
42
+ return True
43
+
44
+ elif "BadOrigin" in error_msg or ("invalid" in error_msg.lower() and "signature" in error_msg.lower()):
45
+ error_panel = HTCLIPanel(
46
+ f"Invalid transaction signature.\n\n"
47
+ f"💡 This usually means:\n"
48
+ f" - Your wallet is not properly unlocked\n"
49
+ f" - The signing key doesn't match the account\n"
50
+ f" - There's an issue with your wallet configuration\n\n"
51
+ f" Try: htcli wallet unlock to unlock your wallet\n"
52
+ f" Or check your wallet configuration: htcli wallet list",
53
+ title="❌ Invalid Signature",
54
+ border_style="htcli.error",
55
+ highlight=True,
56
+ )
57
+ error_panel.render(console.console)
58
+ return True
59
+
60
+ elif "TxRateLimitExceeded" in error_msg:
61
+ error_panel = HTCLIPanel(
62
+ f"Transaction rate limit exceeded.\n\n"
63
+ f"⏱️ You've exceeded the maximum number of transactions allowed for your account.\n\n"
64
+ f"💡 Wait a moment before submitting another transaction.\n"
65
+ f" Rate limits help prevent spam and ensure network stability.",
66
+ title="⏳ Rate Limit Exceeded",
67
+ border_style="htcli.warning",
68
+ highlight=True,
69
+ )
70
+ error_panel.render(console.console)
71
+ return True
72
+
73
+ # Transfer-specific errors
74
+ elif "InsufficientBalance" in error_msg or "NotEnoughBalance" in error_msg or "insufficient balance" in error_msg.lower():
75
+ error_panel = HTCLIPanel(
76
+ f"Insufficient balance to complete the transfer.\n\n"
77
+ f"💡 You don't have enough balance in your wallet to complete this transaction.\n"
78
+ f" Accounts must maintain a minimum balance to stay alive.\n\n"
79
+ f" Check your balance: htcli wallet balance\n"
80
+ f" Reduce the transfer amount and try again.",
81
+ title="❌ Insufficient Balance",
82
+ border_style="htcli.error",
83
+ highlight=True,
84
+ )
85
+ error_panel.render(console.console)
86
+ return True
87
+
88
+ elif "BalanceTooLow" in error_msg or "would kill account" in error_msg.lower() or "BalanceWithdrawalError" in error_msg:
89
+ error_panel = HTCLIPanel(
90
+ f"Cannot transfer - would kill account.\n\n"
91
+ f"💡 Transferring this amount would leave your account with insufficient balance.\n"
92
+ f" Accounts must maintain a minimum balance to stay alive.\n\n"
93
+ f" Reduce the transfer amount and try again.\n"
94
+ f" Check your balance: htcli wallet balance",
95
+ title="❌ Balance Too Low",
96
+ border_style="htcli.error",
97
+ highlight=True,
98
+ )
99
+ error_panel.render(console.console)
100
+ return True
101
+
102
+ elif "InvalidAmount" in error_msg or "AmountZero" in error_msg or "amount must be greater than zero" in error_msg.lower():
103
+ error_panel = HTCLIPanel(
104
+ f"Invalid transfer amount.\n\n"
105
+ f"💡 Transfer amount must be greater than zero.\n"
106
+ f" Provide a valid amount and try again.",
107
+ title="❌ Invalid Amount",
108
+ border_style="htcli.error",
109
+ highlight=True,
110
+ )
111
+ error_panel.render(console.console)
112
+ return True
113
+
114
+ elif "CouldNotConvertToBalance" in error_msg:
115
+ error_panel = HTCLIPanel(
116
+ f"Balance conversion failed.\n\n"
117
+ f"💡 Failed to convert amount to balance type.\n"
118
+ f" This usually indicates an overflow or invalid value.\n"
119
+ f" Check your input values and try again.",
120
+ title="❌ Conversion Error",
121
+ border_style="htcli.error",
122
+ highlight=True,
123
+ )
124
+ error_panel.render(console.console)
125
+ return True
126
+
127
+ # Update coldkey-specific errors
128
+ elif "NotKeyOwner" in error_msg or "not the owner" in error_msg.lower():
129
+ if "update" in operation.lower() or "coldkey" in operation.lower():
130
+ error_panel = HTCLIPanel(
131
+ f"You are not the owner of this hotkey.\n\n"
132
+ f"💡 Only the current coldkey owner can update the hotkey's owner.\n"
133
+ f" Make sure you're using the correct coldkey wallet.\n\n"
134
+ f" Check your wallet: htcli wallet list\n"
135
+ f" Verify hotkey ownership: htcli wallet describe",
136
+ title="❌ Permission Denied",
137
+ border_style="htcli.error",
138
+ highlight=True,
139
+ )
140
+ else:
141
+ error_panel = HTCLIPanel(
142
+ f"You are not authorized to perform this operation.\n\n"
143
+ f"💡 Make sure you're using the correct wallet.\n"
144
+ f" Check your wallet: htcli wallet list",
145
+ title="❌ Permission Denied",
146
+ border_style="htcli.error",
147
+ highlight=True,
148
+ )
149
+ error_panel.render(console.console)
150
+ return True
151
+
152
+ elif "ColdkeyMatchesHotkey" in error_msg or "coldkey matches hotkey" in error_msg.lower():
153
+ error_panel = HTCLIPanel(
154
+ f"Cannot set coldkey to match hotkey.\n\n"
155
+ f"💡 The coldkey and hotkey must be different accounts.\n"
156
+ f" This is a security requirement to prevent key confusion.\n\n"
157
+ f" Use a different coldkey address and try again.",
158
+ title="❌ Invalid Key Configuration",
159
+ border_style="htcli.error",
160
+ highlight=True,
161
+ )
162
+ error_panel.render(console.console)
163
+ return True
164
+
165
+ # Address validation errors
166
+ elif "InvalidAddress" in error_msg or "invalid address" in error_msg.lower():
167
+ error_panel = HTCLIPanel(
168
+ f"Invalid wallet address.\n\n"
169
+ f"💡 The provided address is not valid.\n"
170
+ f" Check the address format and try again.\n\n"
171
+ f" Use: htcli wallet list to see valid wallet addresses",
172
+ title="❌ Invalid Address",
173
+ border_style="htcli.error",
174
+ highlight=True,
175
+ )
176
+ error_panel.render(console.console)
177
+ return True
178
+
179
+ # Transaction errors
180
+ elif "TransactionFailed" in error_msg or "transaction failed" in error_msg.lower():
181
+ error_panel = HTCLIPanel(
182
+ f"Transaction failed on the blockchain.\n\n"
183
+ f"💡 The transaction was submitted but failed during execution.\n"
184
+ f" This could be due to:\n"
185
+ f" - Insufficient balance\n"
186
+ f" - Invalid parameters\n"
187
+ f" - Network conditions\n\n"
188
+ f" Check your balance and parameters, then try again.",
189
+ title="❌ Transaction Failed",
190
+ border_style="htcli.error",
191
+ highlight=True,
192
+ )
193
+ error_panel.render(console.console)
194
+ return True
195
+
196
+ elif "ExhaustedResources" in error_msg or "out of resources" in error_msg.lower():
197
+ error_panel = HTCLIPanel(
198
+ f"Transaction exceeds block weight limit.\n\n"
199
+ f"💡 The transaction is too complex or large for the current block.\n"
200
+ f" Try breaking it into smaller transactions or wait for network conditions to improve.",
201
+ title="❌ Resource Limit Exceeded",
202
+ border_style="htcli.error",
203
+ highlight=True,
204
+ )
205
+ error_panel.render(console.console)
206
+ return True
207
+
208
+ return False # Error not handled by this function
209
+
210
+