Skip to content

Commit

Permalink
Merge pull request #2623 from mickvandijke/chore-check-for-evm-networ…
Browse files Browse the repository at this point in the history
…k-compat

chore: add EVM network mismatch check for payments
  • Loading branch information
mickvandijke authored Jan 23, 2025
2 parents 62b8158 + 6d38fbf commit 959f55d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions autonomi/src/client/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
Expand Down Expand Up @@ -97,6 +101,11 @@ impl Client {
content_addrs: impl Iterator<Item = (XorName, usize)> + 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?;

Expand Down

0 comments on commit 959f55d

Please sign in to comment.