Skip to content

Commit

Permalink
Merge pull request #369 from push-protocol/366-bump-down-oz-version-f…
Browse files Browse the repository at this point in the history
…or-pgp-registry

Downgraded OZ version to 4.9.0
  • Loading branch information
zaryab2000 authored May 29, 2024
2 parents 8c210d5 + 6ab07f5 commit 5ae5940
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 53 deletions.
2 changes: 1 addition & 1 deletion contracts/PushComm/EPNSCommAdmin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ pragma solidity ^0.8.20;
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";

contract EPNSCommAdmin is ProxyAdmin {
constructor(address _pushChannelAdmin) public ProxyAdmin(_pushChannelAdmin) { }
constructor(address _pushChannelAdmin) public ProxyAdmin() { }
}
2 changes: 1 addition & 1 deletion contracts/PushCore/EPNSCoreAdmin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ pragma solidity ^0.8.20;
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";

contract EPNSCoreAdmin is ProxyAdmin {
constructor(address _pushChannelAdmin) public ProxyAdmin(_pushChannelAdmin) { }
constructor(address _pushChannelAdmin) public ProxyAdmin() { }
}
2 changes: 1 addition & 1 deletion contracts/PushCore/PushCoreV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { CoreTypes } from "../libraries/DataTypes.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { PausableUpgradeable, Initializable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import { PausableUpgradeable, Initializable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";

contract PushCoreV3 is Initializable, PushCoreStorageV1_5, PausableUpgradeable, PushCoreStorageV2, IPushCoreV3 {
using SafeERC20 for IERC20;
Expand Down
2 changes: 0 additions & 2 deletions contracts/libraries/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ library Errors {
error InvalidArg_MoreThanExpected(uint256 max_threshold, uint256 actual_value);
/// @notice Reverts when uint256 argument passed is less than expected value.
error InvalidArg_LessThanExpected(uint256 min_threshold, uint256 actual_value);
/// @notice Reverts when operation failed because the contract is paused.
error EnforcedPause();
/// @notice The caller account is not authorized to perform an operation.
error OwnableUnauthorizedAccount(address account);

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/PushCoreMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { PushCoreStorageV2 } from "../PushCore/PushCoreStorageV2.sol";

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { PausableUpgradeable, Initializable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import { PausableUpgradeable, Initializable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";

contract PushCoreMock is Initializable, PushCoreStorageV1_5, PausableUpgradeable, PushCoreStorageV2 {
using SafeERC20 for IERC20;
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/Push.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ contract Push is Ownable{
* @notice Construct a new PUSH token
* @param account The initial account to grant all the tokens
*/
constructor(address account) Ownable(account){
constructor(address account) Ownable(){
// holder weight initial adjustments
holderWeight[account] = block.number;
born = block.number;
Expand Down
4 changes: 2 additions & 2 deletions contracts/token/PushMigration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import { PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";

contract PushMigrationHelper is OwnableUpgradeable, PausableUpgradeable{
using SafeERC20 for IERC20;
Expand All @@ -32,7 +32,7 @@ contract PushMigrationHelper is OwnableUpgradeable, PausableUpgradeable{
function initialize(address _owner, address _oldToken) external initializer {
oldPushToken = IERC20(_oldToken);

__Ownable_init(_owner);
__Ownable_init();
}

function pauseContract() external onlyOwner{
Expand Down
19 changes: 8 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"dependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@openzeppelin/contracts": "^5.0.0",
"@openzeppelin/contracts-upgradeable": "^5.0.0",
"@openzeppelin/contracts": "^4.9.0",
"@openzeppelin/contracts-upgradeable": "^4.9.0",
"bip39": "3.0.3",
"chai": "^4.3.4",
"chalk": "^4.1.1",
Expand Down
32 changes: 13 additions & 19 deletions test/BaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {EPNSCommProxy} from "contracts/PushComm/EPNSCommProxy.sol";
import {EPNSCommAdmin} from "contracts/PushComm/EPNSCommAdmin.sol";
import {PushMigrationHelper} from "contracts/token/PushMigration.sol";
import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";

import {Actors} from "./utils/Actors.sol";
import {Events} from "./utils/Events.sol";
Expand All @@ -35,6 +36,7 @@ abstract contract BaseTest is Test, Constants, Events {
PushMigrationHelper public pushMigrationHelper;
PushMigrationHelper public pushMigrationHelperProxy;
TransparentUpgradeableProxy public pushMigrationProxy;
ProxyAdmin public pushProxyAdmin;

/* ***************
Main Actors in Test
Expand Down Expand Up @@ -79,12 +81,14 @@ abstract contract BaseTest is Test, Constants, Events {
tim_push_holder: createActor("tim_push_holder")
});

changePrank(actor.admin);
pushNttToken = new Push(actor.admin);
pushProxyAdmin = new ProxyAdmin();

// Initialize pushMigration proxy admin and proxy contract
pushMigrationProxy = new TransparentUpgradeableProxy(
address(pushMigrationHelper),
actor.admin,
address(pushProxyAdmin),
abi.encodeWithSignature(
"initialize(address,address)",
actor.admin,
Expand All @@ -95,13 +99,14 @@ abstract contract BaseTest is Test, Constants, Events {
address(pushMigrationProxy)
);
// set governance as minter of ntt token
vm.prank(actor.admin);
changePrank(actor.admin);
pushNttToken.setMinter(actor.governance);

epnsCoreProxyAdmin = new EPNSCoreAdmin(actor.admin);
// Initialize coreMock proxy admin and coreProxy contract
epnsCoreProxy = new EPNSCoreProxy(
address(coreMock),
actor.admin,
address(epnsCoreProxyAdmin),
actor.admin,
address(pushToken),
address(0), // WETH Address
Expand All @@ -111,25 +116,14 @@ abstract contract BaseTest is Test, Constants, Events {
address(0), // aDai address
0
);
address admin = address(
uint160(
uint256(
vm.load(
address(epnsCoreProxy),
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103
)
)
)
);
vm.prank(actor.admin);
EPNSCoreAdmin(admin).upgradeAndCall(
changePrank(actor.admin);
epnsCoreProxyAdmin.upgrade(
ITransparentUpgradeableProxy(address(epnsCoreProxy)),
address(coreProxy),
""
address(coreProxy)
);

coreProxy = PushCoreV3(address(epnsCoreProxy));
vm.prank(tokenDistributor);
changePrank(tokenDistributor);
pushToken.transfer(address(coreProxy), 1 ether);

// Initialize comm proxy admin and commProxy contract
Expand All @@ -143,7 +137,7 @@ abstract contract BaseTest is Test, Constants, Events {
commProxy = PushCommV3(address(epnsCommProxy));

// Set-up Core Address in Comm & Vice-Versa
vm.startPrank(actor.admin);
changePrank(actor.admin);
commProxy.setEPNSCoreAddress(address(coreProxy));
commProxy.setPushTokenAddress(address(pushToken));
coreProxy.setEpnsCommunicatorAddress(address(commProxy));
Expand Down
4 changes: 2 additions & 2 deletions test/PushComm/unit_tests/WalletPGPActions/walletPGP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ contract walletPGP_Test is BasePushCommTest {
// it should REVERT
bytes memory _data = getEncodedData(actor.bob_channel_owner);

vm.expectRevert("Nothing to delete");
vm.expectRevert("Invalid Call");
changePrank(actor.bob_channel_owner);
commProxy.removeWalletFromUser(_data, false);
}
Expand Down Expand Up @@ -212,7 +212,7 @@ contract walletPGP_Test is BasePushCommTest {
// it should REVERT
bytes memory _data = getEncodedData(address(firstERC721), 0);

vm.expectRevert("Nothing to delete");
vm.expectRevert("Invalid Call");
changePrank(actor.bob_channel_owner);
commProxy.removeWalletFromUser(_data, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ contract walletPGP_Test is BasePushCommTest {
// it should REVERT
bytes memory _data = getEncodedData(actor.bob_channel_owner);

vm.expectRevert("Nothing to delete");
vm.expectRevert("Invalid Call");
changePrank(actor.bob_channel_owner);
commProxyEth.removeWalletFromUser(_data, false);
}
Expand Down Expand Up @@ -234,7 +234,7 @@ contract walletPGP_Test is BasePushCommTest {
uint coreBalanceBefore = pushToken.balanceOf(address(coreProxy));
bytes memory _data = getEncodedData(address(firstERC721), 0);

vm.expectRevert("Nothing to delete");
vm.expectRevert("Invalid Call");
changePrank(actor.bob_channel_owner);
commProxyEth.removeWalletFromUser(_data, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ contract ContractPausability_Test is BasePushCoreTest {
vm.prank(actor.admin);
coreProxy.pauseContract();

vm.expectRevert(abi.encodeWithSelector(Errors.EnforcedPause.selector));
vm.expectRevert("Pausable: paused");
_createChannel(actor.bob_channel_owner);
}

Expand All @@ -57,7 +57,7 @@ contract ContractPausability_Test is BasePushCoreTest {
vm.prank(actor.admin);
coreProxy.pauseContract();

vm.expectRevert(abi.encodeWithSelector(Errors.EnforcedPause.selector));
vm.expectRevert("Pausable: paused");
vm.prank(actor.bob_channel_owner);
coreProxy.updateChannelState(0);
}
Expand All @@ -70,7 +70,7 @@ contract ContractPausability_Test is BasePushCoreTest {
vm.prank(actor.admin);
coreProxy.pauseContract();

vm.expectRevert(abi.encodeWithSelector(Errors.EnforcedPause.selector));
vm.expectRevert("Pausable: paused");
vm.prank(actor.bob_channel_owner);
coreProxy.updateChannelState(ADD_CHANNEL_MIN_FEES);
}
Expand All @@ -81,7 +81,7 @@ contract ContractPausability_Test is BasePushCoreTest {
vm.prank(actor.admin);
coreProxy.pauseContract();

vm.expectRevert(abi.encodeWithSelector(Errors.EnforcedPause.selector));
vm.expectRevert("Pausable: paused");
vm.prank(actor.admin);
coreProxy.blockChannel(actor.bob_channel_owner);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract MigrationAdminActions_Test is BaseTest {

function test_Revertwhen_NonAdminCalls_SetNewPushToken() public onlyOwner {
vm.prank(actor.dan_push_holder);
vm.expectRevert(abi.encodeWithSelector(Errors.OwnableUnauthorizedAccount.selector, actor.dan_push_holder));
vm.expectRevert("Ownable: caller is not the owner");
pushMigrationHelperProxy.setNewPushToken(address(pushNttToken));
}

Expand Down Expand Up @@ -53,7 +53,7 @@ contract MigrationAdminActions_Test is BaseTest {

function test_Revertwhen_NonAdminCalls_ToggleUnMigrationStatus() public onlyOwner {
vm.prank(actor.dan_push_holder);
vm.expectRevert(abi.encodeWithSelector(Errors.OwnableUnauthorizedAccount.selector, actor.dan_push_holder));
vm.expectRevert("Ownable: caller is not the owner");
pushMigrationHelperProxy.toggleUnMigrationStatus(true);
}

Expand All @@ -77,7 +77,7 @@ contract MigrationAdminActions_Test is BaseTest {

function test_Revertwhen_NonAdminCalls_BurnOldTokens() public onlyOwner {
vm.prank(actor.dan_push_holder);
vm.expectRevert(abi.encodeWithSelector(Errors.OwnableUnauthorizedAccount.selector, actor.dan_push_holder));
vm.expectRevert("Ownable: caller is not the owner");
pushMigrationHelperProxy.burnOldTokens(1_000 ether);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ contract SetMinter_Test is BaseTest {

function test_Revertwhen_CallerNotOwner() public onlyOwner {
vm.prank(actor.dan_push_holder);
vm.expectRevert(abi.encodeWithSelector(Errors.OwnableUnauthorizedAccount.selector, actor.dan_push_holder));
vm.expectRevert("Ownable: caller is not the owner");
pushNttToken.setMinter(actor.admin);
}

Expand Down

0 comments on commit 5ae5940

Please sign in to comment.