From 6d38fbf8b64d92a4313b54e56ce6b967b4b3dfad Mon Sep 17 00:00:00 2001 From: Warm Beer Date: Thu, 23 Jan 2025 14:09:10 +0100 Subject: [PATCH] chore: add EVM network mismatch check for payments --- autonomi/src/client/payment.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/autonomi/src/client/payment.rs b/autonomi/src/client/payment.rs index ca928c6d07..a1bdc6802e 100644 --- a/autonomi/src/client/payment.rs +++ b/autonomi/src/client/payment.rs @@ -14,6 +14,10 @@ pub type AlreadyPaidAddressesCount = usize; /// 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.")] @@ -97,6 +101,11 @@ impl Client { content_addrs: impl Iterator + 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(data_type, content_addrs).await?;