Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log responses from etherscan #85

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading