Skip to content

Commit

Permalink
Merge pull request #32 from bcnmy/fix/duplicate-emit
Browse files Browse the repository at this point in the history
fix:duplicate emit
  • Loading branch information
livingrockrises authored Oct 23, 2024
2 parents 21525d8 + 4a36a32 commit 9c7638b
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions contracts/sponsorship/BiconomySponsorshipPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import { IBiconomySponsorshipPaymaster } from "../interfaces/IBiconomySponsorshi
* and Manages it's own deposit on the EntryPoint.
*/

// @Todo: Add more methods in interface

contract BiconomySponsorshipPaymaster is
BasePaymaster,
ReentrancyGuardTransient,
Expand All @@ -50,7 +48,6 @@ contract BiconomySponsorshipPaymaster is
// Offset in PaymasterAndData to get to PAYMASTER_ID_OFFSET
uint256 private constant _PAYMASTER_ID_OFFSET = _PAYMASTER_DATA_OFFSET;
// Limit for unaccounted gas cost
// Review cap
uint256 private constant _UNACCOUNTED_GAS_LIMIT = 100_000;

mapping(address => uint256) public paymasterIdBalances;
Expand Down Expand Up @@ -348,7 +345,7 @@ contract BiconomySponsorshipPaymaster is
abi.decode(context, (address, uint32, uint256));

// Include unaccountedGas since EP doesn't include this in actualGasCost
// unaccountedGas = postOpGas + EP overhead gas + estimated penalty
// unaccountedGas = postOpGas + EP overhead gas
actualGasCost = actualGasCost + (unaccountedGas * actualUserOpFeePerGas);
// Apply the price markup
uint256 adjustedGasCost = (actualGasCost * priceMarkup) / _PRICE_DENOMINATOR;
Expand All @@ -367,21 +364,23 @@ contract BiconomySponsorshipPaymaster is
}
// here adjustedGasCost does not account for gasPenalty. prechargedAmount accounts for penalty with maxGasPenalty
emit GasBalanceDeducted(paymasterId, adjustedGasCost, premium);

// here adjustedGasCost does not account for gasPenalty. prechargedAmount accounts for penalty with
// maxGasPenalty
emit GasBalanceDeducted(paymasterId, adjustedGasCost, premium);
}

/**
* verify our external signer signed this request.
* the "paymasterAndData" is expected to be the paymaster and a signature over the entire request params
* @dev verify our external signer signed this request.
* Adds maxPenalty to the effectiveCost to protect PM.
* The "paymasterAndData" is expected to be the paymaster and a signature over the entire request params.
* paymasterAndData[:20] : address(this)
* paymasterAndData[52:72] : paymasterId (dappDepositor)
* paymasterAndData[72:78] : validUntil
* paymasterAndData[78:84] : validAfter
* paymasterAndData[84:88] : priceMarkup
* paymasterAndData[88:] : signature
* @param userOp The user operation to validate.
* @param userOpHash The hash of the user operation.
* @param requiredPreFund The required pre-fund amount.
* @return context The context for the paymaster.
* @return validationData The validation data as per ERC-4337.
*/
function _validatePaymasterUserOp(
PackedUserOperation calldata userOp,
Expand Down Expand Up @@ -451,7 +450,7 @@ contract BiconomySponsorshipPaymaster is

context = abi.encode(paymasterId, priceMarkup, effectiveCost);

//no need for other on-chain validation: entire UserOp should have been checked
// no need for other on-chain validation: entire UserOp should have been checked
// by the external service prior to signing it.
return (context, _packValidationData(false, validUntil, validAfter));
}
Expand Down

0 comments on commit 9c7638b

Please sign in to comment.