4
4
import pathlib as pl
5
5
6
6
from cardano_clusterlib import clusterlib_helpers
7
+ from cardano_clusterlib import exceptions
7
8
from cardano_clusterlib import helpers
8
9
from cardano_clusterlib import structs
9
10
from cardano_clusterlib import types as itp
@@ -15,6 +16,25 @@ class ConwayGovDrepGroup:
15
16
def __init__ (self , clusterlib_obj : "itp.ClusterLib" ) -> None :
16
17
self ._clusterlib_obj = clusterlib_obj
17
18
self ._group_args = ("governance" , "drep" )
19
+ self ._has_output_hex_prop : bool | None = None
20
+
21
+ @property
22
+ def _has_output_hex (self ) -> bool :
23
+ """Check if `drep id` has a `--output-hex` option."""
24
+ if self ._has_output_hex_prop is not None :
25
+ return self ._has_output_hex_prop
26
+
27
+ err = ""
28
+ try :
29
+ self ._clusterlib_obj .cli (
30
+ ["cardano-cli" , "conway" , "governance" , "drep" , "id" , "--output-hex" ],
31
+ add_default_args = False ,
32
+ )
33
+ except exceptions .CLIError as excp :
34
+ err = str (excp )
35
+
36
+ self ._has_output_hex_prop = "Invalid option" not in err
37
+ return self ._has_output_hex_prop
18
38
19
39
def _get_cred_args (
20
40
self ,
@@ -94,7 +114,13 @@ def get_id(
94
114
raise AssertionError (msg )
95
115
96
116
if out_format :
97
- cli_args .extend (["--output-format" , str (out_format )])
117
+ if out_format not in ("hex" , "bech32" ):
118
+ msg = f"Invalid output format: { out_format } (expected 'hex' or 'bech32')."
119
+ raise AssertionError (msg )
120
+ if self ._has_output_hex :
121
+ cli_args .append (f"--output-{ out_format } " )
122
+ else :
123
+ cli_args .extend (["--output-format" , str (out_format )])
98
124
99
125
drep_id = (
100
126
self ._clusterlib_obj .cli (
0 commit comments