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

GITC-616: fetch gas price from polygon gas tracker #9733

Merged
merged 4 commits into from
Nov 30, 2021

Conversation

chibie
Copy link
Contributor

@chibie chibie commented Nov 25, 2021

Description

This pr fetches the gas price from polygon gas tracker as opposed to hardcoding it.

Refers/Fixes
Testing

tested locally

@@ -381,6 +382,14 @@ Vue.component('grantsCartEthereumPolygon', {

let gasLimit = 0;

// fetch gas prices from polygon gas tracker
if (!this.polygon.gasPrices) {
const priceUrl = 'https://api.polygonscan.com/api?module=gastracker&action=gasoracle&apikey=I28K1DVQAWAISBSI146I71YQDBK6N1C9GJ';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to switch this out for a paid account or move this to the backend and set up a cron to store and update the safeGasPrice periodically.

This is going to get hammered if we call it every time a user hits the checkout.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say set a high default price and wrap this in a try catch for now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we load the api key from the settings?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that is a nice catch ! @chibie i agree with nutrina here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we should really be protecting that key - I would recommend moving this to the backend and returning the safeGasPrice as part of the context.

Copy link
Contributor Author

@chibie chibie Nov 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gdixon pushed a commit c2cfb70

we should set POLYGONSCAN_API_KEY env and run ./manage.py fetch_gas_prices after deploy

Copy link
Contributor

@gdixon gdixon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @chibie, nicely done 🙌

@thelostone-mc thelostone-mc merged commit 2ce8e89 into master Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants