Skip to content

Commit d12c23c

Browse files
committed
More error info in case of failed transaction and slightly better timing
1 parent cfd367b commit d12c23c

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/soroban/invoke.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,25 @@ def invoke(
7474
)
7575

7676
tx.sign(identity.keypair)
77+
7778
transaction = soroban_server.send_transaction(tx)
7879

7980
if transaction.status != SendTransactionStatus.PENDING:
80-
raise SdkError(f"Failed to send transaction: {transaction.hash}")
81+
raise SdkError(
82+
f"Failed to send transaction: {transaction.hash!r} with {transaction.error_result_xdr!r}"
83+
)
8184

8285
i = 0
8386
while i < 10:
87+
time.sleep(3)
8488
transaction_result = soroban_server.get_transaction(transaction.hash)
8589
if transaction_result.status != GetTransactionStatus.NOT_FOUND:
8690
break
87-
time.sleep(3)
8891
i += 1
8992
else:
90-
raise SdkError(f"Timeout - could not validate transaction: {transaction.hash}")
93+
raise SdkError(
94+
f"Timeout - could not validate transaction: {transaction.hash!r} with {transaction.error_result_xdr!r}"
95+
)
9196

9297
transaction_envelope = stellar_sdk.parse_transaction_envelope_from_xdr(
9398
transaction_result.envelope_xdr, network_passphrase=network.network_passphrase
@@ -101,4 +106,6 @@ def invoke(
101106
result = transaction_meta.v3.soroban_meta.return_value
102107
return result
103108
else:
104-
raise SdkError(f"Transaction failed: {transaction_result.result_xdr}")
109+
raise SdkError(
110+
f"Transaction failed: {transaction.hash!r} with {transaction_result.result_xdr!r}"
111+
)

0 commit comments

Comments
 (0)