-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Revert): "refactor: purge unconstrained functions where possible" (…
…#5911) Reverts #5819. The use of constrained functions made the writing of tests etc nicer, but the testing time absolutely exploded as an effect 💀 Co-authored-by: ludamad <[email protected]>
- Loading branch information
Showing
18 changed files
with
250 additions
and
112 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
30 changes: 0 additions & 30 deletions
30
noir-projects/noir-contracts/contracts/lending_contract/src/position.nr
This file was deleted.
Oops, something went wrong.
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
9 changes: 9 additions & 0 deletions
9
noir-projects/noir-contracts/contracts/reader_contract/Nargo.toml
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,9 @@ | ||
[package] | ||
name = "reader_contract" | ||
authors = [""] | ||
compiler_version = ">=0.25.0" | ||
type = "contract" | ||
|
||
[dependencies] | ||
aztec = { path = "../../../aztec-nr/aztec" } | ||
compressed_string = { path = "../../../aztec-nr/compressed-string" } |
69 changes: 69 additions & 0 deletions
69
noir-projects/noir-contracts/contracts/reader_contract/src/main.nr
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,69 @@ | ||
contract Reader { | ||
use dep::aztec::prelude::{AztecAddress, FunctionSelector, Deserialize}; | ||
|
||
use dep::compressed_string::FieldCompressedString; | ||
|
||
#[aztec(private)] | ||
fn constructor() {} | ||
|
||
#[aztec(public)] | ||
fn check_name_public(who: AztecAddress, what: str<31>) { | ||
let selector = FunctionSelector::from_signature("public_get_name()"); | ||
let name: FieldCompressedString = context.call_public_function_no_args(who, selector).deserialize_into(); | ||
let _what = FieldCompressedString::from_string(what); | ||
assert(name.is_eq(_what)); | ||
} | ||
|
||
#[aztec(private)] | ||
fn check_name_private(who: AztecAddress, what: str<31>) { | ||
let selector = FunctionSelector::from_signature("private_get_name()"); | ||
let name: FieldCompressedString = context.call_private_function_no_args(who, selector).unpack_into(); | ||
let _what = FieldCompressedString::from_string(what); | ||
assert(name.is_eq(_what)); | ||
} | ||
|
||
unconstrained fn get_name(who: AztecAddress) -> pub str<6> { | ||
// We cannot yet call an unconstrained function from another | ||
"Reader" | ||
} | ||
|
||
#[aztec(public)] | ||
fn check_symbol_public(who: AztecAddress, what: str<31>) { | ||
let selector = FunctionSelector::from_signature("public_get_symbol()"); | ||
let symbol: FieldCompressedString = context.call_public_function_no_args(who, selector).deserialize_into(); | ||
let _what = FieldCompressedString::from_string(what); | ||
assert(symbol.is_eq(_what)); | ||
} | ||
|
||
#[aztec(private)] | ||
fn check_symbol_private(who: AztecAddress, what: str<31>) { | ||
let selector = FunctionSelector::from_signature("private_get_symbol()"); | ||
let symbol: FieldCompressedString = context.call_private_function_no_args(who, selector).unpack_into(); | ||
let _what = FieldCompressedString::from_string(what); | ||
assert(symbol.is_eq(_what)); | ||
} | ||
|
||
unconstrained fn get_symbol(who: AztecAddress) -> pub str<3> { | ||
// We cannot yet call an unconstrained function from another | ||
"RDR" | ||
} | ||
|
||
#[aztec(public)] | ||
fn check_decimals_public(who: AztecAddress, what: u8) { | ||
let selector = FunctionSelector::from_signature("public_get_decimals()"); | ||
let ret: u8 = context.call_public_function_no_args(who, selector).deserialize_into(); | ||
assert(ret == what); | ||
} | ||
|
||
#[aztec(private)] | ||
fn check_decimals_private(who: AztecAddress, what: u8) { | ||
let selector = FunctionSelector::from_signature("private_get_decimals()"); | ||
let result: u8 = context.call_private_function_no_args(who, selector).unpack_into(); | ||
assert(result == what); | ||
} | ||
|
||
unconstrained fn get_decimals(who: AztecAddress) -> pub u8 { | ||
// We cannot yet call an unconstrained function from another | ||
18 | ||
} | ||
} |
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.