Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use set_block instead of with_block for better usage #33

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
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
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: block_id.clone(), ..self }
pub fn set_block(mut self, block_id: #snrs_types::BlockId) {
self.block_id = block_id;
}
}

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

pub fn with_block(self, block_id: &#snrs_types::BlockId) -> Self {
Self { block_id: block_id.clone(), ..self }
pub fn set_block(mut self, block_id: #snrs_types::BlockId) {
self.block_id = block_id;
}
}
};
Expand Down
9 changes: 2 additions & 7 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::{BlockId, BlockTag, FieldElement},
core::types::FieldElement,
providers::{jsonrpc::HttpTransport, AnyProvider, JsonRpcClient},
signers::{LocalWallet, SigningKey},
};
Expand Down Expand Up @@ -37,8 +37,7 @@ async fn main() {
ExecutionEncoding::New,
));

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

let byte_array =
ByteArray::from_string("super long string that does not fit into a felt252").unwrap();
Expand Down Expand Up @@ -72,8 +71,4 @@ 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);
}
Loading