Search code examples
kotlinblockchainslackcordadiscourse

Display the state information to a list of participants dynamically


I have tweeked the Yo- CordApp to send to a list of participants instead of single participant in the target. I would like to send the YO to more than one Party, moreover I just want to display the state information to the parties which does not require the signatures of all parties. But I am stuck with the below error. Please help.

FlowLogicRef cannot be constructed for FlowLogic of type net.corda.yo.YoFlow as could not find matching constructor for: {target=null}

The link to my code: https://github.com/ToniyaSundaram/CordaProjects.


Solution

  • It looks like a bug in your API endpoint code.

    You set:

    val acceptors : ArrayList<Party>? = null;
    

    And then in the subsequent loop, you have the following logic for expanding the array:

    if (acceptors != null) {
        acceptors.add(to)
    }
    

    Since acceptors is initialised to null, this condition is never true and you never expand the list. As a result, when you try to construct the YoFlow, you are trying to set the target parameter to null, which isn't allowed due to Kotlin's null safety.

    Try this instead:

    val acceptors = mutableListOf<Party>()
    

    Re: your comment, you have to collect the signatures of any required signers listed on the commands, or your transaction will be considered invalid.