From 73035d20f55e617653e1a1c17351b94d73b5ccf8 Mon Sep 17 00:00:00 2001 From: Ammar Arif Date: Sun, 11 Jun 2023 00:56:49 +0800 Subject: [PATCH] refactor(sozo): change param type to environment metadata (#464) --- crates/sozo/src/commands/migrate.rs | 2 +- crates/sozo/src/commands/options/world.rs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/sozo/src/commands/migrate.rs b/crates/sozo/src/commands/migrate.rs index 34cf280a1f..3fea17897d 100644 --- a/crates/sozo/src/commands/migrate.rs +++ b/crates/sozo/src/commands/migrate.rs @@ -46,7 +46,7 @@ impl MigrateArgs { .or(env_metadata); ws.config().tokio_handle().block_on(async { - let world_address = self.world.address(&ws).ok(); + let world_address = self.world.address(env_metadata.as_ref()).ok(); let provider = self.starknet.provider(env_metadata.as_ref())?; let account = self diff --git a/crates/sozo/src/commands/options/world.rs b/crates/sozo/src/commands/options/world.rs index 7822413f22..920c09ef3c 100644 --- a/crates/sozo/src/commands/options/world.rs +++ b/crates/sozo/src/commands/options/world.rs @@ -2,10 +2,8 @@ use std::str::FromStr; use anyhow::{anyhow, Result}; use clap::Args; -use scarb::core::Workspace; use starknet::core::types::FieldElement; - -use super::dojo_metadata_from_workspace; +use toml::Value; #[derive(Debug, Args)] #[command(next_help_heading = "World options")] @@ -16,10 +14,10 @@ pub struct WorldOptions { } impl WorldOptions { - pub fn address(&self, ws: &Workspace<'_>) -> Result { + pub fn address(&self, env_metadata: Option<&Value>) -> Result { if let Some(world_address) = self.world_address { return Ok(world_address); - } else if let Some(dojo_metadata) = dojo_metadata_from_workspace(ws) { + } else if let Some(dojo_metadata) = env_metadata { if let Some(world_address) = dojo_metadata.get("world_address") { if let Some(world_address) = world_address.as_str() { let world_address = FieldElement::from_str(world_address)?;