mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-26 03:33:44 +03:00
Merge pull request #2270 from AleoHQ/fix/circleci
Fix CircleCI scripts.
This commit is contained in:
commit
cc23fb0bea
1
.circleci/config.yml
Normal file → Executable file
1
.circleci/config.yml
Normal file → Executable file
@ -131,6 +131,7 @@ jobs:
|
|||||||
name: test examples example
|
name: test examples example
|
||||||
command: |
|
command: |
|
||||||
export LEO=/home/circleci/project/project/bin/leo
|
export LEO=/home/circleci/project/project/bin/leo
|
||||||
|
export EXAMPLES=/home/circleci/project/project/examples
|
||||||
./project/.circleci/test-examples.sh
|
./project/.circleci/test-examples.sh
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
# Create a new Leo program named `foo`.
|
# Create a new Leo program named `foo`.
|
||||||
$LEO new foo
|
$LEO new foo || exit
|
||||||
ls -la
|
ls -la
|
||||||
cd foo && ls -la
|
cd foo && ls -la
|
||||||
|
|
||||||
# Run `leo build`.
|
# Run `leo build`.
|
||||||
$LEO build
|
$LEO build || exit
|
||||||
|
|
||||||
# Assert that the 'build' folder exists.
|
# Assert that the 'build' folder exists.
|
||||||
if [ "$(ls -A build)" ]; then
|
if [ "$(ls -A build)" ]; then
|
||||||
@ -15,7 +15,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Run `leo clean`
|
# Run `leo clean`
|
||||||
$LEO clean
|
$LEO clean || exit
|
||||||
|
|
||||||
# Assert that the 'build' folder is empty.
|
# Assert that the 'build' folder is empty.
|
||||||
if [ "$(ls -A build)" ]; then
|
if [ "$(ls -A build)" ]; then
|
||||||
|
@ -3,7 +3,8 @@ echo "
|
|||||||
Step 4: Downloading parameters. This may take a few minutes..."
|
Step 4: Downloading parameters. This may take a few minutes..."
|
||||||
|
|
||||||
# Create a new dummy Leo project.
|
# Create a new dummy Leo project.
|
||||||
$LEO new dummy > /dev/null 2>&1 && cd dummy
|
$LEO new dummy || exit
|
||||||
|
cd dummy || exit
|
||||||
|
|
||||||
# Attempt to compile the dummy program until it passes.
|
# Attempt to compile the dummy program until it passes.
|
||||||
# This is necessary to ensure that the universal parameters are downloaded.
|
# This is necessary to ensure that the universal parameters are downloaded.
|
||||||
@ -13,7 +14,7 @@ DONE=1
|
|||||||
|
|
||||||
while [ $DONE -ne 0 ]
|
while [ $DONE -ne 0 ]
|
||||||
do
|
do
|
||||||
$LEO build > /dev/null 2>&1
|
$LEO build
|
||||||
DONE=$?
|
DONE=$?
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
done
|
done
|
||||||
|
@ -1,155 +1,274 @@
|
|||||||
#!/bin/bash
|
# Alias the leo command to use the local binary.
|
||||||
# First check that Leo is installed.
|
# Note: Use a full path for $LEO when running locally.
|
||||||
if ! command -v leo &> /dev/null
|
leo() {
|
||||||
then
|
$LEO "$@"
|
||||||
echo "leo is not installed."
|
}
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Clone the 'leo' repository, or pull if it already exists.
|
|
||||||
git clone https://github.com/AleoHQ/leo.git leo 2> /dev/null || (cd leo ; git pull)
|
|
||||||
|
|
||||||
# Install 'leo'.
|
|
||||||
cd leo && cargo install --path . && cd ..
|
|
||||||
|
|
||||||
# Build and run the auction Leo program.
|
# Build and run the auction Leo program.
|
||||||
|
echo "Building and running the \`auction\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/auction || exit
|
cd $EXAMPLES/auction || exit
|
||||||
$LEO run place_bid
|
$LEO run place_bid || exit
|
||||||
$LEO run resolve
|
$LEO run resolve || exit
|
||||||
$LEO run finish
|
$LEO run finish || exit
|
||||||
|
|
||||||
chmod +x ./run.sh
|
chmod +x $EXAMPLES/auction/run.sh || exit
|
||||||
./run.sh
|
export -f leo || exit
|
||||||
|
$EXAMPLES/auction/run.sh || exit
|
||||||
)
|
)
|
||||||
|
# Check that the auction program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`auction\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the basic_bank Leo program.
|
# Build and run the basic_bank Leo program.
|
||||||
|
echo "Building and running the \`basic_bank\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/basic_bank || exit
|
cd $EXAMPLES/basic_bank || exit
|
||||||
$LEO run issue
|
$LEO run issue || exit
|
||||||
$LEO run deposit
|
$LEO run deposit || exit
|
||||||
$LEO run withdraw
|
$LEO run withdraw || exit
|
||||||
|
|
||||||
chmod +x ./run.sh
|
chmod +x $EXAMPLES/basic_bank/run.sh || exit
|
||||||
./run.sh
|
export -f leo || exit
|
||||||
|
$EXAMPLES/basic_bank/run.sh || exit
|
||||||
)
|
)
|
||||||
|
# Check that the basic_bank program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`basic_bank\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the battleship Leo program.
|
# Build and run the battleship Leo program.
|
||||||
|
echo "Building and running the \`battleship\` program..."
|
||||||
|
which leo
|
||||||
(
|
(
|
||||||
cd ./project/examples/battleship || exit
|
cd $EXAMPLES/battleship || exit
|
||||||
|
|
||||||
chmod +x ./run.sh
|
chmod +x $EXAMPLES/battleship/run.sh || exit
|
||||||
./run.sh
|
export -f leo || exit
|
||||||
|
$EXAMPLES/battleship/run.sh || exit
|
||||||
)
|
)
|
||||||
|
# Check that the battleship program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`battleship\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the bubblesort Leo program.
|
# Build and run the bubblesort Leo program.
|
||||||
|
echo "Building and running the \`bubblesort\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/bubblesort || exit
|
cd $EXAMPLES/bubblesort || exit
|
||||||
$LEO run bubblesort
|
$LEO run bubble_sort || exit
|
||||||
)
|
)
|
||||||
|
# Check that the bubblesort program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`bubblesort\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the core example Leo program.
|
# Build and run the core example Leo program.
|
||||||
|
echo "Building and running the \`core\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/core || exit
|
cd $EXAMPLES/core || exit
|
||||||
$LEO run main
|
$LEO run main || exit
|
||||||
)
|
)
|
||||||
|
# Check that the core program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`core\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the groups example Leo program.
|
# Build and run the groups example Leo program.
|
||||||
|
echo "Building and running the \`groups\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/groups || exit
|
cd $EXAMPLES/groups || exit
|
||||||
$LEO run main
|
$LEO run main || exit
|
||||||
)
|
)
|
||||||
|
# Check that the groups program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`groups\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the hackers-delight/ntzdebruijin program.
|
# Build and run the hackers-delight/ntzdebruijn program.
|
||||||
|
echo "Building and running the \`hackers-delight/ntzdebruijn\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/hackers-delight/ntzdebruijin || exit
|
cd $EXAMPLES/hackers-delight/ntzdebruijn || exit
|
||||||
$LEO run
|
$LEO run || exit
|
||||||
)
|
)
|
||||||
|
# Check that the hackers-delight/ntzdebruijn program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`hackers-delight/ntzdebruijn\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the hackers-delight/ntzgaudet program.
|
# Build and run the hackers-delight/ntzgaudet program.
|
||||||
|
echo "Building and running the \`hackers-delight/ntzgaudet\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/hackers-delight/ntzgaudet || exit
|
cd $EXAMPLES/hackers-delight/ntzgaudet || exit
|
||||||
$LEO run
|
$LEO run || exit
|
||||||
)
|
)
|
||||||
|
# Check that the hackers-delight/ntzgaudet program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`hackers-delight/ntzgaudet\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the hackers-delight/ntzloops program.
|
# Build and run the hackers-delight/ntzloops program.
|
||||||
|
echo "Building and running the \`hackers-delight/ntzloops\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/hackers-delight/ntzloops || exit
|
cd $EXAMPLES/hackers-delight/ntzloops || exit
|
||||||
$LEO run
|
$LEO run || exit
|
||||||
)
|
)
|
||||||
|
# Check that the hackers-delight/ntzloops program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`hackers-delight/ntzloops\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the hackers-delight/ntzmasks program.
|
# Build and run the hackers-delight/ntzmasks program.
|
||||||
|
echo "Building and running the \`hackers-delight/ntzmasks\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/hackers-delight/ntzmasks || exit
|
cd $EXAMPLES/hackers-delight/ntzmasks || exit
|
||||||
$LEO run
|
$LEO run || exit
|
||||||
)
|
)
|
||||||
|
# Check that the hackers-delight/ntzmasks program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`hackers-delight/ntzmasks\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the hackers-delight/ntzreisers program.
|
# Build and run the hackers-delight/ntzreisers program.
|
||||||
|
echo "Building and running the \`hackers-delight/ntzreisers\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/hackers-delight/ntzreisers || exit
|
cd $EXAMPLES/hackers-delight/ntzreisers || exit
|
||||||
$LEO run
|
$LEO run || exit
|
||||||
)
|
)
|
||||||
|
# Check that the hackers-delight/ntzreisers program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`hackers-delight/ntzreisers\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the hackers-delight/ntzseals program.
|
# Build and run the hackers-delight/ntzseals program.
|
||||||
|
echo "Building and running the \`hackers-delight/ntzseals\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/hackers-delight/ntzseals || exit
|
cd $EXAMPLES/hackers-delight/ntzseals || exit
|
||||||
$LEO run
|
$LEO run || exit
|
||||||
)
|
)
|
||||||
|
# Check that the hackers-delight/ntzseals program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`hackers-delight/ntzseals\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the hackers-delight/ntzsearchtree program.
|
# Build and run the hackers-delight/ntzsearchtree program.
|
||||||
|
echo "Building and running the \`hackers-delight/ntzsearchtree\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/hackers-delight/ntzsearchtree || exit
|
cd $EXAMPLES/hackers-delight/ntzsearchtree || exit
|
||||||
$LEO run
|
$LEO run || exit
|
||||||
)
|
)
|
||||||
|
# Check that the hackers-delight/ntzsearchtree program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`hackers-delight/ntzsearchtree\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the hackers-delight/ntzsmallvals program.
|
# Build and run the hackers-delight/ntzsmallvals program.
|
||||||
|
echo "Building and running the \`hackers-delight/ntzsmallvals\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/hackers-delight/ntzsmallvals || exit
|
cd $EXAMPLES/hackers-delight/ntzsmallvals || exit
|
||||||
$LEO run
|
$LEO run || exit
|
||||||
)
|
)
|
||||||
|
# Check that the hackers-delight/ntzsmallvals program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`hackers-delight/ntzsmallvals\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the helloworld Leo program.
|
# Build and run the helloworld Leo program.
|
||||||
|
echo "Building and running the \`helloworld\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/helloworld || exit
|
cd $EXAMPLES/helloworld || exit
|
||||||
$LEO run main
|
$LEO run main || exit
|
||||||
)
|
)
|
||||||
|
# Check that the helloworld program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`helloworld\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the import point example Leo program.
|
|
||||||
(
|
|
||||||
cd ./project/examples/import_point || exit
|
|
||||||
$LEO run main
|
|
||||||
)
|
|
||||||
|
|
||||||
# Build and run the interest example Leo programs.
|
# Build and run the interest example Leo programs.
|
||||||
|
echo "Building and running the \`interest\` programs..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/import_point || exit
|
cd $EXAMPLES/interest || exit
|
||||||
|
|
||||||
# Run the fixed period interest program.
|
# Run the fixed period interest program.
|
||||||
$LEO run fixed_period_interest
|
$LEO run fixed_iteration_interest || exit
|
||||||
|
|
||||||
# Run the bounded period interest program.
|
# Run the bounded period interest program.
|
||||||
$LEO run bounded_period_interest
|
$LEO run bounded_iteration_interest || exit
|
||||||
)
|
)
|
||||||
|
# Check that the interest programs ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`interest\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the message example Leo program.
|
# Build and run the message example Leo program.
|
||||||
|
echo "Building and running the \`message\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/message || exit
|
cd $EXAMPLES/message || exit
|
||||||
$LEO run main
|
$LEO run main || exit
|
||||||
)
|
)
|
||||||
|
# Check that the message program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`message\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the tic tac toe example Leo program.
|
# Build and run the tic tac toe example Leo program.
|
||||||
|
echo "Building and running the \`tictactoe\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/tictactoe || exit
|
cd $EXAMPLES/tictactoe || exit
|
||||||
$LEO run new
|
$LEO run new || exit
|
||||||
$LEO run make_move
|
$LEO run make_move || exit
|
||||||
|
|
||||||
chmod +x ./run.sh
|
chmod +x $EXAMPLES/tictactoe/run.sh || exit
|
||||||
./run.sh
|
export -f leo
|
||||||
|
$EXAMPLES/tictactoe/run.sh || exit
|
||||||
)
|
)
|
||||||
|
# Check that the tic tac toe program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`tictactoe\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the simple token example programs.
|
# Build and run the simple token example programs.
|
||||||
|
echo "Building and running the \`simple_token\` programs..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/simple_token || exit
|
cd $EXAMPLES/simple_token || exit
|
||||||
|
|
||||||
# Run the mint program.
|
# Run the mint program.
|
||||||
$LEO run mint
|
$LEO run mint
|
||||||
@ -157,40 +276,68 @@ cd leo && cargo install --path . && cd ..
|
|||||||
# Run the transfer program.
|
# Run the transfer program.
|
||||||
$LEO run transfer
|
$LEO run transfer
|
||||||
)
|
)
|
||||||
|
# Check that the simple token programs ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`simple_token\` programs failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the token example program.
|
# Build and run the token example program.
|
||||||
|
echo "Building and running the \`token\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/token || exit
|
cd $EXAMPLES/token || exit
|
||||||
|
|
||||||
# Run the mint_public function.
|
# Run the mint_public function.
|
||||||
$LEO run mint_public
|
$LEO run mint_public || exit
|
||||||
|
|
||||||
# Run the mint_private function.
|
# Run the mint_private function.
|
||||||
$LEO run mint_private
|
$LEO run mint_private || exit
|
||||||
|
|
||||||
# Run the transfer_public function.
|
# Run the transfer_public function.
|
||||||
$LEO run transfer_public
|
$LEO run transfer_public || exit
|
||||||
|
|
||||||
# Run the transfer_private function.
|
# Run the transfer_private function.
|
||||||
$LEO run transfer_private
|
$LEO run transfer_private || exit
|
||||||
|
|
||||||
# Run the transfer_private_to_public function.
|
# Run the transfer_private_to_public function.
|
||||||
$LEO run transfer_private_to_public
|
$LEO run transfer_private_to_public || exit
|
||||||
|
|
||||||
# Run the transfer_public_to_private function.
|
# Run the transfer_public_to_private function.
|
||||||
$LEO run transfer_public_to_private
|
$LEO run transfer_public_to_private || exit
|
||||||
)
|
)
|
||||||
|
# Check that the token program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`token\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the two-adicity program.
|
# Build and run the two-adicity program.
|
||||||
|
echo "Building and running the \`twoadicity\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/twoadicity || exit
|
cd $EXAMPLES/twoadicity || exit
|
||||||
$LEO run main
|
$LEO run main || exit
|
||||||
)
|
)
|
||||||
|
# Check that the two-adicity program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`twoadicity\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and run the vote Leo program.
|
# Build and run the vote Leo program.
|
||||||
|
echo "Building and running the \`vote\` program..."
|
||||||
(
|
(
|
||||||
cd ./project/examples/vote || exit
|
cd $EXAMPLES/vote || exit
|
||||||
|
|
||||||
chmod +x ./run.sh
|
chmod +x $EXAMPLES/vote/run.sh || exit
|
||||||
./run.sh
|
export -f leo
|
||||||
|
$EXAMPLES/vote/run.sh || exit
|
||||||
)
|
)
|
||||||
|
# Check that the vote program ran successfully.
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ $EXITCODE -ne 0 ]; then
|
||||||
|
echo "The \`vote\` program failed to run successfully."
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
|
63
Cargo.lock
generated
63
Cargo.lock
generated
@ -70,11 +70,10 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aleo"
|
name = "aleo"
|
||||||
version = "0.3.4"
|
version = "0.3.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c1e4929cda45548d053c11a8e08eb0c530361b441f31ad7cf6f066289368d1df"
|
checksum = "17259b13bd25bf6fdc8d6a207fd690daca08640dd364d7072ba425b5a5bfa6cd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aleo-rust",
|
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
"colored",
|
"colored",
|
||||||
@ -82,7 +81,6 @@ dependencies = [
|
|||||||
"parking_lot",
|
"parking_lot",
|
||||||
"rand",
|
"rand",
|
||||||
"rand_chacha",
|
"rand_chacha",
|
||||||
"rpassword",
|
|
||||||
"self_update 0.32.0",
|
"self_update 0.32.0",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@ -93,22 +91,6 @@ dependencies = [
|
|||||||
"warp",
|
"warp",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "aleo-rust"
|
|
||||||
version = "0.3.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "34efc6c260c8e720f02a96e72748e6d9392b985dd0883d923882a20500274eef"
|
|
||||||
dependencies = [
|
|
||||||
"anyhow",
|
|
||||||
"indexmap",
|
|
||||||
"once_cell",
|
|
||||||
"rand",
|
|
||||||
"serde_json",
|
|
||||||
"snarkvm",
|
|
||||||
"snarkvm-wasm",
|
|
||||||
"ureq",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aleo-std"
|
name = "aleo-std"
|
||||||
version = "0.1.15"
|
version = "0.1.15"
|
||||||
@ -932,10 +914,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
|
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"js-sys",
|
|
||||||
"libc",
|
"libc",
|
||||||
"wasi",
|
"wasi",
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2123,27 +2103,6 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rpassword"
|
|
||||||
version = "7.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"rtoolbox",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rtoolbox"
|
|
||||||
version = "0.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.21"
|
version = "0.1.21"
|
||||||
@ -2945,13 +2904,11 @@ dependencies = [
|
|||||||
"parking_lot",
|
"parking_lot",
|
||||||
"paste",
|
"paste",
|
||||||
"rand",
|
"rand",
|
||||||
"reqwest",
|
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2",
|
"sha2",
|
||||||
"snarkvm-curves",
|
"snarkvm-curves",
|
||||||
"snarkvm-utilities",
|
"snarkvm-utilities",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"wasm-bindgen-futures",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3030,20 +2987,6 @@ dependencies = [
|
|||||||
"syn 1.0.107",
|
"syn 1.0.107",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "snarkvm-wasm"
|
|
||||||
version = "0.9.13"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "eab1c2fc59610557d3f4e8c215d43bdb90748aec810ba0b04e6fa7d1b6543ece"
|
|
||||||
dependencies = [
|
|
||||||
"getrandom",
|
|
||||||
"rand",
|
|
||||||
"serde",
|
|
||||||
"snarkvm-console",
|
|
||||||
"snarkvm-utilities",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "socket2"
|
name = "socket2"
|
||||||
version = "0.4.7"
|
version = "0.4.7"
|
||||||
@ -3632,8 +3575,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
|
checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"wasm-bindgen-macro",
|
"wasm-bindgen-macro",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ ci_skip = [ "leo-compiler/ci_skip" ]
|
|||||||
noconfig = [ ]
|
noconfig = [ ]
|
||||||
|
|
||||||
[dependencies.aleo]
|
[dependencies.aleo]
|
||||||
version = "0.3.4"
|
version = "=0.3.3"
|
||||||
|
|
||||||
[dependencies.leo-ast]
|
[dependencies.leo-ast]
|
||||||
path = "./compiler/ast"
|
path = "./compiler/ast"
|
||||||
|
@ -28,7 +28,7 @@ pub struct CodeGenerator<'a> {
|
|||||||
/// The struct dependency graph for the program.
|
/// The struct dependency graph for the program.
|
||||||
pub(crate) struct_graph: &'a StructGraph,
|
pub(crate) struct_graph: &'a StructGraph,
|
||||||
/// The call graph for the program.
|
/// The call graph for the program.
|
||||||
pub(crate) call_graph: &'a CallGraph,
|
pub(crate) _call_graph: &'a CallGraph,
|
||||||
/// A counter to track the next available register.
|
/// A counter to track the next available register.
|
||||||
pub(crate) next_register: u64,
|
pub(crate) next_register: u64,
|
||||||
/// Reference to the current function.
|
/// Reference to the current function.
|
||||||
@ -47,12 +47,12 @@ pub struct CodeGenerator<'a> {
|
|||||||
|
|
||||||
impl<'a> CodeGenerator<'a> {
|
impl<'a> CodeGenerator<'a> {
|
||||||
/// Initializes a new `CodeGenerator`.
|
/// Initializes a new `CodeGenerator`.
|
||||||
pub fn new(symbol_table: &'a SymbolTable, struct_graph: &'a StructGraph, call_graph: &'a CallGraph) -> Self {
|
pub fn new(symbol_table: &'a SymbolTable, struct_graph: &'a StructGraph, _call_graph: &'a CallGraph) -> Self {
|
||||||
// Initialize variable mapping.
|
// Initialize variable mapping.
|
||||||
Self {
|
Self {
|
||||||
symbol_table,
|
symbol_table,
|
||||||
struct_graph,
|
struct_graph,
|
||||||
call_graph,
|
_call_graph,
|
||||||
next_register: 0,
|
next_register: 0,
|
||||||
current_function: None,
|
current_function: None,
|
||||||
variable_mapping: IndexMap::new(),
|
variable_mapping: IndexMap::new(),
|
||||||
|
@ -62,9 +62,12 @@ impl<'a> CodeGenerator<'a> {
|
|||||||
&order
|
&order
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|name| {
|
.map(|name| {
|
||||||
// Note that this unwrap is safe since type checking guarantees that all structs are declared.
|
match program_scope.structs.get(&name) {
|
||||||
let struct_ = program_scope.structs.get(&name).unwrap();
|
// If the struct is found, it is a local struct.
|
||||||
self.visit_struct_or_record(struct_)
|
Some(struct_) => self.visit_struct_or_record(struct_),
|
||||||
|
// If the struct is not found, it is an imported struct.
|
||||||
|
None => String::new(),
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.join("\n"),
|
.join("\n"),
|
||||||
);
|
);
|
||||||
@ -81,18 +84,14 @@ impl<'a> CodeGenerator<'a> {
|
|||||||
.join("\n"),
|
.join("\n"),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get the post-order ordering of the call graph.
|
// Visit each function in the program scope and produce an Aleo function.
|
||||||
// Note that the unwrap is safe since type checking guarantees that the call graph is acyclic.
|
// Note that in the function inlining pass, we reorder the functions such that they are in post-order.
|
||||||
let order = self.call_graph.post_order().unwrap();
|
// In other words, a callee function precedes its caller function in the program scope.
|
||||||
|
|
||||||
// Visit each function in the post-ordering and produce an Aleo function.
|
|
||||||
program_string.push_str(
|
program_string.push_str(
|
||||||
&order
|
&program_scope
|
||||||
.into_iter()
|
.functions
|
||||||
.map(|function_name| {
|
.values()
|
||||||
// Note that this unwrap is safe since type checking guarantees that all functions are declared.
|
.map(|function| {
|
||||||
let function = program_scope.functions.get(&function_name).unwrap();
|
|
||||||
|
|
||||||
// Set the `is_transition_function` flag.
|
// Set the `is_transition_function` flag.
|
||||||
self.is_transition_function = matches!(function.variant, Variant::Transition);
|
self.is_transition_function = matches!(function.variant, Variant::Transition);
|
||||||
|
|
||||||
|
@ -28,6 +28,11 @@ impl ExpressionReconstructor for FunctionInliner<'_> {
|
|||||||
type AdditionalOutput = Vec<Statement>;
|
type AdditionalOutput = Vec<Statement>;
|
||||||
|
|
||||||
fn reconstruct_call(&mut self, input: CallExpression) -> (Expression, Self::AdditionalOutput) {
|
fn reconstruct_call(&mut self, input: CallExpression) -> (Expression, Self::AdditionalOutput) {
|
||||||
|
// Type checking guarantees that only functions local to the program scope can be inlined.
|
||||||
|
if input.external.is_some() {
|
||||||
|
return (Expression::Call(input), Default::default());
|
||||||
|
}
|
||||||
|
|
||||||
// Get the name of the callee function.
|
// Get the name of the callee function.
|
||||||
let function_name = match *input.function {
|
let function_name = match *input.function {
|
||||||
Expression::Identifier(identifier) => identifier.name,
|
Expression::Identifier(identifier) => identifier.name,
|
||||||
|
@ -27,14 +27,22 @@ impl ProgramReconstructor for FunctionInliner<'_> {
|
|||||||
|
|
||||||
// Reconstruct and accumulate each of the functions in post-order.
|
// Reconstruct and accumulate each of the functions in post-order.
|
||||||
for function_name in order.into_iter() {
|
for function_name in order.into_iter() {
|
||||||
// Note that this unwrap is safe since type checking guarantees that all functions are declared.
|
// None: If `function_name` is not in `input.functions`, then it must be an external function.
|
||||||
let function = input.functions.remove(&function_name).unwrap();
|
// TODO: Check that this is indeed an external function. Requires a redesign of the symbol table.
|
||||||
|
if let Some(function) = input.functions.remove(&function_name) {
|
||||||
// Reconstruct the function.
|
// Reconstruct the function.
|
||||||
let reconstructed_function = self.reconstruct_function(function);
|
let reconstructed_function = self.reconstruct_function(function);
|
||||||
// Add the reconstructed function to the mapping.
|
// Add the reconstructed function to the mapping.
|
||||||
self.reconstructed_functions
|
self.reconstructed_functions
|
||||||
.insert(function_name, reconstructed_function);
|
.insert(function_name, reconstructed_function);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// Check that `input.functions` is empty.
|
||||||
|
// This is a sanity check to ensure that functions in the program scope have been processed.
|
||||||
|
assert!(
|
||||||
|
input.functions.is_empty(),
|
||||||
|
"All functions in the program scope should have been processed."
|
||||||
|
);
|
||||||
|
|
||||||
// Note that this intentionally clears `self.reconstructed_functions` for the next program scope.
|
// Note that this intentionally clears `self.reconstructed_functions` for the next program scope.
|
||||||
let functions = core::mem::take(&mut self.reconstructed_functions);
|
let functions = core::mem::take(&mut self.reconstructed_functions);
|
||||||
|
@ -465,6 +465,11 @@ impl<'a> ExpressionVisitor<'a> for TypeChecker<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check that the call is not to an external `inline` function.
|
||||||
|
if func.variant == Variant::Inline && input.external.is_some() {
|
||||||
|
self.emit_err(TypeCheckerError::cannot_call_external_inline_function(input.span));
|
||||||
|
}
|
||||||
|
|
||||||
let ret = self.assert_and_return_type(func.output_type, expected, input.span());
|
let ret = self.assert_and_return_type(func.output_type, expected, input.span());
|
||||||
|
|
||||||
// Check number of function arguments.
|
// Check number of function arguments.
|
||||||
|
@ -566,4 +566,11 @@ create_messages!(
|
|||||||
msg: format!("A struct cannot have a member with mode `constant`, `private`, or `public`."),
|
msg: format!("A struct cannot have a member with mode `constant`, `private`, or `public`."),
|
||||||
help: None,
|
help: None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@formatted
|
||||||
|
cannot_call_external_inline_function {
|
||||||
|
args: (),
|
||||||
|
msg: format!("Cannot call an external `inline` function."),
|
||||||
|
help: None,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
#!/bin/bash
|
|
||||||
# First check that Leo is installed.
|
|
||||||
if ! command -v leo &> /dev/null
|
|
||||||
then
|
|
||||||
echo "leo is not installed."
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
# The private key and address of the first bidder.
|
# The private key and address of the first bidder.
|
||||||
# Swap these into program.json, when running transactions as the first bidder.
|
# Swap these into program.json, when running transactions as the first bidder.
|
||||||
# "private_key": "APrivateKey1zkpG9Af9z5Ha4ejVyMCqVFXRKknSm8L1ELEwcc4htk9YhVK"
|
# "private_key": "APrivateKey1zkpG9Af9z5Ha4ejVyMCqVFXRKknSm8L1ELEwcc4htk9YhVK"
|
||||||
@ -61,7 +53,7 @@ echo "
|
|||||||
######## ########
|
######## ########
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"
|
"
|
||||||
leo run place_bid aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke 10u64
|
leo run place_bid aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke 10u64 || exit
|
||||||
|
|
||||||
# Swap in the private key and address of the second bidder to program.json.
|
# Swap in the private key and address of the second bidder to program.json.
|
||||||
echo "{
|
echo "{
|
||||||
@ -90,7 +82,7 @@ echo "
|
|||||||
######## ########
|
######## ########
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"
|
"
|
||||||
leo run place_bid aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4 90u64
|
leo run place_bid aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4 90u64 || exit
|
||||||
|
|
||||||
# Swap in the private key and address of the auctioneer to program.json.
|
# Swap in the private key and address of the auctioneer to program.json.
|
||||||
echo "{
|
echo "{
|
||||||
@ -132,7 +124,7 @@ leo run resolve "{
|
|||||||
amount: 90u64.private,
|
amount: 90u64.private,
|
||||||
is_winner: false.private,
|
is_winner: false.private,
|
||||||
_nonce: 5952811863753971450641238938606857357746712138665944763541786901326522216736group.public
|
_nonce: 5952811863753971450641238938606857357746712138665944763541786901326522216736group.public
|
||||||
}"
|
}" || exit
|
||||||
|
|
||||||
# Have the auctioneer finish the auction.
|
# Have the auctioneer finish the auction.
|
||||||
echo "
|
echo "
|
||||||
@ -155,7 +147,7 @@ leo run finish "{
|
|||||||
amount: 90u64.private,
|
amount: 90u64.private,
|
||||||
is_winner: false.private,
|
is_winner: false.private,
|
||||||
_nonce: 5952811863753971450641238938606857357746712138665944763541786901326522216736group.public
|
_nonce: 5952811863753971450641238938606857357746712138665944763541786901326522216736group.public
|
||||||
}"
|
}" || exit
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
#!/bin/bash
|
|
||||||
# First check that Leo is installed.
|
|
||||||
if ! command -v leo &> /dev/null
|
|
||||||
then
|
|
||||||
echo "leo is not installed."
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
# The private key and address of the bank.
|
# The private key and address of the bank.
|
||||||
# Swap these into program.json, when running transactions as the first bidder.
|
# Swap these into program.json, when running transactions as the first bidder.
|
||||||
# "private_key": "APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD",
|
# "private_key": "APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD",
|
||||||
@ -69,7 +61,7 @@ echo "
|
|||||||
######## ########
|
######## ########
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"
|
"
|
||||||
leo run issue aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg 100u64;
|
leo run issue aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg 100u64 || exit
|
||||||
|
|
||||||
# Swap in the private key and address of the user to program.json.
|
# Swap in the private key and address of the user to program.json.
|
||||||
echo "{
|
echo "{
|
||||||
@ -129,7 +121,7 @@ leo run deposit "{
|
|||||||
gates: 0u64.private,
|
gates: 0u64.private,
|
||||||
amount: 100u64.private,
|
amount: 100u64.private,
|
||||||
_nonce: 4668394794828730542675887906815309351994017139223602571716627453741502624516group.public
|
_nonce: 4668394794828730542675887906815309351994017139223602571716627453741502624516group.public
|
||||||
}" 50u64
|
}" 50u64 || exit
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -225,4 +217,4 @@ echo "
|
|||||||
######## ########
|
######## ########
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"
|
"
|
||||||
leo run withdraw aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a 50u64 1234u64 15u64;
|
leo run withdraw aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a 50u64 1234u64 15u64 || exit
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
#!/bin/bash
|
|
||||||
# First check that Leo is installed.
|
|
||||||
if ! command -v leo &> /dev/null
|
|
||||||
then
|
|
||||||
echo "leo is not installed."
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Follow along in the README.md for a detailed explanation of each step.
|
# Follow along in the README.md for a detailed explanation of each step.
|
||||||
|
|
||||||
# 1: Initializing Player 1
|
# 1: Initializing Player 1
|
||||||
@ -38,7 +30,7 @@ echo "
|
|||||||
######## ########
|
######## ########
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"
|
"
|
||||||
leo run initialize_board 34084860461056u64 551911718912u64 7u64 1157425104234217472u64 aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry
|
leo run initialize_board 34084860461056u64 551911718912u64 7u64 1157425104234217472u64 aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry || exit
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
✅ Successfully initialized Player 1's board."
|
✅ Successfully initialized Player 1's board."
|
||||||
@ -61,7 +53,7 @@ leo run offer_battleship '{
|
|||||||
player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private,
|
player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private,
|
||||||
game_started: false.private,
|
game_started: false.private,
|
||||||
_nonce: 3887646704618532506963887075433683846689834495661101507703164090915348189037group.public
|
_nonce: 3887646704618532506963887075433683846689834495661101507703164090915348189037group.public
|
||||||
}'
|
}' || exit
|
||||||
echo "
|
echo "
|
||||||
✅ Successfully passed the board to Player 2."
|
✅ Successfully passed the board to Player 2."
|
||||||
|
|
||||||
@ -86,7 +78,7 @@ echo "
|
|||||||
\"license\": \"MIT\"
|
\"license\": \"MIT\"
|
||||||
}" > program.json
|
}" > program.json
|
||||||
|
|
||||||
leo run initialize_board 31u64 2207646875648u64 224u64 9042383626829824u64 aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy
|
leo run initialize_board 31u64 2207646875648u64 224u64 9042383626829824u64 aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy || exit
|
||||||
)
|
)
|
||||||
echo "
|
echo "
|
||||||
✅ Successfully initialized Player 2's board."
|
✅ Successfully initialized Player 2's board."
|
||||||
@ -118,7 +110,7 @@ leo run start_battleship '{
|
|||||||
player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private,
|
player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private,
|
||||||
prev_hit_or_miss: 0u64.private,
|
prev_hit_or_miss: 0u64.private,
|
||||||
_nonce: 4374626042494973146987320062571809401151262172766172816829659487584978644457group.public
|
_nonce: 4374626042494973146987320062571809401151262172766172816829659487584978644457group.public
|
||||||
}'
|
}' || exit
|
||||||
echo "
|
echo "
|
||||||
✅ Successfully passed the board back to Player 1."
|
✅ Successfully passed the board back to Player 1."
|
||||||
|
|
||||||
@ -161,7 +153,7 @@ echo "
|
|||||||
player_2: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private,
|
player_2: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private,
|
||||||
prev_hit_or_miss: 0u64.private,
|
prev_hit_or_miss: 0u64.private,
|
||||||
_nonce: 3742551407126138397717446975757978589064777004441277005584760115236217735495group.public
|
_nonce: 3742551407126138397717446975757978589064777004441277005584760115236217735495group.public
|
||||||
}' 1u64
|
}' 1u64 || exit
|
||||||
)
|
)
|
||||||
echo "
|
echo "
|
||||||
✅ Successfully executed Player 1's turn."
|
✅ Successfully executed Player 1's turn."
|
||||||
@ -205,7 +197,7 @@ echo "
|
|||||||
player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private,
|
player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private,
|
||||||
prev_hit_or_miss: 0u64.private,
|
prev_hit_or_miss: 0u64.private,
|
||||||
_nonce: 5481529266389297320813092061136936339861329677911328036818179854958874588416group.public
|
_nonce: 5481529266389297320813092061136936339861329677911328036818179854958874588416group.public
|
||||||
}' 2048u64
|
}' 2048u64 || exit
|
||||||
)
|
)
|
||||||
echo "
|
echo "
|
||||||
✅ Successfully executed Player 2's turn."
|
✅ Successfully executed Player 2's turn."
|
||||||
@ -249,7 +241,7 @@ echo "
|
|||||||
player_2: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private,
|
player_2: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private,
|
||||||
prev_hit_or_miss: 1u64.private,
|
prev_hit_or_miss: 1u64.private,
|
||||||
_nonce: 5851606198769770675504009323414373017067582072428989801313256693053765675198group.public
|
_nonce: 5851606198769770675504009323414373017067582072428989801313256693053765675198group.public
|
||||||
}' 2u64
|
}' 2u64 || exit
|
||||||
)
|
)
|
||||||
echo "
|
echo "
|
||||||
✅ Successfully executed Player 1's turn."
|
✅ Successfully executed Player 1's turn."
|
||||||
@ -293,7 +285,7 @@ echo "
|
|||||||
player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private,
|
player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private,
|
||||||
prev_hit_or_miss: 0u64.private,
|
prev_hit_or_miss: 0u64.private,
|
||||||
_nonce: 710336412388939616658264778971886770861024495941253598683184288448156545822group.public
|
_nonce: 710336412388939616658264778971886770861024495941253598683184288448156545822group.public
|
||||||
}' 4u64
|
}' 4u64 || exit
|
||||||
)
|
)
|
||||||
echo "
|
echo "
|
||||||
✅ Successfully executed Player 2's turn."
|
✅ Successfully executed Player 2's turn."
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
#!/bin/bash
|
|
||||||
# First check that Leo is installed.
|
|
||||||
if ! command -v leo &> /dev/null
|
|
||||||
then
|
|
||||||
echo "leo is not installed."
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create a new game.
|
# Create a new game.
|
||||||
echo "
|
echo "
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -18,7 +10,7 @@ echo "
|
|||||||
######## ########
|
######## ########
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"
|
"
|
||||||
leo run new
|
leo run new || exit
|
||||||
|
|
||||||
# Have the Player 1 make a move.
|
# Have the Player 1 make a move.
|
||||||
echo "
|
echo "
|
||||||
@ -32,7 +24,7 @@ echo "
|
|||||||
######## ########
|
######## ########
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"
|
"
|
||||||
leo run make_move 1u8 1u8 1u8 "{ r1: { c1: 0u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }"
|
leo run make_move 1u8 1u8 1u8 "{ r1: { c1: 0u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }" || exit
|
||||||
|
|
||||||
# Have the Player 2 make a move.
|
# Have the Player 2 make a move.
|
||||||
echo "
|
echo "
|
||||||
@ -46,7 +38,7 @@ echo "
|
|||||||
######## ########
|
######## ########
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"
|
"
|
||||||
leo run make_move 2u8 2u8 2u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }"
|
leo run make_move 2u8 2u8 2u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }" || exit
|
||||||
|
|
||||||
# Have the Player 1 make a move.
|
# Have the Player 1 make a move.
|
||||||
echo "
|
echo "
|
||||||
@ -60,7 +52,7 @@ echo "
|
|||||||
######## ########
|
######## ########
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"
|
"
|
||||||
leo run make_move 1u8 3u8 1u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 2u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }"
|
leo run make_move 1u8 3u8 1u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 2u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }" || exit
|
||||||
|
|
||||||
# Have the Player 2 make a move.
|
# Have the Player 2 make a move.
|
||||||
echo "
|
echo "
|
||||||
@ -74,7 +66,7 @@ echo "
|
|||||||
######## ########
|
######## ########
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"
|
"
|
||||||
leo run make_move 2u8 2u8 1u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 2u8, c3: 0u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }"
|
leo run make_move 2u8 2u8 1u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 2u8, c3: 0u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }" || exit
|
||||||
|
|
||||||
# Have the Player 1 make a move.
|
# Have the Player 1 make a move.
|
||||||
echo "
|
echo "
|
||||||
@ -88,7 +80,7 @@ echo "
|
|||||||
######## ########
|
######## ########
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"
|
"
|
||||||
leo run make_move 1u8 2u8 3u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 0u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }"
|
leo run make_move 1u8 2u8 3u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 0u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }" || exit
|
||||||
|
|
||||||
# Have the Player 2 make a move.
|
# Have the Player 2 make a move.
|
||||||
echo "
|
echo "
|
||||||
@ -102,7 +94,7 @@ echo "
|
|||||||
######## ########
|
######## ########
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"
|
"
|
||||||
leo run make_move 2u8 1u8 2u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }"
|
leo run make_move 2u8 1u8 2u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }" || exit
|
||||||
|
|
||||||
# Have the Player 1 make a move.
|
# Have the Player 1 make a move.
|
||||||
echo "
|
echo "
|
||||||
@ -116,7 +108,7 @@ echo "
|
|||||||
######## ########
|
######## ########
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"
|
"
|
||||||
leo run make_move 1u8 3u8 2u8 "{ r1: { c1: 1u8, c2: 2u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }"
|
leo run make_move 1u8 3u8 2u8 "{ r1: { c1: 1u8, c2: 2u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }" || exit
|
||||||
|
|
||||||
# Have the Player 2 make a move.
|
# Have the Player 2 make a move.
|
||||||
echo "
|
echo "
|
||||||
@ -130,7 +122,7 @@ echo "
|
|||||||
######## ########
|
######## ########
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"
|
"
|
||||||
leo run make_move 2u8 3u8 3u8 "{ r1: { c1: 1u8, c2: 2u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 1u8, c3: 0u8 } }"
|
leo run make_move 2u8 3u8 3u8 "{ r1: { c1: 1u8, c2: 2u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 1u8, c3: 0u8 } }" || exit
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -143,7 +135,7 @@ echo "
|
|||||||
######## ########
|
######## ########
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"
|
"
|
||||||
leo run make_move 1u8 1u8 3u8 "{ r1: { c1: 1u8, c2: 2u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 1u8, c3: 2u8 } }"
|
leo run make_move 1u8 1u8 3u8 "{ r1: { c1: 1u8, c2: 2u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 1u8, c3: 2u8 } }" || exit
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
program token.aleo
|
program token.aleo;
|
||||||
|
|
||||||
record token:
|
record token:
|
||||||
owner as address.private;
|
owner as address.private;
|
||||||
@ -8,10 +8,10 @@ record token:
|
|||||||
mapping account:
|
mapping account:
|
||||||
key left as address.public;
|
key left as address.public;
|
||||||
value right as u64.public;
|
value right as u64.public;
|
||||||
|
|
||||||
function mint_public:
|
function mint_public:
|
||||||
input r0 as address.public;
|
input r0 as address.public;
|
||||||
input r1 as u64.public;
|
input r1 as u64.public;
|
||||||
|
|
||||||
finalize r0 r1;
|
finalize r0 r1;
|
||||||
|
|
||||||
finalize mint_public:
|
finalize mint_public:
|
||||||
@ -28,6 +28,7 @@ function mint_private:
|
|||||||
function transfer_public:
|
function transfer_public:
|
||||||
input r0 as address.public;
|
input r0 as address.public;
|
||||||
input r1 as u64.public;
|
input r1 as u64.public;
|
||||||
|
|
||||||
finalize self.caller r0 r1;
|
finalize self.caller r0 r1;
|
||||||
|
|
||||||
finalize transfer_public:
|
finalize transfer_public:
|
||||||
@ -54,6 +55,7 @@ function transfer_private_to_public:
|
|||||||
sub r0.amount r2 into r3;
|
sub r0.amount r2 into r3;
|
||||||
cast r0.owner r0.gates r3 into r4 as token.record;
|
cast r0.owner r0.gates r3 into r4 as token.record;
|
||||||
output r4 as token.record;
|
output r4 as token.record;
|
||||||
|
|
||||||
finalize r1 r2;
|
finalize r1 r2;
|
||||||
|
|
||||||
finalize transfer_private_to_public:
|
finalize transfer_private_to_public:
|
||||||
@ -66,10 +68,10 @@ function transfer_public_to_private:
|
|||||||
input r1 as u64.public;
|
input r1 as u64.public;
|
||||||
cast r0 0u64 r1 into r2 as token.record;
|
cast r0 0u64 r1 into r2 as token.record;
|
||||||
output r2 as token.record;
|
output r2 as token.record;
|
||||||
|
|
||||||
finalize self.caller r1;
|
finalize self.caller r1;
|
||||||
|
|
||||||
finalize transfer_public_to_private:
|
finalize transfer_public_to_private:
|
||||||
input r0 as address.public;
|
input r0 as address.public;
|
||||||
input r1 as u64.public;
|
input r1 as u64.public;
|
||||||
decrement account[r0] by r1;
|
decrement account[r0] by r1;
|
||||||
|
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
#!/bin/bash
|
|
||||||
# First check that Leo is installed.
|
|
||||||
if ! command -v leo &> /dev/null
|
|
||||||
then
|
|
||||||
echo "leo is not installed."
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
###############################################################################
|
###############################################################################
|
||||||
######## ########
|
######## ########
|
||||||
|
Loading…
Reference in New Issue
Block a user