From a55eac5a63a630b3fbe3a71680971818e78c6440 Mon Sep 17 00:00:00 2001 From: Nishant_Koyalwar Date: Thu, 17 Aug 2023 23:57:26 +0530 Subject: [PATCH 1/8] moved beneficiary zero address check to Ownable --- contracts/access/Ownable.sol | 3 +++ contracts/finance/VestingWallet.sol | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/access/Ownable.sol b/contracts/access/Ownable.sol index aa495ff4de7..3cf11378261 100644 --- a/contracts/access/Ownable.sol +++ b/contracts/access/Ownable.sol @@ -36,6 +36,9 @@ abstract contract Ownable is Context { * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { + if (initialOwner == address(0)) { + revert OwnableInvalidOwner(address(0)); + } _transferOwnership(initialOwner); } diff --git a/contracts/finance/VestingWallet.sol b/contracts/finance/VestingWallet.sol index 7b50e699e1f..a172444c5e2 100644 --- a/contracts/finance/VestingWallet.sol +++ b/contracts/finance/VestingWallet.sol @@ -46,10 +46,7 @@ contract VestingWallet is Context, Ownable { * vesting duration of the vesting wallet. */ constructor(address beneficiary, uint64 startTimestamp, uint64 durationSeconds) payable Ownable(beneficiary) { - if (beneficiary == address(0)) { - revert VestingWalletInvalidBeneficiary(address(0)); - } - + _start = startTimestamp; _duration = durationSeconds; } From eeb6ec2113d34b6f35e52e565865f474a220592b Mon Sep 17 00:00:00 2001 From: Nishant_Koyalwar Date: Fri, 18 Aug 2023 02:00:52 +0530 Subject: [PATCH 2/8] formatted code using prettier --- contracts/finance/VestingWallet.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/finance/VestingWallet.sol b/contracts/finance/VestingWallet.sol index a172444c5e2..a5ecfaa133d 100644 --- a/contracts/finance/VestingWallet.sol +++ b/contracts/finance/VestingWallet.sol @@ -46,7 +46,6 @@ contract VestingWallet is Context, Ownable { * vesting duration of the vesting wallet. */ constructor(address beneficiary, uint64 startTimestamp, uint64 durationSeconds) payable Ownable(beneficiary) { - _start = startTimestamp; _duration = durationSeconds; } From 72b508c09f63d87b02dffdaa7f647998997bf337 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Fri, 25 Aug 2023 22:49:08 +0200 Subject: [PATCH 3/8] Remove unused error --- contracts/finance/VestingWallet.sol | 5 ----- 1 file changed, 5 deletions(-) diff --git a/contracts/finance/VestingWallet.sol b/contracts/finance/VestingWallet.sol index a5ecfaa133d..f014e59c4bd 100644 --- a/contracts/finance/VestingWallet.sol +++ b/contracts/finance/VestingWallet.sol @@ -31,11 +31,6 @@ contract VestingWallet is Context, Ownable { event EtherReleased(uint256 amount); event ERC20Released(address indexed token, uint256 amount); - /** - * @dev The `beneficiary` is not a valid account. - */ - error VestingWalletInvalidBeneficiary(address beneficiary); - uint256 private _released; mapping(address token => uint256) private _erc20Released; uint64 private immutable _start; From e03cfa99f6024d04dfe19d00f89d28e632593323 Mon Sep 17 00:00:00 2001 From: Nishant_Koyalwar Date: Thu, 31 Aug 2023 19:56:38 +0530 Subject: [PATCH 4/8] added changeset --- .changeset/clever-bats-kick.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/clever-bats-kick.md diff --git a/.changeset/clever-bats-kick.md b/.changeset/clever-bats-kick.md new file mode 100644 index 00000000000..836a0fd9746 --- /dev/null +++ b/.changeset/clever-bats-kick.md @@ -0,0 +1,5 @@ +--- +'openzeppelin-solidity': patch +--- + +moved beneficiay zero address check to Ownable From 1d111c88f0eb594050f818516dc4eed6f52dc6e8 Mon Sep 17 00:00:00 2001 From: NishantKoyalwar <122688383+NishantKoyalwar@users.noreply.github.com> Date: Thu, 31 Aug 2023 22:35:05 +0530 Subject: [PATCH 5/8] Update .changeset/clever-bats-kick.md Co-authored-by: Hadrien Croubois --- .changeset/clever-bats-kick.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/clever-bats-kick.md b/.changeset/clever-bats-kick.md index 836a0fd9746..7d080c22e53 100644 --- a/.changeset/clever-bats-kick.md +++ b/.changeset/clever-bats-kick.md @@ -2,4 +2,4 @@ 'openzeppelin-solidity': patch --- -moved beneficiay zero address check to Ownable +`Ownable`: prevent using address(0) as the initial owner. From e37d5b4125350fe191e918e351da136e62708406 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Fri, 1 Sep 2023 12:06:54 +0200 Subject: [PATCH 6/8] update tests --- test/access/Ownable.test.js | 8 ++++++++ test/finance/VestingWallet.test.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/test/access/Ownable.test.js b/test/access/Ownable.test.js index 079d694d730..0d84709c016 100644 --- a/test/access/Ownable.test.js +++ b/test/access/Ownable.test.js @@ -14,6 +14,14 @@ contract('Ownable', function (accounts) { this.ownable = await Ownable.new(owner); }); + it('rejects zero address for initialOwner', async function () { + await expectRevertCustomError( + Ownable.new(constants.ZERO_ADDRESS), + 'OwnableInvalidOwner', + [constants.ZERO_ADDRESS], + ); + }); + it('has an owner', async function () { expect(await this.ownable.owner()).to.equal(owner); }); diff --git a/test/finance/VestingWallet.test.js b/test/finance/VestingWallet.test.js index d79aea1955a..918e56345fb 100644 --- a/test/finance/VestingWallet.test.js +++ b/test/finance/VestingWallet.test.js @@ -23,7 +23,7 @@ contract('VestingWallet', function (accounts) { it('rejects zero address for beneficiary', async function () { await expectRevertCustomError( VestingWallet.new(constants.ZERO_ADDRESS, this.start, duration), - 'VestingWalletInvalidBeneficiary', + 'OwnableInvalidOwner', [constants.ZERO_ADDRESS], ); }); From 67d1a7c5ccc9365078c0dcd8a9962d3924f93b9e Mon Sep 17 00:00:00 2001 From: Francisco Date: Mon, 4 Sep 2023 13:49:48 -0300 Subject: [PATCH 7/8] lint --- test/access/Ownable.test.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/access/Ownable.test.js b/test/access/Ownable.test.js index 0d84709c016..f85daec5d28 100644 --- a/test/access/Ownable.test.js +++ b/test/access/Ownable.test.js @@ -15,11 +15,7 @@ contract('Ownable', function (accounts) { }); it('rejects zero address for initialOwner', async function () { - await expectRevertCustomError( - Ownable.new(constants.ZERO_ADDRESS), - 'OwnableInvalidOwner', - [constants.ZERO_ADDRESS], - ); + await expectRevertCustomError(Ownable.new(constants.ZERO_ADDRESS), 'OwnableInvalidOwner', [constants.ZERO_ADDRESS]); }); it('has an owner', async function () { From edf487a79143664010a179f73c8c284d3f4b7a64 Mon Sep 17 00:00:00 2001 From: Francisco Date: Mon, 4 Sep 2023 13:50:31 -0300 Subject: [PATCH 8/8] Update clever-bats-kick.md --- .changeset/clever-bats-kick.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/clever-bats-kick.md b/.changeset/clever-bats-kick.md index 7d080c22e53..b35301b73de 100644 --- a/.changeset/clever-bats-kick.md +++ b/.changeset/clever-bats-kick.md @@ -2,4 +2,4 @@ 'openzeppelin-solidity': patch --- -`Ownable`: prevent using address(0) as the initial owner. +`Ownable`: Prevent using address(0) as the initial owner.