diff --git a/src/core/ContractsDSL.kt b/src/core/ContractsDSL.kt index 0ad672f20d..17612c5099 100644 --- a/src/core/ContractsDSL.kt +++ b/src/core/ContractsDSL.kt @@ -94,11 +94,13 @@ fun Iterable.sumOrThrow() = reduce { left, right -> left + right } fun Iterable.sumOrZero(currency: Currency) = if (iterator().hasNext()) sumOrThrow() else Amount(0, currency) //// Authenticated commands /////////////////////////////////////////////////////////////////////////////////////////// + +/** Filters the command list by type, institution and public key all at once. */ inline fun List>.select(signer: PublicKey? = null, institution: Institution? = null) = filter { it.value is T }. - filter { if (signer == null) true else it.signers.contains(signer) }. - filter { if (institution == null) true else it.signingInstitutions.contains(institution) }. - map { AuthenticatedObject(it.signers, it.signingInstitutions, it.value as T) } + filter { if (signer == null) true else it.signers.contains(signer) }. + filter { if (institution == null) true else it.signingInstitutions.contains(institution) }. + map { AuthenticatedObject(it.signers, it.signingInstitutions, it.value as T) } inline fun List>.requireSingleCommand() = try { select().single()