dazraf
dazraf

Reputation: 362

Cordapp fails to execute flow because TransactionState complains that inner class state is bundled with same contract

We have a very simple cordapp that creates a state with a flow. However, when we run the flow tests, we get a rather odd warning:

[WARN] 17:07:15,982 [Mock network] contracts.TransactionState. - State class io.dazraf.multisig.contracts.MultiSigContract$MultiSigAsset belongs to contract io.dazraf.multisig.contracts.MultiSigContract, but is bundled with contract MultiSigContract in TransactionState. Annotate MultiSigAsset with @BelongsToContract(MultiSigContract.class) to remove this warning. {actor_id=Only For Testing, actor_owning_identity=O=Mock Company 1, L=London, C=GB, actor_store_id=TEST, fiber-id=10000001, flow-id=0d663be3-b2e4-4a72-bb49-ba80867f1698, invocation_id=29075169-0b94-4167-8c9d-689b28b7337f, invocation_timestamp=2020-01-15T17:07:15.161Z, origin=Only For Testing, session_id=29075169-0b94-4167-8c9d-689b28b7337f, session_timestamp=2020-01-15T17:07:15.161Z, thread-id=209}

The state class is an inner class of the contract and shouldn't need a @BelongsToContract annotation. Moving the state class to the toplevel, and annotating it as specified, does not fix the problem.

We have a reproducer project here with the full source: https://github.com/dazraf/corda-multi-sig-reproducer

Any help gratefully received. Thanks.

Upvotes: 0

Views: 81

Answers (1)

Adam Houston
Adam Houston

Reputation: 26

In the contract code, the CONTRACT_ID needs to be the fully qualified name. I.e.

class MultiSigContract : Contract {
companion object {
  const val CONTRACT_ID: ContractClassName = "io.dazraf.multisig.contracts.MultiSigContract"
}
...

instead of:

class MultiSigContract : Contract {
companion object {
  const val CONTRACT_ID: ContractClassName = "MultiSigContract"
}
...

Upvotes: 1

Related Questions