Locking a Daml Finance holding in Typescript

Hi, I wish to lock a Daml Finance holding from my UI. One way to do this would be to create a choice on a service contract and call into that, but I would like to be able to do it directly from the UI in TypeScript if possible.

However I am struggling to get the newLockers parameter correct. I want to do something like:

await ledger.exercise(Base.Acquire, borrowedCid as string as ContractId, {newLockers: ???, context:“Lock”, lockType: LockType.Semaphore});

But how do I create the newLockers value in Typescript? I can see it is type DA.Set.Types.Set and I have tried various approaches but not succeeded. I am probably missing something obvious so any pointers appreciated, TIA.

Hi @Ianw1,

Please have a look at the following related forum questions which I trust provide an answer to your question.


Great, thank you @Johan_Sjodin. In case anyone else is looking for this in future here is my code:

  var partiesMap : Map<Party, {}> = emptyMap();
  partiesMap = partiesMap.set(party, {})
  const partiesSet = {map: partiesMap}
  await ledger.exercise(Base.Acquire, borrowedCid as string as ContractId<Base>, {newLockers: partiesSet, context:"Lock", lockType: LockType.Semaphore});