-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
234 additions
and
175 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
use dep::protocol_types::traits::{Deserialize, Serialize}; | ||
|
||
#[oracle(storageRead)] | ||
fn storage_read_oracle<N>(_storage_slot: Field, _number_of_elements: Field) -> [Field; N] {} | ||
fn storage_read_oracle(_storage_slot: Field) -> Field {} | ||
|
||
unconstrained fn storage_read_oracle_wrapper<N>(_storage_slot: Field) -> [Field; N] { | ||
storage_read_oracle(_storage_slot, N) | ||
unconstrained fn storage_read_oracle_wrapper(storage_slot: Field) -> Field { | ||
storage_read_oracle(storage_slot) | ||
} | ||
|
||
pub fn storage_read<N>(storage_slot: Field) -> [Field; N] { | ||
storage_read_oracle_wrapper(storage_slot) | ||
let mut ret: [Field; N] = [0; N]; | ||
for i in 0..N { | ||
ret[i] = storage_read_oracle_wrapper(storage_slot + (i as Field)); | ||
} | ||
ret | ||
} | ||
|
||
#[oracle(storageWrite)] | ||
fn storage_write_oracle<N>(_storage_slot: Field, _values: [Field; N]) -> [Field; N] {} | ||
fn storage_write_oracle(_storage_slot: Field, _value: Field) {} | ||
|
||
unconstrained pub fn storage_write<N>(storage_slot: Field, fields: [Field; N]) { | ||
let _hash = storage_write_oracle(storage_slot, fields); | ||
unconstrained fn storage_write_oracle_wrapper(storage_slot: Field, value: Field) { | ||
storage_write_oracle(storage_slot, value); | ||
} | ||
|
||
pub fn storage_write<N>(storage_slot: Field, fields: [Field; N]) { | ||
for i in 0..N { | ||
storage_write_oracle_wrapper(storage_slot + (i as Field), fields[i]); | ||
} | ||
} |
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
Oops, something went wrong.