Skip to content

Commit

Permalink
separating caller context
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Feb 21, 2024
1 parent 3f5cc12 commit d11c4ad
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mod call_request;
mod private_call_stack_item;
mod public_call_stack_item;
mod call_context;
mod caller_context;

mod public_call_data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
public_accumulated_non_revertible_data::PublicAccumulatedNonRevertibleData,
public_accumulated_revertible_data::PublicAccumulatedRevertibleData
},
call_request::CallRequest, new_contract_data::NewContractData,
call_request::CallRequest, caller_context::CallerContext, new_contract_data::NewContractData,
nullifier_key_validation_request::NullifierKeyValidationRequestContext,
public_data_read::PublicDataRead, public_data_update_request::PublicDataUpdateRequest,
side_effect::{SideEffect, SideEffectLinkedToNoteHash}
Expand Down Expand Up @@ -94,7 +94,7 @@ impl CombinedAccumulatedData {
mod tests {
use crate::abis::{
accumulated_data::combined_accumulated_data_builder::CombinedAccumulatedDataBuilder,
call_request::{CallRequest, CallerContext}, new_contract_data::NewContractData,
call_request::CallRequest, caller_context::CallerContext, new_contract_data::NewContractData,
nullifier_key_validation_request::NullifierKeyValidationRequestContext,
public_data_read::PublicDataRead, public_data_update_request::PublicDataUpdateRequest,
side_effect::{SideEffect, SideEffectLinkedToNoteHash}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
use crate::address::AztecAddress;
use dep::std::cmp::Eq;
use crate::traits::Empty;

struct CallerContext {
msg_sender: AztecAddress,
storage_contract_address: AztecAddress,
}

impl Eq for CallerContext {
fn eq(self, caller_context: CallerContext) -> bool {
caller_context.msg_sender.eq(self.msg_sender)
& caller_context.storage_contract_address.eq(self.storage_contract_address)
}
}

impl Empty for CallerContext {
fn empty() -> Self {
CallerContext {
msg_sender: AztecAddress::zero(),
storage_contract_address: AztecAddress::zero(),
}
}
}

impl CallerContext {
pub fn is_empty(self) -> bool {
self.msg_sender.is_zero() & self.storage_contract_address.is_zero()
}
}
use crate::abis::caller_context::CallerContext;

struct CallRequest {
hash: Field,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use crate::address::AztecAddress;
use dep::std::cmp::Eq;
use crate::traits::Empty;

struct CallerContext {
msg_sender: AztecAddress,
storage_contract_address: AztecAddress,
}

impl Eq for CallerContext {
fn eq(self, caller_context: CallerContext) -> bool {
caller_context.msg_sender.eq(self.msg_sender)
& caller_context.storage_contract_address.eq(self.storage_contract_address)
}
}

impl Empty for CallerContext {
fn empty() -> Self {
CallerContext {
msg_sender: AztecAddress::zero(),
storage_contract_address: AztecAddress::zero(),
}
}
}

impl CallerContext {
pub fn is_empty(self) -> bool {
self.msg_sender.is_zero() & self.storage_contract_address.is_zero()
}
}

0 comments on commit d11c4ad

Please sign in to comment.