diff --git a/crates/parser/src/tokens/constants.rs b/crates/parser/src/tokens/constants.rs index c6e67da..0dc05db 100644 --- a/crates/parser/src/tokens/constants.rs +++ b/crates/parser/src/tokens/constants.rs @@ -22,10 +22,11 @@ pub const CAIRO_CORE_BASIC: [&str; 17] = [ // to match array pattern. pub const CAIRO_CORE_SPAN_ARRAY: [&str; 2] = ["core::array::Span", "core::array::Array"]; -pub const CAIRO_GENERIC_BUILTINS: [&str; 3] = [ +pub const CAIRO_GENERIC_BUILTINS: [&str; 4] = [ "core::option::Option", "core::result::Result", "core::zeroable::NonZero", + "core::internal::bounded_int::BoundedInt", ]; pub const CAIRO_COMPOSITE_BUILTINS: [&str; 3] = [ diff --git a/crates/rs/src/expand/types.rs b/crates/rs/src/expand/types.rs index e400df2..3845dcd 100644 --- a/crates/rs/src/expand/types.rs +++ b/crates/rs/src/expand/types.rs @@ -116,13 +116,14 @@ impl CairoToRust for Token { fn basic_types_to_rust(type_name: &str) -> String { let ccsp = utils::cainome_cairo_serde_path(); + let snrs_types = utils::starknet_rs_types_path(); match type_name { "ClassHash" => format!("{ccsp}::ClassHash"), "ContractAddress" => format!("{ccsp}::ContractAddress"), "EthAddress" => format!("{ccsp}::EthAddress"), - "felt252" => "starknet::core::types::Felt".to_string(), - "felt" => "starknet::core::types::Felt".to_string(), + "felt252" => format!("{snrs_types}::Felt"), + "felt" => format!("{snrs_types}::Felt"), "bytes31" => format!("{ccsp}::Bytes31"), "ByteArray" => format!("{ccsp}::ByteArray"), "NonZero" => format!("{ccsp}::NonZero"), @@ -133,12 +134,15 @@ fn basic_types_to_rust(type_name: &str) -> String { fn builtin_composite_to_rust(type_name: &str) -> (String, bool) { let ccsp = utils::cainome_cairo_serde_path(); + let snrs_types = utils::starknet_rs_types_path(); match type_name { "EthAddress" => (format!("{ccsp}::EthAddress"), true), "ByteArray" => (format!("{ccsp}::ByteArray"), true), "NonZero" => (format!("{ccsp}::NonZero"), true), "U256" => (format!("{ccsp}::U256"), true), + // + "BoundedInt" => (format!("{snrs_types}::Felt"), true), _ => (type_name.to_string(), false), } } diff --git a/crates/rs/src/expand/utils.rs b/crates/rs/src/expand/utils.rs index 46d8fbb..68e2824 100644 --- a/crates/rs/src/expand/utils.rs +++ b/crates/rs/src/expand/utils.rs @@ -41,10 +41,14 @@ pub fn cainome_cairo_serde() -> Type { #[inline] pub fn cainome_cairo_serde_path() -> String { - //String::from("cainome_cairo_serde") String::from("cainome::cairo_serde") } +#[inline] +pub fn starknet_rs_types_path() -> String { + String::from("starknet::core::types") +} + /// Expands the implementation line with generic types. pub fn impl_with_gen_args(entity_name: &Ident, gen_args: &Vec) -> TokenStream2 { let gen_args_rust: Vec = gen_args