From bdf9c0a36a625cf0d94425387feab8adb6f33ca4 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Mon, 12 Feb 2024 16:46:31 -0500 Subject: [PATCH 1/6] update yarn-project to noir-projects --- .github/scripts/update_aztec_contracts.sh | 4 +--- hackathons/INSPIRATION.md | 8 ++++---- hackathons/TOOLS.md | 2 +- .../packages/aztec-contracts/token_bridge/Nargo.toml | 1 + tutorials/token-bridge/contracts/Nargo.toml | 2 ++ tutorials/token-bridge/update_contract.sh | 2 +- tutorials/token-contract/contracts/Nargo.toml | 8 ++++---- tutorials/token-contract/update_contract.sh | 4 ++-- .../packages/aztec-contracts/token_bridge/Nargo.toml | 1 + .../packages/aztec-contracts/uniswap/Nargo.toml | 1 + .../devconnect-2023/build-account-contract/README.md | 4 ++-- .../build-account-contract/contracts/counter/Nargo.toml | 1 + 12 files changed, 21 insertions(+), 17 deletions(-) diff --git a/.github/scripts/update_aztec_contracts.sh b/.github/scripts/update_aztec_contracts.sh index e7953b6..70a680d 100755 --- a/.github/scripts/update_aztec_contracts.sh +++ b/.github/scripts/update_aztec_contracts.sh @@ -17,7 +17,7 @@ base_dirs=("./tutorials" "./workshops") # Repository details repo_url="https://github.com/AztecProtocol/aztec-packages.git" -contracts_path="yarn-project/noir-contracts/contracts" +contracts_path="noir-projects/noir-contracts/contracts" # Dynamic Temporary Directory Based on Environment if [ "$GITHUB_ACTIONS" == "true" ]; then @@ -104,5 +104,3 @@ for base_dir in "${base_dirs[@]}"; do fi done < <(find "$base_dir" -name "Nargo.toml") done - - diff --git a/hackathons/INSPIRATION.md b/hackathons/INSPIRATION.md index 4f7b9c0..b2c5328 100644 --- a/hackathons/INSPIRATION.md +++ b/hackathons/INSPIRATION.md @@ -12,10 +12,10 @@ The lack of privacy is consistently brought up as one of the main reasons we are These projects would be implemented as, or in conjunction with, Aztec contracts: -- **ZK UniSwap frontend -** develop a frontend for our uniswap smart contract found [here](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/noir-contracts/contracts/uniswap_contract) +- **ZK UniSwap frontend -** develop a frontend for our uniswap smart contract found [here](https://github.com/AztecProtocol/aztec-packages/tree/master/noir-projects/noir-contracts/contracts/uniswap_contract) - **Shielding** - an app that allows users to convert public tokens into a private form, perform an action, and then unshield back into original token. This could build on the existing token contract implementation, see the [tutorial here](https://docs.aztec.network/dev_docs/tutorials/writing_token_contract). -- **ZK stablecoin** - build a stablecoin that allows you to wrap a stablecoin so it can be privately transferred -- **Private lending front end** - you can see an example [here](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/noir-contracts/contracts/lending_contract) +- **ZK stablecoin** - build a stablecoin that allows you to wrap a stablecoin so it can be privately transferred +- **Private lending front end** - you can see an example [here](https://github.com/AztecProtocol/aztec-packages/tree/master/noir-projects/noir-contracts/contracts/lending_contract) - **ZKollateral** - privately prove assets for collateral or creditworthiness for a loan - **Proof of Liquidity** - privately prove solvency and/or compliance without exposing the underlying assets or trades - **Private DEX** - allow users to trade assets without revealing the accounts that the assets originate from. @@ -36,7 +36,7 @@ These projects would be implemented for Noir, but could be used for Aztec contra These projects could be done for Noir or Aztec contracts: -- **Boilerplates for more frameworks** - there are [Noir boilerplates](https://github.com/noir-lang/awesome-noir#boilerplates) and [Aztec boilerplates](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/boxes) for a number of popular frameworks already. Consider creating one for your favorite framework if there isn't one yet. +- **Boilerplates for more frameworks** - there are [Noir boilerplates](https://github.com/noir-lang/awesome-noir#boilerplates) and [Aztec boilerplates](https://github.com/AztecProtocol/aztec-packages/tree/master/boxes) for a number of popular frameworks already. Consider creating one for your favorite framework if there isn't one yet. These projects would be specific to Noir: diff --git a/hackathons/TOOLS.md b/hackathons/TOOLS.md index 716ed90..805a5dd 100644 --- a/hackathons/TOOLS.md +++ b/hackathons/TOOLS.md @@ -95,7 +95,7 @@ Many of the plugins and libraries listed above are also useful for writing Aztec #### Aztec Boilerplate -🧰 Aztec boxes - Example full stack Aztec dapps out of the box. See the [private token example](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/boxes/private-token) for a functioning reference and the full list [here](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/boxes). +🧰 Aztec boxes - Example full stack Aztec dapps out of the box. See the full list [here](https://github.com/AztecProtocol/aztec-packages/tree/master/boxes). #### Support diff --git a/tutorials/token-bridge-e2e/packages/aztec-contracts/token_bridge/Nargo.toml b/tutorials/token-bridge-e2e/packages/aztec-contracts/token_bridge/Nargo.toml index c69401c..247047e 100644 --- a/tutorials/token-bridge-e2e/packages/aztec-contracts/token_bridge/Nargo.toml +++ b/tutorials/token-bridge-e2e/packages/aztec-contracts/token_bridge/Nargo.toml @@ -5,6 +5,7 @@ compiler_version = ">=0.18.0" type = "contract" [dependencies] +# path should be updated to "noir-projects/..." if the version tag is updated to >=0.24 aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/aztec-nr/aztec" } token_portal_content_hash_lib = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/noir-contracts/contracts/token_portal_content_hash_lib" } protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/noir-protocol-circuits/src/crates/types"} \ No newline at end of file diff --git a/tutorials/token-bridge/contracts/Nargo.toml b/tutorials/token-bridge/contracts/Nargo.toml index fe6691e..610d778 100644 --- a/tutorials/token-bridge/contracts/Nargo.toml +++ b/tutorials/token-bridge/contracts/Nargo.toml @@ -3,7 +3,9 @@ name = "token_bridge_contract" authors = [""] type = "contract" + [dependencies] +# path should be updated to "noir-projects/..." if the version tag is updated to >=0.24 aztec = { git = 'https://github.com/AztecProtocol/aztec-packages/', tag = 'aztec-packages-v0.16.9', directory = 'yarn-project/aztec-nr/aztec' } protocol_types = { git = 'https://github.com/AztecProtocol/aztec-packages/', tag = 'aztec-packages-v0.16.9', directory = 'yarn-project/noir-protocol-circuits/src/crates/types' } token_portal_content_hash_lib = { git = 'https://github.com/AztecProtocol/aztec-packages/', tag = 'aztec-packages-v0.16.9', directory = 'yarn-project/noir-contracts/src/contracts/token_portal_content_hash_lib' } diff --git a/tutorials/token-bridge/update_contract.sh b/tutorials/token-bridge/update_contract.sh index 0fc38ea..e181a7b 100755 --- a/tutorials/token-bridge/update_contract.sh +++ b/tutorials/token-bridge/update_contract.sh @@ -6,7 +6,7 @@ version="aztec-packages-v0.16.9" nargo_file_path="$copy_to_file_path/Nargo.toml" repo_url="https://github.com/AztecProtocol/aztec-packages.git" -contracts_path="yarn-project/noir-contracts/src/contracts" +contracts_path="noir-projects/noir-contracts/src/contracts" # Check if the file exists if [ ! -f "$nargo_file_path" ]; then diff --git a/tutorials/token-contract/contracts/Nargo.toml b/tutorials/token-contract/contracts/Nargo.toml index e17ca8c..a043227 100644 --- a/tutorials/token-contract/contracts/Nargo.toml +++ b/tutorials/token-contract/contracts/Nargo.toml @@ -4,8 +4,8 @@ authors = [""] type = "contract" [dependencies] +# path should be updated to "noir-projects/..." if the version tag is updated to >=0.24 +compressed_string = {git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/aztec-nr/compressed-string"} aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/aztec-nr/aztec" } -value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/aztec-nr/value-note" } -safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/aztec-nr/safe-math" } -authwit = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/aztec-nr/authwit" } -protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/noir-protocol-circuits/src/crates/types"} \ No newline at end of file +safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/aztec-nr/safe-math"} +authwit={ git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/aztec-nr/authwit"} \ No newline at end of file diff --git a/tutorials/token-contract/update_contract.sh b/tutorials/token-contract/update_contract.sh index 7899de7..92881b7 100755 --- a/tutorials/token-contract/update_contract.sh +++ b/tutorials/token-contract/update_contract.sh @@ -2,11 +2,11 @@ copy_to_file_path="./contracts/" # change this with new releases -version="aztec-packages-v0.16.9" +version="aztec-packages-v0.20.0" nargo_file_path="$copy_to_file_path/Nargo.toml" repo_url="https://github.com/AztecProtocol/aztec-packages.git" -contracts_path="yarn-project/noir-contracts/src/contracts" +contracts_path="noir-projects/noir-contracts/src/contracts" # Check if the file exists if [ ! -f "$nargo_file_path" ]; then diff --git a/tutorials/uniswap-integration-e2e/packages/aztec-contracts/token_bridge/Nargo.toml b/tutorials/uniswap-integration-e2e/packages/aztec-contracts/token_bridge/Nargo.toml index 27c8144..d1e31cd 100644 --- a/tutorials/uniswap-integration-e2e/packages/aztec-contracts/token_bridge/Nargo.toml +++ b/tutorials/uniswap-integration-e2e/packages/aztec-contracts/token_bridge/Nargo.toml @@ -5,6 +5,7 @@ authors = [""] compiler_version = "0.16.0" [dependencies] +# path should be updated to "noir-projects/..." if the version tag is updated to >=0.24 aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/aztec-nr/aztec" } value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/aztec-nr/value-note"} safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/aztec-nr/safe-math"} \ No newline at end of file diff --git a/tutorials/uniswap-integration-e2e/packages/aztec-contracts/uniswap/Nargo.toml b/tutorials/uniswap-integration-e2e/packages/aztec-contracts/uniswap/Nargo.toml index f23f834..fe560af 100644 --- a/tutorials/uniswap-integration-e2e/packages/aztec-contracts/uniswap/Nargo.toml +++ b/tutorials/uniswap-integration-e2e/packages/aztec-contracts/uniswap/Nargo.toml @@ -5,6 +5,7 @@ authors = [""] compiler_version = "0.16.0" [dependencies] +# path should be updated to "noir-projects/..." if the version tag is updated to >=0.24 aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/aztec-nr/aztec" } value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/aztec-nr/value-note"} safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.20.0", directory="yarn-project/aztec-nr/safe-math"} diff --git a/workshops/devconnect-2023/build-account-contract/README.md b/workshops/devconnect-2023/build-account-contract/README.md index e665871..dd51e45 100644 --- a/workshops/devconnect-2023/build-account-contract/README.md +++ b/workshops/devconnect-2023/build-account-contract/README.md @@ -91,5 +91,5 @@ This function is required by the protocol to know how to handle private notes. ## Future work - Implement signature verification -- Discuss [Authentication witnesses](https://docs.aztec.network/concepts/foundation/accounts/authwit) -- Review the existing Schnorr signer [implementation](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/noir-contracts/src/contracts/schnorr_account_contract) +- Discuss [Authentication witnesses](https://docs.aztec.network/learn/concepts/accounts/authwit) +- Review the existing Schnorr signer [implementation](https://github.com/AztecProtocol/aztec-packages/tree/master/noir-projects/noir-contracts/src/contracts/schnorr_account_contract) diff --git a/workshops/devconnect-2023/build-account-contract/contracts/counter/Nargo.toml b/workshops/devconnect-2023/build-account-contract/contracts/counter/Nargo.toml index b23bd82..7b6979d 100644 --- a/workshops/devconnect-2023/build-account-contract/contracts/counter/Nargo.toml +++ b/workshops/devconnect-2023/build-account-contract/contracts/counter/Nargo.toml @@ -6,6 +6,7 @@ compiler_version = ">=0.18.0" type = "contract" [dependencies] +# path should be updated to "noir-projects/..." if the version tag is updated to >=0.24 aztec = { git = 'https://github.com/AztecProtocol/aztec-packages/', tag = 'aztec-packages-v0.14.2', directory = 'yarn-project/aztec-nr/aztec' } value_note = { git = 'https://github.com/AztecProtocol/aztec-packages/', tag = 'aztec-packages-v0.14.2', directory = 'yarn-project/aztec-nr/value-note' } easy_private_state = { git = 'https://github.com/AztecProtocol/aztec-packages/', tag = 'aztec-packages-v0.14.2', directory = 'yarn-project/aztec-nr/easy-private-state' } From 9969de1e1ea01899a74ca606988d9d746824d152 Mon Sep 17 00:00:00 2001 From: josh crites Date: Mon, 12 Feb 2024 16:55:20 -0500 Subject: [PATCH 2/6] Update Nargo.toml --- tutorials/token-bridge/contracts/Nargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/tutorials/token-bridge/contracts/Nargo.toml b/tutorials/token-bridge/contracts/Nargo.toml index 610d778..fe6691e 100644 --- a/tutorials/token-bridge/contracts/Nargo.toml +++ b/tutorials/token-bridge/contracts/Nargo.toml @@ -3,9 +3,7 @@ name = "token_bridge_contract" authors = [""] type = "contract" - [dependencies] -# path should be updated to "noir-projects/..." if the version tag is updated to >=0.24 aztec = { git = 'https://github.com/AztecProtocol/aztec-packages/', tag = 'aztec-packages-v0.16.9', directory = 'yarn-project/aztec-nr/aztec' } protocol_types = { git = 'https://github.com/AztecProtocol/aztec-packages/', tag = 'aztec-packages-v0.16.9', directory = 'yarn-project/noir-protocol-circuits/src/crates/types' } token_portal_content_hash_lib = { git = 'https://github.com/AztecProtocol/aztec-packages/', tag = 'aztec-packages-v0.16.9', directory = 'yarn-project/noir-contracts/src/contracts/token_portal_content_hash_lib' } From 14564ada3795d36af7f359935236bd446eb80dfe Mon Sep 17 00:00:00 2001 From: josh crites Date: Mon, 12 Feb 2024 16:56:31 -0500 Subject: [PATCH 3/6] Delete tutorials/token-contract/update_contract.sh --- tutorials/token-contract/update_contract.sh | 54 --------------------- 1 file changed, 54 deletions(-) delete mode 100755 tutorials/token-contract/update_contract.sh diff --git a/tutorials/token-contract/update_contract.sh b/tutorials/token-contract/update_contract.sh deleted file mode 100755 index 92881b7..0000000 --- a/tutorials/token-contract/update_contract.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -copy_to_file_path="./contracts/" -# change this with new releases -version="aztec-packages-v0.20.0" -nargo_file_path="$copy_to_file_path/Nargo.toml" - -repo_url="https://github.com/AztecProtocol/aztec-packages.git" -contracts_path="noir-projects/noir-contracts/src/contracts" - -# Check if the file exists -if [ ! -f "$nargo_file_path" ]; then - echo "File not found: $nargo_file_path" - exit 1 -fi - -# Extract the value of the 'name' field -name_value=$(grep "^name\s*=" "$nargo_file_path" | sed 's/name\s*=\s*"\(.*\)"/\1/') - -# Check if name_value is not empty -if [ -z "$name_value" ]; then - echo "Name field not found or empty in the TOML file." -else - echo "The value of the 'name' field is: $name_value" -fi - -# Clone the repository into a tmp folder -git clone $repo_url tmp -cd tmp && git checkout $version && cd .. - -# Check if clone was successful -if [ $? -eq 0 ]; then - - # Check if the directory exists - if [ -d "tmp/$contracts_path/$name_value" ]; then - echo "Directory found: $name_value" - cp -r tmp/$contracts_path/$name_value/src/ $copy_to_file_path/ - rm -rf tmp - echo "Copied the contracts to $copy_to_file_path" - # You can add additional commands here to handle the directory - - # Remove docs comments from the files - find "$copy_to_file_path/src" -type f -name "*.nr" | while read file; do - # Remove lines starting with '// docs:' - sed -i '/[ \t]*\/\/ docs:.*/d' "$file" - - echo "Comments removed from $file" - done - else - echo "Directory not found: $name_value" - fi -else - echo "Failed to clone the repository" -fi From 533246e90b732906a9e41d41e89c3288953bdf18 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Mon, 12 Feb 2024 17:11:21 -0500 Subject: [PATCH 4/6] rm --- .../contracts/token_bridge_contract/main.nr | 157 ------------------ .../token_bridge_contract/token_interface.nr | 53 ------ 2 files changed, 210 deletions(-) delete mode 100644 tutorials/token-bridge/contracts/token_bridge_contract/main.nr delete mode 100644 tutorials/token-bridge/contracts/token_bridge_contract/token_interface.nr diff --git a/tutorials/token-bridge/contracts/token_bridge_contract/main.nr b/tutorials/token-bridge/contracts/token_bridge_contract/main.nr deleted file mode 100644 index ebd6109..0000000 --- a/tutorials/token-bridge/contracts/token_bridge_contract/main.nr +++ /dev/null @@ -1,157 +0,0 @@ -mod token_interface; - -// Minimal implementation of the token bridge that can move funds between L1 <> L2. -// The bridge has a corresponding Portal contract on L1 that it is attached to -// And corresponds to a Token on L2 that uses the `AuthWit` accounts pattern. -// Bridge has to be set as a minter on the token before it can be used - -contract TokenBridge { - use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::{ - AztecAddress, - EthAddress, - }, - }; - - use dep::aztec::{ - context::{Context}, - hash::{compute_secret_hash}, - state_vars::{public_state::PublicState}, - }; - - use dep::token_portal_content_hash_lib::{get_mint_public_content_hash, get_mint_private_content_hash, get_withdraw_content_hash}; - - use crate::token_interface::Token; - - // Storage structure, containing all storage, and specifying what slots they use. - struct Storage { - token: PublicState, - } - - // Constructs the contract. - #[aztec(private)] - fn constructor(token: AztecAddress) { - let selector = FunctionSelector::from_signature("_initialize((Field))"); - context.call_public_function(context.this_address(), selector, [token.to_field()]); - } - - // Consumes a L1->L2 message and calls the token contract to mint the appropriate amount publicly - #[aztec(public)] - fn claim_public(to: AztecAddress, amount: Field, canceller: EthAddress, msg_key: Field, secret: Field) { - let content_hash = get_mint_public_content_hash(to, amount, canceller); - - // Consume message and emit nullifier - context.consume_l1_to_l2_message(msg_key, content_hash, secret); - - // Mint tokens - Token::at(storage.token.read()).mint_public(context, to, amount); - } - - // Burns the appropriate amount of tokens and creates a L2 to L1 withdraw message publicly - // Requires `msg.sender` to give approval to the bridge to burn tokens on their behalf using witness signatures - #[aztec(public)] - fn exit_to_l1_public( - recipient: EthAddress, // ethereum address to withdraw to - amount: Field, - callerOnL1: EthAddress, // ethereum address that can call this function on the L1 portal (0x0 if anyone can call) - nonce: Field // nonce used in the approval message by `msg.sender` to let bridge burn their tokens on L2 - ) { - // Send an L2 to L1 message - let content = get_withdraw_content_hash(recipient, amount, callerOnL1); - context.message_portal(content); - - // Burn tokens - Token::at(storage.token.read()).burn_public(context, context.msg_sender(), amount, nonce); - } - // Consumes a L1->L2 message and calls the token contract to mint the appropriate amount in private assets - // User needs to call token.redeem_shield() to get the private assets - #[aztec(private)] - fn claim_private( - secret_hash_for_redeeming_minted_notes: Field, // secret hash used to redeem minted notes at a later time. This enables anyone to call this function and mint tokens to a user on their behalf - amount: Field, - canceller: EthAddress, - msg_key: Field, // L1 to L2 message key as derived from the inbox contract - secret_for_L1_to_L2_message_consumption: Field // secret used to consume the L1 to L2 message - ) { - // Consume L1 to L2 message and emit nullifier - let content_hash = get_mint_private_content_hash(secret_hash_for_redeeming_minted_notes, amount, canceller); - context.consume_l1_to_l2_message(msg_key, content_hash, secret_for_L1_to_L2_message_consumption); - - // Mint tokens on L2 - // `mint_private` on token is public. So we call an internal public function - // which then calls the public method on the token contract. - // Since the secret_hash is passed, no secret is leaked. - context.call_public_function( - context.this_address(), - FunctionSelector::from_signature("_call_mint_on_token(Field,Field)"), - [amount, secret_hash_for_redeeming_minted_notes] - ); - } - - // Burns the appropriate amount of tokens and creates a L2 to L1 withdraw message privately - // Requires `msg.sender` (caller of the method) to give approval to the bridge to burn tokens on their behalf using witness signatures - #[aztec(private)] - fn exit_to_l1_private( - token: AztecAddress, - recipient: EthAddress, // ethereum address to withdraw to - amount: Field, - callerOnL1: EthAddress, // ethereum address that can call this function on the L1 portal (0x0 if anyone can call) - nonce: Field // nonce used in the approval message by `msg.sender` to let bridge burn their tokens on L2 - ) { - // Send an L2 to L1 message - let content = get_withdraw_content_hash(recipient, amount, callerOnL1); - context.message_portal(content); - - // Assert that user provided token address is same as seen in storage. - context.call_public_function( - context.this_address(), - FunctionSelector::from_signature("_assert_token_is_same((Field))"), - [token.to_field()] - ); - - // Burn tokens - Token::at(token).burn(&mut context, context.msg_sender(), amount, nonce); - } - - // View function that is callable by other contracts. - // Unconstrained can't be called by others since it isn't safe. - #[aztec(public)] - fn get_token() -> AztecAddress { - storage.token.read() - } - - // /// Unconstrained /// - - unconstrained fn token() -> pub AztecAddress { - storage.token.read() - } - - #[aztec(public)] - internal fn _initialize(token: AztecAddress) { - storage.token.write(token); - } - - // This is a public call as we need to read from public storage. - // Also, note that user hashes their secret in private and only sends the hash in public - // meaning only user can `redeem_shield` at a later time with their secret. - #[aztec(public)] - internal fn _call_mint_on_token(amount: Field, secret_hash: Field) { - Token::at(storage.token.read()).mint_private(context, amount, secret_hash); - } - - #[aztec(public)] - internal fn _assert_token_is_same(token: AztecAddress) { - assert(storage.token.read().eq(token), "Token address is not the same as seen in storage"); - } - - // TODO: remove this placeholder once https://github.com/AztecProtocol/aztec-packages/issues/2918 is implemented - unconstrained fn compute_note_hash_and_nullifier( - contract_address: AztecAddress, - nonce: Field, - storage_slot: Field, - serialized_note: [Field; 0] - ) -> pub [Field; 4] { - [0, 0, 0, 0] - } -} diff --git a/tutorials/token-bridge/contracts/token_bridge_contract/token_interface.nr b/tutorials/token-bridge/contracts/token_bridge_contract/token_interface.nr deleted file mode 100644 index 9af80c9..0000000 --- a/tutorials/token-bridge/contracts/token_bridge_contract/token_interface.nr +++ /dev/null @@ -1,53 +0,0 @@ -use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::{ - AztecAddress, - EthAddress, - }, -}; -use dep::aztec::{ - context::{ PrivateContext, PublicContext, Context }, -}; - -struct Token { - address: AztecAddress, -} - -impl Token { - pub fn at(address: AztecAddress) -> Self { - Self { address } - } - - pub fn mint_public(self: Self, context: PublicContext, to: AztecAddress, amount: Field) { - let _return_values = context.call_public_function( - self.address, - FunctionSelector::from_signature("mint_public((Field),Field)"), - [to.to_field(), amount] - ); - } - - pub fn burn_public(self: Self, context: PublicContext, from: AztecAddress, amount: Field, nonce: Field) { - let _return_values = context.call_public_function( - self.address, - FunctionSelector::from_signature("burn_public((Field),Field,Field)"), - [from.to_field(), amount, nonce] - ); - } - - pub fn mint_private(self: Self, context: PublicContext, amount: Field, secret_hash: Field) { - let _return_values = context.call_public_function( - self.address, - FunctionSelector::from_signature("mint_private(Field,Field)"), - [amount, secret_hash] - ); - } - - - pub fn burn(self: Self, context: &mut PrivateContext, from: AztecAddress, amount: Field, nonce: Field) { - let _return_values = context.call_private_function( - self.address, - FunctionSelector::from_signature("burn((Field),Field,Field)"), - [from.to_field(), amount, nonce] - ); - } -} From 987fe71563454f1745fb12b62b12254ee7729f8c Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Mon, 12 Feb 2024 17:12:11 -0500 Subject: [PATCH 5/6] add v --- .../contracts/private_token_contract/Nargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/simple-private-token/contracts/private_token_contract/Nargo.toml b/tutorials/simple-private-token/contracts/private_token_contract/Nargo.toml index adf7b96..49a6209 100644 --- a/tutorials/simple-private-token/contracts/private_token_contract/Nargo.toml +++ b/tutorials/simple-private-token/contracts/private_token_contract/Nargo.toml @@ -2,7 +2,7 @@ name = "easy_private_token_contract" type = "contract" authors = [""] -compiler_version = "0.11.1" +compiler_version = ">=0.23.0" [dependencies] aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.23.0", directory="yarn-project/aztec-nr/aztec-noir" } From 370ce9fc7565dabe018e0c5e1968b6dee82c1089 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Mon, 12 Feb 2024 17:16:04 -0500 Subject: [PATCH 6/6] update names --- .../packages/aztec-contracts/token_bridge/Nargo.toml | 2 +- .../packages/aztec-contracts/token_bridge/Nargo.toml | 4 ++-- .../packages/aztec-contracts/uniswap/Nargo.toml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tutorials/token-bridge-e2e/packages/aztec-contracts/token_bridge/Nargo.toml b/tutorials/token-bridge-e2e/packages/aztec-contracts/token_bridge/Nargo.toml index 3c7bd20..2345546 100644 --- a/tutorials/token-bridge-e2e/packages/aztec-contracts/token_bridge/Nargo.toml +++ b/tutorials/token-bridge-e2e/packages/aztec-contracts/token_bridge/Nargo.toml @@ -1,5 +1,5 @@ [package] -name = "token_bridge" +name = "token_bridge_contract" authors = [""] compiler_version = ">=0.18.0" type = "contract" diff --git a/tutorials/uniswap-integration-e2e/packages/aztec-contracts/token_bridge/Nargo.toml b/tutorials/uniswap-integration-e2e/packages/aztec-contracts/token_bridge/Nargo.toml index d0e8c58..518e604 100644 --- a/tutorials/uniswap-integration-e2e/packages/aztec-contracts/token_bridge/Nargo.toml +++ b/tutorials/uniswap-integration-e2e/packages/aztec-contracts/token_bridge/Nargo.toml @@ -1,8 +1,8 @@ [package] -name = "token_bridge" +name = "token_bridge_contract" type = "contract" authors = [""] -compiler_version = "0.16.0" +compiler_version = ">=0.23.0" [dependencies] aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.23.0", directory="yarn-project/aztec-nr/aztec" } diff --git a/tutorials/uniswap-integration-e2e/packages/aztec-contracts/uniswap/Nargo.toml b/tutorials/uniswap-integration-e2e/packages/aztec-contracts/uniswap/Nargo.toml index a4ba025..e647e15 100644 --- a/tutorials/uniswap-integration-e2e/packages/aztec-contracts/uniswap/Nargo.toml +++ b/tutorials/uniswap-integration-e2e/packages/aztec-contracts/uniswap/Nargo.toml @@ -1,8 +1,8 @@ [package] -name = "uniswap" +name = "uniswap_contract" type = "contract" authors = [""] -compiler_version = "0.16.0" +compiler_version = ">=0.23.0" [dependencies] aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.23.0", directory="yarn-project/aztec-nr/aztec" }