From a4781f127cf4789041eb183fc8a9254229962501 Mon Sep 17 00:00:00 2001 From: Jonathan LEI Date: Tue, 3 Oct 2023 04:10:23 +0000 Subject: [PATCH] feat: setting block id in account factories --- starknet-accounts/src/factory/argent.rs | 13 ++++++++++++- starknet-accounts/src/factory/open_zeppelin.rs | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/starknet-accounts/src/factory/argent.rs b/starknet-accounts/src/factory/argent.rs index acc73419..44cc142d 100644 --- a/starknet-accounts/src/factory/argent.rs +++ b/starknet-accounts/src/factory/argent.rs @@ -1,7 +1,7 @@ use crate::{AccountFactory, PreparedAccountDeployment, RawAccountDeployment}; use async_trait::async_trait; -use starknet_core::types::FieldElement; +use starknet_core::types::{BlockId, BlockTag, FieldElement}; use starknet_providers::Provider; use starknet_signers::Signer; @@ -12,6 +12,7 @@ pub struct ArgentAccountFactory { guardian_public_key: FieldElement, signer: S, provider: P, + block_id: BlockId, } impl ArgentAccountFactory @@ -33,8 +34,14 @@ where guardian_public_key, signer, provider, + block_id: BlockId::Tag(BlockTag::Latest), }) } + + pub fn set_block_id(&mut self, block_id: BlockId) -> &Self { + self.block_id = block_id; + self + } } #[cfg_attr(not(target_arch = "wasm32"), async_trait)] @@ -63,6 +70,10 @@ where &self.provider } + fn block_id(&self) -> BlockId { + self.block_id + } + async fn sign_deployment( &self, deployment: &RawAccountDeployment, diff --git a/starknet-accounts/src/factory/open_zeppelin.rs b/starknet-accounts/src/factory/open_zeppelin.rs index 7640e67f..bb1b81b8 100644 --- a/starknet-accounts/src/factory/open_zeppelin.rs +++ b/starknet-accounts/src/factory/open_zeppelin.rs @@ -1,7 +1,7 @@ use crate::{AccountFactory, PreparedAccountDeployment, RawAccountDeployment}; use async_trait::async_trait; -use starknet_core::types::FieldElement; +use starknet_core::types::{BlockId, BlockTag, FieldElement}; use starknet_providers::Provider; use starknet_signers::Signer; @@ -11,6 +11,7 @@ pub struct OpenZeppelinAccountFactory { public_key: FieldElement, signer: S, provider: P, + block_id: BlockId, } impl OpenZeppelinAccountFactory @@ -30,8 +31,14 @@ where public_key: public_key.scalar(), signer, provider, + block_id: BlockId::Tag(BlockTag::Latest), }) } + + pub fn set_block_id(&mut self, block_id: BlockId) -> &Self { + self.block_id = block_id; + self + } } #[cfg_attr(not(target_arch = "wasm32"), async_trait)] @@ -60,6 +67,10 @@ where &self.provider } + fn block_id(&self) -> BlockId { + self.block_id + } + async fn sign_deployment( &self, deployment: &RawAccountDeployment,