Skip to content

Commit 9c5fbab

Browse files
committed
fix: generate blank transition to others iimpls
1 parent de8886d commit 9c5fbab

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

src/persistence/hoard.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ use strict_encoding::TypeName;
3535

3636
use crate::accessors::{MergeReveal, MergeRevealError};
3737
use crate::containers::{Cert, Consignment, ContentId, ContentSigs};
38-
use crate::interface::{rgb20, ContractSuppl, Iface, IfaceId, IfacePair, SchemaIfaces};
38+
use crate::interface::{
39+
rgb20, rgb21, rgb25, ContractSuppl, Iface, IfaceId, IfacePair, SchemaIfaces,
40+
};
3941
use crate::persistence::{InventoryError, Stash, StashError, StashInconsistency};
4042
use crate::LIB_NAME_RGB_STD;
4143

@@ -86,10 +88,16 @@ impl Hoard {
8688
pub fn preset() -> Self {
8789
let rgb20 = rgb20();
8890
let rgb20_id = rgb20.iface_id();
91+
let rgb21 = rgb21();
92+
let rgb21_id = rgb21.iface_id();
93+
let rgb25 = rgb25();
94+
let rgb25_id = rgb25.iface_id();
8995
Hoard {
9096
schemata: none!(),
9197
ifaces: tiny_bmap! {
9298
rgb20_id => rgb20,
99+
rgb21_id => rgb21,
100+
rgb25_id => rgb25,
93101
},
94102
geneses: none!(),
95103
suppl: none!(),

src/persistence/inventory.rs

+21-6
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,28 @@ pub trait Inventory: Deref<Target = Self::Stash> {
507507
let schema_ifaces = self.contract_schema(contract_id)?;
508508
let iface = self.iface_by_name(&iface.into())?;
509509
let schema = &schema_ifaces.schema;
510-
let iimpl = schema_ifaces
511-
.iimpls
512-
.get(&iface.iface_id())
513-
.ok_or(DataError::NoIfaceImpl(schema.schema_id(), iface.iface_id()))?;
514-
let builder =
510+
if schema_ifaces.iimpls.is_empty() {
511+
return Err(InventoryError::DataError(DataError::NoIfaceImpl(
512+
schema.schema_id(),
513+
iface.iface_id(),
514+
)));
515+
}
516+
517+
let builder = if let Some(iimpl) = schema_ifaces.iimpls.get(&iface.iface_id()) {
515518
TransitionBuilder::blank_transition(iface.clone(), schema.clone(), iimpl.clone())
516-
.expect("internal inconsistency");
519+
.expect("internal inconsistency")
520+
} else {
521+
let (default_iface_id, default_iimpl) = schema_ifaces.iimpls.first_key_value().unwrap();
522+
let default_iface = self.iface_by_id(*default_iface_id)?;
523+
524+
TransitionBuilder::blank_transition(
525+
default_iface.clone(),
526+
schema.clone(),
527+
default_iimpl.clone(),
528+
)
529+
.expect("internal inconsistency")
530+
};
531+
517532
Ok(builder)
518533
}
519534

0 commit comments

Comments
 (0)