diff --git a/docs/docs/developers/contracts/writing_contracts/example_contract.md b/docs/docs/developers/contracts/writing_contracts/example_contract.md index bb6806b49c1..82428915fb4 100644 --- a/docs/docs/developers/contracts/writing_contracts/example_contract.md +++ b/docs/docs/developers/contracts/writing_contracts/example_contract.md @@ -8,6 +8,10 @@ In keeping with the origins of blockchain, here's an example of a simple private #include_code easy_private_token_contract /noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr rust +The prelude consists of more commonly imported aztec types that are needed for development. Here is what the prelude includes: + +#include_code prelude /noir-projects/aztec-nr/aztec/src/prelude.nr rust + :::info Disclaimer Please note that any example contract set out herein is provided solely for informational purposes only and does not constitute any inducement to use or deploy. Any implementation of any such contract with an interface or any other infrastructure should be used in accordance with applicable laws and regulations. -::: +::: \ No newline at end of file diff --git a/docs/docs/misc/migration_notes.md b/docs/docs/misc/migration_notes.md index b31899c6083..a222b39ad88 100644 --- a/docs/docs/misc/migration_notes.md +++ b/docs/docs/misc/migration_notes.md @@ -8,6 +8,30 @@ Aztec is in full-speed development. Literally every version breaks compatibility ## 0.25.0 +### [Aztec.nr] Introduction to `prelude` + +A new `prelude` module to include common Aztec modules and types. +This simplifies dependency syntax. For example: +```rust +use dep::aztec::protocol_types::address::AztecAddress; +use dep::aztec::{ + context::{PrivateContext, Context}, note::{note_header::NoteHeader, utils as note_utils}, + state_vars::Map +}; +``` +Becomes: +```rust +use dep::aztec::prelude::{AztecAddress, NoteHeader, PrivateContext, Map}; +use dep::aztec::context::Context; +use dep::aztec::notes::utils as note_utils; +``` + +This will be further simplified in future versions (See [4496](https://github.com/AztecProtocol/aztec-packages/pull/4496) for further details). + +The prelude consists of + +#include_code prelude /noir-projects/aztec-nr/aztec/src/prelude.nr rust + ### [Aztec.nr] No SafeU120 anymore! Noir now have overflow checks by default. So we don't need SafeU120 like libraries anymore. diff --git a/noir-projects/aztec-nr/aztec/src/prelude.nr b/noir-projects/aztec-nr/aztec/src/prelude.nr index 9d65d3f1dc6..b843647d933 100644 --- a/noir-projects/aztec-nr/aztec/src/prelude.nr +++ b/noir-projects/aztec-nr/aztec/src/prelude.nr @@ -1,14 +1,16 @@ +// docs:start:prelude use dep::protocol_types::{address::{AztecAddress, EthAddress}, abis::function_selector::FunctionSelector}; use crate::{ state_vars::{ - map::Map, private_immutable::PrivateImmutable, private_mutable::PrivateMutable, - public_immutable::PublicImmutable, public_mutable::PublicMutable, private_set::PrivateSet, - shared_immutable::SharedImmutable -}, + map::Map, private_immutable::PrivateImmutable, private_mutable::PrivateMutable, + public_immutable::PublicImmutable, public_mutable::PublicMutable, private_set::PrivateSet, + shared_immutable::SharedImmutable + }, log::{emit_unencrypted_log, emit_encrypted_log}, context::PrivateContext, note::{ - note_header::NoteHeader, note_interface::NoteInterface, note_getter_options::NoteGetterOptions, - note_viewer_options::NoteViewerOptions, - utils::compute_note_hash_and_nullifier as utils_compute_note_hash_and_nullifier -} + note_header::NoteHeader, note_interface::NoteInterface, note_getter_options::NoteGetterOptions, + note_viewer_options::NoteViewerOptions, + utils::compute_note_hash_and_nullifier as utils_compute_note_hash_and_nullifier + } }; +// docs:end:prelude