Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Advanced/negotiation-cordapp/repositories.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,28 @@ repositories {
maven { url 'https://jitpack.io' }
maven { url 'https://download.corda.net/maven/corda-dependencies' }
maven { url 'https://repo.gradle.org/gradle/libs-releases' }

// Repository where the user-reported artifact resides
maven {
url "https://software.r3.com/artifactory/r3-corda-releases"
credentials {
username = findProperty('cordaArtifactoryUsername') ?: System.getenv('CORDA_ARTIFACTORY_USERNAME')
password = findProperty('cordaArtifactoryPassword') ?: System.getenv('CORDA_ARTIFACTORY_PASSWORD')
}
content {
includeGroupByRegex 'com\\.r3(\\..*)?'
}
}

// Repository for corda-dev artifacts (contains net.corda SNAPSHOTs like corda-shell 4.14-SNAPSHOT)
maven {
url "https://software.r3.com/artifactory/corda-dev"
credentials {
username = findProperty('cordaArtifactoryUsername') ?: System.getenv('CORDA_ARTIFACTORY_USERNAME')
password = findProperty('cordaArtifactoryPassword') ?: System.getenv('CORDA_ARTIFACTORY_PASSWORD')
}
content {
includeGroupByRegex 'net\\.corda(\\..*)?'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import co.paralleluniverse.fibers.Suspendable;
import com.google.common.collect.ImmutableList;
import net.corda.core.crypto.keyrotation.crossprovider.PartyIdentityResolved;
import net.corda.core.crypto.keyrotation.crossprovider.PartyIdentityResolver;
import net.corda.samples.negotiation.contracts.ProposalAndTradeContract;
import net.corda.samples.negotiation.states.ProposalState;
import net.corda.core.contracts.Command;
Expand Down Expand Up @@ -42,10 +44,12 @@ public SignedTransaction call() throws FlowException {
QueryCriteria.LinearStateQueryCriteria inputCriteria = new QueryCriteria.LinearStateQueryCriteria(null, ImmutableList.of(proposalId), Vault.StateStatus.UNCONSUMED, null);
StateAndRef inputStateAndRef = getServiceHub().getVaultService().queryBy(ProposalState.class, inputCriteria).getStates().get(0);
ProposalState input = (ProposalState) inputStateAndRef.getState().getData();
Party proposerParty = PartyIdentityResolver.Companion.resolveToCurrentParty(input.getProposer(), getServiceHub().getIdentityService());

//Creating the output
Party counterparty = (getOurIdentity().equals(input.getProposer()))? input.getProposee() : input.getProposer();
ProposalState output = new ProposalState(newAmount, input.getBuyer(),input.getSeller(), getOurIdentity(), counterparty, input.getLinearId());
Party myPartyFromInput = (getOurIdentity().equals(proposerParty)) ? input.getProposer() : input.getProposee();
Party counterpartyFromInput = (myPartyFromInput.equals(input.getProposer()))? input.getProposee() : input.getProposer();
ProposalState output = new ProposalState(newAmount, input.getBuyer(),input.getSeller(), myPartyFromInput, counterpartyFromInput, input.getLinearId());

//Creating the command
List<PublicKey> requiredSigners = ImmutableList.of(input.getProposee().getOwningKey(), input.getProposer().getOwningKey());
Expand All @@ -62,7 +66,8 @@ public SignedTransaction call() throws FlowException {
SignedTransaction partStx = getServiceHub().signInitialTransaction(txBuilder);

//Gathering the counterparty's signatures
FlowSession counterpartySession = initiateFlow(counterparty);
Party counterParty = PartyIdentityResolver.Companion.resolveToCurrentParty(counterpartyFromInput, getServiceHub().getIdentityService());
FlowSession counterpartySession = initiateFlow(counterParty);
SignedTransaction fullyStx = subFlow(new CollectSignaturesFlow(partStx, ImmutableList.of(counterpartySession)));

//Finalising the transaction
Expand All @@ -88,7 +93,8 @@ public SignedTransaction call() throws FlowException {
protected void checkTransaction(@NotNull SignedTransaction stx) throws FlowException {
try {
LedgerTransaction ledgerTx = stx.toLedgerTransaction(getServiceHub(), false);
Party proposee = ledgerTx.inputsOfType(ProposalState.class).get(0).getProposee();
ProposalState input = ledgerTx.inputsOfType(ProposalState.class).get(0);
Party proposee = PartyIdentityResolver.Companion.resolveToCurrentParty(input.getProposee(), getServiceHub().getIdentityService());
if(!proposee.equals(counterpartySession.getCounterparty())){
throw new FlowException("Only the proposee can modify a proposal.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public UniqueIdentifier call() throws FlowException {

// Obtain a reference to a notary we wish to use.
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=TestNotaryService, L=London, C=GB"));
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be ignore.


TransactionBuilder txBuilder = new TransactionBuilder(notary)
.addOutputState(output, ProposalAndTradeContract.ID)
Expand Down