Skip to content

Commit

Permalink
Merge pull request #31 from bcnmy/stacked/refund-method
Browse files Browse the repository at this point in the history
Add bulk refund method
  • Loading branch information
livingrockrises authored Oct 23, 2024
2 parents 362bf12 + f72a4a4 commit f4b8544
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions contracts/common/BiconomySponsorshipPaymasterErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,9 @@ contract BiconomySponsorshipPaymasterErrors {
* @notice Thrown when trying to directly withdraw instead of submitting a request
*/
error SubmitRequestInstead();

/**
* @notice Thrown when the array lengths are not equal
*/
error InvalidArrayLengths();
}
15 changes: 15 additions & 0 deletions contracts/sponsorship/BiconomySponsorshipPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ contract BiconomySponsorshipPaymaster is
emit VerifyingSignerChanged(oldSigner, newVerifyingSigner, msg.sender);
}

/**
* @dev Refund balances for multiple paymasterIds
* PM charges more than it should to protect itself.
* This function is used to refund the extra amount
* when the real consumption is known.
* @param paymasterIds The paymasterIds to refund
* @param amounts The amounts to refund
*/
function refundBalances(address[] calldata paymasterIds, uint256[] calldata amounts) external payable onlyOwner {
if (paymasterIds.length != amounts.length) revert InvalidArrayLengths();
for (uint256 i; i < paymasterIds.length; i++) {
paymasterIdBalances[paymasterIds[i]] += amounts[i];
}
}

/**
* @dev Set a new trusted paymasterId.
* Can only be called by the owner of the contract.
Expand Down

0 comments on commit f4b8544

Please sign in to comment.