Skip to content

Commit 9f29ed8

Browse files
committed
refactor: final token naming cleanup
1 parent d14b00e commit 9f29ed8

File tree

75 files changed

+3208
-3164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+3208
-3164
lines changed

docs/docs/guides/developer_guides/getting_started.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ In the next step, let's mint some tokens!
139139
Call the public mint function like this:
140140
141141
```bash
142-
aztec-wallet send mint_public --from accounts:my-wallet --contract-address contracts:testtoken --args accounts:my-wallet 100
142+
aztec-wallet send mint_to_public --from accounts:my-wallet --contract-address contracts:testtoken --args accounts:my-wallet 100
143143
```
144144
145145
This takes
146146
147-
- the function name as the argument, which is `mint_public`
147+
- the function name as the argument, which is `mint_to_public`
148148
- the `from` account (caller) which is `accounts:my-wallet`
149149
- the contract address, which is aliased as `contracts:testtoken` (or simply `testtoken`)
150150
- the args that the function takes, which is the account to mint the tokens into (`my-wallet`), and `amount` (`100`).
@@ -165,7 +165,7 @@ Transaction has been mined
165165
Status: success
166166
Block number: 17
167167
Block hash: 1e27d200600bc45ab94d467c230490808d1e7d64f5ee6cee5e94a08ee9580809
168-
Transaction hash stored in database with aliases last & mint_public-9044
168+
Transaction hash stored in database with aliases last & mint_to_public-9044
169169
```
170170
171171
You can double-check by calling the function that checks your public account balance:

docs/docs/guides/developer_guides/js_apps/authwit.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ Then create the message hash by hashing the inner hash with the authwit receiver
6868

6969
## Create the authwit
7070

71-
There are slightly different interfaces depending on whether your contract is checking the authwit in private or public.
71+
There are slightly different interfaces depending on whether your contract is checking the authwit in private or public.
7272

73-
Public authwits are stored in the account contract and batched with the authwit action call, so a user must send a transaction to update their account contract, authorizing an action before the authorized contract's public call will succeed.
73+
Public authwits are stored in the account contract and batched with the authwit action call, so a user must send a transaction to update their account contract, authorizing an action before the authorized contract's public call will succeed.
7474

7575
Private execution uses oracles and are executed locally by the PXE, so the authwit needs to be created by the authwit giver and then added to the authwit receiver's PXE.
7676

@@ -107,7 +107,7 @@ Set a public authwit like this:
107107
Remember it is a transaction and calls a method in the account contract. In this example,
108108

109109
- `wallets[0]` is the authwit giver
110-
- `wallets[1]` is the authwit reciever and caller of the function
110+
- `wallets[1]` is the authwit receiver and caller of the function
111111
- `action` was [defined previously](#define-the-action)
112112
- `true` sets the `authorized` boolean (`false` would revoke this authwit)
113113

docs/docs/guides/developer_guides/smart_contracts/how_to_compile_contract.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ export class TokenContract extends ContractBase {
199199

200200
/** Type-safe wrappers for the public methods exposed by the contract. */
201201
public override methods!: {
202-
/** transfer_public(from: struct, to: struct, amount: field, nonce: field) */
203-
transfer_public: ((
202+
/** transfer_in_public(from: struct, to: struct, amount: field, nonce: field) */
203+
transfer_in_public: ((
204204
from: AztecAddressLike,
205205
to: AztecAddressLike,
206206
amount: FieldLike,

docs/docs/guides/developer_guides/smart_contracts/testing_contracts/testing.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ Our test environment is capable of utilizing the autogenerated contract interfac
118118

119119
For example, to call the private `transfer` function on the token contract:
120120

121-
#include_code txe_test_transfer_private /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_private.nr rust
121+
#include_code txe_test_transfer_private /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer.nr rust
122122

123123
#### Public
124124

125-
To call the public `transfer_public` function:
125+
To call the public `transfer_in_public` function:
126126

127-
#include_code call_public /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_public.nr rust
127+
#include_code call_public /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_in_public.nr rust
128128

129129
#### Unconstrained
130130

@@ -178,11 +178,11 @@ Reading notes:
178178

179179
You can add [authwits](../writing_contracts/authwit.md) to the TXE. Here is an example of testing a private token transfer using authwits:
180180

181-
#include_code private_authwit /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_private.nr rust
181+
#include_code private_authwit /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_in_private.nr rust
182182

183183
#### Public
184184

185-
#include_code public_authwit /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_public.nr rust
185+
#include_code public_authwit /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_in_public.nr rust
186186

187187
### Storing notes in cache
188188

@@ -206,7 +206,7 @@ You can test functions that you expect to fail generically, with the `#[test(sho
206206

207207
For example:
208208

209-
#include_code fail_with_message /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_private.nr rust
209+
#include_code fail_with_message /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_in_private.nr rust
210210

211211
You can also use the `assert_public_call_fails` or `assert_private_call_fails` methods on the `TestEnvironment` to check that a call fails.
212212

docs/docs/guides/developer_guides/smart_contracts/writing_contracts/authwit.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Then you will be able to import it into your contracts as follows.
141141

142142
Based on the diagram earlier on this page let's take a look at how we can implement the `transfer` function such that it checks if the tokens are to be transferred `from` the caller or needs to be authenticated with an authentication witness.
143143

144-
#include_code transfer_from /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust
144+
#include_code transfer_in_private /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust
145145

146146
The first thing we see in the snippet above, is that if `from` is not the call we are calling the `assert_current_call_valid_authwit` function from [earlier](#private-functions). If the call is not throwing, we are all good and can continue with the transfer.
147147

@@ -151,7 +151,7 @@ In the snippet we are constraining the `else` case such that only `nonce = 0` is
151151

152152
Cool, so we have a function that checks if the current call is authenticated, but how do we actually authenticate it? Well, assuming that we use a wallet that is following the spec, we import `computeAuthWitMessageHash` from `aztec.js` to help us compute the hash, and then we simply `addAuthWitness` to the wallet. Behind the scenes this will make the witness available to the oracle.
153153

154-
#include_code authwit_transfer_example /yarn-project/end-to-end/src/e2e_token_contract/transfer_private.test.ts typescript
154+
#include_code authwit_transfer_example /yarn-project/end-to-end/src/e2e_token_contract/transfer_in_private.test.ts typescript
155155

156156
Learn more about authwits in Aztec.js by [following this guide](../../js_apps/authwit.md).
157157

@@ -161,15 +161,15 @@ With private functions covered, how can we use this in a public function? Well,
161161

162162
#### Checking if the current call is authenticated
163163

164-
#include_code transfer_public /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust
164+
#include_code transfer_in_public /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust
165165

166166
#### Authenticating an action in TypeScript
167167

168168
Authenticating an action in the public domain is slightly different from the private domain, since we are executing a function on the auth registry contract to add the witness flag. As you might recall, this was to ensure that we don't need to call into the account contract from public, which is a potential DOS vector.
169169

170170
In the snippet below, this is done as a separate contract call, but can also be done as part of a batch as mentioned in the [Accounts concepts](../../../../aztec/concepts/accounts/authwit.md#what-about-public).
171171

172-
#include_code authwit_public_transfer_example /yarn-project/end-to-end/src/e2e_token_contract/transfer_public.test.ts typescript
172+
#include_code authwit_public_transfer_example /yarn-project/end-to-end/src/e2e_token_contract/transfer_in_public.test.ts typescript
173173

174174
#### Updating approval state in Noir
175175

docs/docs/guides/developer_guides/smart_contracts/writing_contracts/common_patterns/index.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ We call this the "authentication witness" pattern or authwit for short.
2121
Here you approve a contract to burn funds on your behalf.
2222

2323
- Approve in public domain:
24-
#include_code authwit_public_transfer_example /yarn-project/end-to-end/src/e2e_token_contract/transfer_public.test.ts typescript
24+
#include_code authwit_public_transfer_example /yarn-project/end-to-end/src/e2e_token_contract/transfer_in_public.test.ts typescript
2525

2626
Here you approve someone to transfer funds publicly on your behalf
2727

@@ -84,8 +84,6 @@ Let's say you have some storage in public and want to move them into the private
8484

8585
So you have to create a custom note in the public domain that is not encrypted by some owner - we call such notes a "TransparentNote" since it is created in public, anyone can see the amount and the note is not encrypted by some owner.
8686

87-
This pattern is discussed in detail in [the codealong token tutorial in the shield() method](../../../../../tutorials/codealong/contract_tutorials/token_contract.md#redeem_shield).
88-
8987
### Discovering my notes
9088

9189
When you send someone a note, the note hash gets added to the note hash tree. To spend the note, the receiver needs to get the note itself (the note hash preimage). There are two ways you can get a hold of your notes:

docs/docs/guides/developer_guides/smart_contracts/writing_contracts/portals/communicate_with_portal.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The `content_hash` is a sha256 truncated to a field element (~ 254 bits). In Azt
5353

5454
### Token portal hash library
5555

56-
#include_code mint_public_content_hash_nr /noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr rust
56+
#include_code mint_to_public_content_hash_nr /noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr rust
5757

5858
### Token Portal contract
5959

docs/docs/reference/developer_references/sandbox_reference/cli_wallet_reference.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ The authwit management in private is a two-step process: create and add. It's no
104104

105105
#### Example
106106

107-
An example for authorizing an operator (ex. a DeFi protocol) to call the transfer_from action (transfer on the user's behalf):
107+
An example for authorizing an operator (ex. a DeFi protocol) to call the transfer_in_private action (transfer on the user's behalf):
108108

109109
```bash
110-
aztec-wallet create-authwit transfer_from accounts:coruscant_trader -ca contracts:token --args accounts:jedi_master accounts:coruscant_trader 20 secrets:auth_nonce -f accounts:jedi_master -a secret_trade
110+
aztec-wallet create-authwit transfer_in_private accounts:coruscant_trader -ca contracts:token --args accounts:jedi_master accounts:coruscant_trader 20 secrets:auth_nonce -f accounts:jedi_master -a secret_trade
111111

112112
aztec-wallet add-authwit authwits:secret_trade accounts:jedi_master -f accounts:coruscant_trader
113113
```
@@ -117,7 +117,7 @@ aztec-wallet add-authwit authwits:secret_trade accounts:jedi_master -f accounts:
117117
A similar call to the above, but in public:
118118

119119
```bash
120-
aztec-wallet authorize-action transfer_public accounts:coruscant_trader -ca contracts:token --args accounts:jedi_master accounts:coruscant_trader 20 secrets:auth_nonce -f accounts:jedi_master
120+
aztec-wallet authorize-action transfer_in_public accounts:coruscant_trader -ca contracts:token --args accounts:jedi_master accounts:coruscant_trader 20 secrets:auth_nonce -f accounts:jedi_master
121121
```
122122

123123
### Simulate

docs/docs/tutorials/codealong/cli_wallet/faceid_wallet.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ You should get a prompt to sign this transaction. You can now mint, transfer, an
103103

104104
```bash
105105
aztec-wallet create-account -a new_recipient # creating a schnorr account
106-
aztec-wallet send mint_public -ca last --args accounts:my-wallet 10 -f accounts:my-wallet # minting some tokens in public
106+
aztec-wallet send mint_to_public -ca last --args accounts:my-wallet 10 -f accounts:my-wallet # minting some tokens in public
107107
aztec-wallet simulate balance_of_public -ca contracts:devtoken --args accounts:my-wallet -f my-wallet # checking that my-wallet has 10 tokens
108-
aztec-wallet send transfer_public -ca contracts:devtoken --args accounts:my-wallet accounts:new_recipient 10 0 -f accounts:my-wallet # transferring some tokens in public
108+
aztec-wallet send transfer_in_public -ca contracts:devtoken --args accounts:my-wallet accounts:new_recipient 10 0 -f accounts:my-wallet # transferring some tokens in public
109109
aztec-wallet simulate balance_of_public -ca contracts:devtoken --args accounts:new_recipient -f my-wallet # checking that new_recipient has 10 tokens
110110
```
111111

docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/1_depositing_to_aztec.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Here is an explanation of what it is doing:
5757
- The content is limited to a single field (~254 bits). So if the content is larger, we have to hash it and the hash can be passed along.
5858
- We use our utility method that creates a sha256 hash but truncates it to fit into a field
5959
- Since we want to mint tokens on Aztec publicly, the content here is the amount to mint and the address on Aztec who will receive the tokens.
60-
- We encode this message as a mint_public function call, to specify the exact intentions and parameters we want to execute on L2.
60+
- We encode this message as a mint_to_public function call, to specify the exact intentions and parameters we want to execute on L2.
6161
- In reality the content can be constructed in any manner as long as the sister contract on L2 can also create it. But for clarity, we are constructing the content like an ABI encoded function call.
6262
- It is good practice to include all parameters used by L2 into this content (like the amount and to) so that a malicious actor can’t change the to to themselves when consuming the message.
6363
3. The tokens are transferred from the user to the portal using `underlying.safeTransferFrom()`. This puts the funds under the portal's control.

docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/2_minting_on_aztec.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ The `claim_public` function enables anyone to consume the message on the user's
2828

2929
**What’s happening here?**
3030

31-
1. We first recompute the L1->L2 message content by calling `get_mint_public_content_hash()`. Note that the method does exactly the same as what the TokenPortal contract does in `depositToAztecPublic()` to create the content hash.
31+
1. We first recompute the L1->L2 message content by calling `get_mint_to_public_content_hash()`. Note that the method does exactly the same as what the TokenPortal contract does in `depositToAztecPublic()` to create the content hash.
3232
2. We then attempt to consume the L1->L2 message. Since we are depositing to Aztec publicly, all of the inputs are public.
3333
- `context.consume_l1_to_l2_message()` takes in the few parameters:
34-
- `content_hash`: The content - which is reconstructed in the `get_mint_public_content_hash()`
34+
- `content_hash`: The content - which is reconstructed in the `get_mint_to_public_content_hash()`
3535
- `secret`: The secret used for consumption, often 0 for public messages
3636
- `sender`: Who on L1 sent the message. Which should match the stored `portal_address` in our case as we only want to allow messages from a specific sender.
3737
- `message_leaf_index`: The index in the message tree of the message.
3838
- Note that the `content_hash` requires `to` and `amount`. If a malicious user tries to mint tokens to their address by changing the to address, the content hash will be different to what the token portal had calculated on L1 and thus not be in the tree, failing the consumption. This is why we add these parameters into the content.
39-
3. Then we call `Token::at(storage.token.read()).mint_public()` to mint the tokens to the to address.
39+
3. Then we call `Token::at(storage.token.read()).mint_to_public()` to mint the tokens to the to address.
4040

4141
## Private flow
4242

@@ -48,7 +48,7 @@ Now we will create a function to mint the amount privately. Paste this into your
4848

4949
The `get_mint_private_content_hash` function is imported from the `token_portal_content_hash_lib`.
5050

51-
If the content hashes were constructed similarly for `mint_private` and `mint_publicly`, then content intended for private execution could have been consumed by calling the `claim_public` method. By making these two content hashes distinct, we prevent this scenario.
51+
If the content hashes were constructed similarly for `mint_private` and `mint_to_publicly`, then content intended for private execution could have been consumed by calling the `claim_public` method. By making these two content hashes distinct, we prevent this scenario.
5252

5353
While we mint the tokens on L2, we _still don’t actually mint them to a certain address_. Instead we continue to pass the `secret_hash_for_redeeming_minted_notes` like we did on L1. This means that a user could reveal their secret for L2 message consumption for anyone to mint tokens on L2 but they can redeem these notes at a later time. **This enables a paradigm where an app can manage user’s secrets for L2 message consumption on their behalf**. **The app or any external party can also mint tokens on the user’s behalf should they be comfortable with leaking the secret for L2 Message consumption.** This doesn’t leak any new information to the app because their smart contract on L1 knew that a user wanted to move some amount of tokens to L2. The app still doesn’t know which address on L2 the user wants these notes to be in, but they can mint tokens nevertheless on their behalf.
5454

0 commit comments

Comments
 (0)