How to avoid command deduplication in DAML Trigger

@cocreature @bernhard How to mark some other contract other than TestTrigger as pending while exercising choice on TestTrigger.

Scenario is: I query ACS of ContractA and based on one of the ContractA value, I will then exercise a choice on ContractB.
Here I want to mark ContractA as pending until choice on ContractB is completed.
How to achieve this?

To do that type of stuff you need to use emitCommands instead of the more specific dedupExercise. That accept two arguments: The commands you want to submit and the contracts you want to mark as pending. So you can do things like:

emitCommands [exerciseCmd cid1 Choice] [toAnyContractId cid2]

to exercise a choice on cid1 but mark cid2 as pending

Got it.

And until when will be the cid2 in pending state?

Also if I have list of cid2 then how to add it in emitCommand?

Thanks

Until either the command succeeds and your trigger has processed the resulting transaction or the command fails.

Also if I have list of cid2 then how to add it in emitCommand?

The second argument is a list, so you can do emitCommands [exerciseCmd … _] (map toAnyContractId cid2s)

1 Like

@cocreature I don’t see the same behavior in my case. I have done exactly as you suggested but it doesn’t avoid command deduplication. What are other ways to handle this?

Thanks

Also, is there a way that I can add 2 contract ids of 2 different contracts in toAnyContractId?
@cocreature @bernhard @Gary_Verhaegen

Could you expand on that? What exactly do you have in your code now and what are you observing?

Also, is there a way that I can add 2 contract ids of 2 different contracts in toAnyContractId?

something like [toAnyContractId cid1, toAnyContractId cid2] works. You cannot use map in that case because the list before mapping would have contract ids of different types which is not possible in Daml. List elements always need to have the same type.

Got it