From 3ef3de15522d2099a259fbe32de7aeb11fe4d3c5 Mon Sep 17 00:00:00 2001 From: vignesha22 <82584664+vignesha22@users.noreply.github.com> Date: Tue, 1 Oct 2024 00:12:26 +0530 Subject: [PATCH] bug fixes (#141) * bug fixes * updated package version --- backend/package.json | 2 +- backend/src/paymaster/index.ts | 17 ++++++++--------- backend/src/routes/paymaster-routes.ts | 1 + 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/package.json b/backend/package.json index 5575d3c..4fc1d95 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "arka", - "version": "1.6.0", + "version": "1.6.1", "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 732eaf4..200bc9a 100644 --- a/backend/src/paymaster/index.ts +++ b/backend/src/paymaster/index.ts @@ -236,12 +236,11 @@ export class Paymaster { result.gasEstimates.verificationGasLimit = response.verificationGasLimit; result.feeEstimates.maxFeePerGas = response.maxFeePerGas; result.feeEstimates.maxPriorityFeePerGas = response.maxPriorityFeePerGas; - if (!multiTokenPaymasters[chainId]) { - const paymasterAddress = multiTokenPaymasters[chainId][tokens_list[0]]; - result.paymasterAddress = paymasterAddress; - const paymasterContract = new ethers.Contract(paymasterAddress, MultiTokenPaymasterAbi, provider); - result.postOpGas = await paymasterContract.UNACCOUNTED_COST; - } + + const paymasterKey = Object.keys(multiTokenPaymasters[chainId])[0]; + result.paymasterAddress = multiTokenPaymasters[chainId][paymasterKey]; + const paymasterContract = new ethers.Contract(result.paymasterAddress , MultiTokenPaymasterAbi, provider); + result.postOpGas = await paymasterContract.UNACCOUNTED_COST; for (let i = 0; i < tokens_list.length; i++) { const gasToken = tokens_list[i]; @@ -267,17 +266,17 @@ export class Paymaster { ethPrice = Number(ethers.utils.formatUnits(result, decimals)).toFixed(0); } result.etherUSDExchangeRate = BigNumber.from(ethPrice).toHexString(); - const exchangeRate = 1000000; // This is for setting min tokens required for the txn that gets validated on estimate - const rate = ethers.BigNumber.from(exchangeRate).mul(ethPrice); const tokenContract = new ethers.Contract(gasToken, ERC20Abi, provider) const decimals = await tokenContract.decimals(); + const exchangeRate = 1000000; // This is for setting min tokens required for the txn that gets validated on estimate + const rate = ethers.BigNumber.from(exchangeRate).mul(ethPrice); const symbol = await tokenContract.symbol(); quotes.push({ token: gasToken, symbol: symbol, decimals: decimals, etherTokenExchangeRate: rate.toHexString(), - serviceFeePercent: this.multiTokenMarkUp - 1000000 + serviceFeePercent: (this.multiTokenMarkUp/10000 - 100) }) } } diff --git a/backend/src/routes/paymaster-routes.ts b/backend/src/routes/paymaster-routes.ts index a68c95e..08b469d 100644 --- a/backend/src/routes/paymaster-routes.ts +++ b/backend/src/routes/paymaster-routes.ts @@ -215,6 +215,7 @@ const paymasterRoutes: FastifyPluginAsync = async (server) => { if (!networkConfig.MultiTokenPaymasterOracleUsed || !(networkConfig.MultiTokenPaymasterOracleUsed == "orochi" || networkConfig.MultiTokenPaymasterOracleUsed == "chainlink" || networkConfig.MultiTokenPaymasterOracleUsed == "etherspotChainlink")) throw new Error("Oracle is not Defined/Invalid"); + if (!multiTokenPaymasters[chainId]) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.UNSUPPORTED_NETWORK }) result = await paymaster.getQuotesMultiToken(userOp, entryPoint, chainId, multiTokenPaymasters, tokens_list, multiTokenOracles, bundlerUrl, networkConfig.MultiTokenPaymasterOracleUsed, server.log); } else {