Skip to content
CCPEDIAby Unity Nodes
App Development

reapplyLocks Import Problem

2 posts208 views1 likesLast activity Dec 2022

  1. VictorShneerOP

    Hi everyone!

    I’m working with Daml Finance library. I implement my own Holding:

    instance Fungible.HasImplementation Holding
    

    and when I do

    interface instance Transferable.I for ...
    

    I need to use a function reapplyLocks. I tried to import it from import Daml.Finance.Holding.Util (reapplyLocks). But not succeeded. With an error:

      Could not find module ‘Daml.Finance.Holding.Util’
      It is not a module in the current program, or in any known package.
    

    I had this problem a month ago, and if I remember it correctly I just found this function in the source code and redefined it locally:

    -- | Utility function to reapply holding locks
    reapplyLocks : Lockable.Lock -> ContractId Lockable.I -> Update (ContractId Lockable.I)
    reapplyLocks lock cid =
      let apply accM context = do
            cid <- accM
            exercise cid Lockable.Acquire with newLocker = lock.locker; context; lockType = lock.lockType
      in foldl apply (pure cid) (S.toList lock.context)
    

    But maybe you know what can be the cause of the import problem?
    I have small example project with this case. Here is the file with the import problem. Lines 23-36

  2. Matteo_Limberto 1

    Hi @VictorShneer,

    In order to be able to import the Daml.Finance.Holding.Util module, you need to include the Daml.Finance.Holding package in your daml.yaml file.

    data-dependencies:
      - .lib/daml-finance-holding-0.1.3.dar
      # INTERFACE DEPENDENCIES
      - .lib/daml-finance-interface-holding-0.1.3.dar
      - .lib/daml-finance-interface-instrument-base-0.1.3.dar
      - .lib/daml-finance-interface-settlement-0.1.3.dar
      - .lib/daml-finance-interface-types-0.1.3.dar
    
    

    Thanks,
    Matteo