Code not running
- growtogetherOP
I cant compile it due to errors
daml 1.2 module Main where template Proposal with validationId : Int proposalDetails : ProposalDetails borrower : Party lender : Party where signatory lender observer borrower key (lender,validationId) : (Party,Int) maintainer key._1 controller borrower can AcceptOffer : ContractId FinalAgreement do exerciseByKey @VerifiedRequest (borrower,validationId) ArchiveVerified create FinalAgreement with validationId = validationId proposalDetails = proposalDetails borrower = borrower lender = lender controller borrower can RejectOffer : () do assertMsg "Offer Rejected by Borrower" (1==1) template LoanRequest with borrower : Party content : UserInformation where signatory borrower template Lend with lender : Party value : Decimal depositdate: Date currency: String where signatory lender observer:lender template borrow with borrower : Party value: borrowdate: interest: where signatory borrower observer borrower template pool with amount: where signatory borrower template Validator with validator : Party lender : Party content : UserInformation amount : Decimal where signatory validator observer lender - quidagis 2
Hi @growtogether thank you for the post.
I edited my post after doing some quick research in the Daml Documentation for Data Types.
Also converted all the Template names to start with Uppercase, and indented the one odd Controller code block, and created a
Data TypeforUserInformation.Adjusted code:
module Main where template Proposal with validationId : Int proposalDetails : Text borrower : Party lender : Party where signatory lender observer borrower key (lender,validationId) : (Party,Int) maintainer key._1 controller borrower can AcceptOffer : ContractId FinalAgreement do exerciseByKey @VerifiedRequest (borrower,validationId) ArchiveVerified create FinalAgreement with validationId = validationId proposalDetails = proposalDetails borrower = borrower lender = lender controller borrower can RejectOffer : () do assertMsg "Offer Rejected by Borrower" (1==1) -- Unsure where this Data Type should sit. data UserInformation = UserInformation with name : Text dateOfBirth : Date age : Int location : Text city : Text template LoanRequest with borrower : Party content : UserInformation where signatory borrower template Lend with lender : Party value : Decimal depositdate: Date currency: String where signatory lender observer lender template Borrow with borrower : Party value: Text borrowdate: Date interest: Int where signatory borrower observer borrower template Pool with amount: Int where signatory borrower template Validator with validator : Party lender : Party content : UserInformation amount : Decimal where signatory validator observer lenderIt looks like you need some Type definitions for:
- FinalAgreement
- @VerifiedRequest
I don’t know if a
Data Typeis supposed to go in the header of theMain.damlor above the first instance, perhaps some of the experts can confirm/deny it’s location.Hope this helps.
- growtogether
Thank you so much!
- Stephen 2
quidagis:I don’t know if a
Data Typeis supposed to go in the header of theMain.damlor above the first instance, perhaps some of the experts can confirm/deny it’s location.The only ordering that matters in Daml is
LANGUAGEand other pragmas, thenmoduleheader, then allimports (order doesn’t matter), then everything else (order doesn’t matter). So feel free to choose whatever order is most aesthetically pleasing. - growtogether
SHould I create a new template for finalAgreement? because it gives me errors
- Gary_Verhaegen 1
You have code trying to
createcontracts of typeFinalAgreement, as well as manipulatingContractId FinalAgreement, so, yes, you need a template definition for it.