Skip to content

Commit

Permalink
feat: private field access for RawXxx types
Browse files Browse the repository at this point in the history
Certain custom `Account` implementations require access to these
internal fields, as they do more than just signing on the transaction
hash. Exposing these fields offers the maximum flexibility on how
accounts sign transactions.
  • Loading branch information
xJonathanLEI committed Jan 9, 2024
1 parent c974e5c commit 146ed78
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
28 changes: 28 additions & 0 deletions starknet-accounts/src/account/declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,22 @@ impl RawDeclaration {
self.compiled_class_hash,
])
}

pub fn contract_class(&self) -> &FlattenedSierraClass {
&self.contract_class
}

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

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

pub fn max_fee(&self) -> FieldElement {
self.max_fee
}
}

impl RawLegacyDeclaration {
Expand All @@ -469,6 +485,18 @@ impl RawLegacyDeclaration {
self.nonce,
]))
}

pub fn contract_class(&self) -> &LegacyContractClass {
&self.contract_class
}

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

pub fn max_fee(&self) -> FieldElement {
self.max_fee
}
}

impl<'a, A> PreparedDeclaration<'a, A>
Expand Down
12 changes: 12 additions & 0 deletions starknet-accounts/src/account/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ impl RawExecution {
self.nonce,
])
}

pub fn calls(&self) -> &[Call] {
&self.calls
}

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

pub fn max_fee(&self) -> FieldElement {
self.max_fee
}
}

impl<'a, A> PreparedExecution<'a, A>
Expand Down
14 changes: 14 additions & 0 deletions starknet-accounts/src/factory/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,20 @@ where
}
}

impl RawAccountDeployment {
pub fn salt(&self) -> FieldElement {
self.salt
}

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

pub fn max_fee(&self) -> FieldElement {
self.max_fee
}
}

impl<'f, F> PreparedAccountDeployment<'f, F> {
pub fn from_raw(raw_deployment: RawAccountDeployment, factory: &'f F) -> Self {
Self {
Expand Down

0 comments on commit 146ed78

Please sign in to comment.