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

Improve calculateGasPriceFromGasNow() readeabilty #26

Open
haythemsellami opened this issue Jun 16, 2021 · 0 comments
Open

Improve calculateGasPriceFromGasNow() readeabilty #26

haythemsellami opened this issue Jun 16, 2021 · 0 comments
Assignees
Labels
good first issue Good for newcomers v0.1 v0.1 release

Comments

@haythemsellami
Copy link
Member

haythemsellami commented Jun 16, 2021

I think the current calculateGasPriceFromGasNow() implementation make it hard to read the function or to change it for a new developer.

export async function calculateGasPriceFromGasNow() {
  return BigNumber.from((await (await fetch(gasNowUrl)).json()).data.rapid)
    .mul(Math.round(Number(process.env.GAS_PRICE_MULTIPLIER) * 100000000))
    .div(100000000);
}

IMO make sense to separate and assign values to some variables.

E.g

const rapidGasNow = (await fetch(gasNowUrl)).json()).data.rapid;
const multipliedGasNow = rapidGasNow.mul(...);
...
@haythemsellami haythemsellami added the good first issue Good for newcomers label Jun 16, 2021
@haythemsellami haythemsellami added the v0.1 v0.1 release label Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers v0.1 v0.1 release
Projects
None yet
Development

No branches or pull requests

2 participants