-
Notifications
You must be signed in to change notification settings - Fork 599
feat: TXE 2: Electric boogaloo #7154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 92 commits
39e88bf
de4dfef
584250d
8c5bdf1
3fbc3ee
58c4c82
84af5e8
aab9959
c94d32e
5d857ae
717a16a
58e7bfa
d543edf
92b9a48
c6fdef6
b29b3a4
6628ab0
460a1d1
069a09a
7edc719
f2820a7
cbe1564
2250b98
45434f9
c180bdb
a34bf85
fdbeaf8
12453ea
fdd5cf1
ff3fa71
ea506ab
562e92e
e037804
21f3178
c543a2c
0d1221a
6083ade
b80f6c7
ca42523
38fb77e
dc373da
85b7dec
84292d0
907e26d
5a92553
8b278a1
cf027a2
5e9486e
bbeaa00
963990a
a68fec7
44d63aa
9f1dbe6
93f32d0
19123bd
35fe257
e41a19c
1ccfe4f
eb48006
cca4e8c
83c16e5
f564d92
083b1f8
2155e79
d214093
0a1c2e1
2d934d3
e711f21
553a904
9a09e2b
e3c5f71
891d331
c6b4675
fcf7823
5dc4c9a
1206b87
05cdb9c
aa8e006
53b2192
f180efd
2c2424d
937f561
04d215a
e76229a
899c65a
bd944d2
9b80629
44366a5
0227efe
625a492
151e312
19e323f
d5f28b4
9c55d33
8095410
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| use dep::aztec::{ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find some of the cheatcode structure slightly odd, e.g., having it a bit all over the place instead of having a folder just with cheatcodes. Ideally think it would be nice to have it outside of the others, to not pollute 🤷. But it is something I think we could deal with in a separate PR. Might also just be that I am not thinking about something and we need it this way 👍.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of it is in We could have a separate crate, but I though it wouldn't be so bad if our packages exported their tests interfaces themselves. |
||
| protocol_types::address::AztecAddress, | ||
| context::{public_context::PublicContext, call_interfaces::CallInterface}, test::helpers::cheatcodes, | ||
| hash::hash_args | ||
| }; | ||
|
|
||
| use crate::auth::{compute_inner_authwit_hash, compute_outer_authwit_hash, set_authorized}; | ||
|
|
||
| pub fn add_private_authwit_from_call_interface<C, M, T, P, Env>( | ||
| on_behalf_of: AztecAddress, | ||
| caller: AztecAddress, | ||
| call_interface: C | ||
| ) where C: CallInterface<M, T, P, Env> { | ||
| let target = call_interface.get_contract_address(); | ||
| let inputs = cheatcodes::get_private_context_inputs(cheatcodes::get_block_number()); | ||
| let chain_id = inputs.tx_context.chain_id; | ||
| let version = inputs.tx_context.version; | ||
| let args_hash = hash_args(call_interface.get_args()); | ||
| let selector = call_interface.get_selector(); | ||
| let inner_hash = compute_inner_authwit_hash([caller.to_field(), selector.to_field(), args_hash]); | ||
| let message_hash = compute_outer_authwit_hash(target, chain_id, version, inner_hash); | ||
| cheatcodes::add_authwit(on_behalf_of, message_hash); | ||
| } | ||
|
|
||
| pub fn add_public_authwit_from_call_interface<C, M, T, P, Env>( | ||
| on_behalf_of: AztecAddress, | ||
| caller: AztecAddress, | ||
| call_interface: C | ||
| ) where C: CallInterface<M, T, P, Env> { | ||
| let current_contract = cheatcodes::get_contract_address(); | ||
| cheatcodes::set_contract_address(on_behalf_of); | ||
| let target = call_interface.get_contract_address(); | ||
| let inputs = cheatcodes::get_private_context_inputs(cheatcodes::get_block_number()); | ||
| let chain_id = inputs.tx_context.chain_id; | ||
| let version = inputs.tx_context.version; | ||
| let args_hash = hash_args(call_interface.get_args()); | ||
| let selector = call_interface.get_selector(); | ||
| let inner_hash = compute_inner_authwit_hash([caller.to_field(), selector.to_field(), args_hash]); | ||
| let message_hash = compute_outer_authwit_hash(target, chain_id, version, inner_hash); | ||
| let mut inputs = cheatcodes::get_public_context_inputs(); | ||
| let mut context = PublicContext::new(inputs); | ||
| set_authorized(&mut context, message_hash, true); | ||
| cheatcodes::set_contract_address(current_contract); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,4 @@ mod account; | |
| mod auth_witness; | ||
| mod auth; | ||
| mod entrypoint; | ||
| mod cheatcodes; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| mod test_environment; | ||
| mod cheatcodes; | ||
| mod types; | ||
| mod utils; | ||
| mod keys; |
Uh oh!
There was an error while loading. Please reload this page.