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

display contract addresses in sozo migrate plan #1926

Merged
merged 14 commits into from
May 19, 2024
48 changes: 33 additions & 15 deletions crates/sozo/ops/src/migration/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,54 +681,72 @@
.await
{
Ok(current_class_hash) if current_class_hash != contract.diff.local_class_hash => {
return format!("upgrade {}", contract.diff.name);
return format!("{}: Upgrade", contract.diff.name);

Check warning on line 684 in crates/sozo/ops/src/migration/migrate.rs

View check run for this annotation

Codecov / codecov/patch

crates/sozo/ops/src/migration/migrate.rs#L684

Added line #L684 was not covered by tests
}
Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => {
return format!("deploy {}", contract.diff.name);
return format!("{}: Deploy", contract.diff.name);

Check warning on line 687 in crates/sozo/ops/src/migration/migrate.rs

View check run for this annotation

Codecov / codecov/patch

crates/sozo/ops/src/migration/migrate.rs#L687

Added line #L687 was not covered by tests
}
Ok(_) => return "already deployed".to_string(),
Err(_) => return format!("deploy {}", contract.diff.name),
Ok(_) => return "Already Deployed".to_string(),
Err(_) => return format!("{}: Deploy", contract.diff.name),

Check warning on line 690 in crates/sozo/ops/src/migration/migrate.rs

View check run for this annotation

Codecov / codecov/patch

crates/sozo/ops/src/migration/migrate.rs#L689-L690

Added lines #L689 - L690 were not covered by tests
}
}
}
format!("deploy {}", contract.diff.name)
}

pub async fn print_strategy<P>(ui: &Ui, provider: &P, strategy: &MigrationStrategy)
where
pub async fn print_strategy<P>(
ui: &Ui,
provider: &P,
strategy: &MigrationStrategy,
world_address: FieldElement,
) where
P: Provider + Sync + Send + 'static,
{
ui.print("\n📋 Migration Strategy\n");

ui.print_header(format!("World address: {:#x}", world_address));

ui.print(" ");

if let Some(base) = &strategy.base {
ui.print_header("# Base Contract");
ui.print_sub(format!("declare (class hash: {:#x})\n", base.diff.local_class_hash));
ui.print_sub(format!("Class hash: {:#x}", base.diff.local_class_hash));
}

ui.print(" ");

if let Some(world) = &strategy.world {
ui.print_header("# World");
ui.print_sub(format!("declare (class hash: {:#x})\n", world.diff.local_class_hash));
ui.print_sub(format!("Class hash: {:#x}", world.diff.local_class_hash));
}

ui.print(" ");

if !&strategy.models.is_empty() {
ui.print_header(format!("# Models ({})", &strategy.models.len()));
for m in &strategy.models {
ui.print_sub(format!(
"register {} (class hash: {:#x})",
m.diff.name, m.diff.local_class_hash
));
ui.print(m.diff.name.to_string());
ui.print_sub(format!("Class hash: {:#x}", m.diff.local_class_hash));
}
ui.print(" ");
}

ui.print(" ");

if !&strategy.contracts.is_empty() {
ui.print_header(format!("# Contracts ({})", &strategy.contracts.len()));
for c in &strategy.contracts {
let op_name = get_contract_operation_name(provider, c, strategy.world_address).await;
ui.print_sub(format!("{op_name} (class hash: {:#x})", c.diff.local_class_hash));

ui.print(op_name);
ui.print_sub(format!("Class hash: {:#x}", c.diff.local_class_hash));
let salt = generate_salt(&c.diff.name);
let contract_address =
get_contract_address(salt, c.diff.base_class_hash, &[], world_address);
ui.print_sub(format!("Contract address: {:#x}", contract_address));
}
ui.print(" ");
}

ui.print(" ");
}

#[allow(clippy::too_many_arguments)]
Expand Down
2 changes: 1 addition & 1 deletion crates/sozo/ops/src/migration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ where
let world_address = strategy.world_address().expect("world address must exist");

if dry_run {
print_strategy(&ui, account.provider(), &strategy).await;
print_strategy(&ui, account.provider(), &strategy, world_address).await;

update_manifests_and_abis(
ws,
Expand Down
Empty file modified scripts/rebuild_test_artifacts.sh
100644 → 100755
Empty file.
Loading