Struct MockWallet
pub struct MockWallet { /* private fields */ }Expand description
In-memory test wallet implementation.
Provides configurable behavior for testing contract interactions without a real wallet backend. Simulation and send calls return configurable default results.
Implementations§
§impl MockWallet
impl MockWallet
pub fn new(chain_info: ChainInfo) -> MockWallet
pub fn new(chain_info: ChainInfo) -> MockWallet
Create a new mock wallet with the given chain info and sensible defaults.
pub fn with_simulate_result(self, result: TxSimulationResult) -> MockWallet
pub fn with_simulate_result(self, result: TxSimulationResult) -> MockWallet
Set the default result returned by simulate_tx.
pub fn with_send_result(self, result: SendResult) -> MockWallet
pub fn with_send_result(self, result: SendResult) -> MockWallet
Set the default result returned by send_tx.
pub fn add_account(
&self,
address: AztecAddress,
alias: Option<String>,
) -> Result<(), Error>
pub fn add_account( &self, address: AztecAddress, alias: Option<String>, ) -> Result<(), Error>
Add an account to the mock wallet.
pub fn register_contract_class(
&self,
class_id: Fr,
metadata: ContractClassMetadata,
) -> Result<(), Error>
pub fn register_contract_class( &self, class_id: Fr, metadata: ContractClassMetadata, ) -> Result<(), Error>
Register a contract class in the mock wallet.
Trait Implementations§
§impl Wallet for MockWallet
impl Wallet for MockWallet
§fn get_chain_info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ChainInfo, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
fn get_chain_info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ChainInfo, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
Get chain identification information.
§fn get_accounts<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Aliased<AztecAddress>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
fn get_accounts<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Aliased<AztecAddress>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
Get the list of accounts managed by this wallet.
§fn get_address_book<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Aliased<AztecAddress>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
fn get_address_book<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Aliased<AztecAddress>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
Get the address book entries.
§fn register_sender<'life0, 'async_trait>(
&'life0 self,
address: AztecAddress,
alias: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<AztecAddress, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
fn register_sender<'life0, 'async_trait>(
&'life0 self,
address: AztecAddress,
alias: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<AztecAddress, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
Register a sender address with an optional alias.
§fn get_contract_metadata<'life0, 'async_trait>(
&'life0 self,
address: AztecAddress,
) -> Pin<Box<dyn Future<Output = Result<ContractMetadata, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
fn get_contract_metadata<'life0, 'async_trait>(
&'life0 self,
address: AztecAddress,
) -> Pin<Box<dyn Future<Output = Result<ContractMetadata, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
Get metadata about a registered contract.
§fn get_contract_class_metadata<'life0, 'async_trait>(
&'life0 self,
class_id: Fr,
) -> Pin<Box<dyn Future<Output = Result<ContractClassMetadata, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
fn get_contract_class_metadata<'life0, 'async_trait>(
&'life0 self,
class_id: Fr,
) -> Pin<Box<dyn Future<Output = Result<ContractClassMetadata, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
Get metadata about a registered contract class.
§fn register_contract<'life0, 'async_trait>(
&'life0 self,
instance: ContractInstanceWithAddress,
artifact: Option<ContractArtifact>,
_secret_key: Option<Fr>,
) -> Pin<Box<dyn Future<Output = Result<ContractInstanceWithAddress, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
fn register_contract<'life0, 'async_trait>(
&'life0 self,
instance: ContractInstanceWithAddress,
artifact: Option<ContractArtifact>,
_secret_key: Option<Fr>,
) -> Pin<Box<dyn Future<Output = Result<ContractInstanceWithAddress, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
Register a contract instance (and optionally its artifact) with the wallet.
§fn get_private_events<'life0, 'life1, 'async_trait>(
&'life0 self,
_event_metadata: &'life1 EventMetadataDefinition,
_filter: PrivateEventFilter,
) -> Pin<Box<dyn Future<Output = Result<Vec<PrivateEvent>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MockWallet: 'async_trait,
fn get_private_events<'life0, 'life1, 'async_trait>(
&'life0 self,
_event_metadata: &'life1 EventMetadataDefinition,
_filter: PrivateEventFilter,
) -> Pin<Box<dyn Future<Output = Result<Vec<PrivateEvent>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MockWallet: 'async_trait,
Get private events matching the given filter.
§fn simulate_tx<'life0, 'async_trait>(
&'life0 self,
_exec: ExecutionPayload,
_opts: SimulateOptions,
) -> Pin<Box<dyn Future<Output = Result<TxSimulationResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
fn simulate_tx<'life0, 'async_trait>(
&'life0 self,
_exec: ExecutionPayload,
_opts: SimulateOptions,
) -> Pin<Box<dyn Future<Output = Result<TxSimulationResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
Simulate a transaction without sending it.
§fn execute_utility<'life0, 'async_trait>(
&'life0 self,
_call: FunctionCall,
_opts: ExecuteUtilityOptions,
) -> Pin<Box<dyn Future<Output = Result<UtilityExecutionResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
fn execute_utility<'life0, 'async_trait>(
&'life0 self,
_call: FunctionCall,
_opts: ExecuteUtilityOptions,
) -> Pin<Box<dyn Future<Output = Result<UtilityExecutionResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
Execute a utility (view) function.
§fn profile_tx<'life0, 'async_trait>(
&'life0 self,
_exec: ExecutionPayload,
_opts: ProfileOptions,
) -> Pin<Box<dyn Future<Output = Result<TxProfileResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
fn profile_tx<'life0, 'async_trait>(
&'life0 self,
_exec: ExecutionPayload,
_opts: ProfileOptions,
) -> Pin<Box<dyn Future<Output = Result<TxProfileResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
Profile a transaction for gas estimation and performance data.
§fn send_tx<'life0, 'async_trait>(
&'life0 self,
_exec: ExecutionPayload,
_opts: SendOptions,
) -> Pin<Box<dyn Future<Output = Result<SendResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
fn send_tx<'life0, 'async_trait>(
&'life0 self,
_exec: ExecutionPayload,
_opts: SendOptions,
) -> Pin<Box<dyn Future<Output = Result<SendResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
Send a transaction to the network.
§fn wait_for_contract<'life0, 'async_trait>(
&'life0 self,
_address: AztecAddress,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
fn wait_for_contract<'life0, 'async_trait>(
&'life0 self,
_address: AztecAddress,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
Wait until a deployed contract instance is queryable from the node.
§fn wait_for_tx_proven<'life0, 'async_trait>(
&'life0 self,
_tx_hash: TxHash,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
fn wait_for_tx_proven<'life0, 'async_trait>(
&'life0 self,
_tx_hash: TxHash,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
Wait until the block containing a transaction is proven on L1.
§fn create_auth_wit<'life0, 'async_trait>(
&'life0 self,
_from: AztecAddress,
_message_hash_or_intent: MessageHashOrIntent,
) -> Pin<Box<dyn Future<Output = Result<AuthWitness, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
fn create_auth_wit<'life0, 'async_trait>(
&'life0 self,
_from: AztecAddress,
_message_hash_or_intent: MessageHashOrIntent,
) -> Pin<Box<dyn Future<Output = Result<AuthWitness, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockWallet: 'async_trait,
Create an authorization witness.
§fn get_public_storage_at<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_contract: &'life1 AztecAddress,
_slot: &'life2 Fr,
) -> Pin<Box<dyn Future<Output = Result<Fr, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MockWallet: 'async_trait,
fn get_public_storage_at<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_contract: &'life1 AztecAddress,
_slot: &'life2 Fr,
) -> Pin<Box<dyn Future<Output = Result<Fr, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MockWallet: 'async_trait,
Read a public storage value at the given contract address and slot.
Auto Trait Implementations§
impl !Freeze for MockWallet
impl RefUnwindSafe for MockWallet
impl Send for MockWallet
impl Sync for MockWallet
impl Unpin for MockWallet
impl UnwindSafe for MockWallet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more