How can users query the ledger in Daml Script?

In Daml Script, users can submit commands to the ledger via the submitUser command.

Is there an equivalent for querying the ledger? I couldn’t find any.

The query function and its relatives require an isParties instance and UserId is not one of them.

At the moment there is no function for this. You can build your own as a wrapper. Something like

toParty : UserRight -> Optional Party
toParty ParticipantAdmin = None
toParty (CanActAs p) = Some p
toParty (CanReadAs p) = Some p

queryUser : forall t. Template t => UserId -> Script [(ContractId t, t)]
queryUser userId = do
  rights <- listUserRights userId
  query @t (mapOptional toParty rights)

Not opposed to adding it.


Thanks, Moritz, I think this could be helpful.