From 0d942bb32c2d8a12172f467fd205715dd3f8c185 Mon Sep 17 00:00:00 2001 From: dwzhan Date: Tue, 26 Mar 2024 17:21:33 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20use=20only=20one=20source=20code=20?= =?UTF-8?q?copy=20to=20support=20mutiple=20solc=20version=20included=200.4?= =?UTF-8?q?.25=200.5.2=200=EF=BC=8C6.10=200.8.11?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/fisco/solc/compiler/Version.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/fisco/solc/compiler/Version.java b/src/main/java/org/fisco/solc/compiler/Version.java index 0dfd8c0..1b719c2 100644 --- a/src/main/java/org/fisco/solc/compiler/Version.java +++ b/src/main/java/org/fisco/solc/compiler/Version.java @@ -16,4 +16,4 @@ public enum Version { public String toString() { return this.version; } -} +} \ No newline at end of file From 875fe2097167f2c3b4c3b74a6f4a7d78cb3ad41c Mon Sep 17 00:00:00 2001 From: dwzhan Date: Fri, 29 Mar 2024 10:16:12 +0800 Subject: [PATCH 2/4] fix: format code by google code format plugin. --- src/main/java/org/fisco/solc/compiler/Version.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/fisco/solc/compiler/Version.java b/src/main/java/org/fisco/solc/compiler/Version.java index 1b719c2..0dfd8c0 100644 --- a/src/main/java/org/fisco/solc/compiler/Version.java +++ b/src/main/java/org/fisco/solc/compiler/Version.java @@ -16,4 +16,4 @@ public enum Version { public String toString() { return this.version; } -} \ No newline at end of file +} From 0dac6cfa5c37c0adaa0483a6842918d6396b141b Mon Sep 17 00:00:00 2001 From: dwzhan Date: Sun, 28 Apr 2024 15:02:46 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20The=200.8.11=20solc=20return=20abi?= =?UTF-8?q?=20and=20doc=20as=20json=20object=20but=200.6.10=200.5.2=200.4.?= =?UTF-8?q?25=20solc=20return=20abi=20and=20doc=20as=20string=EF=BC=8C=20s?= =?UTF-8?q?o=20the=20parse=20logic=20should=20handle=20it=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solc/compiler/CompilationResult.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/fisco/solc/compiler/CompilationResult.java b/src/main/java/org/fisco/solc/compiler/CompilationResult.java index e07b581..ecc8cd6 100644 --- a/src/main/java/org/fisco/solc/compiler/CompilationResult.java +++ b/src/main/java/org/fisco/solc/compiler/CompilationResult.java @@ -46,16 +46,16 @@ public static CompilationResult parse(String rawJson) throws IOException { JsonObject contractJsonObject = asJsonObject.get(contract.toString()).getAsJsonObject(); JsonObject abiObject = new JsonObject(); - abiObject.addProperty("abi", contractJsonObject.get("abi").toString()); - abiObject.addProperty("bin", contractJsonObject.get("bin").getAsString()); - abiObject.addProperty("metadata", contractJsonObject.get("metadata").getAsString()); + abiObject.addProperty("abi", getJsonValueAsString(contractJsonObject, "abi")); + abiObject.addProperty("bin", getJsonValueAsString(contractJsonObject, "bin")); + abiObject.addProperty("metadata", getJsonValueAsString(contractJsonObject, "metadata")); if (contractJsonObject.get("userdoc") != null) { - abiObject.addProperty("userdoc", contractJsonObject.get("userdoc").toString()); + abiObject.addProperty("userdoc", getJsonValueAsString(contractJsonObject, "userdoc")); } if (contractJsonObject.get("devdoc") != null) { - abiObject.addProperty("devdoc", contractJsonObject.get("devdoc").toString()); + abiObject.addProperty("devdoc", getJsonValueAsString(contractJsonObject, "devdoc")); } contractObject.add(contract.toString(), abiObject); } @@ -65,6 +65,18 @@ public static CompilationResult parse(String rawJson) throws IOException { } } + private static String getJsonValueAsString(JsonObject jsonObject, String key) { + if (jsonObject == null || jsonObject.get(key) == null || jsonObject.get(key).isJsonNull()) { + return null; + } + + if (jsonObject.get(key).isJsonPrimitive()) { + return jsonObject.get(key).getAsString(); + } + + return jsonObject.get(key).toString(); + } + /** * @param contractName The contract name * @return the first contract found for a given contract name; use {@link #getContract(Path, From 836d8dcafa851d7b615fe08bc60276c0317b210e Mon Sep 17 00:00:00 2001 From: dwzhan Date: Sun, 28 Apr 2024 15:16:47 +0800 Subject: [PATCH 4/4] fix: auto fix by google code format --- .../java/org/fisco/solc/compiler/CompilationResult.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/fisco/solc/compiler/CompilationResult.java b/src/main/java/org/fisco/solc/compiler/CompilationResult.java index ecc8cd6..4318c8d 100644 --- a/src/main/java/org/fisco/solc/compiler/CompilationResult.java +++ b/src/main/java/org/fisco/solc/compiler/CompilationResult.java @@ -48,14 +48,17 @@ public static CompilationResult parse(String rawJson) throws IOException { JsonObject abiObject = new JsonObject(); abiObject.addProperty("abi", getJsonValueAsString(contractJsonObject, "abi")); abiObject.addProperty("bin", getJsonValueAsString(contractJsonObject, "bin")); - abiObject.addProperty("metadata", getJsonValueAsString(contractJsonObject, "metadata")); + abiObject.addProperty( + "metadata", getJsonValueAsString(contractJsonObject, "metadata")); if (contractJsonObject.get("userdoc") != null) { - abiObject.addProperty("userdoc", getJsonValueAsString(contractJsonObject, "userdoc")); + abiObject.addProperty( + "userdoc", getJsonValueAsString(contractJsonObject, "userdoc")); } if (contractJsonObject.get("devdoc") != null) { - abiObject.addProperty("devdoc", getJsonValueAsString(contractJsonObject, "devdoc")); + abiObject.addProperty( + "devdoc", getJsonValueAsString(contractJsonObject, "devdoc")); } contractObject.add(contract.toString(), abiObject); }