Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Address.toPayable #2133

Merged
merged 2 commits into from
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 0 additions & 4 deletions contracts/mocks/AddressImpl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 0 additions & 10 deletions contracts/utils/Address.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 1 addition & 17 deletions test/utils/Address.test.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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();
});
Expand All @@ -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);
Expand Down