Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add EVM network mismatch check for payments #2623

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading