-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: format submodule/contract (#3286)
- Loading branch information
kek kek kek
authored
Oct 25, 2023
1 parent
51831df
commit 534774d
Showing
12 changed files
with
324 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | ||
// Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. | ||
// Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. | ||
// Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | ||
contract Benchmarking { | ||
use dep::value_note::{ | ||
utils::{increment, decrement}, | ||
value_note::{VALUE_NOTE_LEN, ValueNote, ValueNoteMethods}, | ||
}; | ||
|
||
use dep::aztec::{ | ||
context::{Context}, | ||
note::{utils as note_utils, note_getter_options::NoteGetterOptions, note_header::NoteHeader}, | ||
selector::compute_selector, | ||
log::emit_unencrypted_log, | ||
state_vars::{map::Map, public_state::PublicState, set::Set}, | ||
types::type_serialization::field_serialization::{FieldSerializationMethods, FIELD_SERIALIZED_LEN}, | ||
types::address::{AztecAddress}, | ||
}; | ||
|
||
struct Storage { | ||
notes: Map<Set<ValueNote, VALUE_NOTE_LEN>>, | ||
balances: Map<PublicState<Field, FIELD_SERIALIZED_LEN>>, | ||
} | ||
|
||
impl Storage { | ||
fn init(context: Context) -> pub Self { | ||
Storage { | ||
notes: Map::new(context, 1, |context, slot| { Set::new(context, slot, ValueNoteMethods) }), | ||
balances: Map::new(context, 2, |context, slot| { PublicState::new(context, slot, FieldSerializationMethods) }), | ||
} | ||
} | ||
} | ||
|
||
#[aztec(private)] | ||
fn constructor() {} | ||
|
||
// Nec tincidunt praesent semper feugiat nibh sed pulvinar. Nibh nisl condimentum id venenatis a. | ||
#[aztec(private)] | ||
fn create_note(owner: Field, value: Field) { | ||
increment(storage.notes.at(owner), value, owner); | ||
} | ||
|
||
// Diam quam nulla porttitor massa id. Elit ullamcorper dignissim cras tincidunt lobortis feugiat. | ||
#[aztec(private)] | ||
fn recreate_note(owner: Field, index: u32) { | ||
let owner_notes = storage.notes.at(owner); | ||
let getter_options = NoteGetterOptions::new().set_limit(1).set_offset(index); | ||
let notes = owner_notes.get_notes(getter_options); | ||
let note = notes[0].unwrap_unchecked(); | ||
owner_notes.remove(note); | ||
increment(owner_notes, note.value, owner); | ||
} | ||
|
||
// Ultrices in iaculis nunc sed augue lacus. | ||
#[aztec(public)] | ||
fn increment_balance(owner: Field, value: Field) { | ||
let current = storage.balances.at(owner).read(); | ||
storage.balances.at(owner).write(current + value); | ||
let _callStackItem1 = context.call_public_function(context.this_address(), compute_selector("broadcast(Field)"), [owner]); | ||
} | ||
|
||
// Est ultricies integer quis auctor elit sed. In nibh mauris cursus mattis molestie a iaculis. | ||
#[aztec(public)] | ||
fn broadcast(owner: Field) { | ||
emit_unencrypted_log(&mut context, storage.balances.at(owner).read()); | ||
} | ||
|
||
unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: Field, storage_slot: Field, preimage: [Field; VALUE_NOTE_LEN]) -> [Field; 4] { | ||
let note_header = NoteHeader::new(contract_address, nonce, storage_slot); | ||
note_utils::compute_note_hash_and_nullifier(ValueNoteMethods, note_header, preimage) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
mod a { | ||
// hello | ||
} | ||
|
||
mod a { | ||
// hello | ||
mod b { | ||
// hello | ||
} | ||
} | ||
|
||
mod a { | ||
mod b { | ||
mod c {} | ||
} | ||
} | ||
|
||
mod a { | ||
// 1 | ||
// 2 | ||
// 3 | ||
/*test*/ | ||
} | ||
|
||
mod a { | ||
/**/ | ||
mod b { | ||
mod c {} | ||
} | ||
} |
Oops, something went wrong.