Mod note: As of SDK 1.5.0 Scenarios have been superseded by the more powerful Daml Script. We now recommend using that for all purposes. For more information, and to learn how to use Script please check out @Andreas’ post on our blog.
made some further updates but still having some issues on creating the right scenario for the
UpdateRegistration
choice from my DAML
nonconsuming UpdateRegistration : ContractId CitizenRegistration with newCitizenDetails : CitizenInfo do (oldRegistrationCid, oldRegistrationData) <- fetchByKey @CitizenRegistration (key this) archive oldRegistrationCid create CitizenRegistration with registrationCid = oldRegistrationCid registrationData = newCitizenDetails
Here is my scenario
example = scenario do alice <- getParty "Alice" bob <- getParty "Bob" let citizenkey = CitizenKey with citizen = alice ; id = "1" let citizeninfo = CitizenInfo with citizendetail1 = "Text1" ; citizendetail2 ="Text2" ; citizendetail3 = "Text3" aliceregistration <- submit alice do create CitizenRegistration with registrationCid = citizenkey; registrationData = citizeninfo let citizenkey = CitizenKey with citizen = bob ; id = "2" let citizeninfo = CitizenInfo with citizendetail1 = "Text1" ; citizendetail2 ="Text2" ; citizendetail3 = "Text3" bobregistration <- submit bob do create CitizenRegistration with registrationCid = citizenkey; registrationData = citizeninfo let alicekey = CitizenKey with citizen = alice ; id = "1" (oldRegistrationCid, oldRegistrationData) <- fetchByKey @CitizenRegistration (alicekey) let citizenkey = key oldRegistrationData let newCitizenDetails = CitizenInfo with citizendetail1 = "UpdatedText1" ; citizendetail2 ="UpdatedText2" ; citizendetail3 = "UpdatedText3" aliceupdate <- submit alice do exercise UpdateRegistration with registrationCid = key oldRegistrationData ; registrationData = newCitizenDetails return (aliceregistration,bobregistration, aliceupdate)
Getting some errors on this last part
C:\Users\bartc\Documents\Github\DAML-Covid19\daml\Registration.daml:70:18: error: • Couldn't match type ‘Update’ with ‘(->) c0’ arising from a functional dependency between: constraint ‘HasSubmit Scenario ((->) c0)’ arising from a use of ‘submit’ instance ‘HasSubmit Scenario Update’ at <no location info> • In a stmt of a 'do' block: aliceupdate <- submit alice do exercise UpdateRegistration {registrationCid = citizenkey, registrationData = newCitizenDetails} In the first argument of ‘scenario’, namely ‘do alice <- getParty "Alice" bob <- getParty "Bob" let citizenkey = ... let citizeninfo = ... ....’ In the expression: scenario do alice <- getParty "Alice" bob <- getParty "Bob" let citizenkey = ... let citizeninfo = ... ....typecheck Peek Problem (Alt+F8) No quick fixes available C:\Users\bartc\Documents\Github\DAML-Covid19\daml\Registration.daml:65:48: error: • Couldn't match type ‘Update’ with ‘Scenario’ Expected type: Scenario (ContractId CitizenRegistration, CitizenRegistration) Actual type: Update (ContractId CitizenRegistration, CitizenRegistration) • In a stmt of a 'do' block: (oldRegistrationCid, oldRegistrationData) <- fetchByKey @CitizenRegistration (alicekey) In the first argument of ‘scenario’, namely ‘do alice <- getParty "Alice" bob <- getParty "Bob" let citizenkey = ... let citizeninfo = ... ....’ In the expression: scenario do alice <- getParty "Alice" bob <- getParty "Bob" let citizenkey = ... let citizeninfo = ... ....typecheck Peek Problem (Alt+F8) No quick fixes available