Skip to content
Discussions/App Development/How to avoid command deduplication in DAML TriggerForum ↗

How to avoid command deduplication in DAML Trigger

App Development8 posts228 views1 likesLast activity Sep 2022
PR
Pris17OP
Sep 2022

@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?

CO
cocreature
Sep 2022

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

PR
Pris17
Sep 2022

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

CO
cocreature
Sep 2022
Pris17:

And until when will be the cid2 in pending state?

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)

PR
Pris17
Sep 2022

@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

PR
Pris17
Sep 2022

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

CO
cocreature
Sep 2022
Pris17:

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?

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.

PR
Pris17
Sep 2022

Got it

← Back to Discussions