Skip to content

Commit 9cc4ffa

Browse files
committed
cleanup
1 parent fd09f90 commit 9cc4ffa

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

boxes/token/src/contracts/src/main.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ contract Token {
270270

271271
storage.balances.at(from).sub(SafeU120::new(amount));
272272

273-
let selector = compute_selector("_increase_public_balance((Field),Field)");
273+
let selector = FunctionSelector::from_signature("_increase_public_balance((Field),Field)");
274274
let _void = context.call_public_function(context.this_address(), selector, [to.to_field(), amount]);
275275
}
276276
// docs:end:unshield

docs/docs/dev_docs/contracts/syntax/functions.md

-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ Oracles introduce **non-determinism** into a circuit, and thus are `unconstraine
111111

112112
### A few useful inbuilt oracles
113113

114-
- [`compute_selector`](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/selector.nr) - Computes the selector of a function. This is useful for when you want to call a function from within a circuit, but don't have an interface at hand and don't want to hardcode the selector in hex.
115114
- [`debug_log`](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/oracle/debug_log.nr) - Provides a couple of debug functions that can be used to log information to the console.
116115
- [`auth_witness`](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/authwit/src/auth_witness.nr) - Provides a way to fetch the authentication witness for a given address. This is useful when building account contracts to support approve-like functionality.
117116
- [`get_l1_to_l2_message`](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/oracle/get_l1_to_l2_message.nr) - Useful for application that receive messages from L1 to be consumed on L2, such as token bridges or other cross-chain applications.

docs/docs/dev_docs/tutorials/writing_private_voting_contract.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ We are using various utils within the Aztec library:
7171

7272
* `context` - exposes things such as the contract address, msg_sender, etc
7373
* `oracle::get_secret_key` - get your secret key to help us create a randomized nullifier
74-
* `selector::compute_selector` - compute a function selector so we can call functions from other functions
74+
* `FunctionSelector::from_signature` - compute a function selector from signature so we can call functions from other functions
7575
* `state_vars::{ map::Map, public_state::PublicState, }` - we will use a Map to store the votes (key = voteId, value = number of votes), and PublicState to hold our public values that we mentioned earlier
7676
* `types::type_serialization::{..}` - various serialization methods for defining how to use these types
7777
* `types::address::{AztecAddress},` - our admin will be held as an address
@@ -113,7 +113,7 @@ Therefore our constructor must call a public function by using `context.call_pub
113113

114114
`context.call_public_function()` takes three arguments:
115115
1. The contract address whose method we want to call
116-
2. The selector of the function to call (we can use `compute_selector()` for this)
116+
2. The selector of the function to call (we can use `FunctionSelector::from_signature(...)` for this)
117117
3. The arguments of the function (we pass the `admin`)
118118

119119
We now need to write the `_initialize()` function:

noir/tooling/nargo_fmt/tests/expected/contract.nr

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
44
// Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
55
contract Benchmarking {
6+
use dep::protocol_types::abis::function_selector::FunctionSelector;
7+
68
use dep::value_note::{
79
utils::{increment, decrement},
810
value_note::{VALUE_NOTE_LEN, ValueNote, ValueNoteMethods},
@@ -11,7 +13,6 @@ contract Benchmarking {
1113
use dep::aztec::{
1214
context::{Context},
1315
note::{utils as note_utils, note_getter_options::NoteGetterOptions, note_header::NoteHeader},
14-
selector::compute_selector,
1516
log::emit_unencrypted_log,
1617
state_vars::{map::Map, public_state::PublicState, set::Set},
1718
types::type_serialization::field_serialization::{FieldSerializationMethods, FIELD_SERIALIZED_LEN},
@@ -59,7 +60,7 @@ contract Benchmarking {
5960
storage.balances.at(owner).write(current + value);
6061
let _callStackItem1 = context.call_public_function(
6162
context.this_address(),
62-
compute_selector("broadcast(Field)"),
63+
FunctionSelector::from_signature("broadcast(Field)"),
6364
[owner]
6465
);
6566
}

noir/tooling/nargo_fmt/tests/input/contract.nr

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
44
// Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
55
contract Benchmarking {
6+
use dep::protocol_types::abis::function_selector::FunctionSelector;
7+
68
use dep::value_note::{
79
utils::{increment, decrement},
810
value_note::{VALUE_NOTE_LEN, ValueNote, ValueNoteMethods},
@@ -11,7 +13,6 @@ contract Benchmarking {
1113
use dep::aztec::{
1214
context::{Context},
1315
note::{utils as note_utils, note_getter_options::NoteGetterOptions, note_header::NoteHeader},
14-
selector::compute_selector,
1516
log::emit_unencrypted_log,
1617
state_vars::{map::Map, public_state::PublicState, set::Set},
1718
types::type_serialization::field_serialization::{FieldSerializationMethods, FIELD_SERIALIZED_LEN},
@@ -57,7 +58,7 @@ contract Benchmarking {
5758
fn increment_balance(owner: Field, value: Field) {
5859
let current = storage.balances.at(owner).read();
5960
storage.balances.at(owner).write(current + value);
60-
let _callStackItem1 = context.call_public_function(context.this_address(), compute_selector("broadcast(Field)"), [owner]);
61+
let _callStackItem1 = context.call_public_function(context.this_address(), FunctionSelector::from_signature("broadcast(Field)"), [owner]);
6162
}
6263

6364
// Est ultricies integer quis auctor elit sed. In nibh mauris cursus mattis molestie a iaculis.

0 commit comments

Comments
 (0)