Skip to content

Commit

Permalink
Rename GasOpts::empty() to default()
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Apr 8, 2024
1 parent 70efdc3 commit 8fa9373
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 47 deletions.
7 changes: 6 additions & 1 deletion noir-projects/aztec-nr/authwit/src/auth.nr
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ pub fn assert_current_call_valid_authwit(context: &mut PrivateContext, on_behalf
pub fn assert_current_call_valid_authwit_public(context: &mut PublicContext, on_behalf_of: AztecAddress) {
let function_selector = FunctionSelector::from_signature("spend_public_authwit(Field)");
let inner_hash = compute_inner_authwit_hash([context.msg_sender().to_field(), context.selector().to_field(), context.args_hash]);
let result = context.call_public_function(on_behalf_of, function_selector, [inner_hash], GasOpts::empty())[0];
let result = context.call_public_function(
on_behalf_of,
function_selector,
[inner_hash],
GasOpts::default()
)[0];
assert(result == IS_VALID_SELECTOR, "Message not authorized by account");
}
// docs:end:assert_current_call_valid_authwit_public
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/context/gas.nr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct GasOpts {
}

impl GasOpts {
pub fn empty() -> Self {
pub fn default() -> Self {
GasOpts { l1_gas: Option::none(), l2_gas: Option::none(), da_gas: Option::none() }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ contract AvmTest {

// Nested call
let results = context.call_public_function_raw(
GasOpts::empty(),
GasOpts::default(),
context.this_address(),
selector,
[arg_a, arg_b]
Expand Down Expand Up @@ -397,7 +397,7 @@ contract AvmTest {
context.this_address(),
selector,
[arg_a, arg_b],
GasOpts::empty()
GasOpts::default()
);
// this explicit size in the return variable is necessary to ensure that ret_size is compile-time
// (ensure the data_to_return is in a HeapArray not a HeapVector)
Expand All @@ -412,7 +412,7 @@ contract AvmTest {
let selector = FunctionSelector::from_signature("add_args_return(Field,Field)").to_field();

let (result_data, success): ([Field; 1], u8) = context.static_call_public_function_raw(
GasOpts::empty(),
GasOpts::default(),
context.this_address(),
selector,
[arg_a, arg_b]
Expand All @@ -427,7 +427,7 @@ contract AvmTest {
let selector = FunctionSelector::from_signature("set_storage_single(Field)").to_field();
let calldata: [Field; 1] = [20];

let (_data_to_return, success): ([Field; 0], u8) = context.static_call_public_function_raw(GasOpts::empty(), context.this_address(), selector, calldata);
let (_data_to_return, success): ([Field; 0], u8) = context.static_call_public_function_raw(GasOpts::default(), context.this_address(), selector, calldata);

success
}
Expand All @@ -441,7 +441,7 @@ contract AvmTest {
context.this_address(),
selector,
[arg_a, arg_b],
GasOpts::empty()
GasOpts::default()
);

result_data[0]
Expand All @@ -453,6 +453,6 @@ contract AvmTest {
let selector = FunctionSelector::from_signature("set_storage_single(Field)");
let calldata: [Field; 1] = [20];

let _resultData: [Field; RETURN_VALUES_LENGTH] = context.static_call_public_function(context.this_address(), selector, calldata, GasOpts::empty());
let _resultData: [Field; RETURN_VALUES_LENGTH] = context.static_call_public_function(context.this_address(), selector, calldata, GasOpts::default());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract Benchmarking {
context.this_address(),
FunctionSelector::from_signature("broadcast((Field))"),
[owner.to_field()],
GasOpts::empty()
GasOpts::default()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ contract Child {
context.this_address(),
pub_set_value_selector,
[10],
GasOpts::empty()
GasOpts::default()
);

storage.current_value.write(20);
Expand All @@ -113,7 +113,7 @@ contract Child {
context.this_address(),
pub_set_value_selector,
[10],
GasOpts::empty()
GasOpts::default()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Token {
self.address,
FunctionSelector::from_signature("transfer_public((Field),(Field),Field,Field)"),
[from.to_field(), to.to_field(), amount, nonce],
GasOpts::empty()
GasOpts::default()
);
}

Expand All @@ -40,7 +40,7 @@ impl Token {
self.address,
FunctionSelector::from_signature("shield((Field),Field,Field,Field)"),
[from.to_field(), amount, secret_hash, nonce],
GasOpts::empty()
GasOpts::default()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ contract FPC {
storage.gas_token_address.read_public(),
FunctionSelector::from_signature("pay_fee(Field)"),
[amount],
GasOpts::empty()
GasOpts::default()
)[0];

// Just do public refunds for the present
Expand All @@ -80,7 +80,7 @@ contract FPC {
storage.gas_token_address.read_public(),
FunctionSelector::from_signature("pay_fee(Field)"),
[amount],
GasOpts::empty()
GasOpts::default()
)[0];

Token::at(asset).shield(&mut context, context.this_address(), refund, secret_hash, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl PriceFeed {
self.address,
FunctionSelector::from_signature("get_price(Field)"),
[0],
GasOpts::empty()
GasOpts::default()
);

U128::from_integer(return_values[0])
Expand Down Expand Up @@ -47,7 +47,7 @@ impl Token {
self.address,
FunctionSelector::from_signature("transfer_public((Field),(Field),Field,Field)"),
[from.to_field(), to.to_field(), amount, nonce],
GasOpts::empty()
GasOpts::default()
);
}

Expand All @@ -56,7 +56,7 @@ impl Token {
self.address,
FunctionSelector::from_signature("mint_public((Field),Field)"),
[to.to_field(), amount],
GasOpts::empty()
GasOpts::default()
);
}

Expand All @@ -71,7 +71,7 @@ impl Token {
self.address,
FunctionSelector::from_signature("burn_public((Field),Field,Field)"),
[from.to_field(), amount, nonce],
GasOpts::empty()
GasOpts::default()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ contract Lending {
context.this_address(),
selector,
[on_behalf_of, amount, collateral_asset.to_field()],
GasOpts::empty()
GasOpts::default()
);
}

Expand Down Expand Up @@ -162,7 +162,7 @@ contract Lending {
context.this_address(),
selector,
[context.msg_sender().to_field(), to.to_field(), amount],
GasOpts::empty()
GasOpts::default()
);
}

Expand Down Expand Up @@ -221,7 +221,7 @@ contract Lending {
context.this_address(),
selector,
[context.msg_sender().to_field(), to.to_field(), amount],
GasOpts::empty()
GasOpts::default()
);
}

Expand Down Expand Up @@ -285,7 +285,7 @@ contract Lending {
context.this_address(),
selector,
[owner.to_field(), amount, stable_coin.to_field()],
GasOpts::empty()
GasOpts::default()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract Parent {
target_contract,
target_selector,
[init_value],
GasOpts::empty()
GasOpts::default()
);

return_values[0]
Expand All @@ -41,13 +41,13 @@ contract Parent {
target_contract,
target_selector,
[init_value],
GasOpts::empty()
GasOpts::default()
)[0];
let return_values = context.call_public_function(
target_contract,
target_selector,
[return_value],
GasOpts::empty()
GasOpts::default()
);

return_values[0]
Expand Down Expand Up @@ -202,7 +202,7 @@ contract Parent {
target_selector: FunctionSelector,
args: [Field; 1]
) -> Field {
let return_values = context.static_call_public_function(target_contract, target_selector, args, GasOpts::empty());
let return_values = context.static_call_public_function(target_contract, target_selector, args, GasOpts::default());

return_values[0]
}
Expand All @@ -221,7 +221,7 @@ contract Parent {
this_address,
pub_entry_point_selector,
[target_contract.to_field(), target_selector.to_field(), args[0]],
GasOpts::empty()
GasOpts::default()
);
return_values[0]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract StatefulTest {
context.this_address(),
selector,
[owner.to_field(), value],
GasOpts::empty()
GasOpts::default()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ impl TestPublicContextInterface {
self.address,
FunctionSelector::from_field(0x9e88565a),
serialized_args,
GasOpts::empty()
GasOpts::default()
)
}

Expand All @@ -620,7 +620,7 @@ impl TestPublicContextInterface {
self.address,
FunctionSelector::from_field(0x9749ca06),
serialized_args,
GasOpts::empty()
GasOpts::default()
)
}

Expand All @@ -638,7 +638,7 @@ impl TestPublicContextInterface {
self.address,
FunctionSelector::from_field(0x2fb25188),
serialized_args,
GasOpts::empty()
GasOpts::default()
)
}

Expand All @@ -650,7 +650,7 @@ impl TestPublicContextInterface {
self.address,
FunctionSelector::from_field(0xb5bb17fa),
serialized_args,
GasOpts::empty()
GasOpts::default()
)
}

Expand All @@ -670,7 +670,7 @@ impl TestPublicContextInterface {
self.address,
FunctionSelector::from_field(0xa0f84219),
serialized_args,
GasOpts::empty()
GasOpts::default()
)
}

Expand All @@ -690,7 +690,7 @@ impl TestPublicContextInterface {
self.address,
FunctionSelector::from_field(0x42ca6d60),
serialized_args,
GasOpts::empty()
GasOpts::default()
)
}

Expand All @@ -706,7 +706,7 @@ impl TestPublicContextInterface {
self.address,
FunctionSelector::from_field(0x817a64cb),
serialized_args,
GasOpts::empty()
GasOpts::default()
)
}

Expand All @@ -724,7 +724,7 @@ impl TestPublicContextInterface {
self.address,
FunctionSelector::from_field(0xdf02db8d),
serialized_args,
GasOpts::empty()
GasOpts::default()
)
}

Expand All @@ -740,7 +740,7 @@ impl TestPublicContextInterface {
self.address,
FunctionSelector::from_field(0x86e38c61),
serialized_args,
GasOpts::empty()
GasOpts::default()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl SlowMap {
self.address,
FunctionSelector::from_signature("read_at_pub(Field)"),
[index],
GasOpts::empty()
GasOpts::default()
);
_return_values[0]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl Token {
self.address,
FunctionSelector::from_signature("mint_public((Field),Field)"),
[to.to_field(), amount],
GasOpts::empty()
GasOpts::default()
);
}

Expand All @@ -32,7 +32,7 @@ impl Token {
self.address,
FunctionSelector::from_signature("burn_public((Field),Field,Field)"),
[from.to_field(), amount, nonce],
GasOpts::empty()
GasOpts::default()
);
}
// docs:end:public_burn_interface
Expand All @@ -42,7 +42,7 @@ impl Token {
self.address,
FunctionSelector::from_signature("mint_private(Field,Field)"),
[amount, secret_hash],
GasOpts::empty()
GasOpts::default()
);
}

Expand Down
Loading

0 comments on commit 8fa9373

Please sign in to comment.