Skip to content

Commit 7f83a52

Browse files
Merge branch 'main' into release
2 parents fa55658 + 82197de commit 7f83a52

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=onixlabs-corda-core
22
group=io.onixlabs
3-
version=3.1.0
3+
version=3.2.0
44
onixlabs.development.jarsign.keystore=../lib/onixlabs.development.pkcs12
55
onixlabs.development.jarsign.password=5891f47942424d2acbe108691fdb5ba258712fca7e4762be4327241ebf3dbfa3

onixlabs-corda-core-workflow/src/main/kotlin/io/onixlabs/corda/core/workflow/Extensions.FlowLogic.Sessions.kt

+19-7
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,15 @@ fun FlowLogic<*>.initiateFlows(parties: Iterable<AbstractParty>, vararg states:
8282
*
8383
* @param sessions The flow sessions that have been provided to the flow.
8484
* @param states The states that will be used as input or output states in a transaction.
85+
* @param partyProjection Provides a mechanism to project, or resolve anonymous to well-known identities.
8586
* @throws FlowException if a required counter-party session is missing for a state participant.
8687
*/
8788
@Suspendable
88-
fun FlowLogic<*>.checkSufficientSessions(sessions: Iterable<FlowSession>, states: Iterable<ContractState>) {
89+
fun FlowLogic<*>.checkSufficientSessions(
90+
sessions: Iterable<FlowSession>,
91+
states: Iterable<ContractState>,
92+
partyProjection: (AbstractParty) -> AbstractParty = { it }
93+
) {
8994
val stateCounterparties = states
9095
.flatMap { it.participants }
9196
.filter { it !in serviceHub.myInfo.legalIdentities }
@@ -95,7 +100,7 @@ fun FlowLogic<*>.checkSufficientSessions(sessions: Iterable<FlowSession>, states
95100
.map { it.counterparty }
96101
.toSet()
97102

98-
stateCounterparties.forEach {
103+
stateCounterparties.map { partyProjection(it) }.forEach {
99104
if (it !in sessionCounterparties) {
100105
throw FlowException("A flow session must be provided for the specified counter-party: $it.")
101106
}
@@ -111,22 +116,29 @@ fun FlowLogic<*>.checkSufficientSessions(sessions: Iterable<FlowSession>, states
111116
*
112117
* @param sessions The flow sessions that have been provided to the flow.
113118
* @param states The states that will be used as input or output states in a transaction.
119+
* @param partyProjection Provides a mechanism to project, or resolve anonymous to well-known identities.
114120
* @throws FlowException if a required counter-party session is missing for a state participant.
115121
*/
116122
@Suspendable
117-
fun FlowLogic<*>.checkSufficientSessions(sessions: Iterable<FlowSession>, vararg states: ContractState) {
118-
checkSufficientSessions(sessions, states.toSet())
119-
}
123+
fun FlowLogic<*>.checkSufficientSessions(
124+
sessions: Iterable<FlowSession>, vararg states: ContractState,
125+
partyProjection: (AbstractParty) -> AbstractParty = { it }
126+
) = checkSufficientSessions(sessions, states.toSet(), partyProjection)
120127

121128
/**
122129
* Checks that sufficient flow sessions have been provided for the specified transaction.
123130
*
124131
* @param sessions The flow sessions that have been provided to the flow.
125132
* @param transaction The transaction for which to check that sufficient flow sessions exist.
133+
* @param partyProjection Provides a mechanism to project, or resolve anonymous to well-known identities.
126134
* @throws FlowException if a required counter-party session is missing for a state participant.
127135
*/
128136
@Suspendable
129-
fun FlowLogic<*>.checkSufficientSessions(sessions: Iterable<FlowSession>, transaction: TransactionBuilder) {
137+
fun FlowLogic<*>.checkSufficientSessions(
138+
sessions: Iterable<FlowSession>,
139+
transaction: TransactionBuilder,
140+
partyProjection: (AbstractParty) -> AbstractParty = { it }
141+
) {
130142
val ledgerTransaction = transaction.toLedgerTransaction(serviceHub)
131-
checkSufficientSessions(sessions, ledgerTransaction.inputStates + ledgerTransaction.outputStates)
143+
checkSufficientSessions(sessions, ledgerTransaction.inputStates + ledgerTransaction.outputStates, partyProjection)
132144
}

0 commit comments

Comments
 (0)