1- use crate:: {authwit:: utils ::{compute_inner_authwit_hash , IS_VALID_SELECTOR }, context ::{gas::GasOpts , PublicContext }};
2- use crate::protocol:: {abis::function_selector::FunctionSelector , address::AztecAddress , traits::ToField };
1+ use crate::authwit::auth_registry_interface::AuthRegistryInterface ;
2+ use crate::authwit::utils:: {compute_inner_authwit_hash , IS_VALID_SELECTOR };
3+ use crate::context::PublicContext ;
4+ use crate::protocol:: {address::AztecAddress , traits::ToField };
35use crate::standard_addresses::STANDARD_AUTH_REGISTRY_ADDRESS ;
46
57/// Public-flow authwit helpers.
@@ -86,14 +88,8 @@ pub unconstrained fn assert_inner_hash_valid_authwit_public(
8688 on_behalf_of : AztecAddress ,
8789 inner_hash : Field ,
8890) {
89- let results : [Field ] = context .call_public_function (
90- STANDARD_AUTH_REGISTRY_ADDRESS ,
91- comptime { FunctionSelector ::from_signature ("consume((Field),Field)" ) },
92- [on_behalf_of .to_field (), inner_hash ],
93- GasOpts ::default (),
94- );
95- assert (results .len () == 1 , "Invalid response from registry" );
96- assert (results [0 ] == IS_VALID_SELECTOR , "Message not authorized by account" );
91+ let result = AuthRegistryInterface ::at (STANDARD_AUTH_REGISTRY_ADDRESS ).consume (on_behalf_of , inner_hash ).call (context );
92+ assert (result == IS_VALID_SELECTOR , "Message not authorized by account" );
9793}
9894
9995/// Helper function to set the authorization status of a message hash
@@ -103,13 +99,7 @@ pub unconstrained fn assert_inner_hash_valid_authwit_public(
10399/// @param message_hash The hash of the message to authorize @param authorize True if the message should be authorized,
104100/// false if it should be revoked
105101pub unconstrained fn set_authorized (context : PublicContext , message_hash : Field , authorize : bool ) {
106- let res = context .call_public_function (
107- STANDARD_AUTH_REGISTRY_ADDRESS ,
108- comptime { FunctionSelector ::from_signature ("set_authorized(Field,bool)" ) },
109- [message_hash , authorize as Field ],
110- GasOpts ::default (),
111- );
112- assert (res .len () == 0 );
102+ AuthRegistryInterface ::at (STANDARD_AUTH_REGISTRY_ADDRESS ).set_authorized (message_hash , authorize ).call (context );
113103}
114104
115105/// Helper function to reject all authwits
@@ -118,11 +108,5 @@ pub unconstrained fn set_authorized(context: PublicContext, message_hash: Field,
118108///
119109/// @param reject True if all authwits should be rejected, false otherwise
120110pub unconstrained fn set_reject_all (context : PublicContext , reject : bool ) {
121- let res = context .call_public_function (
122- STANDARD_AUTH_REGISTRY_ADDRESS ,
123- comptime { FunctionSelector ::from_signature ("set_reject_all(bool)" ) },
124- [reject as Field ],
125- GasOpts ::default (),
126- );
127- assert (res .len () == 0 );
111+ AuthRegistryInterface ::at (STANDARD_AUTH_REGISTRY_ADDRESS ).set_reject_all (reject ).call (context );
128112}
0 commit comments