Corda: dao updates
This commit is contained in:
parent
7a2a366dd5
commit
beadaba27e
@ -31,7 +31,7 @@ public class GameProposalContract implements net.corda.v5.ledger.utxo.Contract {
|
||||
GameProposalState outputState = trx.getOutputStates(GameProposalState.class).get(0);
|
||||
requireThat(outputState != null, CREATE_OUTPUT_STATE);
|
||||
|
||||
requireThat(outputState.getYouPlayAs() != null, CREATE_NOT_NULL_YOU_PLAY_AS);
|
||||
requireThat(outputState.getRecipientColor() != null, NON_NULL_RECIPIENT_COLOR);
|
||||
} else
|
||||
if (command instanceof Accept) {
|
||||
// TODO outputState -> Game
|
||||
@ -63,7 +63,7 @@ public class GameProposalContract implements net.corda.v5.ledger.utxo.Contract {
|
||||
|
||||
static final String CREATE_INPUT_STATE = "Create command should have no input states";
|
||||
static final String CREATE_OUTPUT_STATE = "Create command should output exactly one GameProposal state";
|
||||
static final String CREATE_NOT_NULL_YOU_PLAY_AS = "GameProposal.youPlayAs field can not be null";
|
||||
static final String NON_NULL_RECIPIENT_COLOR = "GameProposal.recipientColor field can not be null";
|
||||
|
||||
static final String REJECT_INPUT_STATE = "Reject command should have exactly one GameProposal state";
|
||||
static final String REJECT_OUTPUT_STATE = "Reject command should have no output states";
|
||||
|
@ -22,8 +22,8 @@ public class GameProposalState implements ContractState {
|
||||
|
||||
public final MemberX500Name sender;
|
||||
public final MemberX500Name recipient;
|
||||
public final Color youPlayAs;
|
||||
public final String additionalMessage;
|
||||
public final Color recipientColor;
|
||||
public final String message;
|
||||
public final UUID id;
|
||||
public final List<PublicKey> participants;
|
||||
|
||||
@ -32,14 +32,14 @@ public class GameProposalState implements ContractState {
|
||||
public GameProposalState(
|
||||
MemberX500Name sender,
|
||||
MemberX500Name recipient,
|
||||
Color youPlayAs,
|
||||
String additionalMessage,
|
||||
Color recipientColor,
|
||||
String message,
|
||||
UUID id,
|
||||
List<PublicKey> participants) {
|
||||
this.sender = sender;
|
||||
this.recipient = recipient;
|
||||
this.youPlayAs = youPlayAs;
|
||||
this.additionalMessage = additionalMessage;
|
||||
this.recipientColor = recipientColor;
|
||||
this.message = message;
|
||||
this.id = id;
|
||||
this.participants = participants;
|
||||
}
|
||||
@ -52,12 +52,12 @@ public class GameProposalState implements ContractState {
|
||||
return recipient;
|
||||
}
|
||||
|
||||
public Color getYouPlayAs() {
|
||||
return youPlayAs;
|
||||
public Color getRecipientColor() {
|
||||
return recipientColor;
|
||||
}
|
||||
|
||||
public String getAdditionalMessage() {
|
||||
return additionalMessage;
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
@ -67,12 +67,4 @@ public class GameProposalState implements ContractState {
|
||||
public List<PublicKey> getParticipants() {
|
||||
return participants;
|
||||
}
|
||||
|
||||
public String getRecipientCommonName() {
|
||||
return recipient == null ? "" : recipient.getCommonName();
|
||||
}
|
||||
|
||||
public String getSenderCommonName() {
|
||||
return sender == null ? "" : sender.getCommonName();
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class CreateFlow implements ClientStartableFlow{
|
||||
myInfo.getName(),
|
||||
opponentInfo.getName(),
|
||||
GameProposalState.Color.valueOf(args.opponentColor),
|
||||
args.additionalMessage,
|
||||
args.message,
|
||||
UUID.randomUUID(),
|
||||
Arrays.asList(myInfo.getLedgerKeys().get(0), opponentInfo.getLedgerKeys().get(0))
|
||||
);
|
||||
|
@ -3,16 +3,12 @@ package djmil.cordacheckers.gameproposal;
|
||||
public class CreateFlowArgs {
|
||||
public final String opponentName;
|
||||
public final String opponentColor;
|
||||
public final String additionalMessage;
|
||||
|
||||
public CreateFlowArgs(String opponentName, String opponentColor, String additionalMessage) {
|
||||
this.opponentName = opponentName;
|
||||
this.opponentColor = opponentColor;
|
||||
this.additionalMessage = additionalMessage;
|
||||
}
|
||||
public final String message;
|
||||
|
||||
// Serialisation service requires a default constructor
|
||||
public CreateFlowArgs() {
|
||||
this(null, null, null);
|
||||
opponentName = null;
|
||||
opponentColor = null;
|
||||
message = null;
|
||||
}
|
||||
}
|
||||
|
@ -12,24 +12,24 @@ import djmil.cordacheckers.states.GameProposalState;
|
||||
public class ListItem {
|
||||
public final String sender;
|
||||
public final String recipient;
|
||||
public final String youPlayAs;
|
||||
public final String additionalMessage;
|
||||
public final String recipientColor;
|
||||
public final String message;
|
||||
public final UUID id;
|
||||
|
||||
// Serialisation service requires a default constructor
|
||||
public ListItem() {
|
||||
this.sender = null;
|
||||
this.recipient = null;
|
||||
this.youPlayAs = null;
|
||||
this.additionalMessage = null;
|
||||
this.recipientColor = null;
|
||||
this.message = null;
|
||||
this.id = null;
|
||||
}
|
||||
|
||||
public ListItem(GameProposalState state) {
|
||||
this.sender = state.getSenderCommonName();
|
||||
this.recipient = state.getRecipientCommonName();
|
||||
this.youPlayAs = state.getYouPlayAs().name();
|
||||
this.additionalMessage = state.getAdditionalMessage();
|
||||
this.sender = state.getSender().getCommonName();
|
||||
this.recipient = state.getRecipient().getCommonName();
|
||||
this.recipientColor = state.getRecipientColor().name();
|
||||
this.message = state.getMessage();
|
||||
this.id = state.getId();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user