From a2d73f0f4245ebce582189daa96e2aad9a24676c Mon Sep 17 00:00:00 2001 From: Alade Toheeb Date: Sat, 6 Aug 2022 09:26:43 +0100 Subject: [PATCH 1/2] Add transfer --- index.rsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.rsh b/index.rsh index e72c981..63c33d8 100644 --- a/index.rsh +++ b/index.rsh @@ -47,7 +47,7 @@ export const main = Reach.App(() => { .invariant(balance() == (voteFor + voteAgainst) * ticketPrice) .while(keepGoing()) .api_(Voter.vote, (vote) => { - return [0, (k) => { + return [ticketPrice, (k) => { const [nF, nA] = vote ? [1, 0] : [0, 1] return [voteFor + nF, voteAgainst + nA] }] @@ -69,5 +69,7 @@ export const main = Reach.App(() => { const [ [], k ] = call(Voter.showOutcome); k(outcome); commit() + transfe(balance()).to(Governor); + commit(); exit(); }); From 2f14ebfc02901ebe94b621781ac91985ff44e8e3 Mon Sep 17 00:00:00 2001 From: Alade Toheeb Date: Sat, 6 Aug 2022 09:28:41 +0100 Subject: [PATCH 2/2] Edit --- index.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.mjs b/index.mjs index 24ea358..c20284c 100644 --- a/index.mjs +++ b/index.mjs @@ -4,7 +4,7 @@ const stdlib = loadStdlib(process.env); const startingBalance = stdlib.parseCurrency(100); -const accGovernor=await stdlib.newTestAccount(2, startingBalance); +const accGovernor= await stdlib.newTestAccount(2, startingBalance); console.log('Hello, Alice and Bob!'); console.log('Launching...'); @@ -17,8 +17,8 @@ console.log('Starting backends...'); const voters=[] const startingVoting=()=>{ - const acc =await stdlib.newTestAccount(startingBalance) - const ctc=acc.Contract(backend,ctcGovernor.getInfo()) + const acc = await stdlib.newTestAccount(startingBalance) + const ctc = acc.Contract(backend,ctcGovernor.getInfo()) voters }