diff --git a/contracts/facets/IexecERC20Core.sol b/contracts/facets/IexecERC20Core.sol index 567d84719..6f44d11b3 100644 --- a/contracts/facets/IexecERC20Core.sol +++ b/contracts/facets/IexecERC20Core.sol @@ -12,7 +12,13 @@ contract IexecERC20Core is IexecERC20Common, FacetBase { 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(); - $.m_balances[sender] = $.m_balances[sender] - amount; + 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); } @@ -32,8 +38,14 @@ contract IexecERC20Core is IexecERC20Common, FacetBase { function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + uint256 accountBalance = $.m_balances[account]; + // TEMPORARY MIGRATION FIX: Check balance to prevent underflow and revert without reason for backward compatibility + // TODO: Remove this in the next major version + if (accountBalance < amount) { + revert(); + } $.m_totalSupply = $.m_totalSupply - amount; - $.m_balances[account] = $.m_balances[account] - amount; + $.m_balances[account] = accountBalance - amount; emit Transfer(account, address(0), amount); } diff --git a/contracts/facets/IexecERC20Facet.sol b/contracts/facets/IexecERC20Facet.sol index 24570e7ec..eeff38ab9 100644 --- a/contracts/facets/IexecERC20Facet.sol +++ b/contracts/facets/IexecERC20Facet.sol @@ -45,7 +45,13 @@ contract IexecERC20Facet is IexecERC20, FacetBase, IexecERC20Core { ) external override returns (bool) { PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); _transfer(sender, recipient, amount); - _approve(sender, _msgSender(), $.m_allowances[sender][_msgSender()] - amount); + // TEMPORARY MIGRATION FIX: Check allowance to prevent underflow and revert without reason for backward compatibility + // TODO: Remove this in the next major version + uint256 currentAllowance = $.m_allowances[sender][_msgSender()]; + if (currentAllowance < amount) { + revert(); + } + _approve(sender, _msgSender(), currentAllowance - amount); return true; } @@ -63,7 +69,13 @@ contract IexecERC20Facet is IexecERC20, FacetBase, IexecERC20Core { uint256 subtractedValue ) external override returns (bool) { PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - _approve(_msgSender(), spender, $.m_allowances[_msgSender()][spender] - subtractedValue); + // TEMPORARY MIGRATION FIX: Check allowance to prevent underflow and revert without reason for backward compatibility + // TODO: Remove this in the next major version + uint256 currentAllowance = $.m_allowances[_msgSender()][spender]; + if (currentAllowance < subtractedValue) { + revert(); + } + _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } } diff --git a/contracts/facets/IexecEscrowTokenFacet.sol b/contracts/facets/IexecEscrowTokenFacet.sol index 7d044e5df..92761d7aa 100644 --- a/contracts/facets/IexecEscrowTokenFacet.sol +++ b/contracts/facets/IexecEscrowTokenFacet.sol @@ -10,7 +10,6 @@ import {IexecTokenSpender} from "../interfaces/IexecTokenSpender.sol"; import {PocoStorageLib} from "../libs/PocoStorageLib.sol"; contract IexecEscrowTokenFacet is IexecEscrowToken, IexecTokenSpender, FacetBase, IexecERC20Core { - /*************************************************************************** * Escrow methods: public * ***************************************************************************/ diff --git a/contracts/interfaces/IOwnable.sol b/contracts/interfaces/IOwnable.sol index 5a43907e8..f992d2813 100644 --- a/contracts/interfaces/IOwnable.sol +++ b/contracts/interfaces/IOwnable.sol @@ -1,8 +1,7 @@ // SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.0; -pragma experimental ABIEncoderV2; +pragma solidity ^0.8.0; interface IOwnable { event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); diff --git a/contracts/interfaces/IexecAccessorsABILegacy.sol b/contracts/interfaces/IexecAccessorsABILegacy.sol index afba8df8b..cfda88d9c 100644 --- a/contracts/interfaces/IexecAccessorsABILegacy.sol +++ b/contracts/interfaces/IexecAccessorsABILegacy.sol @@ -1,8 +1,7 @@ // SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.0; -pragma experimental ABIEncoderV2; +pragma solidity ^0.8.0; import "../libs/IexecLibCore_v5.sol"; diff --git a/contracts/interfaces/IexecCategoryManager.sol b/contracts/interfaces/IexecCategoryManager.sol index 055addea7..87eba8d8b 100644 --- a/contracts/interfaces/IexecCategoryManager.sol +++ b/contracts/interfaces/IexecCategoryManager.sol @@ -1,8 +1,7 @@ // SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.0; -pragma experimental ABIEncoderV2; +pragma solidity ^0.8.0; interface IexecCategoryManager { event CreateCategory(uint256 catid, string name, string description, uint256 workClockTimeRef); diff --git a/contracts/interfaces/IexecConfiguration.sol b/contracts/interfaces/IexecConfiguration.sol index c184c18af..3d3513495 100644 --- a/contracts/interfaces/IexecConfiguration.sol +++ b/contracts/interfaces/IexecConfiguration.sol @@ -1,9 +1,7 @@ // SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.0; -pragma experimental ABIEncoderV2; - +pragma solidity ^0.8.0; import "../libs/IexecLibOrders_v5.sol"; interface IexecConfiguration { diff --git a/contracts/interfaces/IexecConfigurationExtra.sol b/contracts/interfaces/IexecConfigurationExtra.sol index d5526c9b4..7510ff7a6 100644 --- a/contracts/interfaces/IexecConfigurationExtra.sol +++ b/contracts/interfaces/IexecConfigurationExtra.sol @@ -1,9 +1,7 @@ // SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.0; -pragma experimental ABIEncoderV2; - +pragma solidity ^0.8.0; interface IexecConfigurationExtra { function changeRegistries(address, address, address) external; } diff --git a/contracts/interfaces/IexecERC20.sol b/contracts/interfaces/IexecERC20.sol index 281589934..aebff2cec 100644 --- a/contracts/interfaces/IexecERC20.sol +++ b/contracts/interfaces/IexecERC20.sol @@ -1,13 +1,11 @@ // SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.0; -pragma experimental ABIEncoderV2; +pragma solidity ^0.8.0; import {IexecERC20Common} from "./IexecERC20Common.sol"; interface IexecERC20 is IexecERC20Common { - function transfer(address, uint256) external returns (bool); function approve(address, uint256) external returns (bool); function transferFrom(address, address, uint256) external returns (bool); diff --git a/contracts/interfaces/IexecERC20Common.sol b/contracts/interfaces/IexecERC20Common.sol index 650770883..b17c75581 100644 --- a/contracts/interfaces/IexecERC20Common.sol +++ b/contracts/interfaces/IexecERC20Common.sol @@ -1,9 +1,7 @@ // SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.0; -pragma experimental ABIEncoderV2; - +pragma solidity ^0.8.0; // TODO merge with IexecERC20 interface. interface IexecERC20Common { event Transfer(address indexed from, address indexed to, uint256 value); diff --git a/contracts/interfaces/IexecEscrowNative.sol b/contracts/interfaces/IexecEscrowNative.sol index 749929281..06184c8fb 100644 --- a/contracts/interfaces/IexecEscrowNative.sol +++ b/contracts/interfaces/IexecEscrowNative.sol @@ -1,9 +1,7 @@ // SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.0; -pragma experimental ABIEncoderV2; - +pragma solidity ^0.8.0; interface IexecEscrowNative { receive() external payable; fallback() external payable; diff --git a/contracts/interfaces/IexecEscrowToken.sol b/contracts/interfaces/IexecEscrowToken.sol index 346ef2dbe..cf5994414 100644 --- a/contracts/interfaces/IexecEscrowToken.sol +++ b/contracts/interfaces/IexecEscrowToken.sol @@ -1,8 +1,7 @@ // SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.0; -pragma experimental ABIEncoderV2; +pragma solidity ^0.8.0; interface IexecEscrowToken { receive() external payable; diff --git a/contracts/interfaces/IexecPoco1.sol b/contracts/interfaces/IexecPoco1.sol index 9840fb354..81e0289e0 100644 --- a/contracts/interfaces/IexecPoco1.sol +++ b/contracts/interfaces/IexecPoco1.sol @@ -1,9 +1,7 @@ // SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.0; -pragma experimental ABIEncoderV2; - +pragma solidity ^0.8.0; import {IexecLibOrders_v5} from "../libs/IexecLibOrders_v5.sol"; interface IexecPoco1 { diff --git a/contracts/interfaces/IexecRelay.sol b/contracts/interfaces/IexecRelay.sol index ae1abe3f6..0bc2e2ccc 100644 --- a/contracts/interfaces/IexecRelay.sol +++ b/contracts/interfaces/IexecRelay.sol @@ -1,8 +1,7 @@ // SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.0; -pragma experimental ABIEncoderV2; +pragma solidity ^0.8.0; import "../libs/IexecLibOrders_v5.sol"; diff --git a/contracts/interfaces/IexecTokenSpender.sol b/contracts/interfaces/IexecTokenSpender.sol index c7a34dcad..601ead3f6 100644 --- a/contracts/interfaces/IexecTokenSpender.sol +++ b/contracts/interfaces/IexecTokenSpender.sol @@ -1,8 +1,7 @@ // SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.0; -pragma experimental ABIEncoderV2; +pragma solidity ^0.8.0; interface IexecTokenSpender { function receiveApproval(address, uint256, address, bytes calldata) external returns (bool); diff --git a/contracts/libs/IexecLibCore_v5.sol b/contracts/libs/IexecLibCore_v5.sol index a32c551c0..aca6f5f40 100644 --- a/contracts/libs/IexecLibCore_v5.sol +++ b/contracts/libs/IexecLibCore_v5.sol @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: 2020-2024 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.0; +pragma solidity ^0.8.0; library IexecLibCore_v5 { /** diff --git a/contracts/libs/IexecLibOrders_v5.sol b/contracts/libs/IexecLibOrders_v5.sol index 7fb18a979..a5ba8b13f 100644 --- a/contracts/libs/IexecLibOrders_v5.sol +++ b/contracts/libs/IexecLibOrders_v5.sol @@ -1,9 +1,7 @@ // SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -pragma solidity >=0.6.0; -pragma experimental ABIEncoderV2; - +pragma solidity ^0.8.0; library IexecLibOrders_v5 { // bytes32 public constant EIP712DOMAIN_TYPEHASH = keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'); // bytes32 public constant APPORDER_TYPEHASH = keccak256('AppOrder(address app,uint256 appprice,uint256 volume,bytes32 tag,address datasetrestrict,address workerpoolrestrict,address requesterrestrict,bytes32 salt)'); diff --git a/contracts/registries/Registry.sol b/contracts/registries/Registry.sol index f0fd02f15..cceff82e0 100644 --- a/contracts/registries/Registry.sol +++ b/contracts/registries/Registry.sol @@ -33,6 +33,14 @@ abstract contract Registry is IRegistry, ERC721Enumerable, Ownable { proxyCodeHash = keccak256(proxyCode); } + // TEMPORARY MIGRATION FIX: Override _checkOwner to catch custom errors and throw string errors for backward compatibility + // TODO: Remove this override in the next major version + function _checkOwner() internal view override { + if (owner() != _msgSender()) { + revert("Ownable: caller is not the owner"); + } + } + function initialize(address _previous) external onlyOwner { require(!initialized); initialized = true; @@ -74,8 +82,14 @@ abstract contract Registry is IRegistry, ERC721Enumerable, Ownable { /* Factory */ function _mintCreate(address _owner, bytes memory _args) internal returns (address) { + // TEMPORARY MIGRATION FIX: Check if contract already exists to revert without custom error for backward compatibility + // TODO: Remove this in the next major version + address entry = _mintPredict(_owner, _args); + if (entry.code.length > 0) { + revert("Create2: Failed on deploy"); + } // Create entry (proxy) - address entry = Create2.deploy(0, keccak256(abi.encodePacked(_args, _owner)), proxyCode); + entry = Create2.deploy(0, keccak256(abi.encodePacked(_args, _owner)), proxyCode); InitializableUpgradeabilityProxy(payable(entry)).initialize(master, _args); // Mint corresponding token _mint(_owner, uint256(uint160(entry))); diff --git a/docs/solidity/index.md b/docs/solidity/index.md index 88fdf3fb9..fa5ddcf95 100644 --- a/docs/solidity/index.md +++ b/docs/solidity/index.md @@ -16,9 +16,101 @@ the PoCo contracts in token mode. _Referenced in the SDK with the current path `contracts/IexecInterfaceToken.sol`. Changing the name or the path would cause a breaking change in the SDK._ -## FacetBase +## IexecCategoryManagerFacet + +### createCategory + +```solidity +function createCategory(string name, string description, uint256 workClockTimeRef) external returns (uint256) +``` + +Methods + +## IexecConfigurationExtraFacet + +### changeRegistries + +```solidity +function changeRegistries(address _appregistryAddress, address _datasetregistryAddress, address _workerpoolregistryAddress) external +``` + +## IexecConfigurationFacet + +### configure + +```solidity +function configure(address _token, string _name, string _symbol, uint8 _decimal, address _appregistryAddress, address _datasetregistryAddress, address _workerpoolregistryAddress, address _v3_iexecHubAddress) external +``` + +### domain + +```solidity +function domain() external view returns (struct IexecLibOrders_v5.EIP712Domain) +``` + +### updateDomainSeparator + +```solidity +function updateDomainSeparator() external +``` + +### importScore + +```solidity +function importScore(address _worker) external +``` + +### setTeeBroker + +```solidity +function setTeeBroker(address _teebroker) external +``` + +### setCallbackGas + +```solidity +function setCallbackGas(uint256 _callbackgas) external +``` + +## IexecERC20Core + +## IexecERC20Facet + +### transfer + +```solidity +function transfer(address recipient, uint256 amount) external returns (bool) +``` + +### approve + +```solidity +function approve(address spender, uint256 value) external returns (bool) +``` + +### approveAndCall + +```solidity +function approveAndCall(address spender, uint256 value, bytes extraData) external returns (bool) +``` + +### transferFrom + +```solidity +function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) +``` + +### increaseAllowance + +```solidity +function increaseAllowance(address spender, uint256 addedValue) external returns (bool) +``` + +### decreaseAllowance -_Every facet must inherit from this contract._ +```solidity +function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) +``` ## IexecEscrow @@ -52,6 +144,112 @@ event Reward(address owner, uint256 amount, bytes32 ref) event Seize(address owner, uint256 amount, bytes32 ref) ``` +## IexecEscrowNativeFacet + +### receive + +```solidity +receive() external payable +``` + +### fallback + +```solidity +fallback() external payable +``` + +### deposit + +```solidity +function deposit() external payable returns (bool) +``` + +### depositFor + +```solidity +function depositFor(address target) external payable returns (bool) +``` + +### depositForArray + +```solidity +function depositForArray(uint256[] amounts, address[] targets) external payable returns (bool) +``` + +### withdraw + +```solidity +function withdraw(uint256 amount) external returns (bool) +``` + +### withdrawTo + +```solidity +function withdrawTo(uint256 amount, address target) external returns (bool) +``` + +### recover + +```solidity +function recover() external returns (uint256) +``` + +## IexecEscrowTokenFacet + +### receive + +```solidity +receive() external payable +``` + +### fallback + +```solidity +fallback() external payable +``` + +### deposit + +```solidity +function deposit(uint256 amount) external returns (bool) +``` + +### depositFor + +```solidity +function depositFor(uint256 amount, address target) external returns (bool) +``` + +### depositForArray + +```solidity +function depositForArray(uint256[] amounts, address[] targets) external returns (bool) +``` + +### withdraw + +```solidity +function withdraw(uint256 amount) external returns (bool) +``` + +### withdrawTo + +```solidity +function withdrawTo(uint256 amount, address target) external returns (bool) +``` + +### recover + +```solidity +function recover() external returns (uint256) +``` + +### receiveApproval + +```solidity +function receiveApproval(address sender, uint256 amount, address token, bytes) external returns (bool) +``` + ## IexecOrderManagementFacet ### manageAppOrder @@ -606,6 +804,32 @@ Claim task to get a refund if task is not completed after deadline. | dealId | bytes32 | The ID of the deal. | | index | uint256 | The index of the task. | +## IexecRelayFacet + +### broadcastAppOrder + +```solidity +function broadcastAppOrder(struct IexecLibOrders_v5.AppOrder _apporder) external +``` + +### broadcastDatasetOrder + +```solidity +function broadcastDatasetOrder(struct IexecLibOrders_v5.DatasetOrder _datasetorder) external +``` + +### broadcastWorkerpoolOrder + +```solidity +function broadcastWorkerpoolOrder(struct IexecLibOrders_v5.WorkerpoolOrder _workerpoolorder) external +``` + +### broadcastRequestOrder + +```solidity +function broadcastRequestOrder(struct IexecLibOrders_v5.RequestOrder _requestorder) external +``` + ## IexecLibCore_v5 ### Account @@ -1065,7 +1289,7 @@ struct PocoStorage { address m_teebroker; uint256 m_callbackgas; struct IexecLibCore_v5.Category[] m_categories; - address m_v3_iexecHub; + contract IexecHubV3Interface m_v3_iexecHub; mapping(address => bool) m_v3_scoreImported; mapping(bytes32 => struct IexecLibCore_v5.DealBoost) m_dealsBoost; } @@ -1079,600 +1303,391 @@ struct PocoStorage { function isRegistered(address _entry) external view returns (bool) ``` -## IApp +## Registry -### owner +### master ```solidity -function owner() external view returns (address) +address master ``` -### m_appName +### proxyCode ```solidity -function m_appName() external view returns (string) +bytes proxyCode ``` -### m_appType +### proxyCodeHash ```solidity -function m_appType() external view returns (string) +bytes32 proxyCodeHash ``` -### m_appMultiaddr +### previous ```solidity -function m_appMultiaddr() external view returns (bytes) +contract IRegistry previous ``` -### m_appChecksum +### initialized ```solidity -function m_appChecksum() external view returns (bytes32) +bool initialized ``` -### m_appMREnclave +### initialize ```solidity -function m_appMREnclave() external view returns (bytes) +function initialize(address _previous) external ``` -## IDataset - -### owner - -```solidity -function owner() external view returns (address) -``` - -### m_datasetName - -```solidity -function m_datasetName() external view returns (string) -``` - -### m_datasetMultiaddr - -```solidity -function m_datasetMultiaddr() external view returns (bytes) -``` - -### m_datasetChecksum - -```solidity -function m_datasetChecksum() external view returns (bytes32) -``` - -## IWorkerpool - -### owner - -```solidity -function owner() external view returns (address) -``` - -### m_workerpoolDescription - -```solidity -function m_workerpoolDescription() external view returns (string) -``` - -### m_schedulerRewardRatioPolicy - -```solidity -function m_schedulerRewardRatioPolicy() external view returns (uint256) -``` - -### m_workerStakeRatioPolicy - -```solidity -function m_workerStakeRatioPolicy() external view returns (uint256) -``` - -## IexecCategoryManagerFacet - -### createCategory - -```solidity -function createCategory(string name, string description, uint256 workClockTimeRef) external returns (uint256) -``` - -Methods - -## IexecConfigurationExtraFacet - -### changeRegistries +### setBaseURI ```solidity -function changeRegistries(address _appregistryAddress, address _datasetregistryAddress, address _workerpoolregistryAddress) external +function setBaseURI(string baseUri) external ``` -## IexecConfigurationFacet - -### configure +### baseURI ```solidity -function configure(address _token, string _name, string _symbol, uint8 _decimal, address _appregistryAddress, address _datasetregistryAddress, address _workerpoolregistryAddress, address _v3_iexecHubAddress) external +function baseURI() public view returns (string) ``` -### domain +_Added for retrocompatibility! -```solidity -function domain() external view returns (struct IexecLibOrders_v5.EIP712Domain) -``` - -### updateDomainSeparator - -```solidity -function updateDomainSeparator() external -``` - -### importScore - -```solidity -function importScore(address _worker) external -``` - -### setTeeBroker +Returns the base URI set via {setBaseURI}. This will be +automatically added as a prefix in {tokenURI} to each token's ID._ -```solidity -function setTeeBroker(address _teebroker) external -``` - -### setCallbackGas - -```solidity -function setCallbackGas(uint256 _callbackgas) external -``` - -## IexecERC20Core - -### Transfer +### isRegistered ```solidity -event Transfer(address from, address to, uint256 value) +function isRegistered(address _entry) external view returns (bool) ``` -### Approval +### setName ```solidity -event Approval(address owner, address spender, uint256 value) +function setName(address, string) external ``` -## IexecERC20Facet - -### transfer +Sets the reverse registration name for a registry contract. -```solidity -function transfer(address recipient, uint256 amount) external returns (bool) -``` +_This functionality is supported only on Bellecour Sidechain, calls on other chains +will revert. The function is kept as nonpayable to maintain retrocompatibility with the +iExec SDK._ -### approve +## RegistryEntry -```solidity -function approve(address spender, uint256 value) external returns (bool) -``` +_Referenced in the SDK with the current path `contracts/registries/RegistryEntry.sol`. +Changing the name or the path would cause a breaking change in the SDK._ -### approveAndCall +### registry ```solidity -function approveAndCall(address spender, uint256 value, bytes extraData) external returns (bool) +contract IRegistry registry ``` -### transferFrom +### owner ```solidity -function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) +function owner() public view returns (address) ``` -### increaseAllowance +### setName ```solidity -function increaseAllowance(address spender, uint256 addedValue) external returns (bool) +function setName(address, string) external ``` -### decreaseAllowance - -```solidity -function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) -``` +Sets the reverse registration name for a registry entry contract. -## IexecEscrowNativeFacet +_This functionality is supported only on Bellecour Sidechain, calls on other chains +will revert. The function is kept as nonpayable to maintain retrocompatibility with the +iExec SDK._ -### receive +## App -```solidity -receive() external payable -``` +_Referenced in the SDK with the current path `contracts/registries/apps/AppRegistry.sol`. +Changing the name or the path would cause a breaking change in the SDK._ -### fallback +### m_appName ```solidity -fallback() external payable +string m_appName ``` -### deposit - -```solidity -function deposit() external payable returns (bool) -``` +Members -### depositFor +### m_appType ```solidity -function depositFor(address target) external payable returns (bool) +string m_appType ``` -### depositForArray +### m_appMultiaddr ```solidity -function depositForArray(uint256[] amounts, address[] targets) external payable returns (bool) +bytes m_appMultiaddr ``` -### withdraw +### m_appChecksum ```solidity -function withdraw(uint256 amount) external returns (bool) +bytes32 m_appChecksum ``` -### withdrawTo +### m_appMREnclave ```solidity -function withdrawTo(uint256 amount, address target) external returns (bool) +bytes m_appMREnclave ``` -### recover +### initialize ```solidity -function recover() external returns (uint256) +function initialize(string _appName, string _appType, bytes _appMultiaddr, bytes32 _appChecksum, bytes _appMREnclave) public ``` -## IexecEscrowTokenFacet - -### receive - -```solidity -receive() external payable -``` +Constructor -### fallback +## AppRegistry -```solidity -fallback() external payable -``` +_Referenced in the SDK with the current path `contracts/registries/apps/AppRegistry.sol`. +Changing the name or the path would cause a breaking change in the SDK._ -### deposit +### constructor ```solidity -function deposit(uint256 amount) external returns (bool) +constructor() public ``` -### depositFor - -```solidity -function depositFor(uint256 amount, address target) external returns (bool) -``` +Constructor -### depositForArray +### createApp ```solidity -function depositForArray(uint256[] amounts, address[] targets) external returns (bool) +function createApp(address _appOwner, string _appName, string _appType, bytes _appMultiaddr, bytes32 _appChecksum, bytes _appMREnclave) external returns (contract App) ``` -### withdraw +### predictApp ```solidity -function withdraw(uint256 amount) external returns (bool) +function predictApp(address _appOwner, string _appName, string _appType, bytes _appMultiaddr, bytes32 _appChecksum, bytes _appMREnclave) external view returns (contract App) ``` -### withdrawTo - -```solidity -function withdrawTo(uint256 amount, address target) external returns (bool) -``` +## IApp -### recover +### owner ```solidity -function recover() external returns (uint256) +function owner() external view returns (address) ``` -### receiveApproval +### m_appName ```solidity -function receiveApproval(address sender, uint256 amount, address token, bytes) external returns (bool) +function m_appName() external view returns (string) ``` -## IexecRelayFacet - -### broadcastAppOrder +### m_appType ```solidity -function broadcastAppOrder(struct IexecLibOrders_v5.AppOrder _apporder) external +function m_appType() external view returns (string) ``` -### broadcastDatasetOrder +### m_appMultiaddr ```solidity -function broadcastDatasetOrder(struct IexecLibOrders_v5.DatasetOrder _datasetorder) external +function m_appMultiaddr() external view returns (bytes) ``` -### broadcastWorkerpoolOrder +### m_appChecksum ```solidity -function broadcastWorkerpoolOrder(struct IexecLibOrders_v5.WorkerpoolOrder _workerpoolorder) external +function m_appChecksum() external view returns (bytes32) ``` -### broadcastRequestOrder +### m_appMREnclave ```solidity -function broadcastRequestOrder(struct IexecLibOrders_v5.RequestOrder _requestorder) external +function m_appMREnclave() external view returns (bytes) ``` -## PocoStorageLib - -### PocoStorage - -```solidity -struct PocoStorage { - contract IRegistry m_appregistry; - contract IRegistry m_datasetregistry; - contract IRegistry m_workerpoolregistry; - contract IERC20 m_baseToken; - string m_name; - string m_symbol; - uint8 m_decimals; - uint256 m_totalSupply; - mapping(address => uint256) m_balances; - mapping(address => uint256) m_frozens; - mapping(address => mapping(address => uint256)) m_allowances; - bytes32 m_eip712DomainSeparator; - mapping(bytes32 => address) m_presigned; - mapping(bytes32 => uint256) m_consumed; - mapping(bytes32 => struct IexecLibCore_v5.Deal) m_deals; - mapping(bytes32 => struct IexecLibCore_v5.Task) m_tasks; - mapping(bytes32 => struct IexecLibCore_v5.Consensus) m_consensus; - mapping(bytes32 => mapping(address => struct IexecLibCore_v5.Contribution)) m_contributions; - mapping(address => uint256) m_workerScores; - address m_teebroker; - uint256 m_callbackgas; - struct IexecLibCore_v5.Category[] m_categories; - contract IexecHubV3Interface m_v3_iexecHub; - mapping(address => bool) m_v3_scoreImported; -} -``` +## Dataset -## IRegistry +_Referenced in the SDK with the current path `contracts/registries/datasets/Dataset.sol`. +Changing the name or the path would cause a breaking change in the SDK._ -### isRegistered +### m_datasetName ```solidity -function isRegistered(address _entry) external view returns (bool) +string m_datasetName ``` -## Registry +Members -### master +### m_datasetMultiaddr ```solidity -address master +bytes m_datasetMultiaddr ``` -### proxyCode +### m_datasetChecksum ```solidity -bytes proxyCode +bytes32 m_datasetChecksum ``` -### proxyCodeHash +### initialize ```solidity -bytes32 proxyCodeHash +function initialize(string _datasetName, bytes _datasetMultiaddr, bytes32 _datasetChecksum) public ``` -### previous - -```solidity -contract IRegistry previous -``` +Constructor -### initialized +## DatasetRegistry -```solidity -bool initialized -``` +_Referenced in the SDK with the current path `contracts/registries/datasets/DatasetRegistry.sol`. +Changing the name or the path would cause a breaking change in the SDK._ ### constructor ```solidity -constructor(address _master, string _name, string _symbol) public -``` - -### initialize - -```solidity -function initialize(address _previous) external +constructor() public ``` -### setBaseURI - -```solidity -function setBaseURI(string _baseURI) external -``` +Constructor -### isRegistered +### createDataset ```solidity -function isRegistered(address _entry) external view returns (bool) +function createDataset(address _datasetOwner, string _datasetName, bytes _datasetMultiaddr, bytes32 _datasetChecksum) external returns (contract Dataset) ``` -### setName +### predictDataset ```solidity -function setName(address, string) external +function predictDataset(address _datasetOwner, string _datasetName, bytes _datasetMultiaddr, bytes32 _datasetChecksum) external view returns (contract Dataset) ``` -Sets the reverse registration name for a registry contract. - -_This functionality is supported only on Bellecour Sidechain, calls on other chains -will revert. The function is kept as nonpayable to maintain retrocompatibility with the -iExec SDK._ - -## RegistryEntry - -_Referenced in the SDK with the current path `contracts/registries/RegistryEntry.sol`. -Changing the name or the path would cause a breaking change in the SDK._ - -### registry - -```solidity -contract IRegistry registry -``` +## IDataset ### owner ```solidity -function owner() public view returns (address) +function owner() external view returns (address) ``` -### setName +### m_datasetName ```solidity -function setName(address, string) external +function m_datasetName() external view returns (string) ``` -Sets the reverse registration name for a registry entry contract. - -_This functionality is supported only on Bellecour Sidechain, calls on other chains -will revert. The function is kept as nonpayable to maintain retrocompatibility with the -iExec SDK._ - -## App - -_Referenced in the SDK with the current path `contracts/registries/apps/AppRegistry.sol`. -Changing the name or the path would cause a breaking change in the SDK._ - -### m_appName +### m_datasetMultiaddr ```solidity -string m_appName +function m_datasetMultiaddr() external view returns (bytes) ``` -Members - -### m_appType +### m_datasetChecksum ```solidity -string m_appType +function m_datasetChecksum() external view returns (bytes32) ``` -### m_appMultiaddr - -```solidity -bytes m_appMultiaddr -``` +## Address -### m_appChecksum +## BaseUpgradeabilityProxy -```solidity -bytes32 m_appChecksum -``` +_This contract implements a proxy that allows to change the +implementation address to which it will delegate. +Such a change is called an implementation upgrade._ -### m_appMREnclave +### Upgraded ```solidity -bytes m_appMREnclave +event Upgraded(address implementation) ``` -### initialize +_Emitted when the implementation is upgraded._ -```solidity -function initialize(string _appName, string _appType, bytes _appMultiaddr, bytes32 _appChecksum, bytes _appMREnclave) public -``` +#### Parameters -Constructor +| Name | Type | Description | +| ---- | ---- | ----------- | +| implementation | address | Address of the new implementation. | -## AppRegistry +## InitializableUpgradeabilityProxy -_Referenced in the SDK with the current path `contracts/registries/apps/AppRegistry.sol`. -Changing the name or the path would cause a breaking change in the SDK._ +_Extends BaseUpgradeabilityProxy with an initializer for initializing +implementation and init data._ -### constructor +### initialize ```solidity -constructor() public +function initialize(address _logic, bytes _data) public payable ``` -Constructor - -### createApp +_Contract initializer._ -```solidity -function createApp(address _appOwner, string _appName, string _appType, bytes _appMultiaddr, bytes32 _appChecksum, bytes _appMREnclave) external returns (contract App) -``` - -### predictApp +#### Parameters -```solidity -function predictApp(address _appOwner, string _appName, string _appType, bytes _appMultiaddr, bytes32 _appChecksum, bytes _appMREnclave) external view returns (contract App) -``` +| Name | Type | Description | +| ---- | ---- | ----------- | +| _logic | address | Address of the initial implementation. | +| _data | bytes | Data to send as msg.data to the implementation to initialize the proxied contract. It should include the signature and the parameters of the function to be called, as described in https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. | -## Dataset +## Proxy -_Referenced in the SDK with the current path `contracts/registries/datasets/Dataset.sol`. -Changing the name or the path would cause a breaking change in the SDK._ +_Implements delegation of calls to other contracts, with proper +forwarding of return values and bubbling of failures. +It defines a fallback function that delegates all calls to the address +returned by the abstract _implementation() internal function._ -### m_datasetName +### receive ```solidity -string m_datasetName +receive() external payable virtual ``` -Members +_Receive function. +Implemented entirely in `_fallback`._ -### m_datasetMultiaddr +### fallback ```solidity -bytes m_datasetMultiaddr +fallback() external payable ``` -### m_datasetChecksum +_Fallback function. +Implemented entirely in `_fallback`._ -```solidity -bytes32 m_datasetChecksum -``` +## IWorkerpool -### initialize +### owner ```solidity -function initialize(string _datasetName, bytes _datasetMultiaddr, bytes32 _datasetChecksum) public +function owner() external view returns (address) ``` -Constructor - -## DatasetRegistry - -_Referenced in the SDK with the current path `contracts/registries/datasets/DatasetRegistry.sol`. -Changing the name or the path would cause a breaking change in the SDK._ - -### constructor +### m_workerpoolDescription ```solidity -constructor() public +function m_workerpoolDescription() external view returns (string) ``` -Constructor - -### createDataset +### m_schedulerRewardRatioPolicy ```solidity -function createDataset(address _datasetOwner, string _datasetName, bytes _datasetMultiaddr, bytes32 _datasetChecksum) external returns (contract Dataset) +function m_schedulerRewardRatioPolicy() external view returns (uint256) ``` -### predictDataset +### m_workerStakeRatioPolicy ```solidity -function predictDataset(address _datasetOwner, string _datasetName, bytes _datasetMultiaddr, bytes32 _datasetChecksum) external view returns (contract Dataset) +function m_workerStakeRatioPolicy() external view returns (uint256) ``` ## Workerpool diff --git a/test/000_fullchain-boost.test.ts b/test/000_fullchain-boost.test.ts index 9f47385f9..340728818 100644 --- a/test/000_fullchain-boost.test.ts +++ b/test/000_fullchain-boost.test.ts @@ -7,6 +7,7 @@ import { expect } from 'chai'; import { TypedDataDomain } from 'ethers'; import hre from 'hardhat'; import { + IWorkerpool__factory, IexecInterfaceNative, IexecInterfaceNative__factory, IexecOrderManagement__factory, @@ -14,7 +15,6 @@ import { IexecPocoBoostFacet, IexecPocoBoostFacet__factory, TestClient__factory, - IWorkerpool__factory, } from '../typechain'; import * as constants from '../utils/constants'; import { TAG_TEE } from '../utils/constants'; diff --git a/test/byContract/IexecERC20/IexecERC20.test.ts b/test/byContract/IexecERC20/IexecERC20.test.ts index 1708f9eb7..c812e0a6d 100644 --- a/test/byContract/IexecERC20/IexecERC20.test.ts +++ b/test/byContract/IexecERC20/IexecERC20.test.ts @@ -97,7 +97,7 @@ describe('ERC20', async () => { it('Should not transfer when sender balance is too low', async () => { await expect( iexecPocoAsHolder.transfer(recipient.address, value + 1n), - ).to.be.revertedWithPanic(0x11); + ).to.be.revertedWithoutReason(); }); }); @@ -201,13 +201,13 @@ describe('ERC20', async () => { it('Should not transferFrom when owner balance is too low', async () => { await expect( iexecPocoAsSpender.transferFrom(holder.address, spender.address, value + 1n), - ).to.be.revertedWithPanic(0x11); + ).to.be.revertedWithoutReason(); }); it('Should not transferFrom when spender allowance is too low', async () => { await iexecPocoAsHolder.approve(spender.address, value - 1n).then((tx) => tx.wait()); await expect( iexecPocoAsSpender.transferFrom(holder.address, spender.address, value), - ).to.be.revertedWithPanic(0x11); + ).to.be.revertedWithoutReason(); }); }); @@ -260,7 +260,7 @@ describe('ERC20', async () => { it('Should not decrease allowance of a value greater than old allowance', async () => { await expect( iexecPocoAsHolder.decreaseAllowance(spender.address, 1), - ).to.be.revertedWithPanic(0x11); + ).to.be.revertedWithoutReason(); }); it('Should not decrease allowance from the zero address', async () => { await expect( diff --git a/test/byContract/IexecEscrow/IexecEscrowNative.test.ts b/test/byContract/IexecEscrow/IexecEscrowNative.test.ts index 657c8334d..0c396a957 100644 --- a/test/byContract/IexecEscrow/IexecEscrowNative.test.ts +++ b/test/byContract/IexecEscrow/IexecEscrowNative.test.ts @@ -254,9 +254,9 @@ if (config.isNativeChain()) { }); it('Should not withdraw native tokens with empty balance', async () => { - await expect(iexecPocoAsAccountA.withdraw(...withdrawArg)).to.be.revertedWithPanic( - 0x11, - ); + await expect( + iexecPocoAsAccountA.withdraw(...withdrawArg), + ).to.be.revertedWithoutReason(); }); it('Should not withdraw native tokens with insufficient balance', async () => { @@ -264,7 +264,7 @@ if (config.isNativeChain()) { await expect( iexecPocoAsAccountA.withdraw(depositAmount * 2n), - ).to.be.revertedWithPanic(0x11); + ).to.be.revertedWithoutReason(); }); }); @@ -289,7 +289,7 @@ if (config.isNativeChain()) { const withdrawToArgs = [...withdrawArg, accountB.address] as [bigint, string]; await expect( iexecPocoAsAccountA.withdrawTo(...withdrawToArgs), - ).to.be.revertedWithPanic(0x11); + ).to.be.revertedWithoutReason(); }); it('Should not withdraw To native tokens with insufficient balance', async () => { @@ -297,7 +297,7 @@ if (config.isNativeChain()) { const withdrawToArgs = [...withdrawArg, accountB.address] as [bigint, string]; await expect( iexecPocoAsAccountA.withdrawTo(withdrawToArgs[0] * 2n, withdrawToArgs[1]), - ).to.be.revertedWithPanic(0x11); + ).to.be.revertedWithoutReason(); }); }); diff --git a/test/byContract/IexecEscrow/IexecEscrowToken.test.ts b/test/byContract/IexecEscrow/IexecEscrowToken.test.ts index 10978d2ec..f7bf57223 100644 --- a/test/byContract/IexecEscrow/IexecEscrowToken.test.ts +++ b/test/byContract/IexecEscrow/IexecEscrowToken.test.ts @@ -305,13 +305,13 @@ describe('IexecEscrowToken', () => { .withArgs(proxyAddress, accountA.address, 0); }); it('Should not withdraw tokens with empty balance', async () => { - await expect(iexecPocoAsAccountA.withdraw(amount)).to.be.revertedWithPanic(0x11); + await expect(iexecPocoAsAccountA.withdraw(amount)).to.be.revertedWithoutReason(); }); it('Should not withdraw tokens with insufficient balance', async () => { await rlcInstanceAsAccountA.approve(proxyAddress, amount).then((tx) => tx.wait()); await iexecPocoAsAccountA.deposit(amount).then((tx) => tx.wait()); - await expect(iexecPocoAsAccountA.withdraw(amount + 1n)).to.be.revertedWithPanic(0x11); + await expect(iexecPocoAsAccountA.withdraw(amount + 1n)).to.be.revertedWithoutReason(); }); }); @@ -366,7 +366,7 @@ describe('IexecEscrowToken', () => { it('Should not withdraw to another address with empty balance', async () => { await expect( iexecPocoAsAccountA.withdrawTo(amount, accountB.address), - ).to.be.revertedWithPanic(0x11); + ).to.be.revertedWithoutReason(); }); it('Should not withdraw to another address with insufficient balance', async () => { await rlcInstanceAsAccountA.approve(proxyAddress, amount).then((tx) => tx.wait()); @@ -374,7 +374,7 @@ describe('IexecEscrowToken', () => { await expect( iexecPocoAsAccountA.withdrawTo(amount + 1n, accountB.address), - ).to.be.revertedWithPanic(0x11); + ).to.be.revertedWithoutReason(); }); }); diff --git a/test/byContract/registries/registries.test.ts b/test/byContract/registries/registries.test.ts index 1a13006f3..cf3d94832 100644 --- a/test/byContract/registries/registries.test.ts +++ b/test/byContract/registries/registries.test.ts @@ -15,11 +15,13 @@ import { Dataset__factory, IexecInterfaceNative, IexecInterfaceNative__factory, - InitializableUpgradeabilityProxy__factory, WorkerpoolRegistry, WorkerpoolRegistry__factory, Workerpool__factory, } from '../../../typechain'; +//import the correct InitializableUpgradeabilityProxy__factory from the local registry's proxy instead of @iexec/solidity +//TODO: merge with the previous import when @iexec/solidity will be removed +import { InitializableUpgradeabilityProxy__factory } from '../../../typechain/factories/contracts/registries/proxy/InitializableUpgradeabilityProxy__factory'; import config from '../../../utils/config'; import { MULTIADDR_BYTES } from '../../../utils/constants'; import { getIexecAccounts } from '../../../utils/poco-tools'; @@ -97,15 +99,15 @@ describe('Registries', () => { }); it('Should not initialize when user is not the owner', async () => { - await expect(appRegistry.initialize(ZeroAddress)) - .to.be.revertedWithCustomError(appRegistry, 'OwnableUnauthorizedAccount') - .withArgs(anyone.address); - await expect(datasetRegistry.initialize(ZeroAddress)) - .to.be.revertedWithCustomError(datasetRegistry, 'OwnableUnauthorizedAccount') - .withArgs(anyone.address); - await expect(workerpoolRegistry.initialize(ZeroAddress)) - .to.be.revertedWithCustomError(workerpoolRegistry, 'OwnableUnauthorizedAccount') - .withArgs(anyone.address); + await expect(appRegistry.initialize(ZeroAddress)).to.be.revertedWith( + 'Ownable: caller is not the owner', + ); + await expect(datasetRegistry.initialize(ZeroAddress)).to.be.revertedWith( + 'Ownable: caller is not the owner', + ); + await expect(workerpoolRegistry.initialize(ZeroAddress)).to.be.revertedWith( + 'Ownable: caller is not the owner', + ); }); it('Should not reinitialize', async () => { @@ -131,15 +133,15 @@ describe('Registries', () => { }); it('Should not set base URI when user is not the owner', async () => { - await expect(appRegistry.setBaseURI(`https://new.url.iex.ec/app/`)) - .to.be.revertedWithCustomError(appRegistry, 'OwnableUnauthorizedAccount') - .withArgs(anyone.address); - await expect(datasetRegistry.setBaseURI(`https://new.url.iex.ec/dataset/`)) - .to.be.revertedWithCustomError(datasetRegistry, 'OwnableUnauthorizedAccount') - .withArgs(anyone.address); - await expect(workerpoolRegistry.setBaseURI(`https://new.url.iex.ec/workerpool/`)) - .to.be.revertedWithCustomError(workerpoolRegistry, 'OwnableUnauthorizedAccount') - .withArgs(anyone.address); + await expect(appRegistry.setBaseURI(`https://new.url.iex.ec/app/`)).to.be.revertedWith( + 'Ownable: caller is not the owner', + ); + await expect( + datasetRegistry.setBaseURI(`https://new.url.iex.ec/dataset/`), + ).to.be.revertedWith('Ownable: caller is not the owner'); + await expect( + workerpoolRegistry.setBaseURI(`https://new.url.iex.ec/workerpool/`), + ).to.be.revertedWith('Ownable: caller is not the owner'); }); }); @@ -280,7 +282,7 @@ describe('Registries', () => { await expect( appRegistry.createApp(appProvider.address, ...createAppArgs), - ).to.be.revertedWithCustomError(appRegistry, 'Create2FailedDeployment'); + ).to.be.revertedWith('Create2: Failed on deploy'); }); it('Should check that a new app is well registered on new app registry', async () => { @@ -385,7 +387,7 @@ describe('Registries', () => { await expect( datasetRegistry.createDataset(datasetProvider.address, ...createDatasetArgs), - ).to.be.revertedWithCustomError(datasetRegistry, 'Create2FailedDeployment'); + ).to.be.revertedWith('Create2: Failed on deploy'); }); }); @@ -469,7 +471,7 @@ describe('Registries', () => { await expect( workerpoolRegistry.createWorkerpool(scheduler.address, ...createWorkerpoolArgs), - ).to.be.revertedWithCustomError(workerpoolRegistry, 'Create2FailedDeployment'); + ).to.be.revertedWith('Create2: Failed on deploy'); }); });