ENT-2675 Improve error message (#4258)

* ENT-2675 Improve error message

* ENT-2675 Improve error message
This commit is contained in:
Tudor Malene 2018-11-20 14:19:32 +00:00 committed by Dominic Fox
parent c2364f4431
commit bda07561f7

View File

@ -212,7 +212,7 @@ open class TransactionBuilder @JvmOverloads constructor(
val refStateContractAttachments: List<AttachmentId> = referenceStateGroups
.filterNot { it.key in allContracts }
.map { refStateEntry ->
selectAttachmentThatSatisfiesConstraints(true, refStateEntry.key, refStateEntry.value.map { it.constraint }, services)
selectAttachmentThatSatisfiesConstraints(true, refStateEntry.key, refStateEntry.value, services)
}
// For each contract, resolve the AutomaticPlaceholderConstraint, and select the attachment.
@ -287,7 +287,7 @@ open class TransactionBuilder @JvmOverloads constructor(
fun selectAttachment() = selectAttachmentThatSatisfiesConstraints(
false,
contractClassName,
inputsAndOutputs.map { it.constraint }.toSet().filterNot { it in automaticConstraints },
inputsAndOutputs.filterNot { it.constraint in automaticConstraints },
services)
// This will contain the hash of the JAR that will be used by this Transaction.
@ -417,10 +417,11 @@ open class TransactionBuilder @JvmOverloads constructor(
* TODO - When the SignatureConstraint and contract version logic is in, this will need to query the attachments table and find the latest one that satisfies all constraints.
* TODO - select a version of the contract that is no older than the one from the previous transactions.
*/
private fun selectAttachmentThatSatisfiesConstraints(isReference: Boolean, contractClassName: String, constraints: List<AttachmentConstraint>, services: ServicesForResolution): AttachmentId {
private fun selectAttachmentThatSatisfiesConstraints(isReference: Boolean, contractClassName: String, states: List<TransactionState<ContractState>>, services: ServicesForResolution): AttachmentId {
val constraints = states.map { it.constraint }
require(constraints.none { it in automaticConstraints })
require(isReference || constraints.none { it is HashAttachmentConstraint })
return services.cordappProvider.getContractAttachmentID(contractClassName)!!
return services.cordappProvider.getContractAttachmentID(contractClassName) ?: throw MissingContractAttachments(states)
}
private fun useWhitelistedByZoneAttachmentConstraint(contractClassName: ContractClassName, networkParameters: NetworkParameters) = contractClassName in networkParameters.whitelistedContractImplementations.keys