From 93e4f8fa59ec4787c4d29754a5993ec13ddc76b1 Mon Sep 17 00:00:00 2001 From: vignesha22 <82584664+vignesha22@users.noreply.github.com> Date: Fri, 8 Mar 2024 02:28:53 +0530 Subject: [PATCH] Removed UserOp Signature Overwrite (#72) --- backend/package.json | 2 +- backend/src/paymaster/index.ts | 5 ++--- backend/src/routes/index.ts | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/backend/package.json b/backend/package.json index 8ecc9d1..e798943 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "arka", - "version": "1.1.3", + "version": "1.1.4", "description": "ARKA - (Albanian for Cashier's case) is the first open source Paymaster as a service software", "type": "module", "directories": { diff --git a/backend/src/paymaster/index.ts b/backend/src/paymaster/index.ts index d275c6c..a69a27d 100644 --- a/backend/src/paymaster/index.ts +++ b/backend/src/paymaster/index.ts @@ -38,7 +38,7 @@ export class Paymaster { const provider = new providers.JsonRpcProvider(bundlerRpc); const paymasterContract = new ethers.Contract(paymasterAddress, abi, provider); userOp.paymasterAndData = await this.getPaymasterAndData(userOp, validUntil, validAfter, paymasterContract, signer); - userOp.signature = '0x'; + if (!userOp.signature) userOp.signature = '0x'; const response = await provider.send('eth_estimateUserOperationGas', [userOp, entryPoint]); userOp.verificationGasLimit = response.verificationGasLimit; userOp.preVerificationGas = response.preVerificationGas; @@ -65,10 +65,9 @@ export class Paymaster { let erc20Paymaster; if (customPaymasterAddress) erc20Paymaster = new PimlicoPaymaster(customPaymasterAddress, provider) else erc20Paymaster = await getERC20Paymaster(provider, gasToken, entryPoint) - + if (!userOp.signature) userOp.signature = '0x'; let paymasterAndData = await erc20Paymaster.generatePaymasterAndData(userOp) userOp.paymasterAndData = paymasterAndData; - userOp.signature = '0x'; const response = await provider.send('eth_estimateUserOperationGas', [userOp, entryPoint]); userOp.verificationGasLimit = ethers.BigNumber.from(response.verificationGasLimit).add(100000).toString(); userOp.preVerificationGas = response.preVerificationGas; diff --git a/backend/src/routes/index.ts b/backend/src/routes/index.ts index dbbc589..dbc4709 100644 --- a/backend/src/routes/index.ts +++ b/backend/src/routes/index.ts @@ -28,10 +28,9 @@ const routes: FastifyPluginAsync = async (server) => { let client: SecretsManagerClient; - const unsafeMode = process.env.UNSAFE_MODE ?? false; + const unsafeMode: boolean = process.env.UNSAFE_MODE == "true" ? true : false; if (!unsafeMode) { - console.log('initialised aws secrets'); client = new SecretsManagerClient(); } @@ -372,7 +371,7 @@ const routes: FastifyPluginAsync = async (server) => { request.log.error(err); if (err.name == "ResourceNotFoundException") return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.INVALID_API_KEY }); - return reply.code(ReturnCode.FAILURE).send({ error: err.message ?? ErrorMessage.SOMETHING_WENT_WRONG }) + return reply.code(ReturnCode.FAILURE).send({ error: err.message ?? ErrorMessage.FAILED_TO_PROCESS }) } })