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§
Source§impl MockWallet
impl MockWallet
Sourcepub fn new(chain_info: ChainInfo) -> Self
pub fn new(chain_info: ChainInfo) -> Self
Create a new mock wallet with the given chain info and sensible defaults.
Sourcepub fn with_simulate_result(self, result: TxSimulationResult) -> Self
pub fn with_simulate_result(self, result: TxSimulationResult) -> Self
Set the default result returned by simulate_tx.
Sourcepub fn with_send_result(self, result: SendResult) -> Self
pub fn with_send_result(self, result: SendResult) -> Self
Set the default result returned by send_tx.
Sourcepub 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.
Sourcepub 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§
Source§impl Wallet for MockWallet
impl Wallet for MockWallet
Source§fn get_chain_info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ChainInfo, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_chain_info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ChainInfo, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get chain identification information.
Source§fn get_accounts<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Aliased<AztecAddress>>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_accounts<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Aliased<AztecAddress>>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the list of accounts managed by this wallet.
Source§fn get_address_book<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Aliased<AztecAddress>>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
Get the address book entries.
Source§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
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
Register a sender address with an optional alias.
Source§fn get_contract_metadata<'life0, 'async_trait>(
&'life0 self,
address: AztecAddress,
) -> Pin<Box<dyn Future<Output = Result<ContractMetadata, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
Get metadata about a registered contract.
Source§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
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
Get metadata about a registered contract class.
Source§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
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
Register a contract instance (and optionally its artifact) with the wallet.
Source§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
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get private events matching the given filter.
Source§fn simulate_tx<'life0, 'async_trait>(
&'life0 self,
_exec: ExecutionPayload,
_opts: SimulateOptions,
) -> Pin<Box<dyn Future<Output = Result<TxSimulationResult, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
Simulate a transaction without sending it.
Source§fn execute_utility<'life0, 'async_trait>(
&'life0 self,
_call: FunctionCall,
_opts: ExecuteUtilityOptions,
) -> Pin<Box<dyn Future<Output = Result<UtilityExecutionResult, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
Execute a utility (view) function.
Source§fn profile_tx<'life0, 'async_trait>(
&'life0 self,
_exec: ExecutionPayload,
_opts: ProfileOptions,
) -> Pin<Box<dyn Future<Output = Result<TxProfileResult, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
Profile a transaction for gas estimation and performance data.
Source§fn send_tx<'life0, 'async_trait>(
&'life0 self,
_exec: ExecutionPayload,
_opts: SendOptions,
) -> Pin<Box<dyn Future<Output = Result<SendResult, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
Send a transaction to the network.
Source§fn wait_for_contract<'life0, 'async_trait>(
&'life0 self,
_address: AztecAddress,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn wait_for_contract<'life0, 'async_trait>(
&'life0 self,
_address: AztecAddress,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Wait until a deployed contract instance is queryable from the node.
Source§fn wait_for_tx_proven<'life0, 'async_trait>(
&'life0 self,
_tx_hash: TxHash,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
Wait until the block containing a transaction is proven on L1.
Source§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
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
Create an authorization witness.
Source§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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: '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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: '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