Skip to content

Commit

Permalink
log responses from etherscan (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
vignesha22 authored Apr 9, 2024
1 parent 9b3e4b7 commit 4a949bb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend/src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ export async function getEtherscanFee(chainId: number, log?: FastifyBaseLogger):
if (etherscanUrlsBase64) {
const buffer = Buffer.from(etherscanUrlsBase64, 'base64');
const etherscanUrls = JSON.parse(buffer.toString());
console.log('etherscanUrl: ', etherscanUrls[chainId]);

if (etherscanUrls[chainId]) {
const data = await fetch(etherscanUrls[chainId]);
const response: EtherscanResponse = await data.json();
console.log('Etherscan Response: ', response);
if (response.result && typeof response.result === "object" && response.status === "1") {
console.log('setting maxFeePerGas and maxPriorityFeePerGas as received')
const maxFeePerGas = ethers.utils.parseUnits(response.result.suggestBaseFee, 'gwei')
const fastGasPrice = ethers.utils.parseUnits(response.result.FastGasPrice, 'gwei')
return {
Expand All @@ -55,6 +58,7 @@ export async function getEtherscanFee(chainId: number, log?: FastifyBaseLogger):
}
if (response.result && typeof response.result === "string" && response.jsonrpc) {
const gasPrice = BigNumber.from(response.result)
console.log('setting gas price as received')
return {
maxFeePerGas: gasPrice,
maxPriorityFeePerGas: gasPrice,
Expand Down

0 comments on commit 4a949bb

Please sign in to comment.