diff --git a/core/payment-driver/erc20/src/driver.rs b/core/payment-driver/erc20/src/driver.rs index 21bc7b113f..3b87961a4b 100644 --- a/core/payment-driver/erc20/src/driver.rs +++ b/core/payment-driver/erc20/src/driver.rs @@ -466,6 +466,16 @@ impl Erc20Driver { deposit_spender, ); + if allocation_address != deposit_spender { + log::debug!( + "Deposit validation failed, requested address [{}] doesn't match deposit spender [{}]", + allocation_address, + deposit_spender + ); + + return Ok(ValidateAllocationResult::DepositSpenderMismatch); + } + if msg.amount > deposit_balance { log::debug!( "Deposit validation failed: requested amount [{}] > deposit balance [{}]", @@ -495,16 +505,6 @@ impl Erc20Driver { return Ok(ValidateAllocationResult::TimeoutExceedsDeposit); }; - if allocation_address != deposit_spender { - log::debug!( - "Deposit validation failed, requested address [{}] doesn't match deposit spender [{}]", - allocation_address, - deposit_spender - ); - - return Ok(ValidateAllocationResult::DepositSpenderMismatch); - } - Ok(ValidateAllocationResult::Valid) } }