From 923dd3c6066cf6aea27cffbf3b7c1996ffcb6ea7 Mon Sep 17 00:00:00 2001 From: Pana Date: Wed, 30 Aug 2023 11:16:46 +0800 Subject: [PATCH] SendTransactionError parse bug deal data is null (#48) * SendTransactionError parse bug deal data is null --- CHANGELOG.md | 4 ++++ build.gradle | 2 +- .../conflux/web3j/types/SendTransactionError.java | 13 ++++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53f15c6..620715c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +### 1.2.10 + +1. Fix SendTransactionError parse method to handle data is null + ### 1.2.6 * Add support for Batch Requests diff --git a/build.gradle b/build.gradle index a4442cf..e98338d 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ plugins { } group = 'io.github.conflux-chain' -version = '1.2.9' // SNAPSHOT +version = '1.2.10' // SNAPSHOT repositories { jcenter() diff --git a/src/main/java/conflux/web3j/types/SendTransactionError.java b/src/main/java/conflux/web3j/types/SendTransactionError.java index d66fe72..a5102dd 100644 --- a/src/main/java/conflux/web3j/types/SendTransactionError.java +++ b/src/main/java/conflux/web3j/types/SendTransactionError.java @@ -31,6 +31,9 @@ private SendTransactionError(String prefix, String... texts) { } private boolean matches(String message) { + if (message == null) { + return false; + } if (this.prefix != null && !message.startsWith(this.prefix)) { return false; } @@ -61,11 +64,11 @@ public static SendTransactionError parse(Error rpcError) { String data = rpcError.getData(); if (data != null) { data = data.replace("\"", "").replace("\\", ""); - } - - for (SendTransactionError error : SendTransactionError.values()) { - if (error.matches(data)) { - return error; + + for (SendTransactionError error : SendTransactionError.values()) { + if (error.matches(data)) { + return error; + } } }