Skip to content

Commit

Permalink
don't allow nounsRecipient to be zero address
Browse files Browse the repository at this point in the history
this will cause cancels to revert
  • Loading branch information
davidbrai committed Dec 3, 2024
1 parent 09d5d0d commit a1d38e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/nouns-contracts/contracts/StreamEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
11 changes: 11 additions & 0 deletions packages/nouns-contracts/test/foundry/StreamEscrow.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a1d38e3

Please sign in to comment.