Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions contracts/abstract/IexecEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ abstract contract IexecEscrow is FacetBase, IexecERC20Events, IexecEscrowEvents
/**
* Transfer value from a spender account to a receiver account.
* @notice
* This function does not check for self-transfers
* because its current usage does not require such verification.
* Indeed, all operations that use this function are always between
* the proxy contract and another actor of the platform (requester,
* owner of dataset/application/workerpool).
* This is the single implementation of a balance move over `m_balances`.
* It backs both the escrow operations of this contract (lock, unlock,
* reward) and the ERC-20 entry points of the escrow facet.
*
* A self-transfer is a no-op on the balances and is not rejected.
*
* @param from The address of the spender account.
* @param to The address of the receiver account.
* @param value The value to transfer.
*/
function _transfer(address from, address to, uint256 value) private {
function _transfer(address from, address to, uint256 value) internal {
require(from != address(0), "IexecEscrow: Transfer from empty address");
require(to != address(0), "IexecEscrow: Transfer to empty address");
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
Expand Down
28 changes: 8 additions & 20 deletions contracts/facets/IexecEscrowTokenFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@
pragma solidity ^0.8.0;

import {FacetBase} from "../abstract/FacetBase.sol";
import {IexecEscrow} from "../abstract/IexecEscrow.sol";
import {IexecERC20} from "../interfaces/IexecERC20.sol";
import {IexecEscrowToken} from "../interfaces/IexecEscrowToken.sol";
import {IexecTokenSpender} from "../interfaces/IexecTokenSpender.sol";
import {IexecPoco1} from "../interfaces/IexecPoco1.sol";
import {IexecLibOrders_v5} from "../libs/IexecLibOrders_v5.sol";
import {PocoStorageLib} from "../libs/PocoStorageLib.sol";

contract IexecEscrowTokenFacet is IexecEscrowToken, IexecTokenSpender, IexecERC20, FacetBase {
contract IexecEscrowTokenFacet is
FacetBase,
IexecERC20,
IexecTokenSpender,
IexecEscrowToken,
IexecEscrow
{
/***************************************************************************
* Escrow methods: public *
***************************************************************************/
Expand Down Expand Up @@ -272,25 +279,6 @@ contract IexecEscrowTokenFacet is IexecEscrowToken, IexecTokenSpender, IexecERC2
return true;
}

function _transferUnchecked(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
uint256 senderBalance = $.m_balances[sender];
// TEMPORARY MIGRATION FIX: Check balance to prevent underflow and revert without reason for backward compatibility
// TODO: Remove this in the next major version
if (senderBalance < amount) {
revert();
}
$.m_balances[sender] = senderBalance - amount;
$.m_balances[recipient] = $.m_balances[recipient] + amount;
emit Transfer(sender, recipient, amount);
}

function _transfer(address sender, address recipient, uint256 amount) internal {
_transferUnchecked(sender, recipient, amount);
}

function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
Expand Down
Loading
Loading