Replies: 5 comments 7 replies
-
First of all, you may need an lower bound for UInts, from what I observed it is a common reason for verification errors. Easiest way you can achieve is to set verifyPerConnector options true // Participants
setOptions({ verifyPerConnector: true });
init(); |
Beta Was this translation helpful? Give feedback.
-
Doing this increase the number of failure 2x not sure why |
Beta Was this translation helpful? Give feedback.
-
The two invariants was a mistake on my part I have removed it and also tried adjusting the payment section but the error still persist.
|
Beta Was this translation helpful? Give feedback.
-
You want to use tokens in parallelReduce and in order to do that you have to define a paySpec (a list of tokens you'll include) and change the payment amounts. Final result looks like "reach 0.1";
export const main = Reach.App(() => {
const TicketMarketPlace = Participant('Platform', {
takePlatformFee: UInt,
ready: Fun([], Null)
});
const Organizer = Participant('Organizer', {
ticket: Token,
ticketFee: UInt,
deadline: UInt,
transferReward: Fun([Bool, UInt], Null),
rewardToken: Token,
ready: Fun([], Null),
amt : UInt
});
const RSVPier = API('RSVPier', {
isRSVP: Fun([Address], Bool),
buyTicket: Fun([UInt], Null)
});
const Checkin = API('CHK', {
isCheckin: Fun([Address], Bool),
isTime: Fun([], Bool),
});
const ViewBalance = View('Bals', {
ticket: UInt,
rewardToken: UInt
});
setOptions({ verifyPerConnector: true })
init();
TicketMarketPlace.only(() => {
const platformFee = declassify(interact.takePlatformFee);
});
TicketMarketPlace.publish(platformFee);
TicketMarketPlace.interact.ready();
commit();
Organizer.only(() => {
const ticket = declassify(interact.ticket);
const ticketFee = declassify(interact.ticketFee);
const deadline = declassify(interact.deadline);
const rewardToken = declassify(interact.rewardToken)
const amt = declassify(interact.amt)
assume(ticket != rewardToken);
assume(amt <= UInt.max);
});
Organizer.publish(ticket, ticketFee, rewardToken, deadline, amt);
Organizer.interact.ready();
commit();
Organizer.publish();
const deadlineBlock = relativeTime(deadline);
const RSVPs = new Set();
const [ keepGoing, howMany ] =
parallelReduce([true, 0])
.define(() => {
ViewBalance.ticket.set(balance(ticket));
ViewBalance.rewardToken.set(balance(rewardToken));
})
.while( keepGoing )
.invariant(balance() == howMany * ticketFee)
.paySpec([ ticket ])
.api_(RSVPier.isRSVP, (who) => {
check( ! RSVPs.member(this), "not yet rsvpied" );
return [ [0, [ticketFee, ticket]], (k) => {
k(true);
transfer( amt, ticket).to(who);
RSVPs.insert(this);
return [ keepGoing, howMany + 1 ];
}];
})
.api_(Checkin.isCheckin, (who) => {
check( this == Organizer, "you are the Organizer");
check( RSVPs.member(who), "yeah" );
return [ 0, (k) => {
k(true);
transfer( amt, rewardToken).to(who);
RSVPs.remove(who);
return [ keepGoing, howMany - 1 ];
}];
})
.timeout( deadlineBlock, () => {
const [ [], k ] = call(Checkin.isTime);
k(true);
return [ false, howMany ]
});
const leftovers = howMany;
transfer(leftovers * ticketFee).to(Organizer);
transfer(balance(ticket), ticket).to(Organizer);
transfer(balance(rewardToken), rewardToken).to(Organizer);
commit();
exit();
}); |
Beta Was this translation helpful? Give feedback.
-
Can you add an example or link that shows how this is done? For 1 & 2. Thanks |
Beta Was this translation helpful? Give feedback.
-
Not quite sure what the error means.
Beta Was this translation helpful? Give feedback.
All reactions