Skip to content

Commit

Permalink
chore: add EVM network mismatch check for payments
Browse files Browse the repository at this point in the history
  • Loading branch information
mickvandijke committed Jan 13, 2025
1 parent 98bc1b3 commit 697c684
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions autonomi/src/client/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ pub enum PutError {
/// Errors that can occur during the pay operation.
#[derive(Debug, thiserror::Error)]
pub enum PayError {
#[error(
"EVM wallet and client use different EVM networks. Please use the same network for both."
)]
EvmWalletNetworkMismatch,
#[error("Wallet error: {0:?}")]
EvmWalletError(#[from] EvmWalletError),
#[error("Failed to self-encrypt data.")]
Expand Down
5 changes: 5 additions & 0 deletions autonomi/src/client/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ impl Client {
content_addrs: impl Iterator<Item = XorName> + Clone,
wallet: &EvmWallet,
) -> Result<(Receipt, AlreadyPaidAddressesCount), PayError> {
// Check if the wallet uses the same network as the client
if wallet.network() != &self.evm_network {
return Err(PayError::EvmWalletNetworkMismatch);
}

let number_of_content_addrs = content_addrs.clone().count();
let quotes = self.get_store_quotes(content_addrs).await?;

Expand Down

0 comments on commit 697c684

Please sign in to comment.