diff --git a/starknet-macros/src/abigen/expand/contract.rs b/starknet-macros/src/abigen/expand/contract.rs index b89378d9..7728716d 100644 --- a/starknet-macros/src/abigen/expand/contract.rs +++ b/starknet-macros/src/abigen/expand/contract.rs @@ -19,6 +19,7 @@ impl CairoContract { pub address: starknet::core::types::FieldElement, pub provider: std::sync::Arc
,
pub account: std::option::Option #contract_name
@@ -33,6 +34,7 @@ impl CairoContract {
address,
provider: std::sync::Arc::clone(&provider),
account: None,
+ call_block_id: starknet::core::types::BlockId::Tag(starknet::core::types::BlockTag::Pending),
}
}
@@ -41,6 +43,10 @@ impl CairoContract {
self.account = Some(std::sync::Arc::clone(&account));
self
}
+
+ pub fn set_call_block_id(mut self, block_id: starknet::core::types::BlockId) {
+ self.call_block_id = block_id;
+ }
}
}
}
diff --git a/starknet-macros/src/abigen/expand/function.rs b/starknet-macros/src/abigen/expand/function.rs
index b41da72f..6dc994cc 100644
--- a/starknet-macros/src/abigen/expand/function.rs
+++ b/starknet-macros/src/abigen/expand/function.rs
@@ -96,7 +96,7 @@ impl Expandable for CairoFunction {
entry_point_selector: starknet::macros::selector!(#func_name),
calldata,
},
- BlockId::Tag(BlockTag::Latest),
+ self.call_block_id,
)
.await.map_err(
|err|
@@ -214,7 +214,7 @@ mod tests {
entry_point_selector: starknet::macros::selector!("my_func"),
calldata,
},
- BlockId::Tag(BlockTag::Latest),
+ self.call_block_id,
)
.await.map_err(|err| starknet::contract::abi::cairo_types::Error::Deserialize(format!("Deserialization error {}" , err)))?;