Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update template CLI for latest changes to entropy-test-cli #96

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions templates/basic-template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ strip = "debuginfo"
crate-type = ["cdylib", "rlib"]

[dependencies]
entropy-programs-core={ git="https://github.com/entropyxyz/programs.git", tag="v0.10.0" }
schemars = {version = "0.8.16", optional = true}
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }
entropy-programs-core = { git = "https://github.com/entropyxyz/programs.git", tag = "v0.10.0" }
schemars = { version = "0.8.16", optional = true }
serde = { version = "1.0", default-features = false, features = [
"alloc",
"derive",
] }

# These are used by `cargo component`
[package.metadata.component]
Expand Down
19 changes: 11 additions & 8 deletions templates/basic-template/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ name = "cli"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap ={ version="4.4.6", features=["derive"] }
subxt ={version = "0.35.3", features = ["substrate-compat"]}
colored ="2.0.4"
tokio ={ version="1.16", features=["macros", "rt-multi-thread", "io-util", "process"] }
anyhow ="1.0.82"
clap = { version = "4.5.20", features = ["derive"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clap has been bumped, but most of the other changes in these Cargo.tomls are just from running taplo.

subxt = { version = "0.35.3", features = ["substrate-compat"] }
colored = "2.0.4"
tokio = { version = "1.16", features = [
"macros",
"rt-multi-thread",
"io-util",
"process",
] }
anyhow = "1.0.82"
dotenv = "0.15.0"
generate-types = { path = "../generate-types" }
project-root = "0.2.2"
entropy-test-cli = { git="https://github.com/entropyxyz/entropy-core.git", branch = "master" }
entropy-test-cli = { git = "https://github.com/entropyxyz/entropy-core.git", branch = "master" }
43 changes: 35 additions & 8 deletions templates/basic-template/cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,51 @@
use clap::Parser;
use colored::Colorize;
use entropy_test_cli::{run_command, PROGRAM_VERSION_NUMBER};
use dotenv::dotenv;
use entropy_test_cli::{run_command, Cli, PROGRAM_VERSION_NUMBER};
use generate_types::generate_types;
use project_root::get_project_root;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenv().ok();
let program = format!("{}/target/wasm32-unknown-unknown/release/{{project-name}}.wasm", get_project_root()?.to_string_lossy());
let program = format!(
"{}/target/wasm32-unknown-unknown/release/{{project-name}}.wasm",
get_project_root()?.to_string_lossy()
);
generate_types();
let config_interface = format!("{}/{{project-name}}_serialized_config_type.txt", get_project_root()?.to_string_lossy());
let aux_data_interface = format!("{}/{{project-name}}_serialized_aux_data_type.txt", get_project_root()?.to_string_lossy());
match run_command(Some(program.into()), Some(config_interface.into()), Some(aux_data_interface.into()), Some(PROGRAM_VERSION_NUMBER)).await {
let config_interface = format!(
"{}/{{project-name}}_serialized_config_type.txt",
get_project_root()?.to_string_lossy()
);
let aux_data_interface = format!(
"{}/{{project-name}}_serialized_aux_data_type.txt",
get_project_root()?.to_string_lossy()
);

let cli = Cli::parse();
let json_ouput = cli.json;
match run_command(
cli,
Some(program.into()),
Some(config_interface.into()),
Some(aux_data_interface.into()),
Some(PROGRAM_VERSION_NUMBER),
)
.await
{
Ok(output) => {
println!("Success: {}", output.green());
if json_ouput {
println!("{}", output);
} else {
println!("Success: {}", output.green());
}
Ok(())
}
Err(err) => {
println!("{}", "Failed!".red());
if !json_ouput {
eprintln!("{}", "Failed!".red());
}
Err(err)
}
}
}
}
6 changes: 4 additions & 2 deletions templates/basic-template/generate-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
program = { package= "{{project-name}}", path = "..", default-features = false, features=['std'] }
program = { package = "{{project-name}}", path = "..", default-features = false, features = [
'std',
] }
schemars = "0.8.16"
serde_json = { version = "1.0" }
serde_json = { version = "1.0" }
Loading