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
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 Type
for UserInformation
.
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 lender
It looks like you need some Type definitions for:
- FinalAgreement
- @VerifiedRequest
I don’t know if a Data Type
is supposed to go in the header of the Main.daml
or above the first instance, perhaps some of the experts can confirm/deny it’s location.
Hope this helps.
2 Likes
The only ordering that matters in Daml is LANGUAGE
and other pragmas, then module
header, then all import
s (order doesn’t matter), then everything else (order doesn’t matter). So feel free to choose whatever order is most aesthetically pleasing.
2 Likes
SHould I create a new template for finalAgreement? because it gives me errors
You have code trying to create
contracts of type FinalAgreement
, as well as manipulating ContractId FinalAgreement
, so, yes, you need a template definition for it.
1 Like