11use crate::context::PrivateContext ;
22
3- use dep::protocol_types:: {
4- constants::DOM_SEP__TX_NULLIFIER , hash:: poseidon2_hash_with_separator , traits::Hash ,
5- };
3+ use protocol_types:: {constants::DOM_SEP__TX_NULLIFIER , hash:: poseidon2_hash_with_separator , traits::Hash };
64
75use crate::authwit::auth:: {compute_authwit_message_hash , IS_VALID_SELECTOR };
86use crate::authwit::entrypoint::app::AppPayload ;
@@ -19,40 +17,36 @@ impl<Context> AccountActions<Context> {
1917}
2018
2119// See AccountFeePaymentMethodOptions enum in Aztec.js for docs:
20+ //
21+ //
2222// https://github.com/AztecProtocol/aztec-packages/blob/next/yarn-project/entrypoints/src/account_entrypoint.ts
2323pub struct AccountFeePaymentMethodOptionsEnum {
2424 pub EXTERNAL : u8 ,
2525 pub PREEXISTING_FEE_JUICE : u8 ,
2626 pub FEE_JUICE_WITH_CLAIM : u8 ,
2727}
2828
29- pub global AccountFeePaymentMethodOptions : AccountFeePaymentMethodOptionsEnum = AccountFeePaymentMethodOptionsEnum {
30- EXTERNAL : 0 ,
31- PREEXISTING_FEE_JUICE : 1 ,
32- FEE_JUICE_WITH_CLAIM : 2 ,
33- };
29+ pub global AccountFeePaymentMethodOptions : AccountFeePaymentMethodOptionsEnum =
30+ AccountFeePaymentMethodOptionsEnum { EXTERNAL : 0 , PREEXISTING_FEE_JUICE : 1 , FEE_JUICE_WITH_CLAIM : 2 };
3431
35- /**
36- * An implementation of the Account Action struct for the private context.
37- *
38- * Implements logic to verify authorization and execute payloads.
39- */
32+ /// An implementation of the Account Action struct for the private context.
33+ ///
34+ /// Implements logic to verify authorization and execute payloads.
4035impl AccountActions <&mut PrivateContext > {
4136
4237 /// Verifies that the `app_hash` is authorized and executes the `app_payload`.
4338 ///
4439 /// @param app_payload The payload that contains the calls to be executed in the app phase.
4540 ///
4641 /// @param fee_payment_method The mechanism via which the account contract will pay for the transaction:
47- /// - EXTERNAL (0): Signals that some other contract is in charge of paying the fee, nothing needs to be done.
48- /// - PREEXISTING_FEE_JUICE (1): Makes the account contract publicly pay for the transaction with its own FeeJuice
49- /// balance, which it must already have prior to this transaction. The contract will
50- /// set itself as the fee payer and end the setup phase.
51- /// - FEE_JUICE_WITH_CLAIM (2): Makes the account contract publicly pay for the transaction with its own FeeJuice
52- /// balance which is being claimed in the same transaction. The contract will set
53- /// itself as the fee payer but not end setup phase - this is done by the FeeJuice
54- /// contract after enqueuing a public call, which unlike most public calls is
55- /// whitelisted to be executable during setup.
42+ /// - EXTERNAL (0): Signals that some other contract is in charge of paying the fee, nothing needs to be done.
43+ /// - PREEXISTING_FEE_JUICE (1): Makes the account contract publicly pay for the transaction with its own FeeJuice
44+ /// balance, which it must already have prior to this transaction. The contract will set itself as the fee payer
45+ /// and end the setup phase.
46+ /// - FEE_JUICE_WITH_CLAIM (2): Makes the account contract publicly pay for the transaction with its own FeeJuice
47+ /// balance which is being claimed in the same transaction. The contract will set itself as the fee payer but not
48+ /// end setup phase - this is done by the FeeJuice contract after enqueuing a public call, which unlike most public
49+ /// calls is whitelisted to be executable during setup.
5650 ///
5751 /// @param cancellable Controls whether to emit app_payload.tx_nonce as a nullifier, allowing a subsequent
5852 /// transaction to be sent with a higher priority fee. This can be used to cancel the first transaction sent,
@@ -74,24 +68,22 @@ impl AccountActions<&mut PrivateContext> {
7468 app_payload .execute_calls (self .context );
7569
7670 if cancellable {
77- let tx_nullifier =
78- poseidon2_hash_with_separator ([app_payload .tx_nonce ], DOM_SEP__TX_NULLIFIER );
71+ let tx_nullifier = poseidon2_hash_with_separator ([app_payload .tx_nonce ], DOM_SEP__TX_NULLIFIER );
7972 self .context .push_nullifier (tx_nullifier );
8073 }
8174 }
8275
8376 /// Verifies that the `msg_sender` is authorized to consume `inner_hash` by the account.
8477 ///
85- /// Computes the `message_hash` using the `msg_sender`, `chain_id`, `version` and `inner_hash`.
86- /// Then executes the `is_valid_impl` function to verify that the message is authorized.
78+ /// Computes the `message_hash` using the `msg_sender`, `chain_id`, `version` and `inner_hash`. Then executes the
79+ /// `is_valid_impl` function to verify that the message is authorized.
8780 ///
8881 /// Will revert if the message is not authorized.
8982 ///
9083 /// @param inner_hash The hash of the message that the `msg_sender` is trying to consume.
9184 pub fn verify_private_authwit (self , inner_hash : Field ) -> Field {
92- // The `inner_hash` is "siloed" with the `msg_sender` to ensure that only it can
93- // consume the message.
94- // This ensures that contracts cannot consume messages that are not intended for them.
85+ // The `inner_hash` is "siloed" with the `msg_sender` to ensure that only it can consume the message. This
86+ // ensures that contracts cannot consume messages that are not intended for them.
9587 let message_hash = compute_authwit_message_hash (
9688 self .context .maybe_msg_sender ().unwrap (),
9789 self .context .chain_id (),
0 commit comments