From ec18eea55a5c3c563dc502c051a8df3dfab118a9 Mon Sep 17 00:00:00 2001 From: glihm Date: Thu, 16 May 2024 23:59:19 +0200 Subject: [PATCH] fix: restore with_block to initialize a contract and a reader (#37) --- crates/rs/src/expand/contract.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/rs/src/expand/contract.rs b/crates/rs/src/expand/contract.rs index 8e5e439..63b8984 100644 --- a/crates/rs/src/expand/contract.rs +++ b/crates/rs/src/expand/contract.rs @@ -28,7 +28,7 @@ impl CairoContract { Self { address, account, block_id: #snrs_types::BlockId::Tag(#snrs_types::BlockTag::Pending) } } - pub fn set_contract_address(mut self, address: #snrs_types::FieldElement) { + pub fn set_contract_address(&mut self, address: #snrs_types::FieldElement) { self.address = address; } @@ -39,6 +39,10 @@ impl CairoContract { pub fn set_block(&mut self, block_id: #snrs_types::BlockId) { self.block_id = block_id; } + + pub fn with_block(self, block_id: #snrs_types::BlockId) -> Self { + Self { block_id, ..self } + } } #[derive(Debug)] @@ -56,7 +60,7 @@ impl CairoContract { Self { address, provider, block_id: #snrs_types::BlockId::Tag(#snrs_types::BlockTag::Pending) } } - pub fn set_contract_address(mut self, address: #snrs_types::FieldElement) { + pub fn set_contract_address(&mut self, address: #snrs_types::FieldElement) { self.address = address; } @@ -67,6 +71,10 @@ impl CairoContract { pub fn set_block(&mut self, block_id: #snrs_types::BlockId) { self.block_id = block_id; } + + pub fn with_block(self, block_id: #snrs_types::BlockId) -> Self { + Self { block_id, ..self } + } } };