diff --git a/gradle.properties b/gradle.properties index 4a7ad8c..9c6a7c8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ name=onixlabs-corda-core group=io.onixlabs -version=3.1.0 +version=3.2.0 onixlabs.development.jarsign.keystore=../lib/onixlabs.development.pkcs12 onixlabs.development.jarsign.password=5891f47942424d2acbe108691fdb5ba258712fca7e4762be4327241ebf3dbfa3 diff --git a/onixlabs-corda-core-workflow/src/main/kotlin/io/onixlabs/corda/core/workflow/Extensions.FlowLogic.Sessions.kt b/onixlabs-corda-core-workflow/src/main/kotlin/io/onixlabs/corda/core/workflow/Extensions.FlowLogic.Sessions.kt index 3344698..e437af6 100644 --- a/onixlabs-corda-core-workflow/src/main/kotlin/io/onixlabs/corda/core/workflow/Extensions.FlowLogic.Sessions.kt +++ b/onixlabs-corda-core-workflow/src/main/kotlin/io/onixlabs/corda/core/workflow/Extensions.FlowLogic.Sessions.kt @@ -82,10 +82,15 @@ fun FlowLogic<*>.initiateFlows(parties: Iterable, vararg states: * * @param sessions The flow sessions that have been provided to the flow. * @param states The states that will be used as input or output states in a transaction. + * @param partyProjection Provides a mechanism to project, or resolve anonymous to well-known identities. * @throws FlowException if a required counter-party session is missing for a state participant. */ @Suspendable -fun FlowLogic<*>.checkSufficientSessions(sessions: Iterable, states: Iterable) { +fun FlowLogic<*>.checkSufficientSessions( + sessions: Iterable, + states: Iterable, + partyProjection: (AbstractParty) -> AbstractParty = { it } +) { val stateCounterparties = states .flatMap { it.participants } .filter { it !in serviceHub.myInfo.legalIdentities } @@ -95,7 +100,7 @@ fun FlowLogic<*>.checkSufficientSessions(sessions: Iterable, states .map { it.counterparty } .toSet() - stateCounterparties.forEach { + stateCounterparties.map { partyProjection(it) }.forEach { if (it !in sessionCounterparties) { throw FlowException("A flow session must be provided for the specified counter-party: $it.") } @@ -111,22 +116,29 @@ fun FlowLogic<*>.checkSufficientSessions(sessions: Iterable, states * * @param sessions The flow sessions that have been provided to the flow. * @param states The states that will be used as input or output states in a transaction. + * @param partyProjection Provides a mechanism to project, or resolve anonymous to well-known identities. * @throws FlowException if a required counter-party session is missing for a state participant. */ @Suspendable -fun FlowLogic<*>.checkSufficientSessions(sessions: Iterable, vararg states: ContractState) { - checkSufficientSessions(sessions, states.toSet()) -} +fun FlowLogic<*>.checkSufficientSessions( + sessions: Iterable, vararg states: ContractState, + partyProjection: (AbstractParty) -> AbstractParty = { it } +) = checkSufficientSessions(sessions, states.toSet(), partyProjection) /** * Checks that sufficient flow sessions have been provided for the specified transaction. * * @param sessions The flow sessions that have been provided to the flow. * @param transaction The transaction for which to check that sufficient flow sessions exist. + * @param partyProjection Provides a mechanism to project, or resolve anonymous to well-known identities. * @throws FlowException if a required counter-party session is missing for a state participant. */ @Suspendable -fun FlowLogic<*>.checkSufficientSessions(sessions: Iterable, transaction: TransactionBuilder) { +fun FlowLogic<*>.checkSufficientSessions( + sessions: Iterable, + transaction: TransactionBuilder, + partyProjection: (AbstractParty) -> AbstractParty = { it } +) { val ledgerTransaction = transaction.toLedgerTransaction(serviceHub) - checkSufficientSessions(sessions, ledgerTransaction.inputStates + ledgerTransaction.outputStates) + checkSufficientSessions(sessions, ledgerTransaction.inputStates + ledgerTransaction.outputStates, partyProjection) }