diff --git a/crates/dojo/bindgen/src/lib.rs b/crates/dojo/bindgen/src/lib.rs index 5fafebf89e..704745c31e 100644 --- a/crates/dojo/bindgen/src/lib.rs +++ b/crates/dojo/bindgen/src/lib.rs @@ -257,9 +257,10 @@ mod tests { None }; + dbg!(&config.manifest_path()); let data = gather_dojo_data(&config.manifest_path().to_path_buf(), "ns", "dev", skip_migrations) - .unwrap(); + .expect("Failed to gather dojo data"); assert_eq!(data.models.len(), 6); diff --git a/crates/dojo/bindgen/src/plugins/typescript/generator/function.rs b/crates/dojo/bindgen/src/plugins/typescript/generator/function.rs index 8161ab6a6b..e678ed5b60 100644 --- a/crates/dojo/bindgen/src/plugins/typescript/generator/function.rs +++ b/crates/dojo/bindgen/src/plugins/typescript/generator/function.rs @@ -13,8 +13,13 @@ impl TsFunctionGenerator { fn check_imports(&self, buffer: &mut Buffer) { if !buffer.has("import { DojoProvider } from ") { buffer.insert(0, "import { DojoProvider } from \"@dojoengine/core\";".to_owned()); - buffer - .insert(1, format!("import {{ Account, {} }} from \"starknet\";", JS_BIGNUMBERISH)); + buffer.insert( + 1, + format!( + "import {{ Account, AccountInterface, {} }} from \"starknet\";", + JS_BIGNUMBERISH + ), + ); buffer.insert(2, "import * as models from \"./models.gen\";\n".to_owned()); } } @@ -79,7 +84,7 @@ impl TsFunctionGenerator { fn format_function_inputs(&self, token: &Function) -> String { let inputs = match token.state_mutability { - StateMutability::External => vec!["snAccount: Account".to_owned()], + StateMutability::External => vec!["snAccount: Account | AccountInterface".to_owned()], StateMutability::View => Vec::new(), }; token @@ -260,8 +265,8 @@ mod tests { fn test_generate_system_function() { let generator = TsFunctionGenerator {}; let function = create_change_theme_function(); - let expected = "\tconst actions_changeTheme = async (snAccount: Account, value: \ - BigNumberish) => { + let expected = "\tconst actions_changeTheme = async (snAccount: Account | \ + AccountInterface, value: BigNumberish) => { \t\ttry { \t\t\treturn await provider.execute( \t\t\t\tsnAccount, @@ -293,7 +298,7 @@ mod tests { fn test_format_function_inputs() { let generator = TsFunctionGenerator {}; let function = create_change_theme_function(); - let expected = "snAccount: Account, value: BigNumberish"; + let expected = "snAccount: Account | AccountInterface, value: BigNumberish"; assert_eq!(expected, generator.format_function_inputs(&function)) } #[test] @@ -308,7 +313,7 @@ mod tests { fn test_format_function_inputs_complex() { let generator = TsFunctionGenerator {}; let function = create_change_theme_function(); - let expected = "snAccount: Account, value: BigNumberish"; + let expected = "snAccount: Account | AccountInterface, value: BigNumberish"; assert_eq!(expected, generator.format_function_inputs(&function)) }