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

refactor(sozo): change param type to environment metadata #464

Merged
merged 8 commits into from
Jun 10, 2023
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
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