The issue here is that your auction contract is signed by both the auctioneer (Alice) and the bidder (Bob). But you only have the authorization of the submitter here (Alice) so Bob’s authorization is missing.
Looking at your model, I’m not actually sure this is an issue. Looking at your code it seems like you don’t want people to create Auction
contracts directly, instead they should be created by exercising MakeABid
. In that context you have authorization from both the signatory of the AuctionBid
contract as well as the controller so you can create it. If your adjust your scenario to do this, it passes:
test = scenario do
alice <- getParty "Alice"
bob <- getParty "Bob"
bid <- submit alice do
create AuctionBid
with
auctioneer = alice
bidder = bob
object = "Painting"
bid = 2000.00
limit = 5000.00
currency = "Pound"
start = time (date 2022 Apr 5) 14 30 00
end = time (date 2022 Apr 5) 15 30 00
submit bob do
exercise bid MakeABid with
limitArg = 5000.00
startArg = time (date 2022 Apr 5) 14 30 00
endArg = time (date 2022 Apr 5) 15 30 00
bidArg = 2000.00
currencyArg = "Pound"
pure ()
Note my comment from Parse error on input do - #9 by cocreature You are currently duplicating things like start and end and other fields both on creation of the Auction and then also as choice arguments. You might want to reconsider this and try to structure things such that they only appear in one or the other:
-
start
andend
should probably be a property of the action not of the individual bid so set them in the template. - Same for the limit.
- The bid amount however seems like it should not be set in the template and only passed in
MakeABid
. - Currency depends a bit. Should all bids have the same currency? If so put it on the template, if not put it in the choice.
In summary, something like this might be closer to what you were trying to model:
template AuctionBid
with
auctioneer: Party
bidder: Party
object: Text
currency: Text
limit: Decimal
start: Time
end: Time
where
signatory auctioneer
controller bidder can
MakeABid: ContractId Auction
with
bid: Decimal
do
currentTime <- getTime
create Auction
with
limit = limit
start = start
end = end
bid= bid
currency = currency
auctioneer = auctioneer
bidder = bidder
object = object
dateAuction = toDateUTC currentTime
Decline: ContractId DeclineBid
with
reason: Text
do
create DeclineBid with ..