diff --git a/contracts/abstract/IexecEscrow.sol b/contracts/abstract/IexecEscrow.sol index d3b6c207..b6ee02ba 100644 --- a/contracts/abstract/IexecEscrow.sol +++ b/contracts/abstract/IexecEscrow.sol @@ -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(); diff --git a/contracts/facets/IexecEscrowTokenFacet.sol b/contracts/facets/IexecEscrowTokenFacet.sol index 802ceea5..23a09694 100644 --- a/contracts/facets/IexecEscrowTokenFacet.sol +++ b/contracts/facets/IexecEscrowTokenFacet.sol @@ -4,6 +4,7 @@ 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"; @@ -11,7 +12,13 @@ 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 * ***************************************************************************/ @@ -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(); diff --git a/docs/uml/class-uml-IexecEscrows.svg b/docs/uml/class-uml-IexecEscrows.svg index e7098baf..e587e43e 100644 --- a/docs/uml/class-uml-IexecEscrows.svg +++ b/docs/uml/class-uml-IexecEscrows.svg @@ -4,749 +4,752 @@ - - + + UmlClassDiagram - + 3 - -<<Abstract>> -FacetBase -contracts/abstract/FacetBase.sol - -Internal: -   CONTRIBUTION_DEADLINE_RATIO: uint256 -   REVEAL_DEADLINE_RATIO: uint256 -   FINAL_DEADLINE_RATIO: uint256 -   WORKERPOOL_STAKE_RATIO: uint256 -   KITTY_RATIO: uint256 -   KITTY_MIN: uint256 -   KITTY_ADDRESS: address -   GROUPMEMBER_PURPOSE: uint256 - -Internal: -    owner(): address -    _msgSender(): address -Public: -    <<modifier>> onlyOwner() + +<<Abstract>> +FacetBase +contracts/abstract/FacetBase.sol + +Internal: +   CONTRIBUTION_DEADLINE_RATIO: uint256 +   REVEAL_DEADLINE_RATIO: uint256 +   FINAL_DEADLINE_RATIO: uint256 +   WORKERPOOL_STAKE_RATIO: uint256 +   KITTY_RATIO: uint256 +   KITTY_MIN: uint256 +   KITTY_ADDRESS: address +   GROUPMEMBER_PURPOSE: uint256 + +Internal: +    owner(): address +    _msgSender(): address +Public: +    <<modifier>> onlyOwner() 4 - -<<Abstract>> -IexecEscrow -contracts/abstract/IexecEscrow.sol - -Private: -    _transfer(from: address, to: address, value: uint256) -Internal: -    lock(account: address, value: uint256) -    unlock(account: address, value: uint256) -    reward(account: address, value: uint256, ref: bytes32) -    seize(account: address, value: uint256, ref: bytes32) + +<<Abstract>> +IexecEscrow +contracts/abstract/IexecEscrow.sol + +Internal: +    lock(account: address, value: uint256) +    unlock(account: address, value: uint256) +    reward(account: address, value: uint256, ref: bytes32) +    seize(account: address, value: uint256, ref: bytes32) +    _transfer(from: address, to: address, value: uint256) 4->3 - - + + 26 - -<<Interface>> -IexecERC20Events -contracts/interfaces/IexecERC20Events.sol - -Public: -    <<event>> Transfer(from: address, to: address, value: uint256) + +<<Interface>> +IexecERC20Events +contracts/interfaces/IexecERC20Events.sol + +Public: +    <<event>> Transfer(from: address, to: address, value: uint256) 4->26 - - + + 27 - -<<Interface>> -IexecEscrowEvents -contracts/interfaces/IexecEscrowEvents.sol - -Public: -    <<event>> Lock(owner: address, amount: uint256) -    <<event>> Unlock(owner: address, amount: uint256) -    <<event>> Reward(owner: address, amount: uint256, ref: bytes32) -    <<event>> Seize(owner: address, amount: uint256, ref: bytes32) + +<<Interface>> +IexecEscrowEvents +contracts/interfaces/IexecEscrowEvents.sol + +Public: +    <<event>> Lock(owner: address, amount: uint256) +    <<event>> Unlock(owner: address, amount: uint256) +    <<event>> Reward(owner: address, amount: uint256, ref: bytes32) +    <<event>> Seize(owner: address, amount: uint256, ref: bytes32) 4->27 - - + + 64 - -<<Library>> -PocoStorageLib -contracts/libs/PocoStorageLib.sol - -Private: -   POCO_STORAGE_LOCATION: bytes32 - -Internal: -    getPocoStorage(): ($: PocoStorage) + +<<Library>> +PocoStorageLib +contracts/libs/PocoStorageLib.sol + +Private: +   POCO_STORAGE_LOCATION: bytes32 + +Internal: +    getPocoStorage(): ($: PocoStorage) 4->64 - - + + 65 - -<<Struct>> -PocoStorage -contracts/libs/PocoStorageLib.sol - -m_appregistry: IRegistry -m_datasetregistry: IRegistry -m_workerpoolregistry: IRegistry -m_baseToken: IERC20 -m_name: string -m_symbol: string -m_decimals: uint8 -m_totalSupply: uint256 -m_balances: mapping(address=>uint256) -m_frozens: mapping(address=>uint256) -m_allowances: mapping(address=>mapping(address=>uint256)) -m_eip712DomainSeparator: bytes32 -m_presigned: mapping(bytes32=>address) -m_consumed: mapping(bytes32=>uint256) -m_deals: mapping(bytes32=>IexecLibCore_v5.Deal) -m_tasks: mapping(bytes32=>IexecLibCore_v5.Task) -m_consensus: mapping(bytes32=>IexecLibCore_v5.Consensus) -m_contributions: mapping(bytes32=>mapping(address=>IexecLibCore_v5.Contribution)) -m_workerScores: mapping(address=>uint256) -m_teebroker: address -m_callbackgas: uint256 -m_categories: IexecLibCore_v5.Category[] -m_v3_iexecHub: IexecHubV3Interface -m_v3_scoreImported: mapping(address=>bool) -m_dealsBoost: mapping(bytes32=>IexecLibCore_v5.DealBoost) + +<<Struct>> +PocoStorage +contracts/libs/PocoStorageLib.sol + +m_appregistry: IRegistry +m_datasetregistry: IRegistry +m_workerpoolregistry: IRegistry +m_baseToken: IERC20 +m_name: string +m_symbol: string +m_decimals: uint8 +m_totalSupply: uint256 +m_balances: mapping(address=>uint256) +m_frozens: mapping(address=>uint256) +m_allowances: mapping(address=>mapping(address=>uint256)) +m_eip712DomainSeparator: bytes32 +m_presigned: mapping(bytes32=>address) +m_consumed: mapping(bytes32=>uint256) +m_deals: mapping(bytes32=>IexecLibCore_v5.Deal) +m_tasks: mapping(bytes32=>IexecLibCore_v5.Task) +m_consensus: mapping(bytes32=>IexecLibCore_v5.Consensus) +m_contributions: mapping(bytes32=>mapping(address=>IexecLibCore_v5.Contribution)) +m_workerScores: mapping(address=>uint256) +m_teebroker: address +m_callbackgas: uint256 +m_categories: IexecLibCore_v5.Category[] +m_v3_iexecHub: IexecHubV3Interface +m_v3_scoreImported: mapping(address=>bool) +m_dealsBoost: mapping(bytes32=>IexecLibCore_v5.DealBoost) 4->65 - - + + 11 - -IexecEscrowTokenFacet -contracts/facets/IexecEscrowTokenFacet.sol - -Internal: -    _executeOperation(sender: address, data: bytes) -    _validateMatchOrders(sender: address, data: bytes) -    _deposit(from: address, amount: uint256) -    _withdraw(to: address, amount: uint256) -    _transferUnchecked(sender: address, recipient: address, amount: uint256) -    _transfer(sender: address, recipient: address, amount: uint256) -    _mint(account: address, amount: uint256) -    _burn(account: address, amount: uint256) -    _approve(owner: address, spender: address, amount: uint256) -External: -    <<payable>> null() -    <<payable>> null() -    deposit(amount: uint256): bool -    depositFor(amount: uint256, target: address): bool -    depositForArray(amounts: uint256[], targets: address[]): bool -    withdraw(amount: uint256): bool -    withdrawTo(amount: uint256, target: address): bool -    recover(): uint256 <<onlyOwner>> -    receiveApproval(sender: address, amount: uint256, token: address, data: bytes): bool -    transfer(recipient: address, amount: uint256): bool -    approve(spender: address, value: uint256): bool -    approveAndCall(spender: address, value: uint256, extraData: bytes): bool -    transferFrom(sender: address, recipient: address, amount: uint256): bool -    increaseAllowance(spender: address, addedValue: uint256): bool -    decreaseAllowance(spender: address, subtractedValue: uint256): bool + +IexecEscrowTokenFacet +contracts/facets/IexecEscrowTokenFacet.sol + +Internal: +    _executeOperation(sender: address, data: bytes) +    _validateMatchOrders(sender: address, data: bytes) +    _deposit(from: address, amount: uint256) +    _withdraw(to: address, amount: uint256) +    _mint(account: address, amount: uint256) +    _burn(account: address, amount: uint256) +    _approve(owner: address, spender: address, amount: uint256) +External: +    <<payable>> null() +    <<payable>> null() +    deposit(amount: uint256): bool +    depositFor(amount: uint256, target: address): bool +    depositForArray(amounts: uint256[], targets: address[]): bool +    withdraw(amount: uint256): bool +    withdrawTo(amount: uint256, target: address): bool +    recover(): uint256 <<onlyOwner>> +    receiveApproval(sender: address, amount: uint256, token: address, data: bytes): bool +    transfer(recipient: address, amount: uint256): bool +    approve(spender: address, value: uint256): bool +    approveAndCall(spender: address, value: uint256, extraData: bytes): bool +    transferFrom(sender: address, recipient: address, amount: uint256): bool +    increaseAllowance(spender: address, addedValue: uint256): bool +    decreaseAllowance(spender: address, subtractedValue: uint256): bool - + 11->3 - - + + + + + +11->4 + + 25 - -<<Interface>> -IexecERC20 -contracts/interfaces/IexecERC20.sol - -External: -     transfer(address, uint256): bool -     approve(address, uint256): bool -     transferFrom(address, address, uint256): bool -     increaseAllowance(address, uint256): bool -     decreaseAllowance(address, uint256): bool -     approveAndCall(address, uint256, bytes): bool -Public: -    <<event>> Approval(owner: address, spender: address, value: uint256) + +<<Interface>> +IexecERC20 +contracts/interfaces/IexecERC20.sol + +External: +     transfer(address, uint256): bool +     approve(address, uint256): bool +     transferFrom(address, address, uint256): bool +     increaseAllowance(address, uint256): bool +     decreaseAllowance(address, uint256): bool +     approveAndCall(address, uint256, bytes): bool +Public: +    <<event>> Approval(owner: address, spender: address, value: uint256) - + 11->25 - - + + 28 - -<<Interface>> -IexecEscrowToken -contracts/interfaces/IexecEscrowToken.sol - -External: -     null() -     null() -     deposit(uint256): bool -     depositFor(uint256, address): bool -     depositForArray(uint256[], address[]): bool -     withdraw(uint256): bool -     withdrawTo(uint256, address): bool -     recover(): uint256 + +<<Interface>> +IexecEscrowToken +contracts/interfaces/IexecEscrowToken.sol + +External: +     null() +     null() +     deposit(uint256): bool +     depositFor(uint256, address): bool +     depositForArray(uint256[], address[]): bool +     withdraw(uint256): bool +     withdrawTo(uint256, address): bool +     recover(): uint256 - + 11->28 - - + + 31 - -<<Interface>> -IexecPoco1 -contracts/interfaces/IexecPoco1.sol - -External: -     verifySignature(address, bytes32, bytes): bool -     verifyPresignature(address, bytes32): bool -     verifyPresignatureOrSignature(address, bytes32, bytes): bool -     assertDatasetDealCompatibility(datasetOrder: IexecLibOrders_v5.DatasetOrder, dealId: bytes32) -     matchOrders(IexecLibOrders_v5.AppOrder, IexecLibOrders_v5.DatasetOrder, IexecLibOrders_v5.WorkerpoolOrder, IexecLibOrders_v5.RequestOrder): bytes32 -     sponsorMatchOrders(IexecLibOrders_v5.AppOrder, IexecLibOrders_v5.DatasetOrder, IexecLibOrders_v5.WorkerpoolOrder, IexecLibOrders_v5.RequestOrder): bytes32 -Public: -    <<event>> SchedulerNotice(workerpool: address, dealid: bytes32) -    <<event>> OrdersMatched(dealid: bytes32, appHash: bytes32, datasetHash: bytes32, workerpoolHash: bytes32, requestHash: bytes32, volume: uint256) -    <<event>> DealSponsored(dealId: bytes32, sponsor: address) + +<<Interface>> +IexecPoco1 +contracts/interfaces/IexecPoco1.sol + +External: +     verifySignature(address, bytes32, bytes): bool +     verifyPresignature(address, bytes32): bool +     verifyPresignatureOrSignature(address, bytes32, bytes): bool +     assertDatasetDealCompatibility(datasetOrder: IexecLibOrders_v5.DatasetOrder, dealId: bytes32) +     matchOrders(IexecLibOrders_v5.AppOrder, IexecLibOrders_v5.DatasetOrder, IexecLibOrders_v5.WorkerpoolOrder, IexecLibOrders_v5.RequestOrder): bytes32 +     sponsorMatchOrders(IexecLibOrders_v5.AppOrder, IexecLibOrders_v5.DatasetOrder, IexecLibOrders_v5.WorkerpoolOrder, IexecLibOrders_v5.RequestOrder): bytes32 +Public: +    <<event>> SchedulerNotice(workerpool: address, dealid: bytes32) +    <<event>> OrdersMatched(dealid: bytes32, appHash: bytes32, datasetHash: bytes32, workerpoolHash: bytes32, requestHash: bytes32, volume: uint256) +    <<event>> DealSponsored(dealId: bytes32, sponsor: address) - + 11->31 - - + + 38 - -<<Interface>> -IexecTokenSpender -contracts/interfaces/IexecTokenSpender.sol - -External: -     receiveApproval(address, uint256, address, bytes): bool + +<<Interface>> +IexecTokenSpender +contracts/interfaces/IexecTokenSpender.sol + +External: +     receiveApproval(address, uint256, address, bytes): bool - + 11->38 - - + + 53 - -<<Library>> -IexecLibOrders_v5 -contracts/libs/IexecLibOrders_v5.sol - -Public: -   EIP712DOMAIN_TYPEHASH: bytes32 -   APPORDER_TYPEHASH: bytes32 -   DATASETORDER_TYPEHASH: bytes32 -   WORKERPOOLORDER_TYPEHASH: bytes32 -   REQUESTORDER_TYPEHASH: bytes32 -   APPORDEROPERATION_TYPEHASH: bytes32 -   DATASETORDEROPERATION_TYPEHASH: bytes32 -   WORKERPOOLORDEROPERATION_TYPEHASH: bytes32 -   REQUESTORDEROPERATION_TYPEHASH: bytes32 - -Public: -    hash(_domain: EIP712Domain): (domainhash: bytes32) -    hash(_apporder: AppOrder): (apphash: bytes32) -    hash(_datasetorder: DatasetOrder): (datasethash: bytes32) -    hash(_workerpoolorder: WorkerpoolOrder): (workerpoolhash: bytes32) -    hash(_requestorder: RequestOrder): (requesthash: bytes32) -    hash(_apporderoperation: AppOrderOperation): bytes32 -    hash(_datasetorderoperation: DatasetOrderOperation): bytes32 -    hash(_workerpoolorderoperation: WorkerpoolOrderOperation): bytes32 -    hash(_requestorderoperation: RequestOrderOperation): bytes32 + +<<Library>> +IexecLibOrders_v5 +contracts/libs/IexecLibOrders_v5.sol + +Public: +   EIP712DOMAIN_TYPEHASH: bytes32 +   APPORDER_TYPEHASH: bytes32 +   DATASETORDER_TYPEHASH: bytes32 +   WORKERPOOLORDER_TYPEHASH: bytes32 +   REQUESTORDER_TYPEHASH: bytes32 +   APPORDEROPERATION_TYPEHASH: bytes32 +   DATASETORDEROPERATION_TYPEHASH: bytes32 +   WORKERPOOLORDEROPERATION_TYPEHASH: bytes32 +   REQUESTORDEROPERATION_TYPEHASH: bytes32 + +Public: +    hash(_domain: EIP712Domain): (domainhash: bytes32) +    hash(_apporder: AppOrder): (apphash: bytes32) +    hash(_datasetorder: DatasetOrder): (datasethash: bytes32) +    hash(_workerpoolorder: WorkerpoolOrder): (workerpoolhash: bytes32) +    hash(_requestorder: RequestOrder): (requesthash: bytes32) +    hash(_apporderoperation: AppOrderOperation): bytes32 +    hash(_datasetorderoperation: DatasetOrderOperation): bytes32 +    hash(_workerpoolorderoperation: WorkerpoolOrderOperation): bytes32 +    hash(_requestorderoperation: RequestOrderOperation): bytes32 - + 11->53 - - + + - + 11->64 - - + + - + 11->65 - - + + - + 25->26 - - + + - + 28->27 - - + + 29 - -<<Interface>> -IexecHubV3Interface -contracts/interfaces/IexecHubV3Interface.sol - -External: -     viewScore(worker: address): uint256 + +<<Interface>> +IexecHubV3Interface +contracts/interfaces/IexecHubV3Interface.sol + +External: +     viewScore(worker: address): uint256 - + 31->53 - - + + 56 - -<<Struct>> -AppOrder -contracts/libs/IexecLibOrders_v5.sol - -app: address -appprice: uint256 -volume: uint256 -tag: bytes32 -datasetrestrict: address -workerpoolrestrict: address -requesterrestrict: address -salt: bytes32 -sign: bytes + +<<Struct>> +AppOrder +contracts/libs/IexecLibOrders_v5.sol + +app: address +appprice: uint256 +volume: uint256 +tag: bytes32 +datasetrestrict: address +workerpoolrestrict: address +requesterrestrict: address +salt: bytes32 +sign: bytes - + 31->56 - - + + 57 - -<<Struct>> -DatasetOrder -contracts/libs/IexecLibOrders_v5.sol - -dataset: address -datasetprice: uint256 -volume: uint256 -tag: bytes32 -apprestrict: address -workerpoolrestrict: address -requesterrestrict: address -salt: bytes32 -sign: bytes + +<<Struct>> +DatasetOrder +contracts/libs/IexecLibOrders_v5.sol + +dataset: address +datasetprice: uint256 +volume: uint256 +tag: bytes32 +apprestrict: address +workerpoolrestrict: address +requesterrestrict: address +salt: bytes32 +sign: bytes - + 31->57 - - + + 58 - -<<Struct>> -WorkerpoolOrder -contracts/libs/IexecLibOrders_v5.sol - -workerpool: address -workerpoolprice: uint256 -volume: uint256 -tag: bytes32 -category: uint256 -trust: uint256 -apprestrict: address -datasetrestrict: address -requesterrestrict: address -salt: bytes32 -sign: bytes + +<<Struct>> +WorkerpoolOrder +contracts/libs/IexecLibOrders_v5.sol + +workerpool: address +workerpoolprice: uint256 +volume: uint256 +tag: bytes32 +category: uint256 +trust: uint256 +apprestrict: address +datasetrestrict: address +requesterrestrict: address +salt: bytes32 +sign: bytes - + 31->58 - - + + 59 - -<<Struct>> -RequestOrder -contracts/libs/IexecLibOrders_v5.sol - -app: address -appmaxprice: uint256 -dataset: address -datasetmaxprice: uint256 -workerpool: address -workerpoolmaxprice: uint256 -requester: address -volume: uint256 -tag: bytes32 -category: uint256 -trust: uint256 -beneficiary: address -callback: address -params: string -salt: bytes32 -sign: bytes + +<<Struct>> +RequestOrder +contracts/libs/IexecLibOrders_v5.sol + +app: address +appmaxprice: uint256 +dataset: address +datasetmaxprice: uint256 +workerpool: address +workerpoolmaxprice: uint256 +requester: address +volume: uint256 +tag: bytes32 +category: uint256 +trust: uint256 +beneficiary: address +callback: address +params: string +salt: bytes32 +sign: bytes - + 31->59 - - + + 39 - -<<Library>> -IexecLibCore_v5 -contracts/libs/IexecLibCore_v5.sol + +<<Library>> +IexecLibCore_v5 +contracts/libs/IexecLibCore_v5.sol 55 - -<<Struct>> -EIP712Domain -contracts/libs/IexecLibOrders_v5.sol - -name: string -version: string -chainId: uint256 -verifyingContract: address + +<<Struct>> +EIP712Domain +contracts/libs/IexecLibOrders_v5.sol + +name: string +version: string +chainId: uint256 +verifyingContract: address - + 53->55 - - + + - + 53->56 - - + + - + 53->57 - - + + - + 53->58 - - + + - + 53->59 - - + + 60 - -<<Struct>> -AppOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: AppOrder -operation: OrderOperationEnum -sign: bytes + +<<Struct>> +AppOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: AppOrder +operation: OrderOperationEnum +sign: bytes - + 53->60 - - + + 61 - -<<Struct>> -DatasetOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: DatasetOrder -operation: OrderOperationEnum -sign: bytes + +<<Struct>> +DatasetOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: DatasetOrder +operation: OrderOperationEnum +sign: bytes - + 53->61 - - + + 62 - -<<Struct>> -WorkerpoolOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: WorkerpoolOrder -operation: OrderOperationEnum -sign: bytes + +<<Struct>> +WorkerpoolOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: WorkerpoolOrder +operation: OrderOperationEnum +sign: bytes - + 53->62 - - + + 63 - -<<Struct>> -RequestOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: RequestOrder -operation: OrderOperationEnum -sign: bytes + +<<Struct>> +RequestOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: RequestOrder +operation: OrderOperationEnum +sign: bytes - + 53->63 - - + + 54 - -<<Enum>> -OrderOperationEnum -contracts/libs/IexecLibOrders_v5.sol - -SIGN: 0 -CLOSE: 1 + +<<Enum>> +OrderOperationEnum +contracts/libs/IexecLibOrders_v5.sol + +SIGN: 0 +CLOSE: 1 - + 54->53 - - + + - + 55->53 - - + + - + 56->53 - - + + - + 57->53 - - + + - + 58->53 - - + + - + 59->53 - - + + - + 60->53 - - + + - + 60->54 - - + + - + 60->56 - - + + - + 61->53 - - + + - + 61->54 - - + + - + 61->57 - - + + - + 62->53 - - + + - + 62->54 - - + + - + 62->58 - - + + - + 63->53 - - + + - + 63->54 - - + + - + 63->59 - - + + - + 64->65 - - + + - + 65->29 - - + + - + 65->39 - - + + - + 65->64 - - + + 66 - -<<Interface>> -IRegistry -contracts/registries/IRegistry.sol - -External: -     isRegistered(_entry: address): bool + +<<Interface>> +IRegistry +contracts/registries/IRegistry.sol + +External: +     isRegistered(_entry: address): bool - + 65->66 - - + + diff --git a/docs/uml/class-uml-IexecPocoBoostFacet.svg b/docs/uml/class-uml-IexecPocoBoostFacet.svg index b951ad11..23dcc401 100644 --- a/docs/uml/class-uml-IexecPocoBoostFacet.svg +++ b/docs/uml/class-uml-IexecPocoBoostFacet.svg @@ -36,23 +36,22 @@ 4 - -<<Abstract>> -IexecEscrow -contracts/abstract/IexecEscrow.sol - -Private: -    _transfer(from: address, to: address, value: uint256) -Internal: -    lock(account: address, value: uint256) -    unlock(account: address, value: uint256) -    reward(account: address, value: uint256, ref: bytes32) -    seize(account: address, value: uint256, ref: bytes32) + +<<Abstract>> +IexecEscrow +contracts/abstract/IexecEscrow.sol + +Internal: +    lock(account: address, value: uint256) +    unlock(account: address, value: uint256) +    reward(account: address, value: uint256, ref: bytes32) +    seize(account: address, value: uint256, ref: bytes32) +    _transfer(from: address, to: address, value: uint256) 4->3 - + @@ -69,7 +68,7 @@ 4->26 - + @@ -89,8 +88,8 @@ 4->27 - - + + @@ -109,7 +108,7 @@ 4->64 - + @@ -149,7 +148,7 @@ 4->65 - + @@ -287,8 +286,8 @@ 18->4 - - + + diff --git a/docs/uml/class-uml-IexecPocoFacets.svg b/docs/uml/class-uml-IexecPocoFacets.svg index 12c36931..0fb435d8 100644 --- a/docs/uml/class-uml-IexecPocoFacets.svg +++ b/docs/uml/class-uml-IexecPocoFacets.svg @@ -36,23 +36,22 @@ 4 - -<<Abstract>> -IexecEscrow -contracts/abstract/IexecEscrow.sol - -Private: -    _transfer(from: address, to: address, value: uint256) -Internal: -    lock(account: address, value: uint256) -    unlock(account: address, value: uint256) -    reward(account: address, value: uint256, ref: bytes32) -    seize(account: address, value: uint256, ref: bytes32) + +<<Abstract>> +IexecEscrow +contracts/abstract/IexecEscrow.sol + +Internal: +    lock(account: address, value: uint256) +    unlock(account: address, value: uint256) +    reward(account: address, value: uint256, ref: bytes32) +    seize(account: address, value: uint256, ref: bytes32) +    _transfer(from: address, to: address, value: uint256) 4->3 - + @@ -69,8 +68,8 @@ 4->26 - - + + @@ -89,8 +88,8 @@ 4->27 - - + + @@ -109,7 +108,7 @@ 4->64 - + @@ -149,7 +148,7 @@ 4->65 - + @@ -295,8 +294,8 @@ 14->4 - - + + @@ -581,8 +580,8 @@ 15->4 - - + + diff --git a/docs/uml/class-uml-dir-facets.svg b/docs/uml/class-uml-dir-facets.svg index 98389597..0809a3dd 100644 --- a/docs/uml/class-uml-dir-facets.svg +++ b/docs/uml/class-uml-dir-facets.svg @@ -66,36 +66,34 @@ 4 - -IexecEscrowTokenFacet -contracts/facets/IexecEscrowTokenFacet.sol - -Internal: -    _executeOperation(sender: address, data: bytes) -    _validateMatchOrders(sender: address, data: bytes) -    _deposit(from: address, amount: uint256) -    _withdraw(to: address, amount: uint256) -    _transferUnchecked(sender: address, recipient: address, amount: uint256) -    _transfer(sender: address, recipient: address, amount: uint256) -    _mint(account: address, amount: uint256) -    _burn(account: address, amount: uint256) -    _approve(owner: address, spender: address, amount: uint256) -External: + +IexecEscrowTokenFacet +contracts/facets/IexecEscrowTokenFacet.sol + +Internal: +    _executeOperation(sender: address, data: bytes) +    _validateMatchOrders(sender: address, data: bytes) +    _deposit(from: address, amount: uint256) +    _withdraw(to: address, amount: uint256) +    _mint(account: address, amount: uint256) +    _burn(account: address, amount: uint256) +    _approve(owner: address, spender: address, amount: uint256) +External: +    <<payable>> null()    <<payable>> null() -    <<payable>> null() -    deposit(amount: uint256): bool -    depositFor(amount: uint256, target: address): bool -    depositForArray(amounts: uint256[], targets: address[]): bool -    withdraw(amount: uint256): bool -    withdrawTo(amount: uint256, target: address): bool -    recover(): uint256 <<onlyOwner>> -    receiveApproval(sender: address, amount: uint256, token: address, data: bytes): bool -    transfer(recipient: address, amount: uint256): bool -    approve(spender: address, value: uint256): bool -    approveAndCall(spender: address, value: uint256, extraData: bytes): bool -    transferFrom(sender: address, recipient: address, amount: uint256): bool -    increaseAllowance(spender: address, addedValue: uint256): bool -    decreaseAllowance(spender: address, subtractedValue: uint256): bool +    deposit(amount: uint256): bool +    depositFor(amount: uint256, target: address): bool +    depositForArray(amounts: uint256[], targets: address[]): bool +    withdraw(amount: uint256): bool +    withdrawTo(amount: uint256, target: address): bool +    recover(): uint256 <<onlyOwner>> +    receiveApproval(sender: address, amount: uint256, token: address, data: bytes): bool +    transfer(recipient: address, amount: uint256): bool +    approve(spender: address, value: uint256): bool +    approveAndCall(spender: address, value: uint256, extraData: bytes): bool +    transferFrom(sender: address, recipient: address, amount: uint256): bool +    increaseAllowance(spender: address, addedValue: uint256): bool +    decreaseAllowance(spender: address, subtractedValue: uint256): bool diff --git a/test/byContract/IexecERC20/IexecERC20.test.ts b/test/byContract/IexecERC20/IexecERC20.test.ts index 3c1fa0c0..7c781b05 100644 --- a/test/byContract/IexecERC20/IexecERC20.test.ts +++ b/test/byContract/IexecERC20/IexecERC20.test.ts @@ -87,17 +87,17 @@ describe('ERC20', async () => { it('Should not transfer from the zero address', async () => { await expect( iexecPoco.connect(zeroAddressSigner).transfer(recipient.address, value), - ).to.be.revertedWith('ERC20: transfer from the zero address'); + ).to.be.revertedWith('IexecEscrow: Transfer from empty address'); }); it('Should not transfer to the zero address', async () => { await expect(iexecPocoAsHolder.transfer(ZeroAddress, value)).to.be.revertedWith( - 'ERC20: transfer to the zero address', + 'IexecEscrow: Transfer to empty address', ); }); it('Should not transfer when sender balance is too low', async () => { await expect( iexecPocoAsHolder.transfer(recipient.address, value + 1n), - ).to.be.revertedWithoutReason(); + ).to.be.revertedWith('IexecEscrow: Transfer amount exceeds balance'); }); }); @@ -191,17 +191,17 @@ describe('ERC20', async () => { it('Should not transferFrom when owner is the zero address', async () => { await expect( iexecPocoAsSpender.transferFrom(ZeroAddress, spender.address, value), - ).to.be.revertedWith('ERC20: transfer from the zero address'); + ).to.be.revertedWith('IexecEscrow: Transfer from empty address'); }); it('Should not transferFrom to the zero address', async () => { await expect( iexecPocoAsSpender.transferFrom(holder.address, ZeroAddress, value), - ).to.be.revertedWith('ERC20: transfer to the zero address'); + ).to.be.revertedWith('IexecEscrow: Transfer to empty address'); }); it('Should not transferFrom when owner balance is too low', async () => { await expect( iexecPocoAsSpender.transferFrom(holder.address, spender.address, value + 1n), - ).to.be.revertedWithoutReason(); + ).to.be.revertedWith('IexecEscrow: Transfer amount exceeds balance'); }); it('Should not transferFrom when spender allowance is too low', async () => { await iexecPocoAsHolder.approve(spender.address, value - 1n).then((tx) => tx.wait());