Final Instrument in DynamicInstrument Lifecycling

When lifecycling a DynamicInstrument there is a final Instrument created with no claims that is not returned and is never used. (See daml-finance/Rule.daml at 66a0f679e1f2d3e6b5baf4d4a2e04638b9efc034 · digital-asset/daml-finance · GitHub)

Is there a reason why we would want this Instrument?

This phantom contract and its Reference are tripping up our tests because we systematically check that only expected contracts are created and there’s no ergonomic way to do this (other than querying and trying to filter it somehow) here because it’s never returned and it’s not reachable from anything else.

Could this Instrument just not be created at all or does it make sense for it to exist?
If so could it perhaps be returned from the choice?

1 Like

Hello,

Thank you for pointing this out. You are right, this seems inconsistent at the moment. We are discussing internally how we want this to work. I will let you know as soon as we have a solution.

Markus

1 Like

Update: We decided to indeed create the final instrument, to ensure that it is possible to track the instrument history if required.
However, we now also return it from the choice, to make this more consistent. This change has been merged to main.

Markus

Thanks @Markus_Friberg. That’s quite helpful.

Any idea what release this will make it into?

It doesn’t really warrant an out-of-cycle patch release, so we’d be looking at SDK 2.7 only.

In the meantime, your best option is probably to take a copy of the relevant rule contract into your codebase. You can see the changes required here: Creating new instrument if Zero remaining claims by markus-da · Pull Request #743 · digital-asset/daml-finance · GitHub

1 Like