Skip to content
CCPEDIAby Unity Nodes
App Development

ExerciseByKey wildcard

2 posts190 views1 likesLast activity Aug 2023

  1. Marc54OP

    New to DAML here.

    Looking to implement an update on a group of contracts of another type given a key pattern. can owner update all contracts that have key of owner and wildcard field. Is this possible? Are wildcard pattens supported?

    exerciseByKey @B (owner, <wildcard>) do_something with ....
    

    Current Design is as follows:

    Template A 
    with
     owner: Party
      ...
    where
      signatory owner
    
    choice Update : ContractId A with
    controller owner
          exerciseByKey @B (owner, <wildcard>) do_something with ....
          create this with ...
    
    choice Create B: ContractId B with
      ...
    controller owner
        create B with otherPerson   
    
    Template B
    with
      owner: Party
      otherPerson: Party 
    where
       signatory owner
       observer otherPerson
       key (owner, otherPerson) : (Party, Party)
       maintainer key._1
    
    choice do_something: ContractId B with ....
    
    
  2. cocreature 1

    No, you need to specify the full key. If you need wildcard like behavior you need to resolve the query off-ledger, e.g., have your client track all contracts and build an index to answer those wildcard queries and then pass in the actual contract id you want to exercise on to the ledger