Hi, Daml Finance newbie question…
I’m looking at the code in the “quickstart-finance” template and would like to modify the script in Settlement.daml so that I create an instrument with different parties for the issuer and the depository.
To do that my approach is to implement the workflow and factory pattern similar to the Account Factory in Transfer.daml, but for Instrument.
I have hit upon two challenges:
The Instrument created by the original script is from module
Daml.Finance.Instrument.Base.Instrument but when I look in the Daml Finance library documentation or the current Daml Finance code I cannot find a module
Daml.Finance.Instrument.Base.Instrument. Are things moving around and/or getting renamed between versions of Daml Finance or am I misunderstanding something? What would be best way to retrieve the source code and/or documentation for the version of Daml Finance actually used in the quickstart-finance template?
Related to the above, I’m not sure how to create the Instrument factory. I’ve tried various combinations along the lines of
import Daml.Finance.Interface.Instrument.Base.Factory.Instrument qualified as Instrument (F)
– below line in choice where the instrument should be created
instrumentCid ← exercise instrumentFactoryCid Instrument.Create with
instrument = instrumentKey
description = description
observers = M.fromList [(“InstrumentObservers”, observersSet)]
but as I’m not sure where to find source code or documentation I am kind of guessing and I feel there must be a better way. Any pointers appreciated, thanks!
Regarding 1, things are indeed being renamed / shuffle around while we are still in the Early Access phase for Daml Finance and available documentation currently closely follows the latest version of the library. Specifically,
D.F.Instrument.Base.Instrument has been renamed to
The quickstart template references versions
0.1.3 of the various packages.
When a package is released we apply a tag to the corresponding commit in the Daml Finance repo.
The package versions you mention have been all released at this commit .
The easiest for now is for you to check that commit out and open up the code in studio.
On your second point, in order to create a factory you need to
create an instance of this template. You can then cast it to interface using
In general, a
Factory template corresponds to a concrete template and will not be shipped in an interface module.
I hope this helps!
Thanks very much @Matteo_Limberto that should help. I will let you know if any more problems with the
I did see the tags in the repo but as you say they are for each package. Out of interest it would be good to understand how you identified this commit as the one to look at?
You can see all tags here and immediately have access to the corresponding commit. So the process I followed was
- look at the dependent package version in your
- find the corresponding tag
- click on the corresponding commit hash
I hope this helps.
Got it, it was the clicking on the commit hash for any tag that has the right version number in it that I was missing. Thank you @Matteo_Limberto.