Skip to content

Commit

Permalink
feat(aztec-nr): add enqueue functions to AvmCallInterface (#6264)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanks12 authored May 8, 2024
1 parent 6d3a800 commit 1c74387
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions noir-projects/aztec-nr/aztec/src/context/interface.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use dep::protocol_types::{abis::function_selector::FunctionSelector, address::{AztecAddress, EthAddress}, traits::Deserialize};

use crate::hash::hash_args;
use crate::context::private_context::PrivateContext;
use crate::context::public_context::PublicContext;
use crate::context::avm_context::AvmContext;
Expand Down Expand Up @@ -229,6 +230,21 @@ impl<T> AvmCallInterface<T> {
let returns = context.delegate_call_public_function(self.target_contract, self.selector, self.args);
returns.deserialize_into()
}

pub fn enqueue(self, context: &mut PrivateContext) {
let args_hash = hash_args(self.args);
context.call_public_function_with_packed_args(self.target_contract, self.selector, args_hash, false, false)
}

pub fn static_enqueue(self, context: &mut PrivateContext) {
let args_hash = hash_args(self.args);
context.call_public_function_with_packed_args(self.target_contract, self.selector, args_hash, true, false)
}

pub fn delegate_enqueue(self, context: &mut PrivateContext) {
let args_hash = hash_args(self.args);
context.call_public_function_with_packed_args(self.target_contract, self.selector, args_hash, false, true)
}
}

struct AvmVoidCallInterface {
Expand Down Expand Up @@ -258,4 +274,19 @@ impl AvmVoidCallInterface {
let returns = context.delegate_call_public_function(self.target_contract, self.selector, self.args);
returns.assert_empty()
}

pub fn enqueue(self, context: &mut PrivateContext) {
let args_hash = hash_args(self.args);
context.call_public_function_with_packed_args(self.target_contract, self.selector, args_hash, false, false)
}

pub fn static_enqueue(self, context: &mut PrivateContext) {
let args_hash = hash_args(self.args);
context.call_public_function_with_packed_args(self.target_contract, self.selector, args_hash, true, false)
}

pub fn delegate_enqueue(self, context: &mut PrivateContext) {
let args_hash = hash_args(self.args);
context.call_public_function_with_packed_args(self.target_contract, self.selector, args_hash, false, true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract AvmAcvmInteropTest {
}

#[aztec(public)]
fn new_nullifier_acvm(nullifier: Field) -> pub Field {
fn new_nullifier_acvm(nullifier: Field) {
context.push_new_nullifier(nullifier, 0);
}

Expand Down

0 comments on commit 1c74387

Please sign in to comment.