diff --git a/.circleci/leo-clean.sh b/.circleci/leo-clean.sh index 8ea352f345..895bcfb5bf 100755 --- a/.circleci/leo-clean.sh +++ b/.circleci/leo-clean.sh @@ -3,8 +3,8 @@ $LEO new foo || exit ls -la cd foo && ls -la -# Run `leo build`. -$LEO build || exit +# Run `leo run`. +$LEO run || exit # Assert that the 'build' folder exists. if [ "$(ls -A build)" ]; then diff --git a/.circleci/leo-example.sh b/.circleci/leo-example.sh new file mode 100644 index 0000000000..d0d735ee09 --- /dev/null +++ b/.circleci/leo-example.sh @@ -0,0 +1,32 @@ +( + # Create a new Leo lottery example program. + $LEO example lottery || exit + ls -la + cd lottery && ls -la + + # Run the play function. + $LEO run play || exit +) + +( + # Create a new Leo tictactoe example program. + $LEO example tictactoe || exit + ls -la + cd tictactoe && ls -la + + # Create a new game. + $LEO run new || exit + + # Create a make a move. + $LEO run make_move || exit +) + +( + #Create a new Leo token example program. + $LEO example token || exit + ls -la + cd token && ls -la + + # Run the mint_public function. + $LEO run mint_public || exit +) diff --git a/examples/tictactoe/README.md b/examples/tictactoe/README.md index 47877d52b6..84d6f7f33c 100644 --- a/examples/tictactoe/README.md +++ b/examples/tictactoe/README.md @@ -48,3 +48,35 @@ leo run ```bash leo execute ... ``` + +## Playing the Game + +### 1. Create a new game board +```bash +leo run new +``` +| | | | +|---|---|---| +| 0 | 0 | 0 | +| 0 | 0 | 0 | +| 0 | 0 | 0 | + +### 2. Player 1 makes a move +```bash +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 } }" +``` +| | | | +|---|---|---| +| 1 | 0 | 0 | +| 0 | 0 | 0 | +| 0 | 0 | 0 | + +### 3. Player 2 makes a move +```bash +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 } }" +``` +| | | | +|---|---|---| +| 1 | 0 | 0 | +| 0 | 2 | 0 | +| 0 | 0 | 0 | diff --git a/examples/tictactoe/inputs/tictactoe.in b/examples/tictactoe/inputs/tictactoe.in index 76c9aa77d0..aff78f3ac5 100644 --- a/examples/tictactoe/inputs/tictactoe.in +++ b/examples/tictactoe/inputs/tictactoe.in @@ -11,8 +11,8 @@ player: u8 = 1u8; row: u8 = 1u8; col: u8 = 1u8; board: Board = Board { - r1: Row { c1: 0u8, c2: 1u8, c3: 1u8 }, - r2: Row { c1: 2u8, c2: 2u8, c3: 0u8 }, + r1: Row { c1: 0u8, c2: 0u8, c3: 0u8 }, + r2: Row { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: Row { c1: 0u8, c2: 0u8, c3: 0u8 }, }; diff --git a/examples/token/README.md b/examples/token/README.md index a7cab97a63..cbf994273b 100644 --- a/examples/token/README.md +++ b/examples/token/README.md @@ -8,12 +8,5 @@ A transparent & shielded custom token in Leo. To run this program, run: ```bash -leo run main -``` - -## Execute Guide - -To execute this program, run: -```bash -leo execute main -``` +./run.sh +``` \ No newline at end of file diff --git a/leo/cli/commands/example.rs b/leo/cli/commands/example.rs index 6b9f6eca26..ac3dd06a16 100644 --- a/leo/cli/commands/example.rs +++ b/leo/cli/commands/example.rs @@ -49,7 +49,7 @@ impl Command for Example { fs::write(main_file_path, self.main_file_string()).map_err(CliError::failed_to_write_file)?; // Write the input file. - let input_file_path = package_dir.join("inputs").join("input.in"); + let input_file_path = package_dir.join("inputs").join(format!("{}.in", self.name())); fs::write(input_file_path, self.input_file_string()).map_err(CliError::failed_to_write_file)?; // Write the README file. @@ -98,9 +98,7 @@ impl Example { Self::TicTacToe => { include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/tictactoe/inputs/tictactoe.in")).to_string() } - Self::Token => { - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/token/inputs/token.in")).to_string() - } + Self::Token => include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/token/run.sh")).to_string(), } }