I am experimenting with DAML and wanted to write a module that saves and updates the details of a “Citizen” called CitizenInfo. I also added a Key = CitizenKey
I have the following DAML code
module Registration where data CitizenInfo = CitizenInfo with citizendetail1 : Text citizendetail2 : Text citizendetail3 : Text deriving (Eq, Show) data CitizenKey = CitizenKey with citizen : Party id : Text deriving (Eq, Show) template CitizenRegistration with registrationCid : CitizenKey registrationData : CitizenInfo where signatory registrationCid.citizen key registrationCid : CitizenKey maintainer key.citizen controller registrationCid.citizen can nonconsuming Register : ContractId CitizenRegistration with newRegistrationCid : CitizenKey newRegistrationData : CitizenInfo do create CitizenRegistration with registrationCid = newRegistrationCid registrationData = newRegistrationData nonconsuming UpdateRegistration : ContractId CitizenRegistration with newCitizenDetails : CitizenInfo do (oldRegistrationCid, oldRegistrationData) <- fetchByKey @CitizenRegistration (key this) archive oldRegistrationCid create CitizenRegistration with registrationCid = oldRegistrationCid registrationData = newCitizenDetails
It currently gives me the following error message at the 2nd last line
Couldn't match expected type ‘CitizenKey’ with actual type ‘ContractId CitizenRegistration’ • In the ‘registrationCid’ field of a record In the first argument of ‘create’, namely ‘CitizenRegistration {registrationCid = oldRegistrationCid, registrationData = newCitizenDetails}’ In a stmt of a 'do' block: create CitizenRegistration {registrationCid = oldRegistrationCid, registrationData = newCitizenDetails}type
Also I want to write a scenario for the UpdateRegistration,
so any insights are welcome