Skip to content

Commit

Permalink
git_subrepo.sh: Fix parent in .gitrepo file. [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
AztecBot committed Feb 8, 2024
1 parent f1b9151 commit 8440567
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
12 changes: 11 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions aztec_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ repository.workspace = true
[dependencies]
noirc_frontend.workspace = true
iter-extended.workspace = true
convert_case = "0.6.0"
29 changes: 18 additions & 11 deletions aztec_macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::borrow::{Borrow, BorrowMut};
use std::vec;

use convert_case::{Case, Casing};
use iter_extended::vecmap;
use noirc_frontend::macros_api::FieldElement;
use noirc_frontend::macros_api::{
Expand Down Expand Up @@ -1049,7 +1050,10 @@ 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 path_snippet = ty.to_case(Case::Snake); // e.g. private_context_inputs
let type_path = chained_path!("aztec", "context", "inputs", &path_snippet, ty);

let context_type = make_type(UnresolvedTypeData::Named(type_path, vec![]));
let visibility = Visibility::Private;

Expand Down Expand Up @@ -1088,8 +1092,8 @@ fn create_context(ty: &str, params: &[Param]) -> Result<Vec<Statement>, AztecMac
let let_hasher = mutable_assignment(
"hasher", // Assigned to
call(
variable_path(chained_path!("aztec", "abi", "Hasher", "new")), // Path
vec![], // args
variable_path(chained_path!("aztec", "hasher", "Hasher", "new")), // Path
vec![], // args
),
);

Expand Down Expand Up @@ -1148,12 +1152,14 @@ fn create_context(ty: &str, params: &[Param]) -> Result<Vec<Statement>, AztecMac
vec![], // args
);

let path_snippet = ty.to_case(Case::Snake); // e.g. private_context

// let mut context = {ty}::new(inputs, hash);
let let_context = mutable_assignment(
"context", // Assigned to
call(
variable_path(chained_path!("aztec", "context", ty, "new")), // Path
vec![inputs_expression, hash_call], // args
variable_path(chained_path!("aztec", "context", &path_snippet, ty, "new")), // Path
vec![inputs_expression, hash_call], // args
),
);
injected_expressions.push(let_context);
Expand Down Expand Up @@ -1200,7 +1206,7 @@ fn create_avm_context() -> Result<Statement, AztecMacroError> {
/// ```noir
/// /// Before
/// #[aztec(private)]
/// fn foo() -> abi::PrivateCircuitPublicInputs {
/// fn foo() -> protocol_types::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs {
/// // ...
/// let my_return_value: Field = 10;
/// context.return_values.push(my_return_value);
Expand Down Expand Up @@ -1376,8 +1382,8 @@ fn make_castable_return_type(expression: Expression) -> Statement {

/// Create Return Type
///
/// Public functions return abi::PublicCircuitPublicInputs while
/// private functions return abi::PrivateCircuitPublicInputs
/// Public functions return protocol_types::abis::public_circuit_public_inputs::PublicCircuitPublicInputs while
/// private functions return protocol_types::abis::private_circuit_public_inputs::::PrivateCircuitPublicInputs
///
/// This call constructs an ast token referencing the above types
/// The name is set in the function above `transform`, hence the
Expand All @@ -1387,7 +1393,7 @@ fn make_castable_return_type(expression: Expression) -> Statement {
/// ```noir
///
/// /// Before
/// fn foo() -> abi::PrivateCircuitPublicInputs {
/// fn foo() -> protocol_types::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs {
/// // ...
/// }
///
Expand All @@ -1397,7 +1403,8 @@ fn make_castable_return_type(expression: Expression) -> Statement {
/// // ...
/// }
fn create_return_type(ty: &str) -> FunctionReturnType {
let return_path = chained_path!("aztec", "abi", ty);
let path_snippet = ty.to_case(Case::Snake); // e.g. private_circuit_public_inputs or public_circuit_public_inputs
let return_path = chained_path!("aztec", "protocol_types", "abis", &path_snippet, ty);
return_type(return_path)
}

Expand All @@ -1409,7 +1416,7 @@ fn create_return_type(ty: &str) -> FunctionReturnType {
/// The replaced code:
/// ```noir
/// /// Before
/// fn foo() -> abi::PrivateCircuitPublicInputs {
/// fn foo() -> protocol_types::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs {
/// // ...
/// context.finish()
/// }
Expand Down

0 comments on commit 8440567

Please sign in to comment.