Choice context / accessing `this` and `self`outside a template defn

Say I have several templates which reuse code:

template Factorable
    party : Party
    signatory Party

    choice CanBeFactored : *
      controller party
        do f this self

 f : Template t => t -> ContractId t -> *

The code f can be factored out. But it depends on the context of the choice - i.e. I want to have access to self and this (and I’ve probably missed something else there).

Do i always have to write a function taking these two arguments, or is there some typeclass or other clever mechanism for accessing the context of the choice?

1 Like

Writing a function is your only option here.

1 Like