Skip to content

Commit

Permalink
fix(sozo): handle edge case when base_class_hash is FieldElement::ZERO
Browse files Browse the repository at this point in the history
  • Loading branch information
lambda-0x committed May 17, 2024
1 parent 628542f commit 01bf09d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion crates/dojo-world/src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ impl DeploymentManifest {
self.contracts.iter_mut().for_each(|contract| {
let previous_contract = previous.contracts.iter().find(|c| c.name == contract.name);
if let Some(previous_contract) = previous_contract {
contract.inner.base_class_hash = previous_contract.inner.base_class_hash;
if previous_contract.inner.base_class_hash != FieldElement::ZERO {
contract.inner.base_class_hash = previous_contract.inner.base_class_hash;
}

Check warning on line 183 in crates/dojo-world/src/manifest/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/dojo-world/src/manifest/mod.rs#L181-L183

Added lines #L181 - L183 were not covered by tests
}
});
}
Expand Down
12 changes: 9 additions & 3 deletions crates/sozo/ops/src/migration/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,9 +791,15 @@ pub async fn update_manifests_and_abis(
}

local_manifest.contracts.iter_mut().for_each(|contract| {
let salt = generate_salt(&contract.name);
contract.inner.address =
Some(get_contract_address(salt, contract.inner.base_class_hash, &[], world_address));
if contract.inner.base_class_hash != FieldElement::ZERO {
let salt = generate_salt(&contract.name);
contract.inner.address = Some(get_contract_address(
salt,
contract.inner.base_class_hash,
&[],
world_address,
));

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

View check run for this annotation

Codecov / codecov/patch

crates/sozo/ops/src/migration/migrate.rs#L795-L801

Added lines #L795 - L801 were not covered by tests
}
});

// copy abi files from `abi/base` to `abi/deployments/{chain_id}` and update abi path in
Expand Down
Empty file modified scripts/rebuild_test_artifacts.sh
100644 → 100755
Empty file.

0 comments on commit 01bf09d

Please sign in to comment.