From 1fbc536ed30b1ad431f631c8635e4e52c311b131 Mon Sep 17 00:00:00 2001 From: Kamil Koczurek Date: Wed, 17 Apr 2024 19:32:42 +0200 Subject: [PATCH] erc20: check deposit spender before balance --- core/payment-driver/erc20/src/driver.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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) } }