From b4ee4f5b2af9cffd83dff083d83b489f201c3dbf Mon Sep 17 00:00:00 2001 From: ernestognw Date: Thu, 12 Oct 2023 00:21:00 -0600 Subject: [PATCH 1/2] Add note about `SafeMath.sol` remaining functions moved over to `Math.sol` --- CHANGELOG.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98d06de9980..519369d18d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,10 +71,31 @@ Users that were registering EIP-165 interfaces with `_registerInterface` from `E ```solidity function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { - return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); + return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); } ``` +#### SafeMath + +Methods in SafeMath superseded by native overflow checks in Solidity 0.8.0 were removed along with operations providing an interface for revert strings. The remaining methods were moved to `utils/Math.sol`. + +```diff +- import "@openzeppelin/contracts/utils/math/SafeMath.sol"; ++ import "@openzeppelin/contracts/utils/math/Math.sol"; + + function tryOperations(uint256 x, uint256 y) external { +- (bool overflowsAdd, uint256 resultAdd) = SafeMath.tryAdd(x, y); ++ (bool overflowsAdd, uint256 resultAdd) = Math.tryAdd(x, y); +- (bool overflowsSub, uint256 resultSub) = SafeMath.trySub(x, y); ++ (bool overflowsSub, uint256 resultSub) = Math.trySub(x, y); +- (bool overflowsMul, uint256 resultMul) = SafeMath.tryMul(x, y); ++ (bool overflowsMul, uint256 resultMul) = Math.tryMul(x, y); +- (bool overflowsDiv, uint256 resultDiv) = SafeMath.tryDiv(x, y); ++ (bool overflowsDiv, uint256 resultDiv) = Math.tryDiv(x, y); + // ... + } +``` + ## 4.9.2 (2023-06-16) - `MerkleProof`: Fix a bug in `processMultiProof` and `processMultiProofCalldata` that allows proving arbitrary leaves if the tree contains a node with value 0 at depth 1. From 4ab46e8c9754dd35669010ae75744b344ae7ac8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernesto=20Garc=C3=ADa?= Date: Thu, 12 Oct 2023 00:25:31 -0600 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e65a86dbdf..249eb76a478 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -202,7 +202,7 @@ Methods in SafeMath superseded by native overflow checks in Solidity 0.8.0 were - import "@openzeppelin/contracts/utils/math/SafeMath.sol"; + import "@openzeppelin/contracts/utils/math/Math.sol"; - function tryOperations(uint256 x, uint256 y) external { + function tryOperations(uint256 x, uint256 y) external view { - (bool overflowsAdd, uint256 resultAdd) = SafeMath.tryAdd(x, y); + (bool overflowsAdd, uint256 resultAdd) = Math.tryAdd(x, y); - (bool overflowsSub, uint256 resultSub) = SafeMath.trySub(x, y);