diff --git a/docs/examples/contracts/aave_bridge/src/main.nr b/docs/examples/contracts/aave_bridge/src/main.nr index 4e9890468d1b..8a882d3cf25e 100644 --- a/docs/examples/contracts/aave_bridge/src/main.nr +++ b/docs/examples/contracts/aave_bridge/src/main.nr @@ -56,7 +56,7 @@ pub contract AaveBridge { ); // Mint tokens (including any yield from Aave) - self.call(Token::at(config.token).mint_to_public(to, amount)); + self.call(&Token::at(config.token).mint_to_public(to, amount)); } // docs:end:claim_public @@ -103,7 +103,7 @@ pub contract AaveBridge { self.context.message_portal(config.portal, content); // Burn tokens - self.call(Token::at(config.token).burn_public(self.msg_sender(), amount, authwit_nonce)); + self.call(&Token::at(config.token).burn_public(self.msg_sender(), amount, authwit_nonce)); } // docs:end:exit_to_l1_public diff --git a/docs/examples/contracts/example_uniswap/src/main.nr b/docs/examples/contracts/example_uniswap/src/main.nr index 90f1115c8ec0..6ed214e674c1 100644 --- a/docs/examples/contracts/example_uniswap/src/main.nr +++ b/docs/examples/contracts/example_uniswap/src/main.nr @@ -58,7 +58,7 @@ pub contract ExampleUniswap { } let input_asset_bridge_config = - self.view(TokenBridge::at(input_asset_bridge).get_config_public()); + self.view(&TokenBridge::at(input_asset_bridge).get_config_public()); let input_asset = input_asset_bridge_config.token; let input_asset_bridge_portal_address = input_asset_bridge_config.portal; @@ -78,7 +78,7 @@ pub contract ExampleUniswap { ); set_authorized(self.context, transfer_msg_hash, true); - self.call(Token::at(input_asset).transfer_in_public( + self.call(&Token::at(input_asset).transfer_in_public( sender, self.address, input_amount, @@ -95,7 +95,7 @@ pub contract ExampleUniswap { // Create swap message and send to Outbox for Uniswap Portal let output_asset_bridge_portal_address = - self.view(TokenBridge::at(output_asset_bridge).get_config_public()).portal; + self.view(&TokenBridge::at(output_asset_bridge).get_config_public()).portal; // Ensure portals exist - else funds might be lost assert( @@ -210,7 +210,7 @@ pub contract ExampleUniswap { let this_portal_address = self.storage.portal_address.read(); // Exit to L1 Uniswap Portal - self.call(TokenBridge::at(token_bridge).exit_to_l1_public( + self.call(&TokenBridge::at(token_bridge).exit_to_l1_public( this_portal_address, amount, this_portal_address, diff --git a/noir-projects/aztec-nr/aztec/src/context/calls.nr b/noir-projects/aztec-nr/aztec/src/context/calls.nr index 182d25f021f7..ec073ce76db5 100644 --- a/noir-projects/aztec-nr/aztec/src/context/calls.nr +++ b/noir-projects/aztec-nr/aztec/src/context/calls.nr @@ -106,7 +106,7 @@ impl PublicCall { /// /// Please use the new contract API: `self.call(MyContract::at(address).my_public_function(...args))` instead of /// manually constructing and calling `PublicCall`. - pub unconstrained fn call(self, context: PublicContext) -> T + pub unconstrained fn call(&self, context: &PublicContext) -> T where T: Deserialize, { @@ -120,7 +120,7 @@ impl PublicCall { /// /// Please use the new contract API: `self.enqueue(MyContract::at(address).my_public_function(...args))` instead of /// manually constructing and calling `PublicCall`. - pub fn enqueue(self, context: &mut PrivateContext) { + pub fn enqueue(&self, context: &mut PrivateContext) { self.enqueue_impl(context, false, false) } @@ -128,11 +128,11 @@ impl PublicCall { /// /// Please use the new contract API: `self.enqueue_incognito(MyContract::at(address).my_public_function(...args))` /// instead of manually constructing and calling `PublicCall`. - pub fn enqueue_incognito(self, context: &mut PrivateContext) { + pub fn enqueue_incognito(&self, context: &mut PrivateContext) { self.enqueue_impl(context, false, true) } - fn enqueue_impl(self, context: &mut PrivateContext, is_static_call: bool, hide_msg_sender: bool) { + fn enqueue_impl(&self, context: &mut PrivateContext, is_static_call: bool, hide_msg_sender: bool) { let calldata = [self.selector.to_field()].concat(self.args); let calldata_hash = hash_calldata_array(calldata); execution_cache::store(calldata, calldata_hash); @@ -148,7 +148,7 @@ impl PublicCall { /// /// Please use the new contract API: `self.set_as_teardown(MyContract::at(address).my_public_function(...args))` /// instead of manually constructing and setting the teardown function `PublicCall`. - pub fn set_as_teardown(self, context: &mut PrivateContext) { + pub fn set_as_teardown(&self, context: &mut PrivateContext) { self.set_as_teardown_impl(context, false); } @@ -157,11 +157,11 @@ impl PublicCall { /// Please use the new contract API: /// `self.set_as_teardown_incognito(MyContract::at(address).my_public_function(...args))` instead of manually /// constructing and setting the teardown function `PublicCall`. - pub fn set_as_teardown_incognito(self, context: &mut PrivateContext) { + pub fn set_as_teardown_incognito(&self, context: &mut PrivateContext) { self.set_as_teardown_impl(context, true); } - fn set_as_teardown_impl(self, context: &mut PrivateContext, hide_msg_sender: bool) { + fn set_as_teardown_impl(&self, context: &mut PrivateContext, hide_msg_sender: bool) { let calldata = [self.selector.to_field()].concat(self.args); let calldata_hash = hash_calldata_array(calldata); execution_cache::store(calldata, calldata_hash); @@ -200,7 +200,7 @@ impl PublicStaticCall { /// /// Please use the new contract API: `self.view(MyContract::at(address).my_public_static_function(...args))` /// instead of manually constructing and calling `PublicStaticCall`. - pub unconstrained fn view(self, context: PublicContext) -> T + pub unconstrained fn view(&self, context: &PublicContext) -> T where T: Deserialize, { @@ -214,7 +214,7 @@ impl PublicStaticCall { /// Please use the new contract API: /// `self.enqueue_view(MyContract::at(address).my_public_static_function(...args))` instead of manually /// constructing and calling `PublicStaticCall`. - pub fn enqueue_view(self, context: &mut PrivateContext) { + pub fn enqueue_view(&self, context: &mut PrivateContext) { let calldata = [self.selector.to_field()].concat(self.args); let calldata_hash = hash_calldata_array(calldata); execution_cache::store(calldata, calldata_hash); @@ -233,7 +233,7 @@ impl PublicStaticCall { /// Please use the new contract API: /// `self.enqueue_view_incognito(MyContract::at(address).my_public_static_function(...args))` instead of manually /// constructing and calling `PublicStaticCall`. - pub fn enqueue_view_incognito(self, context: &mut PrivateContext) { + pub fn enqueue_view_incognito(&self, context: &mut PrivateContext) { let calldata = [self.selector.to_field()].concat(self.args); let calldata_hash = hash_calldata_array(calldata); execution_cache::store(calldata, calldata_hash); diff --git a/noir-projects/aztec-nr/aztec/src/context/public_context.nr b/noir-projects/aztec-nr/aztec/src/context/public_context.nr index 8a70842b0bb1..b37a2b8c8d4b 100644 --- a/noir-projects/aztec-nr/aztec/src/context/public_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/public_context.nr @@ -107,7 +107,7 @@ impl PublicContext { /// collisions between logs from different sources. Without domain separation, two unrelated log types that /// happen to share a raw tag value become indistinguishable. Prefer `self.emit(event)` for events, which /// handles tagging automatically. - pub fn emit_public_log_unsafe(_self: Self, tag: Field, log: T) + pub fn emit_public_log_unsafe(_self: &Self, tag: Field, log: T) where T: Serialize, { @@ -129,7 +129,7 @@ impl PublicContext { /// # Returns /// * `bool` - True if the note hash exists at the specified index /// - pub fn note_hash_exists(_self: Self, note_hash: Field, leaf_index: u64) -> bool { + pub fn note_hash_exists(_self: &Self, note_hash: Field, leaf_index: u64) -> bool { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::note_hash_exists(note_hash, leaf_index) } == 1 } @@ -151,7 +151,7 @@ impl PublicContext { /// * Uses the AVM l1_to_l2_msg_exists opcode for tree lookup /// * Messages are copied from L1 Inbox to L2 by block proposers /// - pub fn l1_to_l2_msg_exists(_self: Self, msg_hash: Field, msg_leaf_index: Field) -> bool { + pub fn l1_to_l2_msg_exists(_self: &Self, msg_hash: Field, msg_leaf_index: Field) -> bool { // Safety: AVM opcodes are constrained by the AVM itself TODO(alvaro): Make l1l2msg leaf index a u64 upstream unsafe { avm::l1_to_l2_msg_exists(msg_hash, msg_leaf_index as u64) } == 1 } @@ -201,7 +201,7 @@ impl PublicContext { /// /// This emits the `CHECKNULLIFIEREXISTS` opcode, which conceptually performs a merkle inclusion proof on the /// nullifier tree (both when the nullifier exists and when it doesn't). - pub fn nullifier_exists_unsafe(_self: Self, unsiloed_nullifier: Field, contract_address: AztecAddress) -> bool { + pub fn nullifier_exists_unsafe(_self: &Self, unsiloed_nullifier: Field, contract_address: AztecAddress) -> bool { let siloed_nullifier = compute_siloed_nullifier(contract_address, unsiloed_nullifier); // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::nullifier_exists(siloed_nullifier) } == 1 @@ -230,7 +230,7 @@ impl PublicContext { /// * Message hash is computed from all parameters + chain context /// * Will revert if message doesn't exist or was already consumed /// - pub fn consume_l1_to_l2_message(self: Self, content: Field, secret: Field, sender: EthAddress, leaf_index: Field) { + pub fn consume_l1_to_l2_message(self: &Self, content: Field, secret: Field, sender: EthAddress, leaf_index: Field) { let secret_hash = compute_secret_hash(secret); let message_hash = compute_l1_to_l2_message_hash( sender, @@ -268,7 +268,7 @@ impl PublicContext { /// * `recipient` - Ethereum address that will receive the message /// * `content` - Message content (32 bytes as a Field element) /// - pub fn message_portal(_self: Self, recipient: EthAddress, content: Field) { + pub fn message_portal(_self: &Self, recipient: EthAddress, content: Field) { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::send_l2_to_l1_msg(recipient, content) }; } @@ -287,7 +287,7 @@ impl PublicContext { /// * `[Field]` - Return data from the called function /// pub unconstrained fn call_public_function( - _self: Self, + _self: &Self, contract_address: AztecAddress, function_selector: FunctionSelector, args: [Field; N], @@ -331,7 +331,7 @@ impl PublicContext { /// * `[Field]` - Return data from the called function /// pub unconstrained fn static_call_public_function( - _self: Self, + _self: &Self, contract_address: AztecAddress, function_selector: FunctionSelector, args: [Field; N], @@ -375,7 +375,7 @@ impl PublicContext { /// # Advanced /// * The note hash will be siloed with the contract address by the protocol /// - pub fn push_note_hash(_self: Self, note_hash: Field) { + pub fn push_note_hash(_self: &Self, note_hash: Field) { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::emit_note_hash(note_hash) }; } @@ -400,7 +400,7 @@ impl PublicContext { /// The raw `nullifier` is not what is inserted into the Aztec state tree: it will be first siloed by contract /// address via [`crate::protocol::hash::compute_siloed_nullifier`] in order to prevent accidental or malicious /// interference of nullifiers from different contracts. - pub fn push_nullifier(_self: Self, nullifier: Field) { + pub fn push_nullifier(_self: &Self, nullifier: Field) { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::emit_nullifier(nullifier) }; } @@ -413,7 +413,7 @@ impl PublicContext { /// # Returns /// * `AztecAddress` - The contract address of the current function being executed. /// - pub fn this_address(_self: Self) -> AztecAddress { + pub fn this_address(_self: &Self) -> AztecAddress { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::address() @@ -437,7 +437,7 @@ impl PublicContext { /// * Value is provided by the AVM sender opcode /// * In nested calls, this is the immediate caller, not the original transaction sender /// - pub fn maybe_msg_sender(_self: Self) -> Option { + pub fn maybe_msg_sender(_self: &Self) -> Option { // Safety: AVM opcodes are constrained by the AVM itself let maybe_msg_sender = unsafe { avm::sender() }; if maybe_msg_sender == NULL_MSG_SENDER_CONTRACT_ADDRESS { @@ -458,7 +458,7 @@ impl PublicContext { /// * Extracted from the first element of calldata /// * Used internally for function dispatch in the AVM /// - pub fn selector(_self: Self) -> FunctionSelector { + pub fn selector(_self: &Self) -> FunctionSelector { // The selector is the first element of the calldata when calling a public function through dispatch. // Safety: AVM opcodes are constrained by the AVM itself. let raw_selector: [Field; 1] = unsafe { avm::calldata_copy(0, 1) }; @@ -497,7 +497,7 @@ impl PublicContext { /// fee value. The teardown phase does not consume a variable amount of gas: it always consumes a pre-allocated /// amount of gas, as specified by the user when they generate their tx. /// - pub fn transaction_fee(_self: Self) -> Field { + pub fn transaction_fee(_self: &Self) -> Field { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::transaction_fee() @@ -514,7 +514,7 @@ impl PublicContext { /// # Returns /// * `Field` - The chain ID as a field element /// - pub fn chain_id(_self: Self) -> Field { + pub fn chain_id(_self: &Self) -> Field { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::chain_id() @@ -533,7 +533,7 @@ impl PublicContext { /// # Returns /// * `Field` - The protocol version as a field element /// - pub fn version(_self: Self) -> Field { + pub fn version(_self: &Self) -> Field { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::version() @@ -554,7 +554,7 @@ impl PublicContext { /// # Returns /// * `u32` - The current block number /// - pub fn block_number(_self: Self) -> u32 { + pub fn block_number(_self: &Self) -> u32 { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::block_number() @@ -577,7 +577,7 @@ impl PublicContext { /// # Returns /// * `u64` - Unix timestamp in seconds /// - pub fn timestamp(_self: Self) -> u64 { + pub fn timestamp(_self: &Self) -> u64 { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::timestamp() @@ -601,7 +601,7 @@ impl PublicContext { /// - the exact user (if the gas price is explicitly chosen by the user to be some unique number like 0.123456789, /// or their favorite number). Wallet devs might wish to consider fuzzing the choice of gas price. /// - pub fn min_fee_per_l2_gas(_self: Self) -> u128 { + pub fn min_fee_per_l2_gas(_self: &Self) -> u128 { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::min_fee_per_l2_gas() @@ -617,7 +617,7 @@ impl PublicContext { /// # Returns /// * `u128` - Fee per unit of DA gas /// - pub fn min_fee_per_da_gas(_self: Self) -> u128 { + pub fn min_fee_per_da_gas(_self: &Self) -> u128 { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::min_fee_per_da_gas() @@ -631,7 +631,7 @@ impl PublicContext { /// # Returns /// * `u32` - Remaining L2 gas units /// - pub fn l2_gas_left(_self: Self) -> u32 { + pub fn l2_gas_left(_self: &Self) -> u32 { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::l2_gas_left() @@ -647,7 +647,7 @@ impl PublicContext { /// # Returns /// * `u32` - Remaining DA gas units /// - pub fn da_gas_left(_self: Self) -> u32 { + pub fn da_gas_left(_self: &Self) -> u32 { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::da_gas_left() @@ -660,7 +660,7 @@ impl PublicContext { /// # Returns /// * `bool` - True if in staticcall context, false otherwise /// - pub fn is_static_call(_self: Self) -> bool { + pub fn is_static_call(_self: &Self) -> bool { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::is_static_call() } == 1 } @@ -679,7 +679,7 @@ impl PublicContext { /// # Generic Parameters /// * `N` - the number of consecutive slots to return, starting from the `storage_slot`. /// - pub fn raw_storage_read(self: Self, storage_slot: Field) -> [Field; N] { + pub fn raw_storage_read(self: &Self, storage_slot: Field) -> [Field; N] { let mut out = [0; N]; for i in 0..N { // Safety: AVM opcodes are constrained by the AVM itself @@ -702,7 +702,7 @@ impl PublicContext { /// # Generic Parameters /// * `T` - The type that the caller expects to read from the `storage_slot`. /// - pub fn storage_read(self, storage_slot: Field) -> T + pub fn storage_read(&self, storage_slot: Field) -> T where T: Packable, { @@ -720,7 +720,7 @@ impl PublicContext { /// * `storage_slot` - The starting storage slot to write to /// * `values` - Array of N Fields to write to storage /// - pub fn raw_storage_write(_self: Self, storage_slot: Field, values: [Field; N]) { + pub fn raw_storage_write(_self: &Self, storage_slot: Field, values: [Field; N]) { for i in 0..N { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::storage_write(storage_slot + i as Field, values[i]) }; @@ -739,7 +739,7 @@ impl PublicContext { /// # Generic Parameters /// * `T` - The type to write to storage. /// - pub fn storage_write(self, storage_slot: Field, value: T) + pub fn storage_write(&self, storage_slot: Field, value: T) where T: Packable, { diff --git a/noir-projects/aztec-nr/aztec/src/context/utility_context.nr b/noir-projects/aztec-nr/aztec/src/context/utility_context.nr index ce4891633a39..d885cef094e9 100644 --- a/noir-projects/aztec-nr/aztec/src/context/utility_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/utility_context.nr @@ -20,35 +20,35 @@ impl UtilityContext { Self { block_header: default_context.block_header, contract_address } } - pub fn block_header(self) -> BlockHeader { + pub fn block_header(&self) -> BlockHeader { self.block_header } - pub fn block_number(self) -> u32 { + pub fn block_number(&self) -> u32 { self.block_header.block_number() } - pub fn timestamp(self) -> u64 { + pub fn timestamp(&self) -> u64 { self.block_header.timestamp() } - pub fn this_address(self) -> AztecAddress { + pub fn this_address(&self) -> AztecAddress { self.contract_address } - pub fn version(self) -> Field { + pub fn version(&self) -> Field { self.block_header.version() } - pub fn chain_id(self) -> Field { + pub fn chain_id(&self) -> Field { self.block_header.chain_id() } - pub unconstrained fn raw_storage_read(self: Self, storage_slot: Field) -> [Field; N] { + pub unconstrained fn raw_storage_read(self: &Self, storage_slot: Field) -> [Field; N] { storage_read(self.block_header, self.this_address(), storage_slot) } - pub unconstrained fn storage_read(self, storage_slot: Field) -> T + pub unconstrained fn storage_read(&self, storage_slot: Field) -> T where T: Packable, { diff --git a/noir-projects/aztec-nr/aztec/src/contract_self/contract_self_public.nr b/noir-projects/aztec-nr/aztec/src/contract_self/contract_self_public.nr index ab5026bffaa9..d7c4fb9ff6cf 100644 --- a/noir-projects/aztec-nr/aztec/src/contract_self/contract_self_public.nr +++ b/noir-projects/aztec-nr/aztec/src/contract_self/contract_self_public.nr @@ -137,14 +137,14 @@ impl ContractSelfPublic(self, call: PublicCall) -> T + pub unconstrained fn call(self, call: &PublicCall) -> T where T: Deserialize, { - call.call(self.context) + call.call(&self.context) } /// Makes a public read-only contract call. @@ -162,13 +162,13 @@ impl ContractSelfPublic(self, call: PublicStaticCall) -> T + pub unconstrained fn view(self, call: &PublicStaticCall) -> T where T: Deserialize, { - call.view(self.context) + call.view(&self.context) } } diff --git a/noir-projects/aztec-nr/aztec/src/macros/calls_generation/external_functions_stubs.nr b/noir-projects/aztec-nr/aztec/src/macros/calls_generation/external_functions_stubs.nr index 513ea3593ba8..7651aafe731b 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/calls_generation/external_functions_stubs.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/calls_generation/external_functions_stubs.nr @@ -188,7 +188,7 @@ pub comptime fn create_public_self_call_stub(f: FunctionDefinition) -> Quoted { selector, $fn_name_str, $serialized_args_array_name, - ).call(self.context) + ).call(&self.context) } } } @@ -213,7 +213,7 @@ pub comptime fn create_public_self_call_static_stub(f: FunctionDefinition) -> Qu selector, $fn_name_str, $serialized_args_array_name, - ).view(self.context) + ).view(&self.context) } } } diff --git a/noir-projects/noir-contracts/contracts/app/amm_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app/amm_contract/src/main.nr index 91a35dd56e87..563b467fd7e2 100644 --- a/noir-projects/noir-contracts/contracts/app/amm_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app/amm_contract/src/main.nr @@ -160,10 +160,10 @@ pub contract AMM { // We read the current AMM balance of both tokens. Note that by the time this function is called the token // transfers have already been completed (since those calls were enqueued before this call), and so we need to // subtract the transfer amount to get the pre-deposit balance. - let balance0_plus_amount0_max = self.view(token0.balance_of_public(self.address)); + let balance0_plus_amount0_max = self.view(&token0.balance_of_public(self.address)); let balance0 = balance0_plus_amount0_max - amount0_max; - let balance1_plus_amount1_max = self.view(token1.balance_of_public(self.address)); + let balance1_plus_amount1_max = self.view(&token1.balance_of_public(self.address)); let balance1 = balance1_plus_amount1_max - amount1_max; // With the current balances known, we can calculate the token amounts to the pool, respecting the user's @@ -184,13 +184,13 @@ pub contract AMM { // We can simply skip the refund if the amount to return is 0 in order to save gas: the partial note will // simply stay in public storage and not be completed, but this is not an issue. if (refund_amount_token0 > 0 as u128) { - self.call(token0.finalize_transfer_to_private( + self.call(&token0.finalize_transfer_to_private( refund_amount_token0, refund_token0_partial_note, )); } if (refund_amount_token1 > 0 as u128) { - self.call(token1.finalize_transfer_to_private( + self.call(&token1.finalize_transfer_to_private( refund_amount_token1, refund_token1_partial_note, )); @@ -198,7 +198,7 @@ pub contract AMM { // With the deposit amounts known, we can compute the number of liquidity tokens to mint and finalize the // depositor's partial note. - let total_supply = self.view(liquidity_token.total_supply()); + let total_supply = self.view(&liquidity_token.total_supply()); let liquidity_amount = if total_supply != 0 as u128 { // The liquidity token supply increases by the same ratio as the balances. In case one of the token balances // increased with a ratio different from the other one, we simply take the smallest value. @@ -216,7 +216,7 @@ pub contract AMM { // As part of initialization, we mint some tokens to the zero address to 'lock' them (i.e. make them // impossible to redeem), guaranteeing total supply will never be zero again. liquidity_token.mint_to_public(AztecAddress::zero(), MINIMUM_LIQUIDITY).call( - self.context, + &self.context, ); INITIAL_LIQUIDITY @@ -224,7 +224,7 @@ pub contract AMM { assert(liquidity_amount > 0 as u128, "INSUFFICIENT_LIQUIDITY_MINTED"); liquidity_token.finalize_mint_to_private(liquidity_amount, liquidity_partial_note).call( - self.context, + &self.context, ); } @@ -290,9 +290,9 @@ pub contract AMM { // We need the current balance of both tokens as well as the liquidity token total supply in order to compute // the amounts to send the user. - let balance0 = self.view(token0.balance_of_public(self.address)); - let balance1 = self.view(token1.balance_of_public(self.address)); - let total_supply = self.view(liquidity_token.total_supply()); + let balance0 = self.view(&token0.balance_of_public(self.address)); + let balance1 = self.view(&token1.balance_of_public(self.address)); + let total_supply = self.view(&liquidity_token.total_supply()); // We calculate the amounts of token0 and token1 the user is entitled to based on the amount of liquidity they // are removing, and check that they are above the minimum amounts they requested. @@ -302,9 +302,9 @@ pub contract AMM { // We can now burn the liquidity tokens that had been privately transferred into the AMM, as well as complete // both partial notes. - self.call(liquidity_token.burn_public(self.address, liquidity, 0)); - self.call(token0.finalize_transfer_to_private(amount0, token0_partial_note)); - self.call(token1.finalize_transfer_to_private(amount1, token1_partial_note)); + self.call(&liquidity_token.burn_public(self.address, liquidity, 0)); + self.call(&token0.finalize_transfer_to_private(amount0, token0_partial_note)); + self.call(&token1.finalize_transfer_to_private(amount1, token1_partial_note)); } /// Privately swaps `amount_in` `token_in` tokens for at least `amount_out_mint` `token_out` tokens with the pool. @@ -362,17 +362,17 @@ pub contract AMM { // transfer has already been completed as that function call was enqueued before this one. We therefore need to // subtract the amount in to get the pre-swap balances. let balance_in_plus_amount_in = - self.view(Token::at(token_in).balance_of_public(self.address)); + self.view(&Token::at(token_in).balance_of_public(self.address)); let balance_in = balance_in_plus_amount_in - amount_in; - let balance_out = self.view(Token::at(token_out).balance_of_public(self.address)); + let balance_out = self.view(&Token::at(token_out).balance_of_public(self.address)); // We can now compute the number of tokens to transfer and complete the partial note. let amount_out = get_amount_out(amount_in, balance_in, balance_out); assert(amount_out >= amount_out_min, "INSUFFICIENT_OUTPUT_AMOUNT"); Token::at(token_out).finalize_transfer_to_private(amount_out, token_out_partial_note).call( - self.context, + &self.context, ); } @@ -439,10 +439,10 @@ pub contract AMM { // transfer has already been completed as that function call was enqueued before this one. We therefore need to // subtract the amount in to get the pre-swap balances. let balance_in_plus_amount_in_max = - self.view(Token::at(token_in).balance_of_public(self.address)); + self.view(&Token::at(token_in).balance_of_public(self.address)); let balance_in = balance_in_plus_amount_in_max - amount_in_max; - let balance_out = self.view(Token::at(token_out).balance_of_public(self.address)); + let balance_out = self.view(&Token::at(token_out).balance_of_public(self.address)); // We can now compute the number of tokens we need to receive and complete the partial note with the change. let amount_in = get_amount_in(amount_out, balance_in, balance_out); @@ -450,7 +450,7 @@ pub contract AMM { let change = amount_in_max - amount_in; if (change > 0 as u128) { - self.call(Token::at(token_in).finalize_transfer_to_private( + self.call(&Token::at(token_in).finalize_transfer_to_private( change, change_token_in_partial_note, )); @@ -459,7 +459,7 @@ pub contract AMM { // Note again that we already knew the amount out, but for consistency we want to only commit this note once // all other steps have been performed. Token::at(token_out).finalize_transfer_to_private(amount_out, token_out_partial_note).call( - self.context, + &self.context, ); } diff --git a/noir-projects/noir-contracts/contracts/app/lending_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app/lending_contract/src/main.nr index 242dadbbc1d3..7234d2d87723 100644 --- a/noir-projects/noir-contracts/contracts/app/lending_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app/lending_contract/src/main.nr @@ -134,7 +134,7 @@ pub contract Lending { on_behalf_of: Field, collateral_asset: AztecAddress, ) { - let _ = self.call(Token::at(collateral_asset).transfer_in_public( + let _ = self.call(&Token::at(collateral_asset).transfer_in_public( self.msg_sender(), self.address, amount, @@ -175,7 +175,7 @@ pub contract Lending { #[only_self] fn _withdraw(owner: AztecAddress, recipient: AztecAddress, amount: u128) { let asset = self.call_self.update_accumulator(); - let price = self.view(PriceFeed::at(asset.oracle).get_price(0)).price; + let price = self.view(&PriceFeed::at(asset.oracle).get_price(0)).price; let coll_loc = self.storage.collateral.at(owner); let collateral = coll_loc.read(); @@ -200,7 +200,7 @@ pub contract Lending { // @todo @LHerskind Support both shielding and transfers (for now just transfer) let collateral_asset = self.storage.collateral_asset.read(); - let _ = self.call(Token::at(collateral_asset).transfer_in_public( + let _ = self.call(&Token::at(collateral_asset).transfer_in_public( self.address, recipient, amount, @@ -223,7 +223,7 @@ pub contract Lending { #[only_self] fn _borrow(owner: AztecAddress, to: AztecAddress, amount: u128) { let asset = self.call_self.update_accumulator(); - let price = self.view(PriceFeed::at(asset.oracle).get_price(0)).price; + let price = self.view(&PriceFeed::at(asset.oracle).get_price(0)).price; // Fetch collateral and static_debt, compute health of current position let collateral = self.storage.collateral.at(owner).read(); @@ -239,7 +239,7 @@ pub contract Lending { // @todo @LHerskind Need to support both private and public minting. let stable_coin = self.storage.stable_coin.read(); - let _ = self.call(Token::at(stable_coin).mint_to_public(to, amount)); + let _ = self.call(&Token::at(stable_coin).mint_to_public(to, amount)); } #[external("private")] @@ -266,7 +266,7 @@ pub contract Lending { stable_coin: AztecAddress, ) { let _ = - self.call(Token::at(stable_coin).burn_public(self.msg_sender(), amount, authwit_nonce)); + self.call(&Token::at(stable_coin).burn_public(self.msg_sender(), amount, authwit_nonce)); let _ = self.call_self._repay(owner, amount, stable_coin); } diff --git a/noir-projects/noir-contracts/contracts/app/orderbook_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app/orderbook_contract/src/main.nr index 201954b1c4af..879d87fe5d02 100644 --- a/noir-projects/noir-contracts/contracts/app/orderbook_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app/orderbook_contract/src/main.nr @@ -164,7 +164,7 @@ pub contract Orderbook { ) { // Finalize transfer of bid_amount of bid_token to taker Token::at(bid_token).finalize_transfer_to_private(bid_amount, taker_partial_note).call( - self.context, + &self.context, ); self.emit(OrderFulfilled { order_id }); diff --git a/noir-projects/noir-contracts/contracts/app/simple_token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app/simple_token_contract/src/main.nr index 4ffcdfcd6dcf..d1a9a8b81b48 100644 --- a/noir-projects/noir-contracts/contracts/app/simple_token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app/simple_token_contract/src/main.nr @@ -285,7 +285,7 @@ pub contract SimpleToken { } else { let remaining = amount - subtracted; compute_recurse_subtract_balance_call(*self.context, account, remaining).call( - self.context, + self.context, ) } } diff --git a/noir-projects/noir-contracts/contracts/app/token_bridge_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app/token_bridge_contract/src/main.nr index f3eb8b9f10f7..e51bac81fdeb 100644 --- a/noir-projects/noir-contracts/contracts/app/token_bridge_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app/token_bridge_contract/src/main.nr @@ -64,7 +64,7 @@ pub contract TokenBridge { ); // Mint tokens - self.call(Token::at(config.token).mint_to_public(to, amount)); + self.call(&Token::at(config.token).mint_to_public(to, amount)); } // docs:end:claim_public @@ -85,7 +85,7 @@ pub contract TokenBridge { self.context.message_portal(config.portal, content); // Burn tokens - self.call(Token::at(config.token).burn_public(self.msg_sender(), amount, authwit_nonce)); + self.call(&Token::at(config.token).burn_public(self.msg_sender(), amount, authwit_nonce)); } // docs:end:exit_to_l1_public diff --git a/noir-projects/noir-contracts/contracts/app/uniswap_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app/uniswap_contract/src/main.nr index d4b690e1f9c4..2c8358239bee 100644 --- a/noir-projects/noir-contracts/contracts/app/uniswap_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app/uniswap_contract/src/main.nr @@ -62,13 +62,13 @@ pub contract Uniswap { } let input_asset_bridge_config = - self.view(TokenBridge::at(input_asset_bridge).get_config_public()); + self.view(&TokenBridge::at(input_asset_bridge).get_config_public()); let input_asset = input_asset_bridge_config.token; let input_asset_bridge_portal_address = input_asset_bridge_config.portal; // Transfer funds to this contract - self.call(Token::at(input_asset).transfer_in_public( + self.call(&Token::at(input_asset).transfer_in_public( sender, self.address, input_amount, @@ -84,7 +84,7 @@ pub contract Uniswap { // Create swap message and send to Outbox for Uniswap Portal // this ensures the integrity of what the user originally intends to do on L1. let output_asset_bridge_portal_address = - self.view(TokenBridge::at(output_asset_bridge).get_config_public()).portal; + self.view(&TokenBridge::at(output_asset_bridge).get_config_public()).portal; // ensure portal exists - else funds might be lost assert( !input_asset_bridge_portal_address.is_zero(), @@ -209,7 +209,7 @@ pub contract Uniswap { let this_portal_address = self.storage.portal_address.read(); // Exit to L1 Uniswap Portal ! - self.call(TokenBridge::at(token_bridge).exit_to_l1_public( + self.call(&TokenBridge::at(token_bridge).exit_to_l1_public( this_portal_address, amount, this_portal_address, diff --git a/noir-projects/noir-contracts/contracts/fees/fpc_contract/src/main.nr b/noir-projects/noir-contracts/contracts/fees/fpc_contract/src/main.nr index c0b209eb6451..7d2a0ccfa729 100644 --- a/noir-projects/noir-contracts/contracts/fees/fpc_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/fees/fpc_contract/src/main.nr @@ -135,7 +135,7 @@ pub contract FPC { let refund_amount = max_fee - tx_fee; Token::at(accepted_asset).finalize_transfer_to_private(refund_amount, partial_note).call( - self.context, + &self.context, ); } // docs:end:complete_refund @@ -199,7 +199,7 @@ pub contract FPC { // TODO(#10805): Introduce a real exchange rate let refund = max_fee - actual_fee; - self.call(Token::at(accepted_asset).transfer_in_public( + self.call(&Token::at(accepted_asset).transfer_in_public( self.address, refund_recipient, refund, @@ -218,8 +218,8 @@ pub contract FPC { let token = Token::at(config.accepted_asset); // We send the full balance to `to`. - let balance = self.view(token.balance_of_public(self.address)); - self.call(token.transfer_in_public(self.address, to, balance, 0)); + let balance = self.view(&token.balance_of_public(self.address)); + self.call(&token.transfer_in_public(self.address, to, balance, 0)); } /// Note: Not marked as view as we need it to be callable as an entrypoint since in some places we need to obtain diff --git a/noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/context/public_context.nr b/noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/context/public_context.nr index b1d6c4aa16ac..4ccb18e7f6c0 100644 --- a/noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/context/public_context.nr +++ b/noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/context/public_context.nr @@ -32,7 +32,7 @@ impl PublicContext { } /// Emits a _public_ log that will be visible onchain to everyone. - pub fn emit_public_log(_self: Self, log: T) + pub fn emit_public_log(_self: &Self, log: T) where T: Serialize, { @@ -41,20 +41,20 @@ impl PublicContext { } /// Checks if a given note hash exists in the note hash tree at a particular leaf_index. - pub fn note_hash_exists(_self: Self, note_hash: Field, leaf_index: u64) -> bool { + pub fn note_hash_exists(_self: &Self, note_hash: Field, leaf_index: u64) -> bool { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::note_hash_exists(note_hash, leaf_index) } == 1 } /// Checks if a specific L1-to-L2 message exists in the L1-to-L2 message tree at a particular leaf index. - pub fn l1_to_l2_msg_exists(_self: Self, msg_hash: Field, msg_leaf_index: Field) -> bool { + pub fn l1_to_l2_msg_exists(_self: &Self, msg_hash: Field, msg_leaf_index: Field) -> bool { // Safety: AVM opcodes are constrained by the AVM itself TODO(alvaro): Make l1l2msg leaf index a u64 upstream unsafe { avm::l1_to_l2_msg_exists(msg_hash, msg_leaf_index as u64) } == 1 } /// Returns `true` if an `unsiloed_nullifier` has been emitted by `contract_address`. pub fn nullifier_exists_unsafe( - _self: Self, + _self: &Self, unsiloed_nullifier: Field, contract_address: AztecAddress, ) -> bool { @@ -65,7 +65,7 @@ impl PublicContext { /// Consumes a message sent from Ethereum (L1) to Aztec (L2). pub fn consume_l1_to_l2_message( - self: Self, + self: &Self, content: Field, secret: Field, sender: EthAddress, @@ -97,14 +97,14 @@ impl PublicContext { } /// Sends an "L2 -> L1 message". - pub fn message_portal(_self: Self, recipient: EthAddress, content: Field) { + pub fn message_portal(_self: &Self, recipient: EthAddress, content: Field) { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::send_l2_to_l1_msg(recipient, content) }; } /// Calls a public function on another contract. pub unconstrained fn call_public_function( - _self: Self, + _self: &Self, contract_address: AztecAddress, function_selector: FunctionSelector, args: [Field; N], @@ -131,7 +131,7 @@ impl PublicContext { /// Makes a read-only call to a public function on another contract. pub unconstrained fn static_call_public_function( - _self: Self, + _self: &Self, contract_address: AztecAddress, function_selector: FunctionSelector, args: [Field; N], @@ -157,19 +157,19 @@ impl PublicContext { } /// Adds a new note hash to the Note Hash Tree. - pub fn push_note_hash(_self: Self, note_hash: Field) { + pub fn push_note_hash(_self: &Self, note_hash: Field) { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::emit_note_hash(note_hash) }; } /// Adds a new nullifier to the Nullifier Tree. - pub fn push_nullifier(_self: Self, nullifier: Field) { + pub fn push_nullifier(_self: &Self, nullifier: Field) { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::emit_nullifier(nullifier) }; } /// Returns the address of the current contract being executed. - pub fn this_address(_self: Self) -> AztecAddress { + pub fn this_address(_self: &Self) -> AztecAddress { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::address() @@ -177,7 +177,7 @@ impl PublicContext { } /// Returns the contract address that initiated this function call. - pub fn maybe_msg_sender(_self: Self) -> Option { + pub fn maybe_msg_sender(_self: &Self) -> Option { // Safety: AVM opcodes are constrained by the AVM itself let maybe_msg_sender = unsafe { avm::sender() }; if maybe_msg_sender == NULL_MSG_SENDER_CONTRACT_ADDRESS { @@ -188,7 +188,7 @@ impl PublicContext { } /// Returns the function selector of the currently-executing function. - pub fn selector(_self: Self) -> FunctionSelector { + pub fn selector(_self: &Self) -> FunctionSelector { // The selector is the first element of the calldata when calling a public function through dispatch. // Safety: AVM opcodes are constrained by the AVM itself. let raw_selector: [Field; 1] = unsafe { avm::calldata_copy(0, 1) }; @@ -205,7 +205,7 @@ impl PublicContext { } /// Returns the "transaction fee" for the current transaction. - pub fn transaction_fee(_self: Self) -> Field { + pub fn transaction_fee(_self: &Self) -> Field { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::transaction_fee() @@ -213,7 +213,7 @@ impl PublicContext { } /// Returns the chain ID of the current network. - pub fn chain_id(_self: Self) -> Field { + pub fn chain_id(_self: &Self) -> Field { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::chain_id() @@ -221,7 +221,7 @@ impl PublicContext { } /// Returns the protocol version. - pub fn version(_self: Self) -> Field { + pub fn version(_self: &Self) -> Field { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::version() @@ -229,7 +229,7 @@ impl PublicContext { } /// Returns the current block number. - pub fn block_number(_self: Self) -> u32 { + pub fn block_number(_self: &Self) -> u32 { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::block_number() @@ -237,7 +237,7 @@ impl PublicContext { } /// Returns the timestamp of the current block. - pub fn timestamp(_self: Self) -> u64 { + pub fn timestamp(_self: &Self) -> u64 { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::timestamp() @@ -245,7 +245,7 @@ impl PublicContext { } /// Returns the fee per unit of L2 gas. - pub fn min_fee_per_l2_gas(_self: Self) -> u128 { + pub fn min_fee_per_l2_gas(_self: &Self) -> u128 { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::min_fee_per_l2_gas() @@ -253,7 +253,7 @@ impl PublicContext { } /// Returns the fee per unit of DA gas. - pub fn min_fee_per_da_gas(_self: Self) -> u128 { + pub fn min_fee_per_da_gas(_self: &Self) -> u128 { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::min_fee_per_da_gas() @@ -261,7 +261,7 @@ impl PublicContext { } /// Returns the remaining L2 gas available. - pub fn l2_gas_left(_self: Self) -> u32 { + pub fn l2_gas_left(_self: &Self) -> u32 { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::l2_gas_left() @@ -269,7 +269,7 @@ impl PublicContext { } /// Returns the remaining DA gas available. - pub fn da_gas_left(_self: Self) -> u32 { + pub fn da_gas_left(_self: &Self) -> u32 { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::da_gas_left() @@ -277,13 +277,13 @@ impl PublicContext { } /// Checks if the current execution is within a staticcall context. - pub fn is_static_call(_self: Self) -> bool { + pub fn is_static_call(_self: &Self) -> bool { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::is_static_call() } == 1 } /// Reads raw field values from public storage. - pub fn raw_storage_read(self: Self, storage_slot: Field) -> [Field; N] { + pub fn raw_storage_read(self: &Self, storage_slot: Field) -> [Field; N] { let mut out = [0; N]; for i in 0..N { // Safety: AVM opcodes are constrained by the AVM itself @@ -295,7 +295,7 @@ impl PublicContext { } /// Reads a typed value from public storage. - pub fn storage_read(self, storage_slot: Field) -> T + pub fn storage_read(&self, storage_slot: Field) -> T where T: Packable, { @@ -303,7 +303,7 @@ impl PublicContext { } /// Writes raw field values to public storage. - pub fn raw_storage_write(_self: Self, storage_slot: Field, values: [Field; N]) { + pub fn raw_storage_write(_self: &Self, storage_slot: Field, values: [Field; N]) { for i in 0..N { // Safety: AVM opcodes are constrained by the AVM itself unsafe { avm::storage_write(storage_slot + i as Field, values[i]) }; @@ -311,7 +311,7 @@ impl PublicContext { } /// Writes a typed value to public storage. - pub fn storage_write(self, storage_slot: Field, value: T) + pub fn storage_write(&self, storage_slot: Field, value: T) where T: Packable, { diff --git a/noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/context/utility_context.nr b/noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/context/utility_context.nr index 92019edb5402..1728ba108105 100644 --- a/noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/context/utility_context.nr +++ b/noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/context/utility_context.nr @@ -20,38 +20,38 @@ impl UtilityContext { Self { block_header: default_context.block_header, contract_address } } - pub fn block_header(self) -> BlockHeader { + pub fn block_header(&self) -> BlockHeader { self.block_header } - pub fn block_number(self) -> u32 { + pub fn block_number(&self) -> u32 { self.block_header.global_variables.block_number } - pub fn timestamp(self) -> u64 { + pub fn timestamp(&self) -> u64 { self.block_header.global_variables.timestamp } - pub fn this_address(self) -> AztecAddress { + pub fn this_address(&self) -> AztecAddress { self.contract_address } - pub fn version(self) -> Field { + pub fn version(&self) -> Field { self.block_header.global_variables.version } - pub fn chain_id(self) -> Field { + pub fn chain_id(&self) -> Field { self.block_header.global_variables.chain_id } pub unconstrained fn raw_storage_read( - self: Self, + self: &Self, storage_slot: Field, ) -> [Field; N] { storage_read(self.block_header, self.this_address(), storage_slot) } - pub unconstrained fn storage_read(self, storage_slot: Field) -> T + pub unconstrained fn storage_read(&self, storage_slot: Field) -> T where T: Packable, { diff --git a/noir-projects/noir-contracts/contracts/test/avm_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test/avm_test_contract/src/main.nr index 0453a6e7116d..325a648ef8bd 100644 --- a/noir-projects/noir-contracts/contracts/test/avm_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test/avm_test_contract/src/main.nr @@ -756,7 +756,7 @@ pub contract AvmTest { #[external("public")] fn nested_call_to_nothing() { let garbageAddress = AztecAddress::from_field(42); - self.call(AvmTest::at(garbageAddress).nested_call_to_nothing()) + self.call(&AvmTest::at(garbageAddress).nested_call_to_nothing()) } #[external("public")] @@ -778,7 +778,7 @@ pub contract AvmTest { da_gas: u32, ) -> pub Field { // Note: can't use self.call_self here because we need .with_gas() chaining - self.call(AvmTest::at(self.address).add_args_return(arg_a, arg_b).with_gas(GasOpts::new( + self.call(&AvmTest::at(self.address).add_args_return(arg_a, arg_b).with_gas(GasOpts::new( l2_gas, da_gas, ))) @@ -797,7 +797,7 @@ pub contract AvmTest { arg_a: Field, arg_b: Field, ) -> Field { - AvmTest::at(address).add_args_return(arg_a, arg_b).call(context) + AvmTest::at(address).add_args_return(arg_a, arg_b).call(&context) } #[external("public")] @@ -807,7 +807,7 @@ pub contract AvmTest { for i in 0..MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS + 2 { let addr = addrs[i]; if addr != AztecAddress::empty() { - let _ = self.call(AvmTest::at(addr).add_args_return(1, 2)); + let _ = self.call(&AvmTest::at(addr).add_args_return(1, 2)); } } } @@ -847,13 +847,13 @@ pub contract AvmTest { #[external("public")] fn create_same_nullifier_in_nested_call(nestedAddress: AztecAddress, nullifier: Field) { self.context.push_nullifier(nullifier); - self.call(AvmTest::at(nestedAddress).new_nullifier(nullifier)); + self.call(&AvmTest::at(nestedAddress).new_nullifier(nullifier)); } #[external("public")] fn create_different_nullifier_in_nested_call(nestedAddress: AztecAddress, nullifier: Field) { self.context.push_nullifier(nullifier); - self.call(AvmTest::at(nestedAddress).new_nullifier(nullifier + 1)); + self.call(&AvmTest::at(nestedAddress).new_nullifier(nullifier + 1)); } #[external("public")] @@ -891,19 +891,19 @@ pub contract AvmTest { #[contract_library_method] unconstrained fn _call_fee_juice(context: PublicContext, address: AztecAddress) { - let _ = FeeJuice::at(FEE_JUICE_ADDRESS).balance_of_public(address).view(context); + let _ = FeeJuice::at(FEE_JUICE_ADDRESS).balance_of_public(address).view(&context); } #[external("public")] fn call_auth_registry() { let _ = AuthRegistry::at(CANONICAL_AUTH_REGISTRY_ADDRESS).is_reject_all(self.address).view( - self.context, + &self.context, ); } #[external("public")] fn call_instance_registry() { - let _ = self.view(ContractInstanceRegistry::at(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS) + let _ = self.view(&ContractInstanceRegistry::at(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS) .get_update_delay()); } diff --git a/noir-projects/noir-contracts/contracts/test/import_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test/import_test_contract/src/main.nr index e6dca0df1005..1f7f6eaddcd4 100644 --- a/noir-projects/noir-contracts/contracts/test/import_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test/import_test_contract/src/main.nr @@ -31,6 +31,6 @@ pub contract ImportTest { // See yarn-project/end-to-end/src/e2e_nested_contract.test.ts #[external("public")] fn pub_call_public_fn(target: AztecAddress) { - self.call(Test::at(target).emit_nullifier_public(1)); + self.call(&Test::at(target).emit_nullifier_public(1)); } } diff --git a/noir-projects/noir-contracts/contracts/test/offchain_effect_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test/offchain_effect_contract/src/main.nr index 13d0bd3d9412..82c7111638ed 100644 --- a/noir-projects/noir-contracts/contracts/test/offchain_effect_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test/offchain_effect_contract/src/main.nr @@ -42,7 +42,7 @@ contract OffchainEffect { if effects.len() > 0 { OffchainEffect::at(payload.next_contract).emit_offchain_effects(effects).call( - self.context, + self.context, ); } } diff --git a/noir-projects/noir-contracts/contracts/test/static_parent_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test/static_parent_contract/src/main.nr index 66d65d0c5170..7b1c3d87cdd1 100644 --- a/noir-projects/noir-contracts/contracts/test/static_parent_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test/static_parent_contract/src/main.nr @@ -144,7 +144,7 @@ pub contract StaticParent { // Same as above but using a specific function from the interface #[external("public")] fn public_get_value_from_child(target_contract: AztecAddress, value: Field) -> Field { - self.view(StaticChild::at(target_contract).pub_get_value(value)) + self.view(&StaticChild::at(target_contract).pub_get_value(value)) } // Public function to set a static context and verify correct propagation for nested public calls @@ -156,7 +156,7 @@ pub contract StaticParent { ) -> Field { // Call the target public function through the pub entrypoint statically StaticParent::at(self.address).public_call(target_contract, target_selector, args[0]).view( - self.context, + &self.context, ) } diff --git a/noir-projects/noir-contracts/contracts/test/updatable_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test/updatable_contract/src/main.nr index 08ed569b0d7a..5a458073bd8b 100644 --- a/noir-projects/noir-contracts/contracts/test/updatable_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test/updatable_contract/src/main.nr @@ -58,7 +58,7 @@ contract Updatable { #[external("public")] fn get_update_delay() -> u64 { - self.view(ContractInstanceRegistry::at(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS) + self.view(&ContractInstanceRegistry::at(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS) .get_update_delay()) } diff --git a/noir-projects/noir-contracts/contracts/test/updated_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test/updated_contract/src/main.nr index 762eafb20f02..6b7735f6620d 100644 --- a/noir-projects/noir-contracts/contracts/test/updated_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test/updated_contract/src/main.nr @@ -34,7 +34,7 @@ contract Updated { #[external("public")] fn get_update_delay() -> u64 { - self.view(ContractInstanceRegistry::at(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS) + self.view(&ContractInstanceRegistry::at(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS) .get_update_delay()) }