From 671ee598273ea74ec83f4aad809ab595ce221623 Mon Sep 17 00:00:00 2001 From: mattbradburyr3 Date: Sun, 29 Jan 2023 11:44:42 +0000 Subject: [PATCH] fix contract --- .../csdetemplate/utxoexample/contracts/ChatContract.java | 5 +++-- 1 file changed, 3 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 e42f0ca..77d92d5 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 @@ -34,8 +34,7 @@ public class ChatContract implements Contract { requireThat( transaction.getCommands().size() == 1, "Require a single command."); Command command = transaction.getCommands().get(0); - ChatState input = transaction.getOutputStates(ChatState.class).get(0); - ChatState output = transaction.getInputStates(ChatState.class).get(0); + ChatState output = transaction.getOutputStates(ChatState.class).get(0); requireThat(output.getParticipants().size() == 2, "The output state should have two and only two participants."); @@ -46,6 +45,8 @@ public class ChatContract implements Contract { else if(command.getClass() == Update.class) { requireThat(transaction.getInputContractStates().size() == 1, "When command is Update there should be one and only one input state."); 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(