Asset Servicing Reference Application

Greetings fellow forum-goers,

I am attempting to run the example code on canton by uploading the generated DAR and running the ui

I’ve successfully configured canton and uploaded working DAR files to the instance; However, the latest version of canton is requesting that all DAR files are compiled using DAML-LF > 1.14 and this example is not.

Within the github repository for the example, the README mentions how to update the SDK version. After updating the SDK version in the daml.yaml and ui/project.json, several warnings and errors appeared. Here is a sample of the warnings, there were many instances across the various files

Message: 
  warning:
  In the use of type constructor or class ‘Set’                                                                                       
  (imported from DA.Next.Set):                                                                                                        
  Deprecated: "DA.Next.Set is deprecated. Please use DA.Set instead."
Message:  The "daml 1.2" version header is deprecated, please remove it.

Using sed I replaced the DA.Next.Set with DA.Set and removed the daml 1.2 from all files. This cleared all the warnings, but not the errors

Message: 
  daml/DA/Finance/Utils.daml:21:10: error:
  • Could not deduce (Ord a)                                                                                                          
  arising from the superclasses of an instance declaration                                                                            
  from the context: MapKey a                                                                                                          
  bound by the instance declaration                                                                                                   
  at daml/DA/Finance/Utils.daml:21:10-35                                                                                              
  Possible fix:                                                                                                                       
  add (Ord a) to the context of the instance declaration                                                                              
  • In the instance declaration for ‘MapKey (Set a)’ 

After some digging through the DAML documentations, I noticed that the imported module trying to reference this type was deprecated https://docs.daml.com/daml/stdlib/DA-Next-Map.html#class-da-next-map-mapkey-12781

After switching the module DA.Next.Map to DA.Map I am getting the next error

Compiling daml-app-assetServicing to a DAR.
File:     daml/DA/Finance/Utils.daml
Hidden:   no
Range:    20:22-20:28
Source:   typecheck
Severity: DsError
Message: 
  daml/DA/Finance/Utils.daml:20:22: error:
  Not in scope: type constructor or class ‘MapKey’                                                                                    
  Perhaps you meant ‘HasKey’ (imported from Prelude)                                                                                  
File:     daml/DA/Finance/Utils.daml
Hidden:   no
Range:    24:10-24:16
Source:   typecheck
Severity: DsError
Message: 
  daml/DA/Finance/Utils.daml:24:10: error:
  Not in scope: type constructor or class ‘MapKey’                                                                                    
  Perhaps you meant ‘HasKey’ (imported from Prelude)                                                                                  
File:     daml/DA/Finance/Utils.daml
Hidden:   no
Range:    32:34-32:40
Source:   typecheck
Severity: DsError
Message: 
  daml/DA/Finance/Utils.daml:32:34: error:
  Not in scope: type constructor or class ‘MapKey’                                                                                    
  Perhaps you meant ‘HasKey’ (imported from Prelude)   

I expect the answer to be a simple fix, but I am very new to haskell, daml, and functional programming. Im not sure if Im on the right track here, or just messing this up even more. For context, I am running multiple daml applications using canton on postgresql. the canton instance, and other participants, are all functional. I’d like to borrow some of the functionality of this example, but before pulling out the pieces want to be sure it works on the canton platform.

Thanks to all in advance

1 Like

Hi @ecis_pro and welcome to the forum. I made a PR that updates the SDK version to 1.18 and compiles succesfully Update to SDK 1.18 by cocreature · Pull Request #22 · digital-asset/ex-asset-servicing · GitHub

Two things to note:
First, deprecation warnings are not errors. You can compile the project without replacing the map type. Still a good idea to address this for the future ofc so I’ve done this in my PR.

Second, MapKey is completely unused when switching to the new map types so you can just delete all code that uses it.

Hope that helps

Thank you @cocreature for the notes! How silly, I should have familiarized a bit more with the actually use of the code, so simple!

Really appreciate the github PR using it now

always seems easy after the fact :slight_smile: Don’t worry about it, we all get stuck at times.