Add state query methods to LedgerTransaction.

Update to use LedgerTransaction api

Push query output logic onto BaseTransaction and update usages where possible

Migrate a few more uses

Address some PR comments

Address some PR comments

Fixup after rebase
This commit is contained in:
Matthew Nesbit
2017-07-18 12:02:56 +01:00
parent fe9db6f1f7
commit 9a02a27619
29 changed files with 650 additions and 84 deletions

View File

@ -12,10 +12,7 @@ import net.corda.core.node.services.ServiceType
import net.corda.core.node.services.Vault.Page
import net.corda.core.node.services.queryBy
import net.corda.core.node.services.vault.QueryCriteria.VaultQueryCriteria
import net.corda.core.transactions.LedgerTransaction
import net.corda.core.transactions.SignedTransaction
import net.corda.core.transactions.TransactionBuilder
import net.corda.core.transactions.WireTransaction
import net.corda.core.transactions.*
import net.corda.core.utilities.ProgressTracker
import net.corda.core.utilities.ProgressTracker.Step
import net.corda.core.utilities.UntrustworthyData
@ -416,7 +413,7 @@ object FlowCookbook {
// sign it! We need to make sure the transaction represents an
// agreement we actually want to enter into.
// DOCSTART 34
val outputState: DummyState = wireTx.outputs.single().data as DummyState
val outputState: DummyState = wireTx.outputsOfType<DummyState>().single()
if (outputState.magicNumber == 777) {
// ``FlowException`` is a special exception type. It will be
// propagated back to any counterparty flows waiting for a
@ -548,7 +545,7 @@ object FlowCookbook {
val signTransactionFlow: SignTransactionFlow = object : SignTransactionFlow(counterparty) {
override fun checkTransaction(stx: SignedTransaction) = requireThat {
// Any additional checking we see fit...
val outputState = stx.tx.outputs.single().data as DummyState
val outputState = stx.tx.outputsOfType<DummyState>().single()
assert(outputState.magicNumber == 777)
}
}

View File

@ -79,7 +79,7 @@ data class TradeApprovalContract(override val legalContractReference: SecureHash
"Issue of new WorkflowContract must not include any inputs" using (tx.inputs.isEmpty())
"Issue of new WorkflowContract must be in a unique transaction" using (tx.outputs.size == 1)
}
val issued = tx.outputs[0].data as TradeApprovalContract.State
val issued = tx.outputsOfType<TradeApprovalContract.State>().single()
requireThat {
"Issue requires the source Party as signer" using (command.signers.contains(issued.source.owningKey))
"Initial Issue state must be NEW" using (issued.state == WorkflowState.NEW)