Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions crates/cairo-lang-starknet/src/plugin/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ pub fn handle_trait<'db>(
"contract_address",
"syscalls::call_contract_syscall",
serialization_code.clone(),
ret_decode.clone(),
&ret_decode,
true,
));
library_caller_method_impls.push(declaration_method_impl(
Expand All @@ -245,7 +245,7 @@ pub fn handle_trait<'db>(
"class_hash",
"syscalls::library_call_syscall",
serialization_code.clone(),
ret_decode.clone(),
&ret_decode,
true,
));
safe_contract_caller_method_impls.push(declaration_method_impl(
Expand All @@ -254,7 +254,7 @@ pub fn handle_trait<'db>(
"contract_address",
"syscalls::call_contract_syscall",
serialization_code.clone(),
ret_decode.clone(),
&ret_decode,
false,
));
safe_library_caller_method_impls.push(declaration_method_impl(
Expand All @@ -263,7 +263,7 @@ pub fn handle_trait<'db>(
"class_hash",
"syscalls::library_call_syscall",
serialization_code,
ret_decode,
&ret_decode,
false,
));
}
Expand Down Expand Up @@ -404,14 +404,15 @@ fn declaration_method_impl<'db>(
member: &str,
syscall: &str,
serialization_code: Vec<RewriteNode<'db>>,
ret_decode: String,
ret_decode: &str,
unwrap: bool,
) -> RewriteNode<'db> {
let deserialization_code = if ret_decode.is_empty() {
let ret_decode_is_empty = ret_decode.is_empty();
let deserialization_code = if ret_decode_is_empty {
RewriteNode::text("()")
} else {
RewriteNode::Text(if unwrap {
ret_decode.clone()
ret_decode.to_string()
} else {
ret_decode.split('\n').map(|x| format!(" {x}")).join("\n")
})
Expand All @@ -422,7 +423,7 @@ fn declaration_method_impl<'db>(
"let mut {RET_DATA} = starknet::SyscallResultTrait::unwrap_syscall({RET_DATA});
$deserialization_code$"
)
} else if ret_decode.is_empty() {
} else if ret_decode_is_empty {
format!(
"let mut {RET_DATA} = {RET_DATA}?;
Result::Ok($deserialization_code$)"
Expand Down