Skip to content

Commit

Permalink
fix: remediations. allow receive eth and withdraw stuck eth
Browse files Browse the repository at this point in the history
  • Loading branch information
livingrockrises committed Nov 14, 2024
1 parent d113079 commit b5c0b04
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions contracts/common/BiconomyTokenPaymasterErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,14 @@ contract BiconomyTokenPaymasterErrors {
* @notice Throws when external signer's signature has invalid length
*/
error InvalidSignatureLength();

/**
* @notice Throws when ETH withdrawal fails
*/
error WithdrawalFailed();

/**
* @notice Emitted when ETH is withdrawn from the paymaster
*/
event EthWithdrawn(address indexed recipient, uint256 indexed amount);

Check failure on line 87 in contracts/common/BiconomyTokenPaymasterErrors.sol

View workflow job for this annotation

GitHub Actions / Lint sources

Function order is incorrect, event definition can not go after custom error definition (line 82)
}
17 changes: 17 additions & 0 deletions contracts/token/BiconomyTokenPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ contract BiconomyTokenPaymaster is
}
}

receive() external payable {
// no need to emit an event here
}

/**
* @dev pull tokens out of paymaster in case they were sent to the paymaster at any point.
* @param token the token deposit to withdraw
Expand All @@ -143,6 +147,19 @@ contract BiconomyTokenPaymaster is
_withdrawERC20(token, target, amount);
}

/**
* @dev Withdraw ETH from the paymaster
* @param recipient The address to send the ETH to
* @param amount The amount of ETH to withdraw
*/
function withdrawEth(address payable recipient, uint256 amount) external payable onlyOwner nonReentrant {
(bool success,) = recipient.call{ value: amount }("");
if (!success) {
revert WithdrawalFailed();
}
emit EthWithdrawn(recipient, amount);
}

/**
* @dev pull tokens out of paymaster in case they were sent to the paymaster at any point.
* @param token the token deposit to withdraw
Expand Down

0 comments on commit b5c0b04

Please sign in to comment.