Skip to content

Commit 0857bd6

Browse files
authored
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.
1 parent c974e5c commit 0857bd6

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

starknet-accounts/src/account/declaration.rs

+28
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,22 @@ impl RawDeclaration {
445445
self.compiled_class_hash,
446446
])
447447
}
448+
449+
pub fn contract_class(&self) -> &FlattenedSierraClass {
450+
&self.contract_class
451+
}
452+
453+
pub fn compiled_class_hash(&self) -> FieldElement {
454+
self.compiled_class_hash
455+
}
456+
457+
pub fn nonce(&self) -> FieldElement {
458+
self.nonce
459+
}
460+
461+
pub fn max_fee(&self) -> FieldElement {
462+
self.max_fee
463+
}
448464
}
449465

450466
impl RawLegacyDeclaration {
@@ -469,6 +485,18 @@ impl RawLegacyDeclaration {
469485
self.nonce,
470486
]))
471487
}
488+
489+
pub fn contract_class(&self) -> &LegacyContractClass {
490+
&self.contract_class
491+
}
492+
493+
pub fn nonce(&self) -> FieldElement {
494+
self.nonce
495+
}
496+
497+
pub fn max_fee(&self) -> FieldElement {
498+
self.max_fee
499+
}
472500
}
473501

474502
impl<'a, A> PreparedDeclaration<'a, A>

starknet-accounts/src/account/execution.rs

+12
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,18 @@ impl RawExecution {
246246
self.nonce,
247247
])
248248
}
249+
250+
pub fn calls(&self) -> &[Call] {
251+
&self.calls
252+
}
253+
254+
pub fn nonce(&self) -> FieldElement {
255+
self.nonce
256+
}
257+
258+
pub fn max_fee(&self) -> FieldElement {
259+
self.max_fee
260+
}
249261
}
250262

251263
impl<'a, A> PreparedExecution<'a, A>

starknet-accounts/src/factory/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,20 @@ where
325325
}
326326
}
327327

328+
impl RawAccountDeployment {
329+
pub fn salt(&self) -> FieldElement {
330+
self.salt
331+
}
332+
333+
pub fn nonce(&self) -> FieldElement {
334+
self.nonce
335+
}
336+
337+
pub fn max_fee(&self) -> FieldElement {
338+
self.max_fee
339+
}
340+
}
341+
328342
impl<'f, F> PreparedAccountDeployment<'f, F> {
329343
pub fn from_raw(raw_deployment: RawAccountDeployment, factory: &'f F) -> Self {
330344
Self {

0 commit comments

Comments
 (0)