Skip to content

Commit

Permalink
erc20: check deposit spender before balance
Browse files Browse the repository at this point in the history
  • Loading branch information
kamirr committed Jul 9, 2024
1 parent 36fe0d1 commit fd88e85
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions core/payment-driver/erc20/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 [{}]",
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit fd88e85

Please sign in to comment.