mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-03 22:03:08 +00:00
Use trySafeTransferFrom instead of transferFrom
This commit is contained in:
parent
08e91c2443
commit
0c12a370b9
@ -2,6 +2,7 @@
|
||||
pragma solidity 0.8.28;
|
||||
|
||||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
||||
import "@openzeppelin/contracts/utils/math/Math.sol";
|
||||
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
||||
import "./Configuration.sol";
|
||||
@ -45,6 +46,7 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
|
||||
using EnumerableSet for EnumerableSet.AddressSet;
|
||||
using Requests for Request;
|
||||
using AskHelpers for Ask;
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
IERC20 private immutable _token;
|
||||
MarketplaceConfig private _config;
|
||||
@ -687,7 +689,7 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
|
||||
|
||||
function _transferFrom(address sender, uint256 amount) internal {
|
||||
address receiver = address(this);
|
||||
if (!_token.transferFrom(sender, receiver, amount))
|
||||
if (!_token.trySafeTransferFrom(sender, receiver, amount))
|
||||
revert Marketplace_TransferFailed();
|
||||
}
|
||||
|
||||
|
||||
@ -215,7 +215,7 @@ describe("Marketplace", function () {
|
||||
let insufficient = maxPrice(request) - 1
|
||||
await token.approve(marketplace.address, insufficient)
|
||||
await expect(marketplace.requestStorage(request)).to.be.revertedWith(
|
||||
"ERC20InsufficientAllowance"
|
||||
"Marketplace_TransferFailed"
|
||||
)
|
||||
})
|
||||
|
||||
@ -456,7 +456,7 @@ describe("Marketplace", function () {
|
||||
await marketplace.reserveSlot(slot.request, slot.index)
|
||||
await expect(
|
||||
marketplace.fillSlot(slot.request, slot.index, proof)
|
||||
).to.be.revertedWith("ERC20InsufficientAllowance")
|
||||
).to.be.revertedWith("Marketplace_TransferFailed")
|
||||
})
|
||||
|
||||
it("collects only requested collateral and not more", async function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user