Skip to content

Commit d58ed56

Browse files
committed
Merge branch 'feat/next' into environment-config
2 parents 32787af + e3cb6db commit d58ed56

3 files changed

Lines changed: 36 additions & 7 deletions

File tree

multiversx_sdk_cli/base_transactions_controller.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
)
2323
from multiversx_sdk_cli.cosign_transaction import cosign_transaction
2424
from multiversx_sdk_cli.env import get_address_hrp
25-
from multiversx_sdk_cli.errors import BadUserInput
25+
from multiversx_sdk_cli.errors import BadUserInput, TransactionSigningError
2626
from multiversx_sdk_cli.guardian_relayer_data import GuardianRelayerData
2727
from multiversx_sdk_cli.interfaces import IAccount
2828

@@ -47,7 +47,10 @@ def sign_transaction(
4747
self._set_options_for_hash_signing_if_needed(transaction, sender, guardian, relayer)
4848

4949
if sender:
50-
transaction.signature = sender.sign_transaction(transaction)
50+
try:
51+
transaction.signature = sender.sign_transaction(transaction)
52+
except Exception as e:
53+
raise TransactionSigningError(f"Could not sign transaction: {str(e)}")
5154

5255
self._sign_guarded_transaction_if_guardian(
5356
transaction,
@@ -94,15 +97,21 @@ def _sign_guarded_transaction_if_guardian(
9497
) -> Transaction:
9598
# If the guardian account is provided, we sign locally. Otherwise, we reach for the trusted cosign service.
9699
if guardian:
97-
transaction.guardian_signature = guardian.sign_transaction(transaction)
100+
try:
101+
transaction.guardian_signature = guardian.sign_transaction(transaction)
102+
except Exception as e:
103+
raise TransactionSigningError(f"Could not sign transaction: {str(e)}")
98104
elif transaction.guardian and guardian_service_url and guardian_2fa_code:
99105
cosign_transaction(transaction, guardian_service_url, guardian_2fa_code)
100106

101107
return transaction
102108

103109
def _sign_relayed_transaction_if_relayer(self, transaction: Transaction, relayer: Union[IAccount, None]):
104110
if relayer and transaction.relayer:
105-
transaction.relayer_signature = relayer.sign_transaction(transaction)
111+
try:
112+
transaction.relayer_signature = relayer.sign_transaction(transaction)
113+
except Exception as e:
114+
raise TransactionSigningError(f"Could not sign transaction: {str(e)}")
106115

107116
def _convert_args_to_typed_values(self, arguments: list[str]) -> list[Any]:
108117
args: list[Any] = []

multiversx_sdk_cli/cli_shared.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
ArgumentsNotProvidedError,
3838
BadUsage,
3939
IncorrectWalletError,
40+
LedgerError,
4041
)
4142
from multiversx_sdk_cli.guardian_relayer_data import GuardianRelayerData
4243
from multiversx_sdk_cli.interfaces import IAccount
@@ -353,7 +354,10 @@ def prepare_account(args: Any):
353354
hrp=hrp,
354355
)
355356
elif args.ledger:
356-
return LedgerAccount(address_index=args.sender_wallet_index)
357+
try:
358+
return LedgerAccount(address_index=args.sender_wallet_index)
359+
except Exception as e:
360+
raise LedgerError(str(e))
357361
else:
358362
raise errors.NoWalletProvided()
359363

@@ -409,7 +413,10 @@ def load_guardian_account(args: Any) -> Union[IAccount, None]:
409413
hrp=hrp,
410414
)
411415
elif args.guardian_ledger:
412-
return LedgerAccount(address_index=args.guardian_wallet_index)
416+
try:
417+
return LedgerAccount(address_index=args.guardian_wallet_index)
418+
except Exception as e:
419+
raise LedgerError(str(e))
413420

414421
return None
415422

@@ -540,7 +547,10 @@ def load_relayer_account(args: Any) -> Union[IAccount, None]:
540547
hrp=hrp,
541548
)
542549
elif args.relayer_ledger:
543-
return LedgerAccount(address_index=args.relayer_wallet_index)
550+
try:
551+
return LedgerAccount(address_index=args.relayer_wallet_index)
552+
except Exception as e:
553+
raise LedgerError(str(e))
544554

545555
return None
546556

multiversx_sdk_cli/errors.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ def __init__(self, message: str):
151151
super().__init__(message)
152152

153153

154+
class LedgerError(KnownError):
155+
def __init__(self, message: str):
156+
super().__init__(message)
157+
158+
159+
class TransactionSigningError(KnownError):
160+
def __init__(self, message: str):
161+
super().__init__(message)
162+
163+
154164
class InvalidConfirmationSettingError(KnownError):
155165
def __init__(self, value: str):
156166
super().__init__(

0 commit comments

Comments
 (0)