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

fix: Minor Bug fixes wrt non-EVM audit #440

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
25 changes: 10 additions & 15 deletions contracts/PushComm/PushCommETHV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -123,21 +123,19 @@ 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);
unchecked {
i++;
}
}
return true;
}

/**
Expand Down Expand Up @@ -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;
}

/* *****************************
Expand All @@ -225,22 +222,20 @@ 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);
unchecked {
i++;
}
}
return true;
}

/**
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/PushComm/PushCommEthStorageV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion contracts/PushComm/PushCommStorageV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
37 changes: 18 additions & 19 deletions contracts/PushComm/PushCommV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 { PushCommStorageV2 } from "./PushCommStorageV2.sol";
import { Errors } from "../libraries/Errors.sol";
Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -130,21 +130,19 @@ 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);
unchecked {
i++;
}
}
return true;
}

/**
Expand Down Expand Up @@ -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;
}

/* *****************************
Expand All @@ -232,22 +229,20 @@ 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);
unchecked {
i++;
}
}
return true;
}

/**
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/PushCore/PushCoreV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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://push.org/
*/
import { PushCoreStorageV1_5 } from "./PushCoreStorageV1_5.sol";
import { PushCoreStorageV2 } from "./PushCoreStorageV2.sol";
Expand Down
11 changes: 10 additions & 1 deletion contracts/PushStaking/PushStakingProxy.sol
Original file line number Diff line number Diff line change
@@ -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://push.org/
*/
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

contract PushStakingProxy is TransparentUpgradeableProxy {
Expand Down
12 changes: 6 additions & 6 deletions contracts/interfaces/IPushCommV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions test/PushComm/unit_tests/SubscribeBySig/SubscribeBySig.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down