From 82f82c251efb3b7a36dd0e2fda60c3a6502aa976 Mon Sep 17 00:00:00 2001 From: kubel Date: Wed, 29 Jan 2025 16:29:19 +0100 Subject: [PATCH] handle tx receipt result --- .../reown/sample/wallet/domain/model/Transaction.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sample/wallet/src/main/kotlin/com/reown/sample/wallet/domain/model/Transaction.kt b/sample/wallet/src/main/kotlin/com/reown/sample/wallet/domain/model/Transaction.kt index 59525ac62..c380d15b8 100644 --- a/sample/wallet/src/main/kotlin/com/reown/sample/wallet/domain/model/Transaction.kt +++ b/sample/wallet/src/main/kotlin/com/reown/sample/wallet/domain/model/Transaction.kt @@ -13,6 +13,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.supervisorScope import kotlinx.coroutines.withTimeout import org.json.JSONArray +import org.json.JSONObject import org.web3j.crypto.Credentials import org.web3j.crypto.RawTransaction import org.web3j.crypto.TransactionEncoder @@ -206,7 +207,15 @@ object Transaction { receipt.result == null -> delay(3000) else -> { println("receipt: $receipt") - break + val status = JSONObject(receipt.result.toString()).getString("status") + + if (status == "1") { + break + } else if (status == "0") { + throw Exception("Route Transaction failed. Tx hash: $txHash, chainId: $chainId") + } else { + break + } } } }