G-d willing
Hello,
I have a question regarding fetching contracts using an interface.
For simplicity, I will describe the project like so:
I have 2 daml packages a
and b
. Each package has a template A
and B
respectively.
Package b
is dependent on package a
. So, it means that template B can fetch template A, but not vice versa.
But, I need to exercise a choice within a contract of template A, that among the other things the choice does, it will also archive a contract of template B (according to its key value). In other words to do something similar like we do in late binding
programming. So, for example, exercise the Archive
choice of it, without knowing its type.
Basically, in this situation I would expect that if the choice I am exercising does not exist, an exception will be raised, but if such choice exists, DAML will know how to execute it.
Let me write a simple example, here is the definition of template A:
template A with
admin: Party
id : Int
desc : Text
where
signatory admin
choice DoSomething : ContractId A
controller admin
do
-- need to archive contract of template B which its key is (admin, id)
create this with desc = "Did something"
And here is the definition of template B:
template B with
admin: Party
id : Int
where
signatory admin
key (admin, id) : (Party, Int)
maintainer key._1
What do you think, is there a way to solve this? Maybe a nice workaround?