Skip to content

Commit

Permalink
custom reverts
Browse files Browse the repository at this point in the history
  • Loading branch information
saucepoint committed Aug 30, 2024
1 parent dd948d2 commit 845a1d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/base/Notifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ abstract contract Notifier is INotifier {
_positionConfigs(tokenId).setSubscribe();
ISubscriber _subscriber = subscriber[tokenId];

if (_subscriber != NO_SUBSCRIBER) revert AlreadySubscribed(address(_subscriber));
if (_subscriber != NO_SUBSCRIBER) AlreadySubscribed.selector.revertWith(address(_subscriber));
subscriber[tokenId] = ISubscriber(newSubscriber);

bool success =
Expand All @@ -68,7 +68,7 @@ abstract contract Notifier is INotifier {
{
_positionConfigs(tokenId).setUnsubscribe();
ISubscriber _subscriber = subscriber[tokenId];
if (_subscriber == NO_SUBSCRIBER) revert NotSubscribed();
if (_subscriber == NO_SUBSCRIBER) NotSubscribed.selector.revertWith();

delete subscriber[tokenId];

Expand Down Expand Up @@ -110,7 +110,7 @@ abstract contract Notifier is INotifier {
}

function _call(address target, bytes memory encodedCall) internal returns (bool success) {
if (target.code.length == 0) revert NoCodeSubscriber();
if (target.code.length == 0) NoCodeSubscriber.selector.revertWith();
assembly ("memory-safe") {
success := call(gas(), target, 0, add(encodedCall, 0x20), mload(encodedCall), 0, 0)
}
Expand Down
2 changes: 1 addition & 1 deletion test/position-managers/PositionManager.notifier.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ contract PositionManagerNotifierTest is Test, PosmTestSetup, GasSnapshot {
/// @notice Revert when subscribing to an address without code
function test_subscribe_revert_empty(address _subscriber) public {
vm.assume(_subscriber.code.length == 0);

uint256 tokenId = lpm.nextTokenId();
mint(config, 100e18, alice, ZERO_BYTES);

Expand Down

0 comments on commit 845a1d4

Please sign in to comment.