From 1d1451d95cfcc2863ddd2ba10220bda579d9772c Mon Sep 17 00:00:00 2001 From: Jonatan Chaverri Date: Fri, 16 Feb 2024 19:39:08 -0600 Subject: [PATCH] Split sozo ops into its own crate --- Cargo.lock | 18 +++++++ Cargo.toml | 2 + bin/sozo/Cargo.toml | 36 +------------ bin/sozo/src/lib.rs | 3 -- bin/sozo/src/main.rs | 4 +- crates/benches/Cargo.toml | 1 + crates/benches/src/deployer.rs | 4 +- crates/sozo/ops/Cargo.toml | 51 +++++++++++++++++++ {bin/sozo => crates/sozo/ops}/src/args.rs | 0 .../src/ops => crates/sozo/ops/src}/auth.rs | 0 .../sozo/ops}/src/commands/auth.rs | 2 +- .../sozo/ops}/src/commands/build.rs | 2 +- .../sozo/ops}/src/commands/completions.rs | 0 .../sozo/ops}/src/commands/dev.rs | 2 +- .../sozo/ops}/src/commands/events.rs | 2 +- .../sozo/ops}/src/commands/execute.rs | 2 +- .../sozo/ops}/src/commands/init.rs | 0 .../sozo/ops}/src/commands/migrate.rs | 2 +- .../sozo/ops}/src/commands/mod.rs | 0 .../sozo/ops}/src/commands/model.rs | 2 +- .../sozo/ops}/src/commands/options/account.rs | 0 .../sozo/ops}/src/commands/options/mod.rs | 0 .../ops}/src/commands/options/starknet.rs | 0 .../ops}/src/commands/options/transaction.rs | 0 .../sozo/ops}/src/commands/options/world.rs | 0 .../sozo/ops}/src/commands/register.rs | 2 +- .../sozo/ops}/src/commands/test.rs | 0 .../src/ops => crates/sozo/ops/src}/events.rs | 0 .../ops => crates/sozo/ops/src}/execute.rs | 0 .../ops/mod.rs => crates/sozo/ops/src/lib.rs | 2 + .../sozo/ops/src}/migration/migration_test.rs | 23 +++++---- .../sozo/ops/src}/migration/mod.rs | 0 .../sozo/ops/src}/migration/ui.rs | 0 .../src/ops => crates/sozo/ops/src}/model.rs | 0 .../ops => crates/sozo/ops/src}/register.rs | 0 .../ops}/tests/fixtures/stdout/init.stdout | 0 .../stdout/wrong_cairo_version.stdout | 0 .../sozo/ops}/tests/test_build.rs | 2 +- .../invalid_cairo_version/Scarb.toml | 0 .../test_data/invalid_cairo_version/lib.cairo | 0 .../ops}/tests/test_data/keystore/test.json | 0 .../sozo/ops}/tests/test_data/manifest.json | 0 .../sozo/ops}/tests/test_init.rs | 0 .../sozo/ops}/tests/utils/mod.rs | 0 .../sozo/ops}/tests/utils/snapbox.rs | 0 .../sozo/ops}/tests/utils/stdout.rs | 0 crates/torii/core/Cargo.toml | 1 + crates/torii/core/src/sql_test.rs | 2 +- crates/torii/graphql/Cargo.toml | 1 + crates/torii/graphql/src/tests/mod.rs | 2 +- 50 files changed, 105 insertions(+), 63 deletions(-) delete mode 100644 bin/sozo/src/lib.rs create mode 100644 crates/sozo/ops/Cargo.toml rename {bin/sozo => crates/sozo/ops}/src/args.rs (100%) rename {bin/sozo/src/ops => crates/sozo/ops/src}/auth.rs (100%) rename {bin/sozo => crates/sozo/ops}/src/commands/auth.rs (98%) rename {bin/sozo => crates/sozo/ops}/src/commands/build.rs (95%) rename {bin/sozo => crates/sozo/ops}/src/commands/completions.rs (100%) rename {bin/sozo => crates/sozo/ops}/src/commands/dev.rs (99%) rename {bin/sozo => crates/sozo/ops}/src/commands/events.rs (99%) rename {bin/sozo => crates/sozo/ops}/src/commands/execute.rs (98%) rename {bin/sozo => crates/sozo/ops}/src/commands/init.rs (100%) rename {bin/sozo => crates/sozo/ops}/src/commands/migrate.rs (98%) rename {bin/sozo => crates/sozo/ops}/src/commands/mod.rs (100%) rename {bin/sozo => crates/sozo/ops}/src/commands/model.rs (98%) rename {bin/sozo => crates/sozo/ops}/src/commands/options/account.rs (100%) rename {bin/sozo => crates/sozo/ops}/src/commands/options/mod.rs (100%) rename {bin/sozo => crates/sozo/ops}/src/commands/options/starknet.rs (100%) rename {bin/sozo => crates/sozo/ops}/src/commands/options/transaction.rs (100%) rename {bin/sozo => crates/sozo/ops}/src/commands/options/world.rs (100%) rename {bin/sozo => crates/sozo/ops}/src/commands/register.rs (98%) rename {bin/sozo => crates/sozo/ops}/src/commands/test.rs (100%) rename {bin/sozo/src/ops => crates/sozo/ops/src}/events.rs (100%) rename {bin/sozo/src/ops => crates/sozo/ops/src}/execute.rs (100%) rename bin/sozo/src/ops/mod.rs => crates/sozo/ops/src/lib.rs (75%) rename {bin/sozo/src/ops => crates/sozo/ops/src}/migration/migration_test.rs (85%) rename {bin/sozo/src/ops => crates/sozo/ops/src}/migration/mod.rs (100%) rename {bin/sozo/src/ops => crates/sozo/ops/src}/migration/ui.rs (100%) rename {bin/sozo/src/ops => crates/sozo/ops/src}/model.rs (100%) rename {bin/sozo/src/ops => crates/sozo/ops/src}/register.rs (100%) rename {bin/sozo => crates/sozo/ops}/tests/fixtures/stdout/init.stdout (100%) rename {bin/sozo => crates/sozo/ops}/tests/fixtures/stdout/wrong_cairo_version.stdout (100%) rename {bin/sozo => crates/sozo/ops}/tests/test_build.rs (78%) rename {bin/sozo => crates/sozo/ops}/tests/test_data/invalid_cairo_version/Scarb.toml (100%) rename {bin/sozo => crates/sozo/ops}/tests/test_data/invalid_cairo_version/lib.cairo (100%) rename {bin/sozo => crates/sozo/ops}/tests/test_data/keystore/test.json (100%) rename {bin/sozo => crates/sozo/ops}/tests/test_data/manifest.json (100%) rename {bin/sozo => crates/sozo/ops}/tests/test_init.rs (100%) rename {bin/sozo => crates/sozo/ops}/tests/utils/mod.rs (100%) rename {bin/sozo => crates/sozo/ops}/tests/utils/snapbox.rs (100%) rename {bin/sozo => crates/sozo/ops}/tests/utils/stdout.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 0038279ed1..9722ccd491 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -975,6 +975,7 @@ dependencies = [ "serde", "serde_json", "sozo", + "sozo-ops", "starknet", "tokio", ] @@ -10960,6 +10961,21 @@ dependencies = [ [[package]] name = "sozo" version = "0.6.0-alpha.0" +dependencies = [ + "anyhow", + "camino", + "clap", + "clap-verbosity-flag", + "dojo-lang", + "scarb", + "scarb-ui", + "semver 1.0.21", + "sozo-ops", +] + +[[package]] +name = "sozo-ops" +version = "0.6.0-alpha.0" dependencies = [ "anyhow", "assert_fs", @@ -12335,6 +12351,7 @@ dependencies = [ "serde_json", "slab", "sozo", + "sozo-ops", "sqlx", "starknet", "starknet-crypto 0.6.1", @@ -12368,6 +12385,7 @@ dependencies = [ "serde_json", "serial_test", "sozo", + "sozo-ops", "sqlx", "starknet", "starknet-crypto 0.6.1", diff --git a/Cargo.toml b/Cargo.toml index f48170bb6b..6e110a04c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ members = [ "crates/metrics", "crates/saya/core", "crates/sozo/signers", + "crates/sozo/ops", "crates/torii/client", "crates/torii/server", "crates/torii/types-test", @@ -92,6 +93,7 @@ saya-core = { path = "crates/saya/core" } # sozo sozo-signers = { path = "crates/sozo/signers" } +sozo-ops = { path = "crates/sozo/ops" } anyhow = "1.0.75" assert_matches = "1.5.0" diff --git a/bin/sozo/Cargo.toml b/bin/sozo/Cargo.toml index 752f36e41f..c5b460fb47 100644 --- a/bin/sozo/Cargo.toml +++ b/bin/sozo/Cargo.toml @@ -7,45 +7,11 @@ version.workspace = true [dependencies] anyhow.workspace = true -async-trait.workspace = true -cairo-lang-compiler.workspace = true -cairo-lang-defs.workspace = true -cairo-lang-filesystem.workspace = true -cairo-lang-plugins.workspace = true -cairo-lang-project.workspace = true -cairo-lang-sierra-to-casm.workspace = true -cairo-lang-sierra.workspace = true -cairo-lang-starknet.workspace = true -cairo-lang-test-plugin.workspace = true -cairo-lang-test-runner.workspace = true -cairo-lang-utils.workspace = true camino.workspace = true clap-verbosity-flag = "2.0.1" clap.workspace = true -clap_complete.workspace = true -console.workspace = true -dojo-bindgen.workspace = true dojo-lang.workspace = true -dojo-types.workspace = true -dojo-world = { workspace = true, features = [ "contracts", "metadata", "migration" ] } -notify = "6.0.1" -notify-debouncer-mini = "0.3.0" scarb-ui.workspace = true scarb.workspace = true semver.workspace = true -serde.workspace = true -serde_json.workspace = true -smol_str.workspace = true -starknet-crypto.workspace = true -starknet.workspace = true -thiserror.workspace = true -tokio.workspace = true -tracing-log = "0.1.3" -tracing.workspace = true -url.workspace = true - -[dev-dependencies] -assert_fs = "1.0.10" -dojo-test-utils = { workspace = true, features = [ "build-examples" ] } -katana-runner.workspace = true -snapbox = "0.4.6" +sozo-ops.workspace = true diff --git a/bin/sozo/src/lib.rs b/bin/sozo/src/lib.rs deleted file mode 100644 index fc9ec51d87..0000000000 --- a/bin/sozo/src/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod args; -pub mod commands; -pub mod ops; diff --git a/bin/sozo/src/main.rs b/bin/sozo/src/main.rs index e0385cf849..fee80bb791 100644 --- a/bin/sozo/src/main.rs +++ b/bin/sozo/src/main.rs @@ -11,7 +11,7 @@ use scarb::compiler::CompilerRepository; use scarb::core::{Config, TomlManifest}; use scarb_ui::{OutputFormat, Ui}; use semver::Version; -use sozo::args::{Commands, SozoArgs}; +use sozo_ops::args::{Commands, SozoArgs}; fn main() { let args = SozoArgs::parse(); @@ -48,7 +48,7 @@ fn cli_main(args: SozoArgs) -> Result<()> { .compilers(compilers) .build()?; - sozo::commands::run(args.command, &config) + sozo_ops::commands::run(args.command, &config) } fn verify_cairo_version_compatibility(manifest_path: &Utf8PathBuf) -> Result<()> { diff --git a/crates/benches/Cargo.toml b/crates/benches/Cargo.toml index 0ae0ae4923..2a84b79e42 100644 --- a/crates/benches/Cargo.toml +++ b/crates/benches/Cargo.toml @@ -26,6 +26,7 @@ clap.workspace = true scarb.workspace = true dojo-lang.workspace = true dojo-world.workspace = true +sozo-ops.workspace = true [features] default = ["skip-benchmarks"] diff --git a/crates/benches/src/deployer.rs b/crates/benches/src/deployer.rs index 12c440e19b..51f16ecae3 100644 --- a/crates/benches/src/deployer.rs +++ b/crates/benches/src/deployer.rs @@ -12,8 +12,8 @@ use katana_runner::KatanaRunner; use scarb::compiler::CompilerRepository; use scarb::core::{Config, TargetKind}; use scarb::ops::CompileOpts; -use sozo::args::{Commands, SozoArgs}; -use sozo::ops::migration; +use sozo_ops::args::{Commands, SozoArgs}; +use sozo_ops::migration; use starknet::core::types::FieldElement; use tokio::process::Command; diff --git a/crates/sozo/ops/Cargo.toml b/crates/sozo/ops/Cargo.toml new file mode 100644 index 0000000000..d025bcb83c --- /dev/null +++ b/crates/sozo/ops/Cargo.toml @@ -0,0 +1,51 @@ +[package] +name = "sozo-ops" +edition.workspace = true +version.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow.workspace = true +async-trait.workspace = true +cairo-lang-compiler.workspace = true +cairo-lang-defs.workspace = true +cairo-lang-filesystem.workspace = true +cairo-lang-plugins.workspace = true +cairo-lang-project.workspace = true +cairo-lang-sierra-to-casm.workspace = true +cairo-lang-sierra.workspace = true +cairo-lang-starknet.workspace = true +cairo-lang-test-plugin.workspace = true +cairo-lang-test-runner.workspace = true +cairo-lang-utils.workspace = true +camino.workspace = true +clap-verbosity-flag = "2.0.1" +clap.workspace = true +clap_complete.workspace = true +console.workspace = true +dojo-bindgen.workspace = true +dojo-lang.workspace = true +dojo-types.workspace = true +dojo-world = { workspace = true, features = [ "contracts", "metadata", "migration" ] } +notify = "6.0.1" +notify-debouncer-mini = "0.3.0" +scarb-ui.workspace = true +scarb.workspace = true +semver.workspace = true +serde.workspace = true +serde_json.workspace = true +smol_str.workspace = true +starknet-crypto.workspace = true +starknet.workspace = true +thiserror.workspace = true +tokio.workspace = true +tracing-log = "0.1.3" +tracing.workspace = true +url.workspace = true + +[dev-dependencies] +assert_fs = "1.0.10" +dojo-test-utils = { workspace = true, features = [ "build-examples" ] } +katana-runner.workspace = true +snapbox = "0.4.6" diff --git a/bin/sozo/src/args.rs b/crates/sozo/ops/src/args.rs similarity index 100% rename from bin/sozo/src/args.rs rename to crates/sozo/ops/src/args.rs diff --git a/bin/sozo/src/ops/auth.rs b/crates/sozo/ops/src/auth.rs similarity index 100% rename from bin/sozo/src/ops/auth.rs rename to crates/sozo/ops/src/auth.rs diff --git a/bin/sozo/src/commands/auth.rs b/crates/sozo/ops/src/commands/auth.rs similarity index 98% rename from bin/sozo/src/commands/auth.rs rename to crates/sozo/ops/src/commands/auth.rs index 76b45137c7..8b1763a280 100644 --- a/bin/sozo/src/commands/auth.rs +++ b/crates/sozo/ops/src/commands/auth.rs @@ -8,7 +8,7 @@ use super::options::account::AccountOptions; use super::options::starknet::StarknetOptions; use super::options::transaction::TransactionOptions; use super::options::world::WorldOptions; -use crate::ops::auth; +use crate::auth; #[derive(Debug, Args)] pub struct AuthArgs { diff --git a/bin/sozo/src/commands/build.rs b/crates/sozo/ops/src/commands/build.rs similarity index 95% rename from bin/sozo/src/commands/build.rs rename to crates/sozo/ops/src/commands/build.rs index cd7db4f1d9..aec8d122e2 100644 --- a/bin/sozo/src/commands/build.rs +++ b/crates/sozo/ops/src/commands/build.rs @@ -61,7 +61,7 @@ mod tests { #[test] fn build_example_with_typescript_and_unity_bindings() { - let config = build_test_config("../../examples/spawn-and-move/Scarb.toml").unwrap(); + let config = build_test_config("../../../examples/spawn-and-move/Scarb.toml").unwrap(); let build_args = BuildArgs { bindings_output: "generated".to_string(), typescript: true, unity: true }; diff --git a/bin/sozo/src/commands/completions.rs b/crates/sozo/ops/src/commands/completions.rs similarity index 100% rename from bin/sozo/src/commands/completions.rs rename to crates/sozo/ops/src/commands/completions.rs diff --git a/bin/sozo/src/commands/dev.rs b/crates/sozo/ops/src/commands/dev.rs similarity index 99% rename from bin/sozo/src/commands/dev.rs rename to crates/sozo/ops/src/commands/dev.rs index b55a24b9af..c2a6f19094 100644 --- a/bin/sozo/src/commands/dev.rs +++ b/crates/sozo/ops/src/commands/dev.rs @@ -24,7 +24,7 @@ use tracing_log::log; use super::options::account::AccountOptions; use super::options::starknet::StarknetOptions; use super::options::world::WorldOptions; -use crate::ops::migration; +use crate::migration; #[derive(Args)] pub struct DevArgs { diff --git a/bin/sozo/src/commands/events.rs b/crates/sozo/ops/src/commands/events.rs similarity index 99% rename from bin/sozo/src/commands/events.rs rename to crates/sozo/ops/src/commands/events.rs index 48fdb46aed..86810cfe59 100644 --- a/bin/sozo/src/commands/events.rs +++ b/crates/sozo/ops/src/commands/events.rs @@ -10,7 +10,7 @@ use starknet::core::utils::starknet_keccak; use super::options::starknet::StarknetOptions; use super::options::world::WorldOptions; -use crate::ops::events; +use crate::events; #[derive(Parser, Debug)] pub struct EventsArgs { diff --git a/bin/sozo/src/commands/execute.rs b/crates/sozo/ops/src/commands/execute.rs similarity index 98% rename from bin/sozo/src/commands/execute.rs rename to crates/sozo/ops/src/commands/execute.rs index 0a494b1333..4a8286a698 100644 --- a/bin/sozo/src/commands/execute.rs +++ b/crates/sozo/ops/src/commands/execute.rs @@ -7,7 +7,7 @@ use starknet::core::types::FieldElement; use super::options::account::AccountOptions; use super::options::starknet::StarknetOptions; use super::options::transaction::TransactionOptions; -use crate::ops::execute; +use crate::execute; #[derive(Debug, Args)] #[command(about = "Execute a system with the given calldata.")] diff --git a/bin/sozo/src/commands/init.rs b/crates/sozo/ops/src/commands/init.rs similarity index 100% rename from bin/sozo/src/commands/init.rs rename to crates/sozo/ops/src/commands/init.rs diff --git a/bin/sozo/src/commands/migrate.rs b/crates/sozo/ops/src/commands/migrate.rs similarity index 98% rename from bin/sozo/src/commands/migrate.rs rename to crates/sozo/ops/src/commands/migrate.rs index b34f000da0..52452ec9cf 100644 --- a/bin/sozo/src/commands/migrate.rs +++ b/crates/sozo/ops/src/commands/migrate.rs @@ -8,7 +8,7 @@ use super::options::account::AccountOptions; use super::options::starknet::StarknetOptions; use super::options::transaction::TransactionOptions; use super::options::world::WorldOptions; -use crate::ops::migration; +use crate::migration; #[derive(Args)] pub struct MigrateArgs { diff --git a/bin/sozo/src/commands/mod.rs b/crates/sozo/ops/src/commands/mod.rs similarity index 100% rename from bin/sozo/src/commands/mod.rs rename to crates/sozo/ops/src/commands/mod.rs diff --git a/bin/sozo/src/commands/model.rs b/crates/sozo/ops/src/commands/model.rs similarity index 98% rename from bin/sozo/src/commands/model.rs rename to crates/sozo/ops/src/commands/model.rs index b4f00d0055..4d11190059 100644 --- a/bin/sozo/src/commands/model.rs +++ b/crates/sozo/ops/src/commands/model.rs @@ -6,7 +6,7 @@ use starknet::core::types::FieldElement; use super::options::starknet::StarknetOptions; use super::options::world::WorldOptions; -use crate::ops::model; +use crate::model; #[derive(Debug, Args)] pub struct ModelArgs { diff --git a/bin/sozo/src/commands/options/account.rs b/crates/sozo/ops/src/commands/options/account.rs similarity index 100% rename from bin/sozo/src/commands/options/account.rs rename to crates/sozo/ops/src/commands/options/account.rs diff --git a/bin/sozo/src/commands/options/mod.rs b/crates/sozo/ops/src/commands/options/mod.rs similarity index 100% rename from bin/sozo/src/commands/options/mod.rs rename to crates/sozo/ops/src/commands/options/mod.rs diff --git a/bin/sozo/src/commands/options/starknet.rs b/crates/sozo/ops/src/commands/options/starknet.rs similarity index 100% rename from bin/sozo/src/commands/options/starknet.rs rename to crates/sozo/ops/src/commands/options/starknet.rs diff --git a/bin/sozo/src/commands/options/transaction.rs b/crates/sozo/ops/src/commands/options/transaction.rs similarity index 100% rename from bin/sozo/src/commands/options/transaction.rs rename to crates/sozo/ops/src/commands/options/transaction.rs diff --git a/bin/sozo/src/commands/options/world.rs b/crates/sozo/ops/src/commands/options/world.rs similarity index 100% rename from bin/sozo/src/commands/options/world.rs rename to crates/sozo/ops/src/commands/options/world.rs diff --git a/bin/sozo/src/commands/register.rs b/crates/sozo/ops/src/commands/register.rs similarity index 98% rename from bin/sozo/src/commands/register.rs rename to crates/sozo/ops/src/commands/register.rs index a1df25a833..544b99549d 100644 --- a/bin/sozo/src/commands/register.rs +++ b/crates/sozo/ops/src/commands/register.rs @@ -8,7 +8,7 @@ use super::options::account::AccountOptions; use super::options::starknet::StarknetOptions; use super::options::transaction::TransactionOptions; use super::options::world::WorldOptions; -use crate::ops::register; +use crate::register; #[derive(Debug, Args)] pub struct RegisterArgs { diff --git a/bin/sozo/src/commands/test.rs b/crates/sozo/ops/src/commands/test.rs similarity index 100% rename from bin/sozo/src/commands/test.rs rename to crates/sozo/ops/src/commands/test.rs diff --git a/bin/sozo/src/ops/events.rs b/crates/sozo/ops/src/events.rs similarity index 100% rename from bin/sozo/src/ops/events.rs rename to crates/sozo/ops/src/events.rs diff --git a/bin/sozo/src/ops/execute.rs b/crates/sozo/ops/src/execute.rs similarity index 100% rename from bin/sozo/src/ops/execute.rs rename to crates/sozo/ops/src/execute.rs diff --git a/bin/sozo/src/ops/mod.rs b/crates/sozo/ops/src/lib.rs similarity index 75% rename from bin/sozo/src/ops/mod.rs rename to crates/sozo/ops/src/lib.rs index abf4eb9c5c..c3200fc4e4 100644 --- a/bin/sozo/src/ops/mod.rs +++ b/crates/sozo/ops/src/lib.rs @@ -1,4 +1,6 @@ +pub mod args; pub mod auth; +pub mod commands; pub mod events; pub mod execute; pub mod migration; diff --git a/bin/sozo/src/ops/migration/migration_test.rs b/crates/sozo/ops/src/migration/migration_test.rs similarity index 85% rename from bin/sozo/src/ops/migration/migration_test.rs rename to crates/sozo/ops/src/migration/migration_test.rs index 967ee392df..8b620ebf2b 100644 --- a/bin/sozo/src/ops/migration/migration_test.rs +++ b/crates/sozo/ops/src/migration/migration_test.rs @@ -17,15 +17,16 @@ use starknet::providers::JsonRpcClient; use starknet::signers::{LocalWallet, SigningKey}; use crate::commands::options::transaction::TransactionOptions; -use crate::ops::migration::execute_strategy; +use crate::migration::execute_strategy; #[tokio::test(flavor = "multi_thread")] async fn migrate_with_auto_mine() { - let config = build_test_config("../../examples/spawn-and-move/Scarb.toml").unwrap(); + let config = build_test_config("../../../examples/spawn-and-move/Scarb.toml").unwrap(); let ws = ops::read_workspace(config.manifest_path(), &config) .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); - let migration = prepare_migration("../../examples/spawn-and-move/target/dev".into()).unwrap(); + let migration = + prepare_migration("../../../examples/spawn-and-move/target/dev".into()).unwrap(); let sequencer = TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; @@ -40,11 +41,12 @@ async fn migrate_with_auto_mine() { #[tokio::test(flavor = "multi_thread")] async fn migrate_with_block_time() { - let config = build_test_config("../../examples/spawn-and-move/Scarb.toml").unwrap(); + let config = build_test_config("../../../examples/spawn-and-move/Scarb.toml").unwrap(); let ws = ops::read_workspace(config.manifest_path(), &config) .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); - let migration = prepare_migration("../../examples/spawn-and-move/target/dev".into()).unwrap(); + let migration = + prepare_migration("../../../examples/spawn-and-move/target/dev".into()).unwrap(); let sequencer = TestSequencer::start( SequencerConfig { block_time: Some(1000), ..Default::default() }, @@ -61,11 +63,12 @@ async fn migrate_with_block_time() { #[tokio::test(flavor = "multi_thread")] async fn migrate_with_small_fee_multiplier_will_fail() { - let config = build_test_config("../../examples/spawn-and-move/Scarb.toml").unwrap(); + let config = build_test_config("../../../examples/spawn-and-move/Scarb.toml").unwrap(); let ws = ops::read_workspace(config.manifest_path(), &config) .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); - let migration = prepare_migration("../../examples/spawn-and-move/target/dev".into()).unwrap(); + let migration = + prepare_migration("../../../examples/spawn-and-move/target/dev".into()).unwrap(); let sequencer = TestSequencer::start( Default::default(), @@ -99,7 +102,7 @@ async fn migrate_with_small_fee_multiplier_will_fail() { #[test] fn migrate_world_without_seed_will_fail() { let target_dir = - Utf8PathBuf::from_path_buf("../../examples/spawn-and-move/target/dev".into()).unwrap(); + Utf8PathBuf::from_path_buf("../../../examples/spawn-and-move/target/dev".into()).unwrap(); let manifest = Manifest::load_from_path(target_dir.join("manifest.json")).unwrap(); let world = WorldDiff::compute(manifest, None); let res = prepare_for_migration(None, None, target_dir, world); @@ -109,11 +112,11 @@ fn migrate_world_without_seed_will_fail() { #[ignore] #[tokio::test] async fn migration_from_remote() { - let config = build_test_config("../../examples/spawn-and-move/Scarb.toml").unwrap(); + let config = build_test_config("../../../examples/spawn-and-move/Scarb.toml").unwrap(); let ws = ops::read_workspace(config.manifest_path(), &config) .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); let target_dir = - Utf8PathBuf::from_path_buf("../../examples/spawn-and-move/target/dev".into()).unwrap(); + Utf8PathBuf::from_path_buf("../../../examples/spawn-and-move/target/dev".into()).unwrap(); let sequencer = TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; diff --git a/bin/sozo/src/ops/migration/mod.rs b/crates/sozo/ops/src/migration/mod.rs similarity index 100% rename from bin/sozo/src/ops/migration/mod.rs rename to crates/sozo/ops/src/migration/mod.rs diff --git a/bin/sozo/src/ops/migration/ui.rs b/crates/sozo/ops/src/migration/ui.rs similarity index 100% rename from bin/sozo/src/ops/migration/ui.rs rename to crates/sozo/ops/src/migration/ui.rs diff --git a/bin/sozo/src/ops/model.rs b/crates/sozo/ops/src/model.rs similarity index 100% rename from bin/sozo/src/ops/model.rs rename to crates/sozo/ops/src/model.rs diff --git a/bin/sozo/src/ops/register.rs b/crates/sozo/ops/src/register.rs similarity index 100% rename from bin/sozo/src/ops/register.rs rename to crates/sozo/ops/src/register.rs diff --git a/bin/sozo/tests/fixtures/stdout/init.stdout b/crates/sozo/ops/tests/fixtures/stdout/init.stdout similarity index 100% rename from bin/sozo/tests/fixtures/stdout/init.stdout rename to crates/sozo/ops/tests/fixtures/stdout/init.stdout diff --git a/bin/sozo/tests/fixtures/stdout/wrong_cairo_version.stdout b/crates/sozo/ops/tests/fixtures/stdout/wrong_cairo_version.stdout similarity index 100% rename from bin/sozo/tests/fixtures/stdout/wrong_cairo_version.stdout rename to crates/sozo/ops/tests/fixtures/stdout/wrong_cairo_version.stdout diff --git a/bin/sozo/tests/test_build.rs b/crates/sozo/ops/tests/test_build.rs similarity index 78% rename from bin/sozo/tests/test_build.rs rename to crates/sozo/ops/tests/test_build.rs index 552f62f1fc..d57661737f 100644 --- a/bin/sozo/tests/test_build.rs +++ b/crates/sozo/ops/tests/test_build.rs @@ -7,7 +7,7 @@ use utils::stdout::expected_stdout; #[test] fn test_invalid_cairo_version() { - let path = fs::canonicalize("./tests/test_data/invalid_cairo_version"); + let path = fs::canonicalize("./ops/tests/test_data/invalid_cairo_version"); let assert = get_snapbox().arg("build").current_dir(path.unwrap()).assert().failure(); assert.stdout_eq(expected_stdout("wrong-cairo-version")); } diff --git a/bin/sozo/tests/test_data/invalid_cairo_version/Scarb.toml b/crates/sozo/ops/tests/test_data/invalid_cairo_version/Scarb.toml similarity index 100% rename from bin/sozo/tests/test_data/invalid_cairo_version/Scarb.toml rename to crates/sozo/ops/tests/test_data/invalid_cairo_version/Scarb.toml diff --git a/bin/sozo/tests/test_data/invalid_cairo_version/lib.cairo b/crates/sozo/ops/tests/test_data/invalid_cairo_version/lib.cairo similarity index 100% rename from bin/sozo/tests/test_data/invalid_cairo_version/lib.cairo rename to crates/sozo/ops/tests/test_data/invalid_cairo_version/lib.cairo diff --git a/bin/sozo/tests/test_data/keystore/test.json b/crates/sozo/ops/tests/test_data/keystore/test.json similarity index 100% rename from bin/sozo/tests/test_data/keystore/test.json rename to crates/sozo/ops/tests/test_data/keystore/test.json diff --git a/bin/sozo/tests/test_data/manifest.json b/crates/sozo/ops/tests/test_data/manifest.json similarity index 100% rename from bin/sozo/tests/test_data/manifest.json rename to crates/sozo/ops/tests/test_data/manifest.json diff --git a/bin/sozo/tests/test_init.rs b/crates/sozo/ops/tests/test_init.rs similarity index 100% rename from bin/sozo/tests/test_init.rs rename to crates/sozo/ops/tests/test_init.rs diff --git a/bin/sozo/tests/utils/mod.rs b/crates/sozo/ops/tests/utils/mod.rs similarity index 100% rename from bin/sozo/tests/utils/mod.rs rename to crates/sozo/ops/tests/utils/mod.rs diff --git a/bin/sozo/tests/utils/snapbox.rs b/crates/sozo/ops/tests/utils/snapbox.rs similarity index 100% rename from bin/sozo/tests/utils/snapbox.rs rename to crates/sozo/ops/tests/utils/snapbox.rs diff --git a/bin/sozo/tests/utils/stdout.rs b/crates/sozo/ops/tests/utils/stdout.rs similarity index 100% rename from bin/sozo/tests/utils/stdout.rs rename to crates/sozo/ops/tests/utils/stdout.rs diff --git a/crates/torii/core/Cargo.toml b/crates/torii/core/Cargo.toml index 8baed226c5..6faaeb040e 100644 --- a/crates/torii/core/Cargo.toml +++ b/crates/torii/core/Cargo.toml @@ -35,6 +35,7 @@ tokio = { version = "1.32.0", features = [ "sync" ], default-features = true } tokio-stream = "0.1.11" tokio-util = "0.7.7" tracing.workspace = true +sozo-ops.workspace = true [dev-dependencies] camino.workspace = true diff --git a/crates/torii/core/src/sql_test.rs b/crates/torii/core/src/sql_test.rs index b1d20358ab..0acabcf8f4 100644 --- a/crates/torii/core/src/sql_test.rs +++ b/crates/torii/core/src/sql_test.rs @@ -8,7 +8,7 @@ use dojo_test_utils::sequencer::{ use dojo_world::contracts::world::WorldContractReader; use dojo_world::migration::strategy::MigrationStrategy; use scarb::ops; -use sozo::ops::migration::execute_strategy; +use sozo_ops::migration::execute_strategy; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; use starknet::core::types::{BlockId, BlockTag, Event, FieldElement}; use starknet::providers::jsonrpc::HttpTransport; diff --git a/crates/torii/graphql/Cargo.toml b/crates/torii/graphql/Cargo.toml index fed37b5f4a..c8e2b6dcea 100644 --- a/crates/torii/graphql/Cargo.toml +++ b/crates/torii/graphql/Cargo.toml @@ -34,6 +34,7 @@ torii-core = { path = "../core" } tracing.workspace = true url.workspace = true warp.workspace = true +sozo-ops.workspace = true [dev-dependencies] camino.workspace = true diff --git a/crates/torii/graphql/src/tests/mod.rs b/crates/torii/graphql/src/tests/mod.rs index 5abb2da9f0..e3b376a1a7 100644 --- a/crates/torii/graphql/src/tests/mod.rs +++ b/crates/torii/graphql/src/tests/mod.rs @@ -15,7 +15,7 @@ use dojo_world::utils::TransactionWaiter; use scarb::ops; use serde::Deserialize; use serde_json::Value; -use sozo::ops::migration::execute_strategy; +use sozo_ops::migration::execute_strategy; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; use sqlx::SqlitePool; use starknet::accounts::{Account, Call};