Skip to content

Commit

Permalink
add use_legacy_storage flag in ModelDef
Browse files Browse the repository at this point in the history
  • Loading branch information
remybar committed Mar 3, 2025
1 parent 7026e34 commit a4a6f88
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub mod attacker_model {
schema: DojoStoredModelImpl::schema(self),
packed_size: Self::packed_size(self),
unpacked_size: Self::unpacked_size(self),
use_legacy_storage: Self::use_legacy_storage(self),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ pub mod foo_invalid_name {
schema: StoredModelImpl::schema(self),
packed_size: Self::packed_size(self),
unpacked_size: Self::unpacked_size(self),
use_legacy_storage: Self::use_legacy_storage(self),
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/dojo/core/src/model/definition.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ pub struct ModelDef {
pub schema: Struct,
pub packed_size: Option<usize>,
pub unpacked_size: Option<usize>,
pub use_legacy_storage: bool,
}
1 change: 1 addition & 0 deletions crates/dojo/core/src/model/model.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ pub impl ModelImpl<M, +ModelParser<M>, +ModelDefinition<M>, +Serde<M>, +Drop<M>>
schema: Self::schema(),
packed_size: Self::packed_size(),
unpacked_size: Self::unpacked_size(),
use_legacy_storage: Self::use_legacy_storage(),
}
}

Expand Down
5 changes: 5 additions & 0 deletions crates/dojo/world/src/contracts/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub trait ModelReader<E> {
async fn unpacked_size(&self) -> Result<u32, E>;
async fn layout(&self) -> Result<abigen::model::Layout, E>;
async fn use_legacy_storage(&self) -> Result<bool, E>;
async fn definition(&self) -> Result<abigen::model::ModelDef, E>;
}

#[derive(Debug)]
Expand Down Expand Up @@ -209,6 +210,10 @@ where
async fn use_legacy_storage(&self) -> Result<bool, ModelError> {
Ok(self.model_reader.use_legacy_storage().call().await?)
}

async fn definition(&self) -> Result<abigen::model::ModelDef, ModelError> {
Ok(self.model_reader.definition().call().await?)
}
}

fn parse_schema(ty: &abigen::model::Ty) -> Result<Ty, ParseError> {
Expand Down

0 comments on commit a4a6f88

Please sign in to comment.