From 974a6be2b5e1a2cf710beb3625f40266ef01def3 Mon Sep 17 00:00:00 2001 From: mattbradburyr3 Date: Sun, 29 Jan 2023 12:40:20 +0000 Subject: [PATCH] fixes to contract --- .../csdetemplate/utxoexample/contracts/ChatContract.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/contracts/src/main/java/com/r3/developers/csdetemplate/utxoexample/contracts/ChatContract.java b/contracts/src/main/java/com/r3/developers/csdetemplate/utxoexample/contracts/ChatContract.java index 77d92d5..1367913 100644 --- a/contracts/src/main/java/com/r3/developers/csdetemplate/utxoexample/contracts/ChatContract.java +++ b/contracts/src/main/java/com/r3/developers/csdetemplate/utxoexample/contracts/ChatContract.java @@ -8,8 +8,11 @@ import net.corda.v5.ledger.utxo.ContractState; import net.corda.v5.ledger.utxo.StateAndRef; import net.corda.v5.ledger.utxo.transaction.UtxoLedgerTransaction; import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.security.PublicKey; +import java.util.Objects; import java.util.Set; import static java.util.Objects.*; @@ -18,6 +21,8 @@ import static java.util.Objects.*; public class ChatContract implements Contract { + private final static Logger log = LoggerFactory.getLogger(ChatContract.class); + public static class Create implements Command { } public static class Update implements Command { } @@ -47,8 +52,8 @@ public class ChatContract implements Contract { requireThat(transaction.getOutputContractStates().size() == 1, "When command is Update there should be one and only one output state."); ChatState input = transaction.getInputStates(ChatState.class).get(0); - requireThat(input.getId() == output.getId(), "When command is Update id must not change."); - requireThat(input.getChatName() == output.getChatName(), "When command is Update chatName must not change."); + requireThat(input.getId().equals(output.getId()), "When command is Update id must not change."); + requireThat(input.getChatName().equals(output.getChatName()), "When command is Update chatName must not change."); requireThat( input.getParticipants().containsAll(output.getParticipants()) && output.getParticipants().containsAll(input.getParticipants()),