Skip to content

Commit

Permalink
Update CI and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
d0cd committed Sep 29, 2023
1 parent db3224a commit 23c075d
Show file tree
Hide file tree
Showing 14 changed files with 297 additions and 338 deletions.
508 changes: 244 additions & 264 deletions .circleci/test-examples.sh

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions examples/basic_bank/build/main.aleo
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ record Token:


mapping balances:
key left as field.public;
value right as u64.public;
key as field.public;
value as u64.public;

function issue:
input r0 as address.private;
Expand All @@ -22,9 +22,9 @@ function deposit:
input r1 as u64.private;
sub r0.amount r1 into r2;
cast r0.owner r2 into r3 as Token.record;
hash.bhp256 r0.owner into r4 as field; output r3 as Token.record;

finalize r4 r1;
hash.bhp256 r0.owner into r4 as field;
async deposit r4 r1 into r5; output r3 as Token.record;
output r5 as basic_bank.aleo/deposit.future;

finalize deposit:
input r0 as field.public;
Expand Down Expand Up @@ -547,11 +547,11 @@ function withdraw:
input r2 as u64.private;
input r3 as u64.private;
assert.eq self.caller aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a;
hash.bhp256 r0 into r4 as field; call calculate_interest r1 r2 r3 into r5;
hash.bhp256 r0 into r4 as field;
call calculate_interest r1 r2 r3 into r5;
cast r0 r5 into r6 as Token.record;
output r6 as Token.record;

finalize r4 r1;
async withdraw r4 r1 into r7; output r6 as Token.record;
output r7 as basic_bank.aleo/withdraw.future;

finalize withdraw:
input r0 as field.public;
Expand Down
2 changes: 0 additions & 2 deletions examples/bubblesort/inputs/bubblesort.in
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
13u32 2u32 4u32 3u32 5u32 10u32 7u32 1u32


5 changes: 4 additions & 1 deletion examples/core/build/main.aleo
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ program core.aleo;

function main:
input r0 as field.private;
hash.bhp256 r0 into r1 as field; hash.psd2 r1 into r2 as field; commit.bhp256 r2 1scalar into r3 as field; output r3 as field.private;
hash.bhp256 r0 into r1 as field;
hash.psd2 r1 into r2 as field;
commit.bhp256 r2 1scalar into r3 as field;
output r3 as field.private;
9 changes: 4 additions & 5 deletions examples/lottery/build/main.aleo
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ record Ticket:


mapping num_winners:
key left as u8.public;
value right as u8.public;
key as u8.public;
value as u8.public;

function play:
cast self.caller into r0 as Ticket.record;
output r0 as Ticket.record;

finalize;
async play into r1; output r0 as Ticket.record;
output r1 as lottery.aleo/play.future;

finalize play:
lte block.height 1000u32 into r0;
Expand Down
6 changes: 1 addition & 5 deletions examples/simple_token/inputs/transfer.in
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
"{
owner: aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau,
amount: 100u64,
_nonce: 0group,
}" aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau 50u64
"{ owner: aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau.private, amount: 100u64.private, _nonce: 0group.public }" aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau 50u64
7 changes: 1 addition & 6 deletions examples/tictactoe/inputs/tictactoe.in
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
1u8 1u8 1u8 "{
r1: Row { c1: 0u8, c2: 0u8, c3: 0u8 },
r2: Row { c1: 0u8, c2: 0u8, c3: 0u8 },
r3: Row { c1: 0u8, c2: 0u8, c3: 0u8 },
}"

1u8 1u8 1u8 "{ r1: { c1: 0u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }"
4 changes: 3 additions & 1 deletion examples/token/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpGZsYM8WQJMDDrzeAhB2SB3N9WcGt9Ks6NLBKCWyiMKv8
PRIVATE_KEY=APrivateKey1zkp1w8PTxrRgGfAtfKUSq43iQyVbdQHfhGbiNPEg2LVSEXR

20 changes: 8 additions & 12 deletions examples/token/build/main.aleo
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ record token:


mapping account:
key left as address.public;
value right as u64.public;
key as address.public;
value as u64.public;

function mint_public:
input r0 as address.public;
input r1 as u64.public;

finalize r0 r1;
async mint_public r0 r1 into r2; output r2 as token.aleo/mint_public.future;

finalize mint_public:
input r0 as address.public;
Expand All @@ -33,8 +32,7 @@ function mint_private:
function transfer_public:
input r0 as address.public;
input r1 as u64.public;

finalize self.caller r0 r1;
async transfer_public self.caller r0 r1 into r2; output r2 as token.aleo/transfer_public.future;

finalize transfer_public:
input r0 as address.public;
Expand Down Expand Up @@ -65,9 +63,8 @@ function transfer_private_to_public:
input r2 as u64.public;
sub r0.amount r2 into r3;
cast r0.owner r3 into r4 as token.record;
output r4 as token.record;

finalize r1 r2;
async transfer_private_to_public r1 r2 into r5; output r4 as token.record;
output r5 as token.aleo/transfer_private_to_public.future;

finalize transfer_private_to_public:
input r0 as address.public;
Expand All @@ -81,9 +78,8 @@ function transfer_public_to_private:
input r0 as address.public;
input r1 as u64.public;
cast r0 r1 into r2 as token.record;
output r2 as token.record;

finalize self.caller r1;
async transfer_public_to_private self.caller r1 into r3; output r2 as token.record;
output r3 as token.aleo/transfer_public_to_private.future;

finalize transfer_public_to_private:
input r0 as address.public;
Expand Down
35 changes: 16 additions & 19 deletions examples/vote/build/main.aleo
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@ record Ticket:


mapping proposals:
key left as field.public;
value right as ProposalInfo.public;
key as field.public;
value as ProposalInfo.public;


mapping tickets:
key left as field.public;
value right as u64.public;
key as field.public;
value as u64.public;


mapping agree_votes:
key left as field.public;
value right as u64.public;
key as field.public;
value as u64.public;


mapping disagree_votes:
key left as field.public;
value right as u64.public;
key as field.public;
value as u64.public;

function propose:
input r0 as ProposalInfo.public;
assert.eq self.caller r0.proposer;
hash.bhp256 r0.title into r1 as field; cast self.caller r1 r0 into r2 as Proposal.record;
output r2 as Proposal.record;

finalize r1;
hash.bhp256 r0.title into r1 as field;
cast self.caller r1 r0 into r2 as Proposal.record;
async propose r1 into r3; output r2 as Proposal.record;
output r3 as vote.aleo/propose.future;

finalize propose:
input r0 as field.public;
Expand All @@ -51,9 +51,8 @@ function new_ticket:
input r0 as field.public;
input r1 as address.public;
cast r1 r0 into r2 as Ticket.record;
output r2 as Ticket.record;

finalize r0;
async new_ticket r0 into r3; output r2 as Ticket.record;
output r3 as vote.aleo/new_ticket.future;

finalize new_ticket:
input r0 as field.public;
Expand All @@ -64,8 +63,7 @@ finalize new_ticket:

function agree:
input r0 as Ticket.record;

finalize r0.pid;
async agree r0.pid into r1; output r1 as vote.aleo/agree.future;

finalize agree:
input r0 as field.public;
Expand All @@ -76,8 +74,7 @@ finalize agree:

function disagree:
input r0 as Ticket.record;

finalize r0.pid;
async disagree r0.pid into r1; output r1 as vote.aleo/disagree.future;

finalize disagree:
input r0 as field.public;
Expand Down
6 changes: 1 addition & 5 deletions examples/vote/inputs/argree.in
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
"{
owner: aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau,
pid: 2264670486490520844857553240576860973319410481267184439818180411609250173817field,
_nonce: 1637267040221574073903539416642641433705357302885235345311606754421919550724group
}"
"{ owner: aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau.private, pid: 2264670486490520844857553240576860973319410481267184439818180411609250173817field.private, _nonce: 1637267040221574073903539416642641433705357302885235345311606754421919550724group.public }"
1 change: 1 addition & 0 deletions examples/vote/inputs/disagree.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"{ owner: aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau.private, pid: 2264670486490520844857553240576860973319410481267184439818180411609250173817field.private, _nonce: 1637267040221574073903539416642641433705357302885235345311606754421919550724group.public }"
6 changes: 1 addition & 5 deletions examples/vote/inputs/propose.in
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
"{
title: 2077160157502449938194577302446444field,
content: 1452374294790018907888397545906607852827800436field,
proposer: aleo1kkk52quhnxgn2nfrcd9jqk7c9x27c23f2wvw7fyzcze56yahvcgszgttu2,
}"
"{ title: 2077160157502449938194577302446444field.private, content: 1452374294790018907888397545906607852827800436field.private, proposer: aleo1kkk52quhnxgn2nfrcd9jqk7c9x27c23f2wvw7fyzcze56yahvcgszgttu2.private }"
8 changes: 4 additions & 4 deletions examples/vote/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ echo "
"
# Run the `propose` program function
(
leo run propose || exit
cat ./inputs/propose.in | xargs leo run propose || exit
)

echo "
Expand All @@ -39,7 +39,7 @@ echo "
"
# Run the `new_ticket` program function
(
leo run new_ticket || exit
cat ./inputs/new_ticket.in | xargs leo run new_ticket || exit
)

echo "
Expand All @@ -57,6 +57,6 @@ echo "
"
# Run the `agree` or `disagree` program function
(
leo run agree || exit
# leo run disagree || exit
cat ./inputs/agree.in | xargs leo run agree || exit
#cat ./inputs/disagree.in | xargs leo run disagree || exit
)

0 comments on commit 23c075d

Please sign in to comment.