Skip to content

Commit

Permalink
Merge pull request #3184 from golemfactory/kek/deposit-validation-reo…
Browse files Browse the repository at this point in the history
…rder

erc20: check deposit spender before balance
  • Loading branch information
kamirr committed Apr 24, 2024
2 parents 0a7280a + 1fbc536 commit 0d353ab
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 @@ -487,6 +487,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 @@ -516,16 +526,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 0d353ab

Please sign in to comment.