T.dedupExercisebyKey, how do I use it
- rikotacardsOP
I think I’m having some knowledge gaps here, and it would be helpful to point out where I can narrow those gaps.
Looking at the below:
: (Eq c, Eq k, Choice t c r, TemplateKey t k) => k → c → TriggerA s ()
Exercise the choice on the given contract if it is not already in flight.
Note that this will send the exercise as a single-command transaction. If you need to send multiple commands in one transaction, use
emitCommandswithexerciseCmdand handle filtering yourself.Question:
What is Eq C, eq k ?I can’t seem to find an example where dedupExerciseByKey is used. I found
https://raw.githubusercontent.com/digital-asset/daml/11e5dd37e730156b97748d67914b5e3f14a48625/triggers/tests/daml/ExerciseByKey.damlThe example above is
dedupExerciseByKey @T party CI’ve written
txApproval <- T.dedupExerciseByKey @AssetHoldingAccount (m.asset.assetType, p) Preapprove_Transfer_In with asset = m.asset
which is basically
T.dedupExerciseByKey @templateName (key field 1, keyfield 2) choice_name with choiceArg = someArgIs that correct? I feel like I’m trying to guess this function signature, a real life example would be super helpful, thanks!
- cocreature
Eq c, Eq kare typeclass constraints that require thatc(the choice type) andk(the key type) can be compared for equality. This is satisfied for any template so you don’t really need to worry about it when you use it.Your example looks very sensible. You can use
exerciseByKeyjust likeexerciseexcept that you specify the contract key instead of the contract id.