Multiple party agreement

I’ve been following the documentation on how to setup a Multiple Party Agreement. (Great improvement to the documentation by the way. This was much needed)

My issue is that in the documentation example the observers are a party in the final contract to be created. However, in the multiple party agreement that I am creating, the observers are in a different contract called Guild.

So I included guild as

guild: Guild in my pending contract so that I could use the members party as observers. However, in setting this up, I am getting an error which I think is because I have included this incorrectly(?)

Could someone please give me some guidance?

Also, in the documentation example, the code used for sorting a list is just sort but I actually had to use DA.List.Sort ? Is that because of some change to the SDK?

Here is the error message

/Users/khurammalik/DevTree/Qirad Agent Network/app/daml/Qirad.daml:126:19: error:
    • No instance for (DA.Internal.Record.HasField
                         "member" Guild [Party])
        arising from a use of ‘DA.Internal.Record.getField’
    • In the first argument of ‘DA.List.sort’, namely
        ‘(DA.Internal.Record.getField @"member" guild)’
      In the second argument of ‘(==)’, namely
        ‘DA.List.sort (DA.Internal.Record.getField @"member" guild)’
      In the first argument of ‘assert’, namely
        ‘(DA.List.sort approvingmember
            == DA.List.sort (DA.Internal.Record.getField @"member" guild))’

Here is my Guild , proposal and `ProposalGuildApproval’ code for reference.

template Guild with
    guildName: Text
    creator: Party
    members: [Party]
  where
    signatory creator, members
    ensure length members >= 4 && DA.List.unique members
template Proposal with
    issuer: Party
    investor: Party
    guild: Guild
    projectdescription: Text
    unitsrequired: Int
    marketingcost: Int
    distributioncost: Int
    additionalcost: Int
    proposalId: Text -- Key
    item: Item

  where
    signatory issuer, guild.members
    observer investor
template ProposalGuildApproval with
    signedproposal: Proposal
    guild: Guild
    approvingmember: [Party]

  where
     signatory approvingmember
     observer guild.members

     ensure 
      DA.List.unique approvingmember
-- The parties who need to approve is the guild.members with approvingmember filtered out     
     let toApprove = filter (`notElem` approvingmember) guild.members

     preconsuming choice Approve : ContractId ProposalGuildApproval with
        approver : Party
      controller approver
        do
          -- Check the approver is in the toApprove list, and if they are, approve the ProposalGuildApproval contract
          assert (approver `elem` toApprove)
          create this with approvingmember = approver :: approvingmember

     preconsuming choice FinaliseApproval : ContractId Proposal with
        approver : Party
      controller approver
        do
          -- Check that all the required signatories have signed Pending
          assert (DA.List.sort approvingmember == DA.List.sort guild.member)
          create signedproposal
1 Like

The error is in this line

          assert (DA.List.sort approvingmember == DA.List.sort guild.member)

There is a typo in the field name: member instead of members. So try

          assert (DA.List.sort approvingmember == DA.List.sort guild.members)
1 Like

Gah! Thank you – so sorry for wasting your time!

Nothing to be sorry for, we’ve all been in the situation where we’ve stared at our code very confused until someone else pointed out the typo :slight_smile:

2 Likes

Thanks again :slight_smile:

1 Like