Skip to content

Commit

Permalink
MTP Error Handling (#172)
Browse files Browse the repository at this point in the history
* added check to see if paymaster addr is available

* removed logs
  • Loading branch information
vignesha22 authored Jan 23, 2025
1 parent 0788a29 commit a924657
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 0 additions & 3 deletions backend/src/paymaster/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,6 @@ export class Paymaster {

const isCoingeckoAvailable = this.coingeckoPrice.get(`${chainId}-${feeToken}`);

console.log('oracleAggregator: ', oracleAggregator, isCoingeckoAvailable, this.coingeckoPrice);

if (!oracleAggregator) {
if (!isCoingeckoAvailable) throw new Error('Unable to fetch token price. Please try again later.')
const {latestAnswer, decimals} = await this.getLatestAnswerAndDecimals(provider, nativeOracleAddress, chainId);
Expand Down Expand Up @@ -1145,6 +1143,5 @@ export class Paymaster {
const cacheKey = `${chainId}-${ethers.utils.getAddress(tokenAddress)}`;
this.coingeckoPrice.set(cacheKey, {data: coingeckoPrices[tokenAddress], expiry: Date.now() + ttl});
}
console.log('Coingecko Price Set: ', this.coingeckoPrice);
}
}
4 changes: 3 additions & 1 deletion backend/src/routes/paymaster-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ const paymasterRoutes: FastifyPluginAsync<PaymasterRoutesOpts> = async (server,
case 'multitoken': {
if (epVersion !== EPVersions.EPV_06)
throw new Error('Currently only EPV06 entryPoint address is supported')
if (!(multiTokenPaymasters[chainId] && multiTokenPaymasters[chainId][gasToken]))
return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.UNSUPPORTED_NETWORK_TOKEN })
const date = new Date();
const provider = new providers.JsonRpcProvider(bundlerUrl);
const signer = new Wallet(privateKey, provider)
Expand All @@ -306,7 +308,7 @@ const paymasterRoutes: FastifyPluginAsync<PaymasterRoutesOpts> = async (server,
throw new Error("Oracle is not Defined/Invalid");
if (networkConfig.MultiTokenPaymasterOracleUsed == "chainlink" && !NativeOracles[chainId])
throw new Error("Native Oracle address not set for this chainId")
result = await paymaster.signMultiTokenPaymaster(userOp, str, str1, entryPoint, multiTokenPaymasters[chainId][gasToken], gasToken, multiTokenOracles[chainId][gasToken], bundlerUrl, signer, networkConfig.MultiTokenPaymasterOracleUsed, NativeOracles[chainId], chainId, server.log);
result = await paymaster.signMultiTokenPaymaster(userOp, str, str1, entryPoint, multiTokenPaymasters[chainId][gasToken], gasToken, multiTokenOracles[chainId] ? multiTokenOracles[chainId][gasToken] : '', bundlerUrl, signer, networkConfig.MultiTokenPaymasterOracleUsed, NativeOracles[chainId], chainId, server.log);
break;
}
case 'vps': {
Expand Down

0 comments on commit a924657

Please sign in to comment.