Skip to content

Commit

Permalink
fix: change block id to ref (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm authored May 2, 2024
1 parent 60da94a commit a3ef5bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 4 additions & 4 deletions crates/rs/src/expand/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ impl CairoContract {
self.account.provider()
}

pub fn with_block(self, block_id: #snrs_types::BlockId) -> Self {
Self { block_id, ..self }
pub fn with_block(self, block_id: &#snrs_types::BlockId) -> Self {
Self { block_id: block_id.clone(), ..self }
}
}

Expand All @@ -64,8 +64,8 @@ impl CairoContract {
&self.provider
}

pub fn with_block(self, block_id: #snrs_types::BlockId) -> Self {
Self { block_id, ..self }
pub fn with_block(self, block_id: &#snrs_types::BlockId) -> Self {
Self { block_id: block_id.clone(), ..self }
}
}
};
Expand Down
9 changes: 7 additions & 2 deletions examples/byte_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use cainome::cairo_serde::ByteArray;
use cainome::rs::abigen;
use starknet::{
accounts::{ExecutionEncoding, SingleOwnerAccount},
core::types::FieldElement,
core::types::{BlockId, BlockTag, FieldElement},
providers::{jsonrpc::HttpTransport, AnyProvider, JsonRpcClient},
signers::{LocalWallet, SigningKey},
};
Expand Down Expand Up @@ -37,7 +37,8 @@ async fn main() {
ExecutionEncoding::New,
));

let contract = MyContract::new(contract_address, account);
// Clone Arc only.
let contract = MyContract::new(contract_address, account.clone());

let byte_array =
ByteArray::from_string("super long string that does not fit into a felt252").unwrap();
Expand Down Expand Up @@ -71,4 +72,8 @@ async fn main() {

let string: String = byte_array.to_string().unwrap();
println!("byte_array str: {}", string);

let block_id = BlockId::Tag(BlockTag::Latest);

let _contract = MyContract::new(contract_address, account).with_block(&block_id);
}

0 comments on commit a3ef5bb

Please sign in to comment.