Skip to content

Commit

Permalink
refactor(sozo): change param type to environment metadata (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy authored Jun 10, 2023
1 parent c6952d1 commit 73035d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/sozo/src/commands/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions crates/sozo/src/commands/options/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -16,10 +14,10 @@ pub struct WorldOptions {
}

impl WorldOptions {
pub fn address(&self, ws: &Workspace<'_>) -> Result<FieldElement> {
pub fn address(&self, env_metadata: Option<&Value>) -> Result<FieldElement> {
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)?;
Expand Down

0 comments on commit 73035d2

Please sign in to comment.