Choice context / accessing `this` and `self`outside a template defn
App Development2 posts180 views2 likesLast activity Jan 2022
LU
LucianoOP
Jan 2022Say I have several templates which reuse code:
template Factorable
with
party : Party
where
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?
CO
cocreature
Jan 2022Writing a function is your only option here.