From 55bb6067a659ad9b5746302771239f68b2ee8306 Mon Sep 17 00:00:00 2001 From: Kieran Simkin <382129+kieransimkin@users.noreply.github.com> Date: Sun, 13 Oct 2024 02:27:25 +0100 Subject: [PATCH 1/2] Fix failure to report blockfrost error when cbor decode fails --- pycardano/backend/blockfrost.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pycardano/backend/blockfrost.py b/pycardano/backend/blockfrost.py index 3d5d1afe..2c427e06 100644 --- a/pycardano/backend/blockfrost.py +++ b/pycardano/backend/blockfrost.py @@ -310,8 +310,13 @@ def evaluate_tx_cbor(self, cbor: Union[bytes, str]) -> Dict[str, ExecutionUnits] cbor = cbor.hex() with tempfile.NamedTemporaryFile(delete=False, mode="w") as f: f.write(cbor) - result = self.api.transaction_evaluate(f.name).result + + result = self.api.transaction_evaluate(f.name) os.remove(f.name) + if not hasattr(result, "result"): + raise TransactionFailedException(result) + else: + result = result.result return_val = {} if not hasattr(result, "EvaluationResult"): raise TransactionFailedException(result) From e3336507eddc0a29a98e706aec70d078c73707fc Mon Sep 17 00:00:00 2001 From: Kieran Simkin <382129+kieransimkin@users.noreply.github.com> Date: Tue, 15 Oct 2024 00:11:25 +0100 Subject: [PATCH 2/2] Fix formatting issue --- pycardano/backend/blockfrost.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycardano/backend/blockfrost.py b/pycardano/backend/blockfrost.py index 2c427e06..f5a906ea 100644 --- a/pycardano/backend/blockfrost.py +++ b/pycardano/backend/blockfrost.py @@ -310,7 +310,7 @@ def evaluate_tx_cbor(self, cbor: Union[bytes, str]) -> Dict[str, ExecutionUnits] cbor = cbor.hex() with tempfile.NamedTemporaryFile(delete=False, mode="w") as f: f.write(cbor) - + result = self.api.transaction_evaluate(f.name) os.remove(f.name) if not hasattr(result, "result"):