From 697c6842304fe818d4c40efc261c653e6c619ea5 Mon Sep 17 00:00:00 2001 From: Warm Beer Date: Mon, 13 Jan 2025 10:23:38 +0100 Subject: [PATCH] chore: add EVM network mismatch check for payments --- autonomi/src/client/data/mod.rs | 4 ++++ autonomi/src/client/utils.rs | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/autonomi/src/client/data/mod.rs b/autonomi/src/client/data/mod.rs index 5fc1eb3290..09bd116c55 100644 --- a/autonomi/src/client/data/mod.rs +++ b/autonomi/src/client/data/mod.rs @@ -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.")] diff --git a/autonomi/src/client/utils.rs b/autonomi/src/client/utils.rs index ae0cac0b48..01ce37da01 100644 --- a/autonomi/src/client/utils.rs +++ b/autonomi/src/client/utils.rs @@ -170,6 +170,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(content_addrs).await?;