diff --git a/objects/src/accounts/component/template/mod.rs b/objects/src/accounts/component/template/mod.rs index 0f1c891fc..361bc06e3 100644 --- a/objects/src/accounts/component/template/mod.rs +++ b/objects/src/accounts/component/template/mod.rs @@ -98,7 +98,10 @@ impl Deserializable for AccountComponentTemplate { /// index 0. /// - Storage slots are laid out in a contiguous manner. /// - Storage placeholders can appear multiple times, but only if the expected [StorageValue] is of -/// the same type in all instances. +/// the same type in all instances. The expected placeholders can be retrieved with +/// [AccountComponentMetadata::get_unique_storage_placeholders()], which returns a map from +/// [StoragePlaceholder] to [PlaceholderType] (which, in turn, indicates the expected value type +/// for the placeholder). /// /// # Example /// @@ -193,7 +196,7 @@ impl AccountComponentMetadata { /// Retrieves a map of unique storage placeholders mapped to their expected type that require /// a value at the moment of component instantiation. These values will be used for - /// initializing storage slot values, or storage map entries.For a full example on how a + /// initializing storage slot values, or storage map entries. For a full example on how a /// placeholder may be utilized, please refer to the docs for [AccountComponentMetadata]. /// /// Types for the returned storage placeholders are inferred based on their location in the @@ -240,7 +243,7 @@ impl AccountComponentMetadata { /// # Errors /// /// - If the specified storage slots contain duplicates. - /// - If the template contains multiple storage placeholders with of different type. + /// - If the template contains multiple storage placeholders of different type. /// - If the slot numbers do not start at zero. /// - If the slots are not contiguous. fn validate(&self) -> Result<(), AccountComponentTemplateError> { @@ -299,7 +302,7 @@ impl AccountComponentMetadata { Ok(()) } - /// Validates map keys. + /// Validates map keys by checking for duplicates. /// Because keys can be represented in a variety of ways, the `to_string()` implementation is /// used to check for duplicates. fn validate_map_keys(&self) -> Result<(), AccountComponentTemplateError> { diff --git a/objects/src/accounts/component/template/storage/value_type.rs b/objects/src/accounts/component/template/storage/value_type.rs index 4730f41c7..efa43e596 100644 --- a/objects/src/accounts/component/template/storage/value_type.rs +++ b/objects/src/accounts/component/template/storage/value_type.rs @@ -1,4 +1,4 @@ -use alloc::{boxed::Box, collections::BTreeSet, string::ToString, vec::Vec}; +use alloc::{boxed::Box, collections::BTreeSet, vec::Vec}; use vm_core::{ utils::{ByteReader, ByteWriter, Deserializable, Serializable}, @@ -138,15 +138,15 @@ impl core::fmt::Display for WordRepresentation { WordRepresentation::Value(hex) => f.write_str(&Digest::from(hex).to_hex()), WordRepresentation::Array(array) => { f.write_str("[")?; - f.write_str(&format!("{}, ", array[0]))?; - f.write_str(&format!("{}, ", array[1]))?; - f.write_str(&format!("{}, ", array[2]))?; - f.write_str(&format!("{}, ", array[3]))?; + f.write_fmt(format_args!("{}, ", array[0]))?; + f.write_fmt(format_args!("{}, ", array[1]))?; + f.write_fmt(format_args!("{}, ", array[2]))?; + f.write_fmt(format_args!("{}, ", array[3]))?; f.write_str("]") }, WordRepresentation::Template(storage_placeholder) => { - f.write_str(&storage_placeholder.to_string()) + f.write_fmt(format_args!("{}", storage_placeholder)) }, } } @@ -259,10 +259,14 @@ impl Deserializable for FeltRepresentation { impl core::fmt::Display for FeltRepresentation { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { - FeltRepresentation::Hexadecimal(base_element) => f.write_str(&base_element.to_string()), - FeltRepresentation::Decimal(base_element) => f.write_str(&base_element.to_string()), + FeltRepresentation::Hexadecimal(base_element) => { + f.write_fmt(format_args!("{}", base_element)) + }, + FeltRepresentation::Decimal(base_element) => { + f.write_fmt(format_args!("{}", base_element)) + }, FeltRepresentation::Template(storage_placeholder) => { - f.write_str(&storage_placeholder.to_string()) + f.write_fmt(format_args!("{}", storage_placeholder)) }, } }