From d1825261f723521bbc283b180f9669195726e0b4 Mon Sep 17 00:00:00 2001 From: Andrius Dagys Date: Fri, 25 Aug 2017 14:49:37 +0100 Subject: [PATCH] AttachmentDemo: Make sure the demo transaction is valid under new constraints --- .../kotlin/net/corda/attachmentdemo/AttachmentDemo.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt b/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt index adc945e56b..c883411e67 100644 --- a/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt +++ b/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt @@ -6,6 +6,7 @@ import net.corda.client.rpc.CordaRPCClient import net.corda.core.concurrent.CordaFuture import net.corda.core.contracts.Contract import net.corda.core.contracts.ContractState +import net.corda.core.contracts.TypeOnlyCommandData import net.corda.core.crypto.SecureHash import net.corda.core.flows.FinalityFlow import net.corda.core.flows.FlowLogic @@ -115,8 +116,9 @@ class AttachmentDemoFlow(val otherSide: Party, val notary: Party, val hash: Secu override fun call(): SignedTransaction { // Create a trivial transaction with an output that describes the attachment, and the attachment itself val ptx = TransactionBuilder(notary) - ptx.addOutputState(AttachmentContract.State(hash)) - ptx.addAttachment(hash) + .addOutputState(AttachmentContract.State(hash)) + .addCommand(AttachmentContract.Command, serviceHub.legalIdentityKey) + .addAttachment(hash) progressTracker.currentStep = SIGNING @@ -183,6 +185,8 @@ class AttachmentContract : Contract { require(state.hash == attachment.id) } + object Command : TypeOnlyCommandData() + data class State(val hash: SecureHash.SHA256) : ContractState { override val contract: Contract = AttachmentContract() override val participants: List = emptyList()