Skip to content

Commit e5e600b

Browse files
committed
refactor(public_checks): move caller helpers into aztec-nr
1 parent e216fbc commit e5e600b

7 files changed

Lines changed: 23 additions & 10 deletions

File tree

noir-projects/aztec-nr/aztec/src/lib.nr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub use protocol_types as protocol;
4646
pub(crate) mod logging;
4747
pub mod utils;
4848
pub mod authwit;
49+
pub mod public_checks;
4950
pub mod macros;
5051

5152
pub mod test;

noir-projects/noir-contracts/contracts/protocol/public_checks_contract/src/utils.nr renamed to noir-projects/aztec-nr/aztec/src/public_checks.nr

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use crate::PublicChecks;
2-
use aztec::context::PrivateContext;
3-
use aztec::protocol::constants::PUBLIC_CHECKS_ADDRESS;
1+
use crate::context::calls::PublicStaticCall;
2+
use crate::context::PrivateContext;
3+
use crate::protocol::abis::function_selector::FunctionSelector;
4+
use crate::protocol::constants::PUBLIC_CHECKS_ADDRESS;
45

56
// docs:start:helper_public_checks_functions
67
/// Asserts that the current timestamp in the enqueued public call enqueued by `check_timestamp` satisfies
@@ -9,7 +10,14 @@ use aztec::protocol::constants::PUBLIC_CHECKS_ADDRESS;
910
/// This conceals an address of the calling contract by setting `context.msg_sender` to the public checks contract
1011
/// address.
1112
pub fn privately_check_timestamp(operation: u8, value: u64, context: &mut PrivateContext) {
12-
PublicChecks::at(PUBLIC_CHECKS_ADDRESS).check_timestamp(operation, value).enqueue_view_incognito(context);
13+
let selector = comptime { FunctionSelector::from_signature("check_timestamp(u8,u64)") };
14+
PublicStaticCall::<15, 2, ()>::new(
15+
PUBLIC_CHECKS_ADDRESS,
16+
selector,
17+
"check_timestamp",
18+
[operation as Field, value as Field],
19+
)
20+
.enqueue_view_incognito(context);
1321
}
1422

1523
/// Asserts that the current block number in the enqueued public call enqueued by `check_block_number` satisfies
@@ -19,7 +27,14 @@ pub fn privately_check_timestamp(operation: u8, value: u64, context: &mut Privat
1927
/// address.
2028
pub fn privately_check_block_number(operation: u8, value: u32, context: &mut PrivateContext) {
2129
// docs:start:enqueueing
22-
PublicChecks::at(PUBLIC_CHECKS_ADDRESS).check_block_number(operation, value).enqueue_view_incognito(context);
30+
let selector = comptime { FunctionSelector::from_signature("check_block_number(u8,u32)") };
31+
PublicStaticCall::<18, 2, ()>::new(
32+
PUBLIC_CHECKS_ADDRESS,
33+
selector,
34+
"check_block_number",
35+
[operation as Field, value as Field],
36+
)
37+
.enqueue_view_incognito(context);
2338
// docs:end:enqueueing
2439
}
2540
// docs:end:helper_public_checks_functions

noir-projects/noir-contracts/contracts/app/app_subscription_contract/Nargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ type = "contract"
77
[dependencies]
88
aztec = { path = "../../../../aztec-nr/aztec" }
99
token = { path = "../token_contract" }
10-
public_checks = { path = "../../protocol/public_checks_contract" }

noir-projects/noir-contracts/contracts/app/app_subscription_contract/src/main.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub contract AppSubscription {
5252
state_vars::{Owned, PrivateMutable, PublicImmutable},
5353
utils::comparison::Comparator,
5454
};
55-
use public_checks::utils::privately_check_block_number;
55+
use aztec::public_checks::privately_check_block_number;
5656
use token::Token;
5757

5858
#[storage]

noir-projects/noir-contracts/contracts/app/crowdfunding_contract/Nargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ type = "contract"
88
aztec = { path = "../../../../aztec-nr/aztec" }
99
uint_note = { path = "../../../../aztec-nr/uint-note" }
1010
token = { path = "../token_contract" }
11-
public_checks = { path = "../../protocol/public_checks_contract" }

noir-projects/noir-contracts/contracts/app/crowdfunding_contract/src/main.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub contract Crowdfunding {
1313
utils::{array, comparison::Comparator},
1414
};
1515
use aztec::note::{constants::MAX_NOTES_PER_PAGE, HintedNote, note_getter_options::NoteStatus};
16-
use public_checks::utils::privately_check_timestamp;
16+
use aztec::public_checks::privately_check_timestamp;
1717
use token::Token;
1818
use uint_note::UintNote;
1919

noir-projects/noir-contracts/contracts/protocol/public_checks_contract/src/main.nr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
mod test;
2-
pub mod utils;
32

43
use aztec::macros::aztec;
54

0 commit comments

Comments
 (0)