diff --git a/.circleci/config.yml b/.circleci/config.yml index ec466f2fa1..e840bc91a4 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -274,19 +274,6 @@ jobs: export LEO=/home/circleci/project/project/bin/leo ./project/.circleci/leo-clean.sh - leo-example: - docker: - - image: cimg/rust:1.82 - resource_class: xlarge - steps: - - attach_workspace: - at: /home/circleci/project/ - - run: - name: leo example - command: | - export LEO=/home/circleci/project/project/bin/leo - ./project/.circleci/leo-example.sh - test-examples: docker: - image: cimg/rust:1.82 @@ -316,9 +303,6 @@ workflows: - leo-clean: requires: - leo-executable - - leo-example: - requires: - - leo-executable - test-examples: requires: - leo-executable diff --git a/.circleci/leo-example.sh b/.circleci/leo-example.sh deleted file mode 100755 index 8fbce490c0..0000000000 --- a/.circleci/leo-example.sh +++ /dev/null @@ -1,41 +0,0 @@ -# Alias the leo command to use the local binary. -# Note: Use a full path for $LEO when running locally. -leo() { - $LEO "$@" -} - -( - # Create a new Leo lottery example program. - $LEO example lottery || exit - ls -la - cd lottery && ls -la - - # Run the script. - chmod +x ./run.sh || exit - export -f leo - ./run.sh || exit -) - -( - # Create a new Leo tictactoe example program. - $LEO example tictactoe || exit - ls -la - cd tictactoe && ls -la - - # Run the script. - chmod +x ./run.sh || exit - export -f leo - ./run.sh || exit -) - -( - #Create a new Leo token example program. - $LEO example token || exit - ls -la - cd token && ls -la - - # Run the script. - chmod +x ./run.sh || exit - export -f leo - ./run.sh || exit -) diff --git a/README.md b/README.md index 66e0d12112..80521cfe23 100644 --- a/README.md +++ b/README.md @@ -67,8 +67,8 @@ We recommend installing Rust using [rustup](https://www.rustup.rs/). You can ins We recommend installing Leo by building from the source code as follows: ```bash -# Download the source code and initialize the submodules -git clone --recurse-submodules https://github.com/ProvableHQ/leo +# Download the source code +git clone https://github.com/ProvableHQ/leo cd leo # Install 'leo' diff --git a/leo/cli/cli.rs b/leo/cli/cli.rs index a2c14b69cc..ada4024fa1 100644 --- a/leo/cli/cli.rs +++ b/leo/cli/cli.rs @@ -52,11 +52,6 @@ enum Commands { #[clap(flatten)] command: LeoNew, }, - #[clap(about = "Create a new Leo example package in a new directory")] - Example { - #[clap(flatten)] - command: LeoExample, - }, #[clap(about = "Run a program with input variables")] Run { #[clap(flatten)] @@ -147,7 +142,6 @@ pub fn run_with_args(cli: CLI) -> Result<()> { Commands::Query { command } => command.try_execute(context), Commands::Clean { command } => command.try_execute(context), Commands::Deploy { command } => command.try_execute(context), - Commands::Example { command } => command.try_execute(context), Commands::Run { command } => command.try_execute(context), Commands::Execute { command } => command.try_execute(context), Commands::Remove { command } => command.try_execute(context), diff --git a/leo/cli/commands/example.rs b/leo/cli/commands/example.rs deleted file mode 100644 index 0df8a6534f..0000000000 --- a/leo/cli/commands/example.rs +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (C) 2019-2025 Provable Inc. -// This file is part of the Leo library. - -// The Leo library is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// The Leo library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with the Leo library. If not, see . - -use super::*; - -use std::fs; - -/// Initialize a new Leo example. -#[derive(Parser, Debug)] -pub struct LeoExample { - #[clap(name = "NAME", help = "The example to initialize.")] - pub(crate) name: String, - #[clap(short = 'n', long, help = "Name of the network to use", default_value = "testnet")] - pub(crate) network: String, - #[clap( - short = 'e', - long, - help = "Endpoint to retrieve network state from.", - default_value = "https://api.explorer.provable.com/v1" - )] - pub(crate) endpoint: String, -} - -impl Command for LeoExample { - type Input = ::Output; - type Output = (); - - fn prelude(&self, context: Context) -> Result { - // Run leo new --network - (LeoNew { name: self.name.clone(), network: self.network.clone(), endpoint: self.endpoint.clone() }) - .execute(context) - } - - fn apply(self, context: Context, _: Self::Input) -> Result - where - Self: Sized, - { - let package_dir = context.dir()?; - - // Parse the example variant. - let example_variant = - ExampleVariant::try_from(self.name.as_str()).map_err(|_| CliError::invalid_example(self.name.as_str()))?; - - // Write the main file. - let main_file_path = package_dir.join("src").join("main.leo"); - fs::write(main_file_path, example_variant.main_file_string()).map_err(CliError::failed_to_write_file)?; - - // Write the README file. - let readme_file_path = package_dir.join("README.md"); - let readme_file_path_string = readme_file_path.display().to_string(); - fs::write(readme_file_path, example_variant.readme_file_string()).map_err(CliError::failed_to_write_file)?; - - // Write the run.sh file. - let run_file_path = package_dir.join("run.sh"); - fs::write(run_file_path, example_variant.run_file_string()).map_err(CliError::failed_to_write_file)?; - - tracing::info!( - "🚀 To run the '{}' program follow the instructions at {}", - example_variant.name().bold(), - readme_file_path_string - ); - - Ok(()) - } -} - -/// The example programs that can be generated. -#[derive(Parser, Debug, Copy, Clone)] -pub enum ExampleVariant { - #[clap(name = "lottery", about = "A public lottery program")] - Lottery, - #[clap(name = "tictactoe", about = "A standard tic-tac-toe game program")] - TicTacToe, - #[clap(name = "token", about = "A transparent & shielded custom token program")] - Token, -} - -impl ExampleVariant { - fn name(&self) -> String { - match self { - Self::Lottery => "lottery".to_string(), - Self::TicTacToe => "tictactoe".to_string(), - Self::Token => "token".to_string(), - } - } - - fn main_file_string(&self) -> String { - match self { - Self::Lottery => { - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/lottery/src/main.leo")).to_string() - } - Self::TicTacToe => { - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/tictactoe/src/main.leo")).to_string() - } - Self::Token => { - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/token/src/main.leo")).to_string() - } - } - } - - fn readme_file_string(&self) -> String { - match self { - Self::Lottery => { - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/lottery/README.md")).to_string() - } - Self::TicTacToe => { - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/tictactoe/README.md")).to_string() - } - Self::Token => include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/token/README.md")).to_string(), - } - } - - fn run_file_string(&self) -> String { - match self { - Self::Lottery => include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/lottery/run.sh")).to_string(), - Self::TicTacToe => { - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/tictactoe/run.sh")).to_string() - } - Self::Token => include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/token/run.sh")).to_string(), - } - } -} - -impl TryFrom<&str> for ExampleVariant { - type Error = (); - - fn try_from(value: &str) -> std::result::Result { - match value { - "lottery" => Ok(Self::Lottery), - "tictactoe" => Ok(Self::TicTacToe), - "token" => Ok(Self::Token), - _ => Err(()), - } - } -} diff --git a/leo/cli/commands/mod.rs b/leo/cli/commands/mod.rs index f2e50c67d5..d6c51ec3cd 100644 --- a/leo/cli/commands/mod.rs +++ b/leo/cli/commands/mod.rs @@ -32,9 +32,6 @@ pub use debug::LeoDebug; pub mod deploy; pub use deploy::Deploy; -pub mod example; -pub use example::LeoExample; - pub mod execute; pub use execute::LeoExecute;