Partiture

Partiture

  • Documentation
  • Repository

›Guides

Guides

  • Introduction
  • Input Converters
  • TX Strategies
  • Output Converters
  • Responders
  • Changelog

Output Converters

As with input processing, Partiture attempts to decouple output and TX processing in flows. For that purpose, PartitureFlow.processOutput() attempts to use the outputConverter passed via it's constructor to create an instance of OUT (per PartitureFlow's generic argument) as the flow's (call) output. If outputConverter is null, an error will be thrown.

Overriding processOutput() is strongly discouraged, as output converters are typically more widely applicable than input converters.

Build-in Output Converters

Build-in converters reside in the com.github.manosbatsis.partiture.flow.io.output package.

ClassOUT Type, Description
FinalizedTxOutputConverterList<SignedTransaction>. Converts to the finalized transactions of (each entry in) the given CallContext. Throws an error if none is available for any an entry
SingleFinalizedTxOutputConverterSignedTransaction. Converts to the finalized transaction of the single CallContext entry if available, throws an error otherwise
OutputStatesConverterList<ContractState>. Produce the output by gathering output states, optionally applying an additional filter. Supports an optional filter Predicate
TypedOutputStatesConverter<T: ContractState> List<T>. Output by gathering output states of the given type, optionally applying an additional filter Predicate

Custom Output Converters

To create a custom converter, begin by matching the PartitureFlow's OUT generic argument of your flow subclass. For example, to return a list of FooState:

/** Get all FooState instances from the CallContext */
class FooStateOutputConverter : PartitureFlowDelegateBase(), OutputConverter<List<FooState>> {
        
    /** Get those foo states! */
    override fun convert(input: CallContext): List<FooState> {
        return input.entries.flatMap {
            // get the entry's FooState(s)
        }
    }
}
← TX StrategiesResponders →
  • Build-in Output Converters
  • Custom Output Converters
Copyright © 2021 Manos Batsis. Got a remote contract? Contact me by email or linkedin