Skip to content

Commit

Permalink
fix: generate blank transition to others iimpls
Browse files Browse the repository at this point in the history
  • Loading branch information
crisdut committed Oct 26, 2023
1 parent 8c82a0b commit c436445
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions std/src/persistence/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,32 @@ pub trait Inventory: Deref<Target = Self::Stash> {
let schema_ifaces = self.contract_schema(contract_id)?;
let iface = self.iface_by_name(&iface.into())?;
let schema = &schema_ifaces.schema;
let iimpl = schema_ifaces
.iimpls
.get(&iface.iface_id())
.ok_or(DataError::NoIfaceImpl(schema.schema_id(), iface.iface_id()))?;
let builder =
TransitionBuilder::blank_transition(iface.clone(), schema.clone(), iimpl.clone())
.expect("internal inconsistency");

if schema_ifaces.iimpls.is_empty() {
return Err(InventoryError::DataError(DataError::NoIfaceImpl(
schema.schema_id(),
iface.iface_id(),
)));
}

Check warning on line 419 in std/src/persistence/inventory.rs

View check run for this annotation

Codecov / codecov/patch

std/src/persistence/inventory.rs#L413-L419

Added lines #L413 - L419 were not covered by tests

let builder = if let Some(iimpl) = schema_ifaces.iimpls.get(&iface.iface_id()) {
let builder =
TransitionBuilder::blank_transition(iface.clone(), schema.clone(), iimpl.clone())
.expect("internal inconsistency");
builder

Check warning on line 425 in std/src/persistence/inventory.rs

View check run for this annotation

Codecov / codecov/patch

std/src/persistence/inventory.rs#L421-L425

Added lines #L421 - L425 were not covered by tests
} else {
let (default_iface_id, default_iimpl) = schema_ifaces.iimpls.first_key_value().unwrap();
let default_iface = self.iface_by_id(default_iface_id.clone())?;

Check warning on line 428 in std/src/persistence/inventory.rs

View check run for this annotation

Codecov / codecov/patch

std/src/persistence/inventory.rs#L427-L428

Added lines #L427 - L428 were not covered by tests

let builder = TransitionBuilder::blank_transition(
default_iface.clone(),
schema.clone(),
default_iimpl.clone(),
)
.expect("internal inconsistency");
builder

Check warning on line 436 in std/src/persistence/inventory.rs

View check run for this annotation

Codecov / codecov/patch

std/src/persistence/inventory.rs#L430-L436

Added lines #L430 - L436 were not covered by tests
};

Ok(builder)
}

Expand Down

0 comments on commit c436445

Please sign in to comment.