Skip to content

Commit

Permalink
rebased
Browse files Browse the repository at this point in the history
  • Loading branch information
aniketpr01 committed Jun 17, 2024
1 parent bcc926b commit 59b0115
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 109 deletions.
14 changes: 7 additions & 7 deletions starknet-accounts/src/account/declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ impl<'a, A> DeclarationV2<'a, A> {
}
}

/// Calling this function after manually specifying `nonce` and `max_fee` turns [DeclarationV2]
/// into [PreparedDeclarationV2]. Returns `Err` if either field is `None`.
/// Calling this function after manually specifying `nonce` and `max_fee` turns [`DeclarationV2`]
/// into [`PreparedDeclarationV2`]. Returns `Err` if either field is `None`.
pub fn prepared(self) -> Result<PreparedDeclarationV2<'a, A>, NotPreparedError> {
let nonce = self.nonce.ok_or(NotPreparedError)?;
let max_fee = self.max_fee.ok_or(NotPreparedError)?;
Expand Down Expand Up @@ -309,7 +309,7 @@ impl<'a, A> DeclarationV3<'a, A> {
}

/// Calling this function after manually specifying `nonce`, `gas` and `gas_price` turns
/// [DeclarationV3] into [PreparedDeclarationV3]. Returns `Err` if any field is `None`.
/// [`DeclarationV3`] into [`PreparedDeclarationV3`]. Returns `Err` if any field is `None`.
pub fn prepared(self) -> Result<PreparedDeclarationV3<'a, A>, NotPreparedError> {
let nonce = self.nonce.ok_or(NotPreparedError)?;
let gas = self.gas.ok_or(NotPreparedError)?;
Expand Down Expand Up @@ -825,19 +825,19 @@ impl RawDeclarationV3 {
&self.contract_class
}

pub fn compiled_class_hash(&self) -> Felt {
pub const fn compiled_class_hash(&self) -> Felt {
self.compiled_class_hash
}

pub fn nonce(&self) -> Felt {
pub const fn nonce(&self) -> Felt {
self.nonce
}

pub fn gas(&self) -> u64 {
pub const fn gas(&self) -> u64 {
self.gas
}

pub fn gas_price(&self) -> u128 {
pub const fn gas_price(&self) -> u128 {
self.gas_price
}
}
Expand Down
12 changes: 6 additions & 6 deletions starknet-accounts/src/account/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ impl<'a, A> ExecutionV1<'a, A> {
}
}

/// Calling this function after manually specifying `nonce` and `max_fee` turns [ExecutionV1] into
/// [PreparedExecutionV1]. Returns `Err` if either field is `None`.
/// Calling this function after manually specifying `nonce` and `max_fee` turns [`ExecutionV1`] into
/// [`PreparedExecutionV1`]. Returns `Err` if either field is `None`.
pub fn prepared(self) -> Result<PreparedExecutionV1<'a, A>, NotPreparedError> {
let nonce = self.nonce.ok_or(NotPreparedError)?;
let max_fee = self.max_fee.ok_or(NotPreparedError)?;
Expand Down Expand Up @@ -138,7 +138,7 @@ impl<'a, A> ExecutionV3<'a, A> {
}

/// Calling this function after manually specifying `nonce`, `gas` and `gas_price` turns
/// [ExecutionV3] into [PreparedExecutionV3]. Returns `Err` if any field is `None`.
/// [`ExecutionV3`] into [`PreparedExecutionV3`]. Returns `Err` if any field is `None`.
pub fn prepared(self) -> Result<PreparedExecutionV3<'a, A>, NotPreparedError> {
let nonce = self.nonce.ok_or(NotPreparedError)?;
let gas = self.gas.ok_or(NotPreparedError)?;
Expand Down Expand Up @@ -631,15 +631,15 @@ impl RawExecutionV3 {
&self.calls
}

pub fn nonce(&self) -> Felt {
pub const fn nonce(&self) -> Felt {
self.nonce
}

pub fn gas(&self) -> u64 {
pub const fn gas(&self) -> u64 {
self.gas
}

pub fn gas_price(&self) -> u128 {
pub const fn gas_price(&self) -> u128 {
self.gas_price
}
}
Expand Down
40 changes: 20 additions & 20 deletions starknet-accounts/src/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,32 @@ pub trait Account: ExecutionEncoder + Sized {
query_only: bool,
) -> Result<Vec<Felt>, Self::SignError>;

fn execute_v1(&self, calls: Vec<Call>) -> ExecutionV1<Self> {
fn execute_v1(&self, calls: Vec<Call>) -> ExecutionV1<'_, Self> {
ExecutionV1::new(calls, self)
}

fn execute_v3(&self, calls: Vec<Call>) -> ExecutionV3<Self> {
fn execute_v3(&self, calls: Vec<Call>) -> ExecutionV3<'_, Self> {
ExecutionV3::new(calls, self)
}

#[deprecated = "use version specific variants (`execute_v1` & `execute_v3`) instead"]
fn execute(&self, calls: Vec<Call>) -> ExecutionV1<Self> {
fn execute(&self, calls: Vec<Call>) -> ExecutionV1<'_, Self> {
self.execute_v1(calls)
}

fn declare_v2(
&self,
contract_class: Arc<FlattenedSierraClass>,
compiled_class_hash: Felt,
) -> DeclarationV2<Self> {
) -> DeclarationV2<'_, Self> {
DeclarationV2::new(contract_class, compiled_class_hash, self)
}

fn declare_v3(
&self,
contract_class: Arc<FlattenedSierraClass>,
compiled_class_hash: Felt,
) -> DeclarationV3<Self> {
) -> DeclarationV3<'_, Self> {
DeclarationV3::new(contract_class, compiled_class_hash, self)
}

Expand All @@ -89,11 +89,11 @@ pub trait Account: ExecutionEncoder + Sized {
&self,
contract_class: Arc<FlattenedSierraClass>,
compiled_class_hash: Felt,
) -> DeclarationV2<Self> {
) -> DeclarationV2<'_, Self> {
self.declare_v2(contract_class, compiled_class_hash)
}

fn declare_legacy(&self, contract_class: Arc<LegacyContractClass>) -> LegacyDeclaration<Self> {
fn declare_legacy(&self, contract_class: Arc<LegacyContractClass>) -> LegacyDeclaration<'_, Self> {
LegacyDeclaration::new(contract_class, self)
}
}
Expand Down Expand Up @@ -127,7 +127,7 @@ pub trait ConnectedAccount: Account {

/// Abstraction over `INVOKE` transactions from accounts for invoking contracts. This struct uses
/// v1 `INVOKE` transactions under the hood, and hence pays transaction fees in ETH. To use v3
/// transactions for STRK fee payment, use [ExecutionV3] instead.
/// transactions for STRK fee payment, use [`ExecutionV3`] instead.
///
/// This is an intermediate type allowing users to optionally specify `nonce` and/or `max_fee`.
#[must_use]
Expand All @@ -142,7 +142,7 @@ pub struct ExecutionV1<'a, A> {

/// Abstraction over `INVOKE` transactions from accounts for invoking contracts. This struct uses
/// v3 `INVOKE` transactions under the hood, and hence pays transaction fees in STRK. To use v1
/// transactions for ETH fee payment, use [ExecutionV1] instead.
/// transactions for ETH fee payment, use [`ExecutionV1`] instead.
///
/// This is an intermediate type allowing users to optionally specify `nonce`, `gas`, and/or
/// `gas_price`.
Expand All @@ -160,7 +160,7 @@ pub struct ExecutionV3<'a, A> {

/// Abstraction over `DECLARE` transactions from accounts for invoking contracts. This struct uses
/// v2 `DECLARE` transactions under the hood, and hence pays transaction fees in ETH. To use v3
/// transactions for STRK fee payment, use [DeclarationV3] instead.
/// transactions for STRK fee payment, use [`DeclarationV3`] instead.
///
/// An intermediate type allowing users to optionally specify `nonce` and/or `max_fee`.
#[must_use]
Expand All @@ -176,7 +176,7 @@ pub struct DeclarationV2<'a, A> {

/// Abstraction over `DECLARE` transactions from accounts for invoking contracts. This struct uses
/// v3 `DECLARE` transactions under the hood, and hence pays transaction fees in STRK. To use v2
/// transactions for ETH fee payment, use [DeclarationV2] instead.
/// transactions for ETH fee payment, use [`DeclarationV2`] instead.
///
/// This is an intermediate type allowing users to optionally specify `nonce`, `gas`, and/or
/// `gas_price`.
Expand Down Expand Up @@ -204,15 +204,15 @@ pub struct LegacyDeclaration<'a, A> {
fee_estimate_multiplier: f64,
}

/// [ExecutionV1] but with `nonce` and `max_fee` already determined.
/// [`ExecutionV1`] but with `nonce` and `max_fee` already determined.
#[derive(Debug)]
pub struct RawExecutionV1 {
calls: Vec<Call>,
nonce: Felt,
max_fee: Felt,
}

/// [ExecutionV3] but with `nonce`, `gas` and `gas_price` already determined.
/// [`ExecutionV3`] but with `nonce`, `gas` and `gas_price` already determined.
#[derive(Debug)]
pub struct RawExecutionV3 {
calls: Vec<Call>,
Expand All @@ -221,7 +221,7 @@ pub struct RawExecutionV3 {
gas_price: u128,
}

/// [DeclarationV2] but with `nonce` and `max_fee` already determined.
/// [`DeclarationV2`] but with `nonce` and `max_fee` already determined.
#[derive(Debug)]
pub struct RawDeclarationV2 {
contract_class: Arc<FlattenedSierraClass>,
Expand All @@ -230,7 +230,7 @@ pub struct RawDeclarationV2 {
max_fee: Felt,
}

/// [DeclarationV3] but with `nonce`, `gas` and `gas_price` already determined.
/// [`DeclarationV3`] but with `nonce`, `gas` and `gas_price` already determined.
#[derive(Debug)]
pub struct RawDeclarationV3 {
contract_class: Arc<FlattenedSierraClass>,
Expand All @@ -240,36 +240,36 @@ pub struct RawDeclarationV3 {
gas_price: u128,
}

/// [LegacyDeclaration] but with `nonce` and `max_fee` already determined.
/// [`LegacyDeclaration`] but with `nonce` and `max_fee` already determined.
#[derive(Debug)]
pub struct RawLegacyDeclaration {
contract_class: Arc<LegacyContractClass>,
nonce: Felt,
max_fee: Felt,
}

/// [RawExecutionV1] but with an account associated.
/// [`RawExecutionV1`] but with an account associated.
#[derive(Debug)]
pub struct PreparedExecutionV1<'a, A> {
account: &'a A,
inner: RawExecutionV1,
}

/// [RawExecutionV3] but with an account associated.
/// [`RawExecutionV3`] but with an account associated.
#[derive(Debug)]
pub struct PreparedExecutionV3<'a, A> {
account: &'a A,
inner: RawExecutionV3,
}

/// [RawDeclarationV2] but with an account associated.
/// [`RawDeclarationV2`] but with an account associated.
#[derive(Debug)]
pub struct PreparedDeclarationV2<'a, A> {
account: &'a A,
inner: RawDeclarationV2,
}

/// [RawDeclarationV3] but with an account associated.
/// [`RawDeclarationV3`] but with an account associated.
#[derive(Debug)]
pub struct PreparedDeclarationV3<'a, A> {
account: &'a A,
Expand Down
Loading

0 comments on commit 59b0115

Please sign in to comment.