diff --git a/backend/src/paymaster/index.ts b/backend/src/paymaster/index.ts index 72b2e2f..f1fa9ac 100644 --- a/backend/src/paymaster/index.ts +++ b/backend/src/paymaster/index.ts @@ -125,7 +125,7 @@ export class Paymaster { const paymasterPostOpGasLimit = BigNumber.from("40000").toHexString(); if (estimate) { userOp.paymaster = paymasterAddress; - userOp.paymasterVerificationGasLimit = this.EP7_PVGL; + userOp.paymasterVerificationGasLimit = this.EP7_PVGL.toHexString(); userOp.paymasterPostOpGasLimit = paymasterPostOpGasLimit; const accountGasLimits = this.packUint(userOp.verificationGasLimit, userOp.callGasLimit) const gasFees = this.packUint(userOp.maxPriorityFeePerGas, userOp.maxFeePerGas); @@ -199,7 +199,7 @@ export class Paymaster { const paymasterPostOpGasLimit = BigNumber.from("40000").toHexString(); if (estimate) { userOp.paymaster = paymasterAddress; - userOp.paymasterVerificationGasLimit = this.EP8_PVGL; + userOp.paymasterVerificationGasLimit = this.EP8_PVGL.toHexString(); userOp.paymasterPostOpGasLimit = paymasterPostOpGasLimit; const accountGasLimits = this.packUint(userOp.verificationGasLimit, userOp.callGasLimit) const gasFees = this.packUint(userOp.maxPriorityFeePerGas, userOp.maxFeePerGas); diff --git a/backend/src/routes/paymaster-routes.ts b/backend/src/routes/paymaster-routes.ts index 8e5d989..7c295af 100644 --- a/backend/src/routes/paymaster-routes.ts +++ b/backend/src/routes/paymaster-routes.ts @@ -267,6 +267,9 @@ const paymasterRoutes: FastifyPluginAsync = async (server, } result = await paymaster.signV07(userOp, str, str1, entryPoint, networkConfig.contracts.etherspotPaymasterAddress, bundlerUrl, signer, estimate, server.log); } else { + if (!networkConfig.contracts.etherspotPaymasterAddress) { + throw new Error('Please use useVP flag to use your deployed verifying paymaster as global paymaster is not defined'); + } result = await paymaster.signV08(userOp, str, str1, entryPoint, networkConfig.contracts.etherspotPaymasterAddress, bundlerUrl, signer, estimate, server.log); } break; @@ -590,13 +593,13 @@ const paymasterRoutes: FastifyPluginAsync = async (server, async function checkWhitelist(api_key: string, epVersion: EPVersions, senderAddress: string, policyId: number) { const globalWhitelistRecord = await server.whitelistRepository.findOneByApiKeyAndPolicyId(api_key); - if (!globalWhitelistRecord?.addresses.includes(senderAddress)) { + if (!globalWhitelistRecord?.addresses?.includes(senderAddress)) { const existingWhitelistRecord = await server.whitelistRepository.findOneByApiKeyAndPolicyId(api_key, policyId); - if (!existingWhitelistRecord?.addresses.includes(senderAddress)) { + if (!existingWhitelistRecord?.addresses?.includes(senderAddress)) { const existingEpWhitelistRecord = await server.whitelistRepository.findOneByApiKeyEPVersionAndPolicyId(api_key, epVersion, policyId); - if (!existingEpWhitelistRecord?.addresses.includes(senderAddress)) { + if (!existingEpWhitelistRecord?.addresses?.includes(senderAddress)) { const existingEpWhitelistRecord2 = await server.whitelistRepository.findOneByApiKeyEPVersionAndPolicyId(api_key, epVersion); - if (!existingEpWhitelistRecord2?.addresses.includes(senderAddress)) { + if (!existingEpWhitelistRecord2?.addresses?.includes(senderAddress)) { return false; } } diff --git a/backend/src/types/whitelist-dto.ts b/backend/src/types/whitelist-dto.ts index aa9d29f..19a038d 100644 --- a/backend/src/types/whitelist-dto.ts +++ b/backend/src/types/whitelist-dto.ts @@ -1,6 +1,8 @@ +import { EPVersions } from "./sponsorship-policy-dto"; + export interface WhitelistDto { apiKey: string; addresses: string[]; policyId?: number; - epVersion?: string; + epVersion?: EPVersions; } \ No newline at end of file