diff --git a/contracts/PushComm/PushCommETHV3.sol b/contracts/PushComm/PushCommETHV3.sol index faf0526d..6faa2496 100644 --- a/contracts/PushComm/PushCommETHV3.sol +++ b/contracts/PushComm/PushCommETHV3.sol @@ -12,7 +12,7 @@ pragma solidity ^0.8.20; * @dev Some imperative functionalities that the Push Communicator Protocol allows * are Subscribing to a particular channel, Unsubscribing a channel, Sending * Notifications to a particular recipient or all subscribers of a Channel etc. - * + * @Custom:security-contact https://push.org/ */ import { PushCommEthStorageV2 } from "./PushCommEthStorageV2.sol"; import { Errors } from "../libraries/Errors.sol"; @@ -78,11 +78,11 @@ contract PushCommETHV3 is Initializable, PushCommEthStorageV2, IPushCommV3 { ***************************** */ function verifyChannelAlias(string memory _channelAddress) external { - emit ChannelAlias(chainName, chainID, msg.sender, _channelAddress); + emit ChannelAlias(chainName, block.chainid, msg.sender, _channelAddress); } function removeChannelAlias(string memory _channelAddress) external { - emit RemoveChannelAlias(chainName, chainID, msg.sender, _channelAddress); + emit RemoveChannelAlias(chainName, block.chainid, msg.sender, _channelAddress); } // function completeMigration() external onlyPushChannelAdmin { @@ -123,13 +123,12 @@ contract PushCommETHV3 is Initializable, PushCommEthStorageV2, IPushCommV3 { } /// @inheritdoc IPushCommV3 - function subscribe(address _channel) external returns (bool) { + function subscribe(address _channel) external { _subscribe(_channel, msg.sender); - return true; } /// @inheritdoc IPushCommV3 - function batchSubscribe(address[] calldata _channelList) external returns (bool) { + function batchSubscribe(address[] calldata _channelList) external { uint256 channelListLength = _channelList.length; for (uint256 i = 0; i < channelListLength;) { _subscribe(_channelList[i], msg.sender); @@ -137,7 +136,6 @@ contract PushCommETHV3 is Initializable, PushCommEthStorageV2, IPushCommV3 { i++; } } - return true; } /** @@ -213,9 +211,8 @@ contract PushCommETHV3 is Initializable, PushCommEthStorageV2, IPushCommV3 { } /// @inheritdoc IPushCommV3 - function subscribeViaCore(address _channel, address _user) external onlyPushCore returns (bool) { + function subscribeViaCore(address _channel, address _user) external onlyPushCore { _subscribe(_channel, _user); - return true; } /* ***************************** @@ -225,14 +222,13 @@ contract PushCommETHV3 is Initializable, PushCommEthStorageV2, IPushCommV3 { ***************************** */ /// @inheritdoc IPushCommV3 - function unsubscribe(address _channel) external returns (bool) { + function unsubscribe(address _channel) external { // Call actual unsubscribe _unsubscribe(_channel, msg.sender); - return true; } /// @inheritdoc IPushCommV3 - function batchUnsubscribe(address[] calldata _channelList) external returns (bool) { + function batchUnsubscribe(address[] calldata _channelList) external { uint256 channelListLength = _channelList.length; for (uint256 i = 0; i < channelListLength;) { _unsubscribe(_channelList[i], msg.sender); @@ -240,7 +236,6 @@ contract PushCommETHV3 is Initializable, PushCommEthStorageV2, IPushCommV3 { i++; } } - return true; } /** @@ -314,9 +309,8 @@ contract PushCommETHV3 is Initializable, PushCommEthStorageV2, IPushCommV3 { } /// @inheritdoc IPushCommV3 - function unSubscribeViaCore(address _channel, address _user) external onlyPushCore returns (bool) { + function unSubscribeViaCore(address _channel, address _user) external onlyPushCore { _unsubscribe(_channel, _user); - return true; } /** @@ -354,6 +348,7 @@ contract PushCommETHV3 is Initializable, PushCommEthStorageV2, IPushCommV3 { /// @inheritdoc IPushCommV3 function removeDelegate(address _delegate) external { delegatedNotificationSenders[msg.sender][_delegate] = false; + _unsubscribe(msg.sender, _delegate); emit RemoveDelegate(msg.sender, _delegate); } diff --git a/contracts/PushComm/PushCommEthStorageV2.sol b/contracts/PushComm/PushCommEthStorageV2.sol index f40dfbae..abea0d21 100644 --- a/contracts/PushComm/PushCommEthStorageV2.sol +++ b/contracts/PushComm/PushCommEthStorageV2.sol @@ -17,7 +17,7 @@ contract PushCommEthStorageV2 { */ address public governance; address public pushChannelAdmin; - uint256 public chainID; + uint256 public chainID; // Unused Variable uint256 public usersCount; bool public isMigrationComplete; address public PushCoreAddress; diff --git a/contracts/PushComm/PushCommStorageV2.sol b/contracts/PushComm/PushCommStorageV2.sol index b187b514..629603c3 100644 --- a/contracts/PushComm/PushCommStorageV2.sol +++ b/contracts/PushComm/PushCommStorageV2.sol @@ -22,7 +22,7 @@ contract PushCommStorageV2 { */ address public governance; address public pushChannelAdmin; - uint256 public chainID; + uint256 public chainID; //Unused Variable uint256 public usersCount; bool public isMigrationComplete; address public PushCoreAddress; diff --git a/contracts/PushComm/PushCommV3.sol b/contracts/PushComm/PushCommV3.sol index 236669db..03fe5c5a 100644 --- a/contracts/PushComm/PushCommV3.sol +++ b/contracts/PushComm/PushCommV3.sol @@ -12,7 +12,7 @@ pragma solidity ^0.8.20; * @dev Some imperative functionalities that the Push Communicator Protocol allows * are Subscribing to a particular channel, Unsubscribing a channel, Sending * Notifications to a particular recipient or all subscribers of a Channel etc. - * + * @Custom:security-contact https://immunefi.com/bug-bounty/pushprotocol/information/ */ import { PushCommStorageV2 } from "./PushCommStorageV2.sol"; import { Errors } from "../libraries/Errors.sol"; @@ -84,7 +84,7 @@ contract PushCommV3 is Initializable, PushCommStorageV2, IPushCommV3, PausableUp ***************************** */ function verifyChannelAlias(string memory _channelAddress) external { - emit ChannelAlias(chainName, chainID, msg.sender, _channelAddress); + emit ChannelAlias(chainName, block.chainid, msg.sender, _channelAddress); } @@ -130,13 +130,12 @@ contract PushCommV3 is Initializable, PushCommStorageV2, IPushCommV3, PausableUp } /// @inheritdoc IPushCommV3 - function subscribe(address _channel) external returns (bool) { + function subscribe(address _channel) external { _subscribe(_channel, msg.sender); - return true; } /// @inheritdoc IPushCommV3 - function batchSubscribe(address[] calldata _channelList) external returns (bool) { + function batchSubscribe(address[] calldata _channelList) external { uint256 channelListLength = _channelList.length; for (uint256 i = 0; i < channelListLength;) { _subscribe(_channelList[i], msg.sender); @@ -144,7 +143,6 @@ contract PushCommV3 is Initializable, PushCommStorageV2, IPushCommV3, PausableUp i++; } } - return true; } /** @@ -220,9 +218,8 @@ contract PushCommV3 is Initializable, PushCommStorageV2, IPushCommV3, PausableUp } /// @inheritdoc IPushCommV3 - function subscribeViaCore(address _channel, address _user) external onlyPushCore returns (bool) { + function subscribeViaCore(address _channel, address _user) external onlyPushCore { _subscribe(_channel, _user); - return true; } /* ***************************** @@ -232,14 +229,13 @@ contract PushCommV3 is Initializable, PushCommStorageV2, IPushCommV3, PausableUp ***************************** */ /// @inheritdoc IPushCommV3 - function unsubscribe(address _channel) external returns (bool) { + function unsubscribe(address _channel) external { // Call actual unsubscribe _unsubscribe(_channel, msg.sender); - return true; } /// @inheritdoc IPushCommV3 - function batchUnsubscribe(address[] calldata _channelList) external returns (bool) { + function batchUnsubscribe(address[] calldata _channelList) external { uint256 channelListLength = _channelList.length; for (uint256 i = 0; i < channelListLength;) { _unsubscribe(_channelList[i], msg.sender); @@ -247,7 +243,6 @@ contract PushCommV3 is Initializable, PushCommStorageV2, IPushCommV3, PausableUp i++; } } - return true; } /** @@ -321,9 +316,8 @@ contract PushCommV3 is Initializable, PushCommStorageV2, IPushCommV3, PausableUp } /// @inheritdoc IPushCommV3 - function unSubscribeViaCore(address _channel, address _user) external onlyPushCore returns (bool) { + function unSubscribeViaCore(address _channel, address _user) external onlyPushCore { _unsubscribe(_channel, _user); - return true; } /** @@ -353,15 +347,20 @@ contract PushCommV3 is Initializable, PushCommStorageV2, IPushCommV3, PausableUp /// @inheritdoc IPushCommV3 function addDelegate(address _delegate) external { - delegatedNotificationSenders[msg.sender][_delegate] = true; - _subscribe(msg.sender, _delegate); - emit AddDelegate(msg.sender, _delegate); + if(delegatedNotificationSenders[msg.sender][_delegate] == false){ + delegatedNotificationSenders[msg.sender][_delegate] = true; + _subscribe(msg.sender, _delegate); + emit AddDelegate(msg.sender, _delegate); + } } /// @inheritdoc IPushCommV3 function removeDelegate(address _delegate) external { - delegatedNotificationSenders[msg.sender][_delegate] = false; - emit RemoveDelegate(msg.sender, _delegate); + if(delegatedNotificationSenders[msg.sender][_delegate] == false){ + delegatedNotificationSenders[msg.sender][_delegate] = false; + _unsubscribe(msg.sender, _delegate); + emit RemoveDelegate(msg.sender, _delegate); + } } /** diff --git a/contracts/PushCore/PushCoreV3.sol b/contracts/PushCore/PushCoreV3.sol index 6a9aa77b..8bb3f147 100644 --- a/contracts/PushCore/PushCoreV3.sol +++ b/contracts/PushCore/PushCoreV3.sol @@ -9,7 +9,7 @@ pragma solidity ^0.8.20; * @dev This protocol will be specifically deployed on Ethereum Blockchain while the Communicator * protocols can be deployed on Multiple Chains. * The Push Core is more inclined towards the storing and handling the Channel related functionalties. - * + * @Custom:security-contact https://immunefi.com/bug-bounty/pushprotocol/information/ */ import { PushCoreStorageV1_5 } from "./PushCoreStorageV1_5.sol"; import { PushCoreStorageV2 } from "./PushCoreStorageV2.sol"; diff --git a/contracts/PushStaking/PushStakingProxy.sol b/contracts/PushStaking/PushStakingProxy.sol index 098dac46..830e8fec 100644 --- a/contracts/PushStaking/PushStakingProxy.sol +++ b/contracts/PushStaking/PushStakingProxy.sol @@ -1,7 +1,16 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; - +/** + * @title PushStakingProxy + * @author Push Protocol + * @notice Push Stakin will deal with the handling of staking initiatives by Push Protocol. + * + * @dev This protocol will be specifically deployed on Ethereum Blockchain and will be connected to Push Core + * contract in a way that the core contract handles all the funds and this contract handles the state + * of stakers. + * @Custom:security-contact https://immunefi.com/bug-bounty/pushprotocol/information/ + */ import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; contract PushStakingProxy is TransparentUpgradeableProxy { diff --git a/contracts/interfaces/IPushCommV3.sol b/contracts/interfaces/IPushCommV3.sol index 4c34a9b9..5511c71f 100644 --- a/contracts/interfaces/IPushCommV3.sol +++ b/contracts/interfaces/IPushCommV3.sol @@ -67,11 +67,11 @@ interface IPushCommV3 { /// @dev Subscribes the caller of the function to a particular Channel /// - Takes into Consideration the "msg.sender" /// @param _channel address of the channel that the user is subscribing to - function subscribe(address _channel) external returns (bool); + function subscribe(address _channel) external; /// @notice Allows users to subscribe a List of Channels at once /// @param _channelList array of addresses of the channels that the user wishes to Subscribe - function batchSubscribe(address[] calldata _channelList) external returns (bool); + function batchSubscribe(address[] calldata _channelList) external; /// @notice Subscribe Function through Meta TX /// @dev Takes into Consideration the Sign of the User @@ -98,7 +98,7 @@ interface IPushCommV3 { /// @param _channel address of the channel that the user is subscribing to /// @param _user address of the Subscriber of a Channel - function subscribeViaCore(address _channel, address _user) external returns (bool); + function subscribeViaCore(address _channel, address _user) external; /// @notice Allows PushCore contract to call the Base UnSubscribe function whenever a User Destroys his/her /// TimeBound Channel. @@ -110,19 +110,19 @@ interface IPushCommV3 { /// @param _channel address of the channel being unsubscribed /// @param _user address of the UnSubscriber of a Channel - function unSubscribeViaCore(address _channel, address _user) external returns (bool); + function unSubscribeViaCore(address _channel, address _user) external; /// @notice External Unsubcribe Function that allows users to directly unsubscribe from a particular channel /// @dev UnSubscribes the caller of the function from the particular Channel. /// Takes into Consideration the "msg.sender" /// @param _channel address of the channel that the user is unsubscribing to - function unsubscribe(address _channel) external returns (bool); + function unsubscribe(address _channel) external; /// @notice Allows users to unsubscribe from a List of Channels at once /// @param _channelList array of addresses of the channels that the user wishes to Unsubscribe - function batchUnsubscribe(address[] calldata _channelList) external returns (bool); + function batchUnsubscribe(address[] calldata _channelList) external; /// @notice Unsubscribe Function through Meta TX /// @dev Takes into Consideration the Signer of the transactioner diff --git a/test/PushComm/unit_tests/SubscribeBySig/SubscribeBySig.t.sol b/test/PushComm/unit_tests/SubscribeBySig/SubscribeBySig.t.sol index 492be3ba..0d7bec7a 100644 --- a/test/PushComm/unit_tests/SubscribeBySig/SubscribeBySig.t.sol +++ b/test/PushComm/unit_tests/SubscribeBySig/SubscribeBySig.t.sol @@ -166,8 +166,7 @@ contract SubscribeBySig_Test is BasePushCommTest { function test_WhenUsersUnsubscribeWith712Sig() public { //Alice subscribes to bob's channel to check the unsubscribe function changePrank(actor.alice_channel_owner); - bool res = commProxy.subscribe(actor.bob_channel_owner); - assertEq(res, true); + commProxy.subscribe(actor.bob_channel_owner); bytes32 DOMAIN_SEPARATOR = getDomainSeparator(); SubscribeUnsubscribe memory _subscribeUnsubscribe = SubscribeUnsubscribe(