Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Feb 7, 2024
1 parent ad45f85 commit c5b1125
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 78 deletions.
2 changes: 1 addition & 1 deletion noir/aztec_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ fn generate_selector_impl(structure: &NoirStruct) -> TypeImpl {
fn create_inputs(ty: &str) -> Param {
let context_ident = ident("inputs");
let context_pattern = Pattern::Identifier(context_ident);
let type_path = chained_path!("aztec", "abi", ty);
let type_path = chained_path!("aztec", "context", "inputs", "private_context_inputs", ty);
let context_type = make_type(UnresolvedTypeData::Named(type_path, vec![]));
let visibility = Visibility::Private;

Expand Down
70 changes: 0 additions & 70 deletions yarn-project/aztec-nr/aztec/src/abi.nr

This file was deleted.

11 changes: 7 additions & 4 deletions yarn-project/aztec-nr/aztec/src/context.nr
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
mod private;
mod public;
mod globals;
mod inputs;

mod private_context;
mod public_context;
mod avm;

use public::PublicContext;
use private::PrivateContext;
use private_context::PrivateContext;
use public_context::PublicContext;
use avm::AVMContext;

struct Context {
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/aztec-nr/aztec/src/context/globals.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod private_global_variables;
mod public_global_variables;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use dep::protocol_types::traits::Serialize;

// docs:start:private-global-variables
struct PrivateGlobalVariables {
chain_id: Field,
version: Field,
}
// docs:end:private-global-variables

impl Serialize<2> for PrivateGlobalVariables {
fn serialize(self) -> [Field; 2] {
[self.chain_id, self.version]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use dep::protocol_types::{
address::{
AztecAddress,
EthAddress,
},
traits::Serialize,
};

// docs:start:public-global-variables
struct PublicGlobalVariables {
chain_id: Field,
version: Field,
block_number: Field,
timestamp: Field,
coinbase: EthAddress,
fee_recipient: AztecAddress,
}
// docs:end:public-global-variables

impl Serialize<6> for PublicGlobalVariables {
fn serialize(self) -> [Field; 6] {
[
self.chain_id,
self.version,
self.block_number,
self.timestamp,
self.coinbase.to_field(),
self.fee_recipient.to_field(),
]
}
}
2 changes: 2 additions & 0 deletions yarn-project/aztec-nr/aztec/src/context/inputs.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod private_context_inputs;
mod public_context_inputs;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use dep::protocol_types::{
abis::call_context::CallContext,
contrakt::deployment_data::ContractDeploymentData,
header::Header,
};
use crate::context::globals::private_global_variables::PrivateGlobalVariables;

// PrivateContextInputs are expected to be provided to each private function
// docs:start:private-context-inputs
struct PrivateContextInputs {
call_context : CallContext,
historical_header: Header,
contract_deployment_data: ContractDeploymentData,
private_global_variables: PrivateGlobalVariables,
}
// docs:end:private-context-inputs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use crate::context::globals::public_global_variables::PublicGlobalVariables;

use dep::protocol_types::{
abis::call_context::CallContext,
header::Header,
};

// PublicContextInputs are expected to be provided to each public function
// docs:start:public-context-inputs
struct PublicContextInputs {
call_context: CallContext,
historical_header: Header,

public_global_variables: PublicGlobalVariables,
}
// docs:end:public-context-inputs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
abi::PrivateContextInputs,
context::inputs::private_context_inputs::PrivateContextInputs,
key::nullifier_key::validate_nullifier_key_against_address,
messaging::process_l1_to_l2_message,
oracle::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
abi::PublicContextInputs,
context::inputs::public_context_inputs::PublicContextInputs,
messaging::process_l1_to_l2_message,
oracle::{
arguments,
Expand Down
1 change: 0 additions & 1 deletion yarn-project/aztec-nr/aztec/src/lib.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mod abi;
mod avm;
mod context;
mod hash;
Expand Down

0 comments on commit c5b1125

Please sign in to comment.