From 7e7d13d60fb3e35a608a016c66bf84e13500c625 Mon Sep 17 00:00:00 2001 From: Asuka Date: Mon, 30 Aug 2021 12:03:17 +0800 Subject: [PATCH] feature: adjust printed info for constant trigger --- .../java/org/tron/walletserver/WalletApi.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/tron/walletserver/WalletApi.java b/src/main/java/org/tron/walletserver/WalletApi.java index 8f5a05ccd..19ce7122a 100644 --- a/src/main/java/org/tron/walletserver/WalletApi.java +++ b/src/main/java/org/tron/walletserver/WalletApi.java @@ -2178,15 +2178,13 @@ public boolean triggerContract( Transaction transaction = transactionExtention .getTransaction(); // for constant - if (transaction.getRetCount() != 0 - && transactionExtention.getConstantResult(0) != null - && transactionExtention.getResult() != null) { - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println( - ":" + ByteArray.toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - System.out.println("EnergyUsed:" + transactionExtention.getEnergyUsed()); + if (transaction.getRetCount() != 0) { + TransactionExtention.Builder builder = + transactionExtention.toBuilder().clearTransaction().clearTxid(); + if (transaction.getRet(0).getRet() == Result.code.FAILED) { + builder.setResult(builder.getResult().toBuilder().setResult(false)); + } + System.out.println("Execution result = " + Utils.formatMessageString(builder.build())); return true; }