Skip to content

Commit

Permalink
CORE-15353: Trade class clean up and ReadMe update
Browse files Browse the repository at this point in the history
Removed unused Trade constructor and renamed Trade.ProposalId to Trade.TradeId because that is what it is. Updated the Accept flow request body in the ReadMe file.
  • Loading branch information
khutsijabari committed Aug 31, 2023
1 parent 1fc90dd commit 4658f48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
6 changes: 4 additions & 2 deletions java-samples/corda5-negotiation-cordapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ check the result. Enter Bob's hash id and the modify flow ID which is "ModifyFlo
#### Step 4: Accept the new proposal from bob `AcceptFlow`
In this step, Alice will accept the new proposal from Bob.
Goto `POST /flow/{holdingidentityshorthash}`, enter Alice's identity short hash and request body, we also need to
provide the proposalId, which is same as the proposal ID used in ModifyFlow body.
provide the proposalId, which is same as the proposal ID used in ModifyFlow body and also Alice's own details
(this is because the Accept smart contract requires this information)
```
{
"clientRequestId": "AcceptFlow",
"flowClassName": "com.r3.developers.samples.negotiation.workflows.accept.AcceptFlowRequest",
"requestBody": {
"proposalID": "<use the proposal id here>"
"proposalID": "<use the proposal id here>",
"acceptor": "CN=Alice, OU=Test Dept, O=R3, L=London, C=GB"
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,19 @@ public class Trade implements ContractState {
private final int amount;
private final Member buyer;
private final Member seller;
private final UUID proposalID;
private final UUID tradeID;
private final MemberX500Name acceptor;
public List<PublicKey> participants;


@ConstructorForDeserialization
public Trade(int amount, Member buyer, Member seller, UUID proposalID, MemberX500Name acceptor, List<PublicKey> participants) {
this.amount = amount;
this.buyer = buyer;
this.seller = seller;
this.proposalID = proposalID;
this.acceptor = acceptor;
this.participants = participants;
}

public Trade(int amount, Member buyer, Member seller, MemberX500Name acceptor, List<PublicKey> participants) {
this.amount = amount;
this.buyer = buyer;
this.seller = seller;
this.acceptor = acceptor;
this.proposalID = UUID.randomUUID();
this.tradeID = UUID.randomUUID();
this.participants = participants;
}


public int getAmount() {
return amount;
}
Expand All @@ -55,8 +43,8 @@ public Member getBuyer() {
return buyer;
}

public UUID getProposalID() {
return proposalID;
public UUID getTradeID() {
return tradeID;
}
public MemberX500Name getAcceptor() {
return acceptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public String call(@NotNull ClientRequestBody requestBody) {
UtxoSignedTransaction signedTransaction = transactionBuilder.toSignedTransaction();
FlowSession counterPartySession = flowMessaging.initiateFlow(counterParty.getName());
flowEngine.subFlow(new FinalizeFlow.FinalizeRequest(signedTransaction, List.of(counterPartySession)));
return output.getProposalID().toString();
return output.getTradeID().toString();
} catch (Exception e) {
throw new CordaRuntimeException(e.getMessage());
}
Expand Down

0 comments on commit 4658f48

Please sign in to comment.