From a1d38e38c1dc8b5608c8e090c1fb390ba38ff1f2 Mon Sep 17 00:00:00 2001 From: davidbrai Date: Tue, 3 Dec 2024 11:50:05 +0000 Subject: [PATCH] don't allow nounsRecipient to be zero address this will cause cancels to revert --- packages/nouns-contracts/contracts/StreamEscrow.sol | 2 ++ .../nouns-contracts/test/foundry/StreamEscrow.t.sol | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/packages/nouns-contracts/contracts/StreamEscrow.sol b/packages/nouns-contracts/contracts/StreamEscrow.sol index 5acd8a077..ed0185666 100644 --- a/packages/nouns-contracts/contracts/StreamEscrow.sol +++ b/packages/nouns-contracts/contracts/StreamEscrow.sol @@ -75,6 +75,7 @@ contract StreamEscrow is IStreamEscrow { ) { daoExecutor = daoExecutor_; ethRecipient = ethRecipient_; + require(nounsRecipient_ != address(0), 'zero address'); nounsRecipient = nounsRecipient_; nounsToken = INounsToken(nounsToken_); allowedToCreateStream[streamCreator_] = true; @@ -279,6 +280,7 @@ contract StreamEscrow is IStreamEscrow { * @notice Allows the DAO to set the address that the Nouns tokens will be sent to when streams are canceled. */ function setNounsRecipient(address newAddress) external onlyDAO { + require(newAddress != address(0), 'zero address'); nounsRecipient = newAddress; emit NounsRecipientSet(newAddress); } diff --git a/packages/nouns-contracts/test/foundry/StreamEscrow.t.sol b/packages/nouns-contracts/test/foundry/StreamEscrow.t.sol index 99d7e1666..6e8dc5f58 100644 --- a/packages/nouns-contracts/test/foundry/StreamEscrow.t.sol +++ b/packages/nouns-contracts/test/foundry/StreamEscrow.t.sol @@ -693,6 +693,17 @@ contract DAOSettersTest is BaseStreamEscrowTest { // check that new recipient received the noun assertEq(nounsToken.ownerOf(1), makeAddr('nounsRecipient2')); } + + function test_setNounsRecipient_cantBeZero() public { + vm.prank(treasury); + vm.expectRevert('zero address'); + escrow.setNounsRecipient(address(0)); + } + + function test_nounsReceipient_cantBeZeroInConstructor() public { + vm.expectRevert('zero address'); + new StreamEscrow(treasury, ethRecipient, address(0), address(nounsToken), streamCreator, 24 hours); + } } contract RescueTokensTest is BaseStreamEscrowTest {