Thanks @cocreature
I was confused about the indentation when it comes to with
- blocks so thank you for clearing that up.
Also, I was upgraded this script from a former scenario
and completely forgot about some of the syntax changes.
That said, the script still isn’t working, and I have a feeling it’s because I have a proposal-accept pattern for my Guild
creation (although for the proposal template, I don’t actually want to create a new Guild, I just want to be able to issue a proposal
. Do you think that’s why the script is failing?
Here’s my full template code for the Guild
and Proposal
for reference (I see you declared the Guild as data in this case which is why the script might have worked for you)
template Guild with
guildName: Text
creator: Party
members: [Party]
where
signatory creator, members
ensure length members >= 4 && DA.List.unique members
-- initial proposal accept pattern for formation of Guild
template ProposeGuild with
guildName: Text
creator: Party
requestedMembers: [Party]
agreedMembers: [Party]
where
signatory creator, agreedMembers
observer requestedMembers
preconsuming choice Agree: ContractId ProposeGuild
with member: Party
controller member
do
assert $ member `elem` requestedMembers -- if member is in the requestedmembers list is = true
create this with agreedMembers = member::agreedMembers -- :: is cons operator to construct a list, so populate agreedmember list with member list
requestedMembers = DA.List.delete member requestedMembers -- now delete members from the requestedmember list cos we're done
preconsuming choice Create: ContractId Guild
controller creator
do
create Guild with guildName, creator, members = agreedMembers
which has a Script that goes like this
guildtest = do
martin <- allocateParty "Martin"
rita <- allocateParty "Rita"
john <- allocateParty "John"
michael <- allocateParty "Michael"
sam <- allocateParty "Sam"
james <- allocateParty "James"
propId1 <- submit martin do
createCmd ProposeGuild with
guildName = "Martin's guild"
creator = martin
requestedMembers = [rita, john, michael, sam, james]
agreedMembers = []
propId2 <- submit rita do
exerciseCmd propId1 Agree with member = rita
propId3 <- submit john do
exerciseCmd propId2 Agree with member = john
propId4 <- submit michael do
exerciseCmd propId3 Agree with member = michael
propId5 <- submit sam do
exerciseCmd propId4 Agree with member = sam
guildId <- submit martin do
exerciseCmd propId5 Create
pure()
This is the modified script i’ve now put together with your input to test Proposal
-- RUN_SCRIPT_PROPOSAL --
exampleproposal = do
-- Creates each party
alice <- allocateParty "Alice"
hakan <- allocateParty "Hakan"
martin <- allocateParty "Martin"
rita <- allocateParty "Rita"
john <- allocateParty "John"
michael <- allocateParty "Michael"
sam <- allocateParty "Sam"
james <- allocateParty "James"
-- Creates an instance of the Investor contract, authorized by "Hakan"
submit alice do
createCmd Proposal with
issuer = alice
investor = hakan
guild = Guild with
guildName = "Martin's Guild"
creator = martin
members = [martin, rita, john, michael, sam, james]
projectdescription = "test"
unitsrequired = 5
marketingcost = 5
distributioncost = 10
additionalcost = 10
proposalId = "p1"
--- because this was a data declaration
item = Item with
unitdesignation = "kilos"
priceperunit = 5
return()
-- END_SCRIPT --
But I get the following error
> /Users/khurammalik/DevTree/Qirad Agent Network/app/daml/Qirad.daml:188:7: error:
• No instance for (Action Commands) arising from a do statement
• In a stmt of a 'do' block:
createCmd
Proposal
{issuer = alice, investor = hakan,
guild = Guild
{guildName = "Martin's Guild", creator = martin,
members = [martin, rita, ....]},
projectdescription = "test", unitsrequired = 5, marketingcost = 5,
distributioncost = 10, additionalcost = 10, proposalId = "p1",
item = Item {unitdesignation = "kilos", priceperunit = 5}}
In the second argument of ‘submit’, namely
‘do createCmd
Proposal
{issuer = alice, investor = hakan,
guild = Guild
{guildName = "Martin's Guild", creator = martin, members = [...]},
projectdescription = "test", unitsrequired = 5, marketingcost = 5,
distributioncost = 10, additionalcost = 10, proposalId = "p1",
item = Item {unitdesignation = "kilos", priceperunit = 5}}
return ()’
In a stmt of a 'do' block:
submit
alice
do createCmd
Proposal
{issuer = alice, investor = hakan,
guild = Guild
{guildName = "Martin's Guild", creator = martin, members = [...]},
projectdescription = "test", unitsrequired = 5, marketingcost = 5,
distributioncost = 10, additionalcost = 10, proposalId = "p1",
item = Item {unitdesignation = "kilos", priceperunit = 5}}
return ()