From 0857bd6cd3bd34cbb06708f0a185757044171d8d Mon Sep 17 00:00:00 2001 From: Jonathan LEI Date: Tue, 9 Jan 2024 14:42:17 -0700 Subject: [PATCH] feat: private field access for `RawXxx` types (#535) 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. --- starknet-accounts/src/account/declaration.rs | 28 ++++++++++++++++++++ starknet-accounts/src/account/execution.rs | 12 +++++++++ starknet-accounts/src/factory/mod.rs | 14 ++++++++++ 3 files changed, 54 insertions(+) diff --git a/starknet-accounts/src/account/declaration.rs b/starknet-accounts/src/account/declaration.rs index 9f39a2ba..ebd19820 100644 --- a/starknet-accounts/src/account/declaration.rs +++ b/starknet-accounts/src/account/declaration.rs @@ -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 { @@ -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> diff --git a/starknet-accounts/src/account/execution.rs b/starknet-accounts/src/account/execution.rs index 8160b84a..6c36700f 100644 --- a/starknet-accounts/src/account/execution.rs +++ b/starknet-accounts/src/account/execution.rs @@ -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> diff --git a/starknet-accounts/src/factory/mod.rs b/starknet-accounts/src/factory/mod.rs index 4c88f5d2..cfe2398f 100644 --- a/starknet-accounts/src/factory/mod.rs +++ b/starknet-accounts/src/factory/mod.rs @@ -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 {