Skip to content

Commit

Permalink
feat: setting block id in account factories
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Oct 3, 2023
1 parent f162718 commit a4781f1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 12 additions & 1 deletion starknet-accounts/src/factory/argent.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -12,6 +12,7 @@ pub struct ArgentAccountFactory<S, P> {
guardian_public_key: FieldElement,
signer: S,
provider: P,
block_id: BlockId,
}

impl<S, P> ArgentAccountFactory<S, P>
Expand All @@ -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)]
Expand Down Expand Up @@ -63,6 +70,10 @@ where
&self.provider
}

fn block_id(&self) -> BlockId {
self.block_id
}

async fn sign_deployment(
&self,
deployment: &RawAccountDeployment,
Expand Down
13 changes: 12 additions & 1 deletion starknet-accounts/src/factory/open_zeppelin.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -11,6 +11,7 @@ pub struct OpenZeppelinAccountFactory<S, P> {
public_key: FieldElement,
signer: S,
provider: P,
block_id: BlockId,
}

impl<S, P> OpenZeppelinAccountFactory<S, P>
Expand All @@ -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)]
Expand Down Expand Up @@ -60,6 +67,10 @@ where
&self.provider
}

fn block_id(&self) -> BlockId {
self.block_id
}

async fn sign_deployment(
&self,
deployment: &RawAccountDeployment,
Expand Down

0 comments on commit a4781f1

Please sign in to comment.