Skip to content

Commit

Permalink
feat(docs): Docs deeper dive into unconstrained functions (#4233)
Browse files Browse the repository at this point in the history
  • Loading branch information
3 people authored Jan 31, 2024
1 parent bbdad91 commit 6af548e
Show file tree
Hide file tree
Showing 23 changed files with 400 additions and 355 deletions.
4 changes: 2 additions & 2 deletions docs/docs/developers/contracts/compiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Read more about interacting with contracts using `aztec.js` [here](../getting_st

### Aztec.nr interfaces

An Aztec.nr contract can [call a function](./syntax/functions.md) in another contract via `context.call_private_function` or `context.call_public_function`. However, this requires manually assembling the function selector and manually serializing the arguments, which is not type-safe.
An Aztec.nr contract can [call a function](./syntax/functions/main.md) in another contract via `context.call_private_function` or `context.call_public_function`. However, this requires manually assembling the function selector and manually serializing the arguments, which is not type-safe.

To make this easier, the compiler can generate contract interface structs that expose a convenience method for each function listed in a given contract artifact. These structs are intended to be used from another contract project that calls into the current one. For each contract, two interface structs are generated: one to be used from private functions with a `PrivateContext`, and one to be used from open functions with a `PublicContext`.

Expand Down Expand Up @@ -209,7 +209,7 @@ impl TokenPublicContextInterface {
}
```

Read more about how to use the Aztec.nr interfaces [here](./syntax/functions.md#contract-interface).
Read more about how to use the Aztec.nr interfaces [here](./syntax/functions/main.md).

:::info
At the moment, the compiler generates these interfaces from already compiled ABIs, and not from source code. This means that you should not import a generated interface from within the same project as its source contract, or you risk circular references.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/developers/contracts/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Structure
---

A contract is a collection of persistent [state variables](./syntax/storage/main.md), and [functions](./syntax/functions) which may manipulate these variables. Functions and state variables within a contract's scope are said to belong to that contract. A contract can only access and modify its own state. If a contract wishes to access or modify another contract's state, it must make a call to an external function of the other contract. For anything to happen on the Aztec network, an external function of a contract needs to be called.
A contract is a collection of persistent [state variables](./syntax/storage/main.md), and [functions](./syntax/functions/main.md) which may manipulate these variables. Functions and state variables within a contract's scope are said to belong to that contract. A contract can only access and modify its own state. If a contract wishes to access or modify another contract's state, it must make a call to an external function of the other contract. For anything to happen on the Aztec network, an external function of a contract needs to be called.

# Contract

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: Developer Documentation to use Authentication Witness for authentic

Authentication Witness is a scheme for authentication actions on Aztec, so users can allow third-parties (eg protocols or other users) to execute an action on their behalf.

How it works logically is explained in the [foundational concepts](./../../../../learn/concepts/accounts/authwit.md) but we will do a short recap here.
How it works logically is explained in the [concepts](./../../../../learn/concepts/accounts/authwit.md) but we will do a short recap here.

An authentication witness is defined for a specific action, such as allowing a Defi protocol to transfer funds on behalf of the user. An action is here something that could be explained as `A is allowed to perform X operation on behalf of B` and we define it as a hash computed as such:

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/developers/contracts/syntax/context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ The `args_hash` is the result of pedersen hashing all of a function's inputs.

### Return Values

The return values are a set of values that are returned from an applications execution to be passed to other functions through the kernel. Developers do not need to worry about passing their function return values to the `context` directly as `Aztec.nr` takes care of it for you. See the documentation surrounding `Aztec.nr` [macro expansion](./functions.md#after-expansion) for more details.
The return values are a set of values that are returned from an applications execution to be passed to other functions through the kernel. Developers do not need to worry about passing their function return values to the `context` directly as `Aztec.nr` takes care of it for you. See the documentation surrounding `Aztec.nr` [macro expansion](./functions/inner_workings.md#after-expansion) for more details.

return_values : BoundedVec<Field, RETURN_VALUES_LENGTH>,

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/developers/contracts/syntax/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ In the future we will allow emitting arbitrary information.
(If you currently emit arbitrary information, PXE will fail to decrypt, process and store this data, so it will not be queryable).
:::

To emit encrypted logs first import the `emit_encrypted_log` utility function which wraps an [oracle](./functions.md#oracle-functions):
To emit encrypted logs first import the `emit_encrypted_log` utility function which wraps an [oracle](./functions/oracles.md):

#include_code encrypted_import /yarn-project/aztec-nr/address-note/src/address_note.nr rust

Expand Down Expand Up @@ -95,7 +95,7 @@ They can be emitted by both public and private functions.

:::danger
- Emitting unencrypted events from private function is a significant privacy leak and it should be considered by the developer whether it is acceptable.
- Unencrypted events are currently **NOT** linked to the contract emitting them, so it is practically a [`debug_log`](./functions.md#a-few-useful-inbuilt-oracles).
- Unencrypted events are currently **NOT** linked to the contract emitting them, so it is practically a [`debug_log`](./functions/oracles.md#a-few-useful-inbuilt-oracles).
:::

To emit unencrypted logs first import the `emit_unencrypted_log` utility function inside your contract:
Expand Down
Loading

0 comments on commit 6af548e

Please sign in to comment.