From 9975a1a0c2bb31ac0f79843fd53a53ba055ff701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Venturo?= Date: Mon, 16 Mar 2020 18:22:02 -0300 Subject: [PATCH] Remove Address.toPayable (#2133) * Remove Address.toPayable * Add changelog entry --- CHANGELOG.md | 1 + contracts/mocks/AddressImpl.sol | 4 ---- contracts/utils/Address.sol | 10 ---------- test/utils/Address.test.js | 18 +----------------- 4 files changed, 2 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d32db2b0..6fe7e2a2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ * `Secondary`: removed from the library, use `Ownable` instead. ([#2120](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2120)) * `Escrow`, `ConditionalEscrow`, `RefundEscrow`: these now use `Ownable` instead of `Secondary`, their external API changed accordingly. ([#2120](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2120)) * `ERC20`: removed `_burnFrom`. ([#2119](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2119)) + * `Address`: removed `toPayable`, use `payable(address)` instead. ([#2133](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2133)) ## 2.5.0 (2020-02-04) diff --git a/contracts/mocks/AddressImpl.sol b/contracts/mocks/AddressImpl.sol index d0f5fa836..a7f357d05 100644 --- a/contracts/mocks/AddressImpl.sol +++ b/contracts/mocks/AddressImpl.sol @@ -7,10 +7,6 @@ contract AddressImpl { return Address.isContract(account); } - function toPayable(address account) external pure returns (address payable) { - return Address.toPayable(account); - } - function sendValue(address payable receiver, uint256 amount) external { Address.sendValue(receiver, amount); } diff --git a/contracts/utils/Address.sol b/contracts/utils/Address.sol index d31cf5c54..5d794ee6d 100644 --- a/contracts/utils/Address.sol +++ b/contracts/utils/Address.sol @@ -32,16 +32,6 @@ library Address { return (codehash != accountHash && codehash != 0x0); } - /** - * @dev Converts an `address` into `address payable`. Note that this is - * simply a type cast: the actual underlying value is not changed. - * - * _Available since v2.4.0._ - */ - function toPayable(address account) internal pure returns (address payable) { - return address(uint160(account)); - } - /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. diff --git a/test/utils/Address.test.js b/test/utils/Address.test.js index 3fa6440c9..1229302ca 100644 --- a/test/utils/Address.test.js +++ b/test/utils/Address.test.js @@ -1,6 +1,6 @@ const { accounts, contract } = require('@openzeppelin/test-environment'); -const { balance, constants, ether, expectRevert, send } = require('@openzeppelin/test-helpers'); +const { balance, ether, expectRevert, send } = require('@openzeppelin/test-helpers'); const { expect } = require('chai'); const AddressImpl = contract.fromArtifact('AddressImpl'); @@ -9,8 +9,6 @@ const EtherReceiver = contract.fromArtifact('EtherReceiverMock'); describe('Address', function () { const [ recipient, other ] = accounts; - const ALL_ONES_ADDRESS = '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF'; - beforeEach(async function () { this.mock = await AddressImpl.new(); }); @@ -26,20 +24,6 @@ describe('Address', function () { }); }); - describe('toPayable', function () { - it('should return a payable address when the account is the zero address', async function () { - expect(await this.mock.toPayable(constants.ZERO_ADDRESS)).to.equal(constants.ZERO_ADDRESS); - }); - - it('should return a payable address when the account is an arbitrary address', async function () { - expect(await this.mock.toPayable(other)).to.equal(other); - }); - - it('should return a payable address when the account is the all ones address', async function () { - expect(await this.mock.toPayable(ALL_ONES_ADDRESS)).to.equal(ALL_ONES_ADDRESS); - }); - }); - describe('sendValue', function () { beforeEach(async function () { this.recipientTracker = await balance.tracker(recipient);