Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cardano_clusterlib/address_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def gen_payment_addr(
cli_args = ["--payment-verification-key", str(payment_vkey)]
else:
msg = "Either `payment_vkey_file`, `payment_script_file` or `payment_vkey` is needed."
raise AssertionError(msg)
raise ValueError(msg)

if stake_vkey:
cli_args.extend(["--stake-verification-key", str(stake_vkey)])
Expand Down Expand Up @@ -137,7 +137,7 @@ def get_payment_vkey_hash(
cli_args = ["--payment-verification-key-file", str(payment_vkey_file)]
else:
msg = "Either `payment_vkey` or `payment_vkey_file` is needed."
raise AssertionError(msg)
raise ValueError(msg)

return (
self._clusterlib_obj.cli(["address", "key-hash", *cli_args])
Expand Down
2 changes: 1 addition & 1 deletion cardano_clusterlib/clusterlib_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def get_epoch_for_slot(cluster_obj: "itp.ClusterLib", slot_no: int) -> EpochInfo
genesis_byron = cluster_obj.state_dir / "byron" / "genesis.json"
if not genesis_byron.exists():
msg = f"File '{genesis_byron}' does not exist."
raise AssertionError(msg)
raise FileNotFoundError(msg)

with open(genesis_byron, encoding="utf-8") as in_json:
byron_dict = json.load(in_json)
Expand Down
8 changes: 4 additions & 4 deletions cardano_clusterlib/gov_action_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _get_deposit_return_key_args(
key_args = ["--deposit-return-stake-key-hash", str(deposit_return_stake_key_hash)]
else:
msg = "Either stake verification key or stake key hash must be set."
raise AssertionError(msg)
raise ValueError(msg)

return key_args

Expand Down Expand Up @@ -86,7 +86,7 @@ def _get_cc_members_args(
)
else:
msg = f"Either {arg_action} cold verification key or its hash must be set."
raise AssertionError(msg)
raise ValueError(msg)

if not remove:
cc_members_args.extend(["--epoch", str(cc_member.epoch)])
Expand All @@ -103,7 +103,7 @@ def _get_optional_prev_action_args(
if prev_action_txid:
if prev_action_ix == -1:
msg = "Previous action index must be set."
raise AssertionError(msg)
raise ValueError(msg)
prev_action_args = [
"--prev-governance-action-tx-id",
str(prev_action_txid),
Expand Down Expand Up @@ -508,7 +508,7 @@ def create_treasury_withdrawal(
]
else:
msg = "Either stake verification key or stake key hash must be set."
raise AssertionError(msg)
raise ValueError(msg)

deposit_key_args = self._get_deposit_return_key_args(
deposit_return_stake_vkey=deposit_return_stake_vkey,
Expand Down
6 changes: 3 additions & 3 deletions cardano_clusterlib/gov_committee_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _get_cold_vkey_args(
key_args = ["--cold-key-hash", str(cold_vkey_hash)]
else:
msg = "Either `cold_vkey`, `cold_vkey_file` or `cold_vkey_hash` is needed."
raise AssertionError(msg)
raise ValueError(msg)

return key_args

Expand Down Expand Up @@ -99,7 +99,7 @@ def gen_hot_key_auth_cert(
hot_key_args = ["--hot-verification-key-hash", str(hot_key_hash)]
else:
msg = "Either `hot_key`, `hot_key_file` or `hot_key_hash` is needed."
raise AssertionError(msg)
raise ValueError(msg)

self._clusterlib_obj.cli(
[
Expand Down Expand Up @@ -176,7 +176,7 @@ def get_key_hash(
key_args = ["--verification-key-file", str(vkey_file)]
else:
msg = "Either `vkey` or `vkey_file` is needed."
raise AssertionError(msg)
raise ValueError(msg)

key_hash = (
self._clusterlib_obj.cli([*self._group_args, "key-hash", *key_args])
Expand Down
6 changes: 3 additions & 3 deletions cardano_clusterlib/gov_drep_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _get_cred_args(
msg = (
"Either `script_hash`, `drep_vkey`, `drep_vkey_file` or `drep_key_hash` is needed."
)
raise AssertionError(msg)
raise ValueError(msg)

return cred_args

Expand Down Expand Up @@ -111,12 +111,12 @@ def get_id(
cli_args = ["--drep-verification-key-file", str(drep_vkey_file)]
else:
msg = "Either `drep_vkey` or `drep_vkey_file` is needed."
raise AssertionError(msg)
raise ValueError(msg)

if out_format:
if out_format not in ("hex", "bech32"):
msg = f"Invalid output format: {out_format} (expected 'hex' or 'bech32')."
raise AssertionError(msg)
raise ValueError(msg)
if self._has_output_hex:
cli_args.append(f"--output-{out_format}")
else:
Expand Down
2 changes: 1 addition & 1 deletion cardano_clusterlib/gov_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_anchor_data_hash(
content_args = ["--file-text", str(file_text)]
else:
msg = "Either `text`, `file_binary` or `file_text` is needed."
raise AssertionError(msg)
raise ValueError(msg)

out_hash = (
self._clusterlib_obj.cli(
Expand Down
10 changes: 5 additions & 5 deletions cardano_clusterlib/gov_vote_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _get_vote_args(
vote_args = ["--abstain"]
else:
msg = "No vote was specified."
raise AssertionError(msg)
raise ValueError(msg)

return vote_args

Expand All @@ -57,7 +57,7 @@ def _get_anchor_args(
if anchor_url:
if not anchor_data_hash:
msg = "Anchor data hash is required when anchor URL is specified."
raise AssertionError(msg)
raise ValueError(msg)
anchor_args = [
"--anchor-url",
str(anchor_url),
Expand Down Expand Up @@ -101,7 +101,7 @@ def create_committee(
cred_args = ["--cc-hot-script-hash", cc_hot_script_hash]
else:
msg = "No CC key or script hash was specified."
raise AssertionError(msg)
raise ValueError(msg)

self._clusterlib_obj.cli(
[
Expand Down Expand Up @@ -166,7 +166,7 @@ def create_drep(
cred_args = ["--drep-script-hash", drep_script_hash]
else:
msg = "No DRep key or script hash was specified."
raise AssertionError(msg)
raise ValueError(msg)

self._clusterlib_obj.cli(
[
Expand Down Expand Up @@ -228,7 +228,7 @@ def create_spo(
key_args = ["--stake-pool-id", stake_pool_id]
else:
msg = "No key was specified."
raise AssertionError(msg)
raise ValueError(msg)

self._clusterlib_obj.cli(
[
Expand Down
4 changes: 2 additions & 2 deletions cardano_clusterlib/query_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def get_utxo(
cli_args.extend(helpers._prepend_flag("--tx-in", utxo_formatted))
else:
msg = "Either `address`, `txin`, `utxo` or `tx_raw_output` need to be specified."
raise AssertionError(msg)
raise ValueError(msg)

utxo_dict = json.loads(self.query_cli(cli_args))
utxos = txtools.get_utxo(utxo_dict=utxo_dict, address=address_single, coins=coins)
Expand Down Expand Up @@ -397,7 +397,7 @@ def get_leadership_schedule(
)
else:
msg = "Either `stake_pool_vkey`, `cold_vkey_file` or `stake_pool_id` is needed."
raise AssertionError(msg)
raise ValueError(msg)

args.append("--next" if for_next else "--current")

Expand Down
10 changes: 5 additions & 5 deletions cardano_clusterlib/stake_address_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _get_stake_vkey_args(
stake_args = ["--stake-address", stake_address]
else:
msg = "Either `stake_vkey_file`, `stake_script_file` or `stake_address` is needed."
raise AssertionError(msg)
raise ValueError(msg)

return stake_args

Expand Down Expand Up @@ -62,7 +62,7 @@ def _get_drep_args(
drep_args = ["--drep-key-hash", str(drep_key_hash)]
else:
msg = "DRep identification, verification key or script hash is needed."
raise AssertionError(msg)
raise ValueError(msg)

return drep_args

Expand All @@ -81,7 +81,7 @@ def _get_pool_key_args(
pool_key_args = ["--stake-pool-id", stake_pool_id]
else:
msg = "No stake pool key was specified."
raise AssertionError(msg)
raise ValueError(msg)

return pool_key_args

Expand Down Expand Up @@ -113,7 +113,7 @@ def gen_stake_addr(
cli_args = ["--stake-script-file", str(stake_script_file)]
else:
msg = "Either `stake_vkey_file` or `stake_script_file` is needed."
raise AssertionError(msg)
raise ValueError(msg)

self._clusterlib_obj.cli(
[
Expand Down Expand Up @@ -517,7 +517,7 @@ def get_stake_vkey_hash(
cli_args = ["--stake-verification-key-file", str(stake_vkey_file)]
else:
msg = "Either `stake_vkey` or `stake_vkey_file` is needed."
raise AssertionError(msg)
raise ValueError(msg)

return (
self._clusterlib_obj.cli(["stake-address", "key-hash", *cli_args])
Expand Down
2 changes: 1 addition & 1 deletion cardano_clusterlib/stake_pool_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def get_stake_pool_id(
key_args = ["--cold-verification-key-file", str(cold_vkey_file)]
else:
msg = "No key was specified."
raise AssertionError(msg)
raise ValueError(msg)

pool_id = (
self._clusterlib_obj.cli(["stake-pool", "id", *key_args]).stdout.strip().decode("ascii")
Expand Down
20 changes: 10 additions & 10 deletions cardano_clusterlib/transaction_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def get_txid(self, tx_body_file: itp.FileType = "", tx_file: itp.FileType = "")
cli_args.extend(["--tx-file", str(tx_file)])
else:
msg = "Either `tx_body_file` or `tx_file` is needed."
raise AssertionError(msg)
raise ValueError(msg)

return (
self._clusterlib_obj.cli(["transaction", "txid", *cli_args])
Expand All @@ -97,7 +97,7 @@ def view_tx(self, tx_body_file: itp.FileType = "", tx_file: itp.FileType = "") -
cli_args.extend(["--tx-file", str(tx_file)])
else:
msg = "Either `tx_body_file` or `tx_file` is needed."
raise AssertionError(msg)
raise ValueError(msg)

if self._has_debug:
cli_args = ["cardano-cli", "debug", *cli_args]
Expand Down Expand Up @@ -148,7 +148,7 @@ def get_hash_script_data(
"Either `script_data_file`, `script_data_cbor_file` or `script_data_value` "
"is needed."
)
raise AssertionError(msg)
raise ValueError(msg)

return (
self._clusterlib_obj.cli(["transaction", "hash-script-data", *cli_args])
Expand Down Expand Up @@ -277,7 +277,7 @@ def build_raw_tx_bare( # noqa: C901
msg = (
"Both `treasury_donation` and `current_treasury_value` must be specified together."
)
raise AssertionError(msg)
raise ValueError(msg)

if tx_files.certificate_files and complex_certs:
LOGGER.warning(
Expand Down Expand Up @@ -769,7 +769,7 @@ def calculate_min_req_utxo(
"""
if not txouts:
msg = "No txout was specified."
raise AssertionError(msg)
raise ValueError(msg)

txout_args, __, txouts_count = txtools._join_txouts(txouts=txouts)

Expand All @@ -778,7 +778,7 @@ def calculate_min_req_utxo(
"Accepts `TxOuts` only for a single transaction txout "
"(same address, datum, script)."
)
raise AssertionError(msg)
raise ValueError(msg)

self._clusterlib_obj.create_pparams_file()
stdout = self._clusterlib_obj.cli(
Expand Down Expand Up @@ -879,7 +879,7 @@ def build_tx( # noqa: C901
if max_txout:
if change_address:
msg = "Cannot use '-1' amount and change address at the same time."
raise AssertionError(msg)
raise ValueError(msg)
change_address = max_txout[0].address
else:
change_address = change_address or src_address
Expand Down Expand Up @@ -1144,7 +1144,7 @@ def build_estimate_tx( # noqa: C901
if max_txout:
if change_address:
msg = "Cannot use '-1' amount and change address at the same time."
raise AssertionError(msg)
raise ValueError(msg)
change_address = max_txout[0].address
else:
change_address = change_address or src_address
Expand All @@ -1153,7 +1153,7 @@ def build_estimate_tx( # noqa: C901
msg = (
"Both `treasury_donation` and `current_treasury_value` must be specified together."
)
raise AssertionError(msg)
raise ValueError(msg)

tx_files = tx_files or structs.TxFiles()
if tx_files.certificate_files and complex_certs:
Expand Down Expand Up @@ -1366,7 +1366,7 @@ def sign_tx(
cli_args = ["--tx-file", str(tx_file)]
else:
msg = "Either `tx_body_file` or `tx_file` is needed."
raise AssertionError(msg)
raise ValueError(msg)

self._clusterlib_obj.cli(
[
Expand Down
8 changes: 4 additions & 4 deletions cardano_clusterlib/txtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def _balance_txouts(
burning_txouts = [r for r in txouts if r.amount < 0 and r.coin != consts.DEFAULT_COIN]
if burning_txouts:
msg = f"Token burning is not allowed in txouts: {burning_txouts}"
raise AssertionError(msg)
raise ValueError(msg)

# Filter out negative amounts (-1 "max" amounts)
txouts_result = [r for r in txouts if r.amount > 0]
Expand All @@ -327,7 +327,7 @@ def _balance_txouts(
max_index = [idx for idx, val in enumerate(coin_txouts) if val.amount == -1]
if len(max_index) > 1:
msg = "Cannot send all remaining funds to more than one address."
raise AssertionError(msg)
raise ValueError(msg)
if max_index:
# Remove the "-1" record and get its address
max_address = coin_txouts.pop(max_index[0]).address
Expand Down Expand Up @@ -608,7 +608,7 @@ def _get_return_collateral_txout_args(txouts: structs.OptionalTxOuts) -> list[st
addresses = {t.address for t in txouts}
if len(addresses) > 1:
msg = "Accepts `txouts` only for single address."
raise AssertionError(msg)
raise ValueError(msg)

txout_records = [
f"{t.amount} {t.coin if t.coin != consts.DEFAULT_COIN else ''}".rstrip() for t in txouts
Expand Down Expand Up @@ -804,7 +804,7 @@ def collect_data_for_build(
script_addresses = {r.address for r in script_txins_records}
if src_address in script_addresses:
msg = "Source address cannot be a script address."
raise AssertionError(msg)
raise ValueError(msg)

# Combine txins and make sure we have enough funds to satisfy all txouts
combined_txins = [
Expand Down
Loading