@@ -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
0 commit comments