File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,22 @@ def is_valid_ss58_address_param(address: Optional[str]) -> Optional[str]:
149149 return address
150150
151151
152+ def validate_claim_type (value : Optional [str ]) -> Optional [claim_stake .ClaimType ]:
153+ """
154+ Validates the claim type argument, allowing case-insensitive input.
155+ """
156+ if value is None :
157+ return None
158+
159+ try :
160+ for member in claim_stake .ClaimType :
161+ if member .value .lower () == value .lower ():
162+ return member
163+ return claim_stake .ClaimType (value )
164+ except ValueError :
165+ raise typer .BadParameter (f"'{ value } ' is not one of 'Keep', 'Swap'." )
166+
167+
152168class Options :
153169 """
154170 Re-usable typer args
@@ -5616,9 +5632,10 @@ def stake_wizard(
56165632 def stake_set_claim_type (
56175633 self ,
56185634 claim_type : Annotated [
5619- Optional [claim_stake . ClaimType ],
5635+ Optional [str ],
56205636 typer .Argument (
56215637 help = "Claim type: 'Keep' or 'Swap'. If omitted, user will be prompted." ,
5638+ callback = validate_claim_type ,
56225639 ),
56235640 ] = None ,
56245641 netuids : Optional [str ] = typer .Option (
You can’t perform that action at this time.
0 commit comments