Skip to content

Commit c7b8067

Browse files
Le-CaignecCopilotzguesmi
authored
feat: make Solidity V8 migration non breaking (#306)
Co-authored-by: Copilot <[email protected]> Co-authored-by: Zied <[email protected]>
1 parent 4bab677 commit c7b8067

24 files changed

+479
-445
lines changed

contracts/facets/IexecERC20Core.sol

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ contract IexecERC20Core is IexecERC20Common, FacetBase {
1212
require(sender != address(0), "ERC20: transfer from the zero address");
1313
require(recipient != address(0), "ERC20: transfer to the zero address");
1414
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
15-
$.m_balances[sender] = $.m_balances[sender] - amount;
15+
uint256 senderBalance = $.m_balances[sender];
16+
// TEMPORARY MIGRATION FIX: Check balance to prevent underflow and revert without reason for backward compatibility
17+
// TODO: Remove this in the next major version
18+
if (senderBalance < amount) {
19+
revert();
20+
}
21+
$.m_balances[sender] = senderBalance - amount;
1622
$.m_balances[recipient] = $.m_balances[recipient] + amount;
1723
emit Transfer(sender, recipient, amount);
1824
}
@@ -32,8 +38,14 @@ contract IexecERC20Core is IexecERC20Common, FacetBase {
3238
function _burn(address account, uint256 amount) internal {
3339
require(account != address(0), "ERC20: burn from the zero address");
3440
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
41+
uint256 accountBalance = $.m_balances[account];
42+
// TEMPORARY MIGRATION FIX: Check balance to prevent underflow and revert without reason for backward compatibility
43+
// TODO: Remove this in the next major version
44+
if (accountBalance < amount) {
45+
revert();
46+
}
3547
$.m_totalSupply = $.m_totalSupply - amount;
36-
$.m_balances[account] = $.m_balances[account] - amount;
48+
$.m_balances[account] = accountBalance - amount;
3749
emit Transfer(account, address(0), amount);
3850
}
3951

contracts/facets/IexecERC20Facet.sol

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ contract IexecERC20Facet is IexecERC20, FacetBase, IexecERC20Core {
4545
) external override returns (bool) {
4646
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
4747
_transfer(sender, recipient, amount);
48-
_approve(sender, _msgSender(), $.m_allowances[sender][_msgSender()] - amount);
48+
// TEMPORARY MIGRATION FIX: Check allowance to prevent underflow and revert without reason for backward compatibility
49+
// TODO: Remove this in the next major version
50+
uint256 currentAllowance = $.m_allowances[sender][_msgSender()];
51+
if (currentAllowance < amount) {
52+
revert();
53+
}
54+
_approve(sender, _msgSender(), currentAllowance - amount);
4955
return true;
5056
}
5157

@@ -63,7 +69,13 @@ contract IexecERC20Facet is IexecERC20, FacetBase, IexecERC20Core {
6369
uint256 subtractedValue
6470
) external override returns (bool) {
6571
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
66-
_approve(_msgSender(), spender, $.m_allowances[_msgSender()][spender] - subtractedValue);
72+
// TEMPORARY MIGRATION FIX: Check allowance to prevent underflow and revert without reason for backward compatibility
73+
// TODO: Remove this in the next major version
74+
uint256 currentAllowance = $.m_allowances[_msgSender()][spender];
75+
if (currentAllowance < subtractedValue) {
76+
revert();
77+
}
78+
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
6779
return true;
6880
}
6981
}

contracts/facets/IexecEscrowTokenFacet.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {IexecTokenSpender} from "../interfaces/IexecTokenSpender.sol";
1010
import {PocoStorageLib} from "../libs/PocoStorageLib.sol";
1111

1212
contract IexecEscrowTokenFacet is IexecEscrowToken, IexecTokenSpender, FacetBase, IexecERC20Core {
13-
1413
/***************************************************************************
1514
* Escrow methods: public *
1615
***************************************************************************/

contracts/interfaces/IOwnable.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
pragma solidity >=0.6.0;
5-
pragma experimental ABIEncoderV2;
4+
pragma solidity ^0.8.0;
65

76
interface IOwnable {
87
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

contracts/interfaces/IexecAccessorsABILegacy.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
pragma solidity >=0.6.0;
5-
pragma experimental ABIEncoderV2;
4+
pragma solidity ^0.8.0;
65

76
import "../libs/IexecLibCore_v5.sol";
87

contracts/interfaces/IexecCategoryManager.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
pragma solidity >=0.6.0;
5-
pragma experimental ABIEncoderV2;
4+
pragma solidity ^0.8.0;
65

76
interface IexecCategoryManager {
87
event CreateCategory(uint256 catid, string name, string description, uint256 workClockTimeRef);

contracts/interfaces/IexecConfiguration.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
pragma solidity >=0.6.0;
5-
pragma experimental ABIEncoderV2;
6-
4+
pragma solidity ^0.8.0;
75
import "../libs/IexecLibOrders_v5.sol";
86

97
interface IexecConfiguration {
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
pragma solidity >=0.6.0;
5-
pragma experimental ABIEncoderV2;
6-
4+
pragma solidity ^0.8.0;
75
interface IexecConfigurationExtra {
86
function changeRegistries(address, address, address) external;
97
}

contracts/interfaces/IexecERC20.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
// SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
pragma solidity >=0.6.0;
5-
pragma experimental ABIEncoderV2;
4+
pragma solidity ^0.8.0;
65

76
import {IexecERC20Common} from "./IexecERC20Common.sol";
87

98
interface IexecERC20 is IexecERC20Common {
10-
119
function transfer(address, uint256) external returns (bool);
1210
function approve(address, uint256) external returns (bool);
1311
function transferFrom(address, address, uint256) external returns (bool);

contracts/interfaces/IexecERC20Common.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
pragma solidity >=0.6.0;
5-
pragma experimental ABIEncoderV2;
6-
4+
pragma solidity ^0.8.0;
75
// TODO merge with IexecERC20 interface.
86
interface IexecERC20Common {
97
event Transfer(address indexed from, address indexed to, uint256 value);

0 commit comments

Comments
 (0)