How to get a list of contract Ids from within a choice (not script)

G-d willing

Hello,
I have an issuer that has a list of offers he received from his customers. On every offer, the issuer is an observer.
I would like to have a choice where the issuer accepts or rejects all the available offers he has. But I don’t know how to fetch the list of the relevant contracts in a single command.

template A
with
issuer: Party
where
signatory issuer

choice DoBulk: ()
controller issuer
  do
    -- get all the contracts of type B that the issuer is an observer

template B
with
customer: Party
issuer: Party
where
signatory customer
observer issuer

You cannot “query” the ledger from within Daml. So you have basically two options here:

  • Keep track of things: require that every time an offer is created, it is added to a list in a ListOfOffers contract or similar.
  • Query from the client side, and provide the list of offers to accept or reject as an argument to the choice.