Skip to content

Commit

Permalink
make block_id customizable for functionc all
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm committed Oct 8, 2023
1 parent 85a5034 commit 60b79ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions starknet-macros/src/abigen/expand/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ impl CairoContract {
pub address: starknet::core::types::FieldElement,
pub provider: std::sync::Arc<P>,
pub account: std::option::Option<std::sync::Arc<starknet::accounts::SingleOwnerAccount<std::sync::Arc<P>, starknet::signers::LocalWallet>>>,
call_block_id: starknet::core::types::BlockId,
}

impl<P> #contract_name<P>
Expand All @@ -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),
}
}

Expand All @@ -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;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions starknet-macros/src/abigen/expand/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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)))?;

Expand Down

0 comments on commit 60b79ce

Please sign in to comment.