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

fix: use hardcoded Infura gas API urls #4068

Merged
merged 11 commits into from
Mar 27, 2024

Conversation

OGPoyraz
Copy link
Member

@OGPoyraz OGPoyraz commented Mar 18, 2024

Explanation

legacyAPIEndpoint and EIP1559APIEndpoint options are the gas API urls used in GasFeeController.
This PR aims to remove those and put the new Infura URL as hardcoded.

New Infura API also expects an auth header on requests, hence this PR is adding new options infuraAPIKey to constructor.

References

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/2254

Changelog

@metamask/gas-fee-controller

  • BREAKING: Removed the constructor options legacyAPIEndpoint and EIP1559APIEndpoint. These URLs are now hardcoded within the controller.
  • BREAKING: The controller's constructor now requires infuraAPIKey. This is used to construct and send the Authorization header for Infura gas API requests.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@OGPoyraz OGPoyraz marked this pull request as ready for review March 18, 2024 11:49
@OGPoyraz OGPoyraz requested a review from a team as a code owner March 18, 2024 11:49
@OGPoyraz OGPoyraz added the team-confirmations-system DEPRECATED: please use "team-confirmations" label instead label Mar 18, 2024
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Left some suggestions as I was passing through.

packages/gas-fee-controller/src/GasFeeController.ts Outdated Show resolved Hide resolved
packages/gas-fee-controller/src/gas-util.test.ts Outdated Show resolved Hide resolved
packages/gas-fee-controller/src/gas-util.ts Outdated Show resolved Hide resolved
@OGPoyraz OGPoyraz changed the title fix: Use hardcoded new infura API urls fix: use hardcoded infura API urls Mar 19, 2024
@OGPoyraz OGPoyraz changed the title fix: use hardcoded infura API urls fix: use hardcoded Infura gas API urls Mar 19, 2024
mcmire
mcmire previously approved these changes Mar 20, 2024
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my comments!

@OGPoyraz OGPoyraz force-pushed the 2254-use-infura-endpoints-in-gas-fee-controller branch from 8268471 to 14be4d0 Compare March 26, 2024 07:16
@OGPoyraz
Copy link
Member Author

@metamaskbot publish-preview

Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "12.0.1-preview-14be4d0",
  "@metamask-previews/address-book-controller": "4.0.1-preview-14be4d0",
  "@metamask-previews/announcement-controller": "6.0.1-preview-14be4d0",
  "@metamask-previews/approval-controller": "6.0.1-preview-14be4d0",
  "@metamask-previews/assets-controllers": "27.2.0-preview-14be4d0",
  "@metamask-previews/base-controller": "5.0.1-preview-14be4d0",
  "@metamask-previews/build-utils": "2.0.1-preview-14be4d0",
  "@metamask-previews/composable-controller": "6.0.1-preview-14be4d0",
  "@metamask-previews/controller-utils": "9.0.2-preview-14be4d0",
  "@metamask-previews/ens-controller": "10.0.1-preview-14be4d0",
  "@metamask-previews/eth-json-rpc-provider": "3.0.1-preview-14be4d0",
  "@metamask-previews/gas-fee-controller": "14.0.1-preview-14be4d0",
  "@metamask-previews/json-rpc-engine": "8.0.1-preview-14be4d0",
  "@metamask-previews/json-rpc-middleware-stream": "7.0.1-preview-14be4d0",
  "@metamask-previews/keyring-controller": "14.0.1-preview-14be4d0",
  "@metamask-previews/logging-controller": "3.0.1-preview-14be4d0",
  "@metamask-previews/message-manager": "8.0.1-preview-14be4d0",
  "@metamask-previews/name-controller": "6.0.1-preview-14be4d0",
  "@metamask-previews/network-controller": "18.0.1-preview-14be4d0",
  "@metamask-previews/notification-controller": "5.0.1-preview-14be4d0",
  "@metamask-previews/permission-controller": "9.0.2-preview-14be4d0",
  "@metamask-previews/permission-log-controller": "2.0.1-preview-14be4d0",
  "@metamask-previews/phishing-controller": "9.0.1-preview-14be4d0",
  "@metamask-previews/polling-controller": "6.0.1-preview-14be4d0",
  "@metamask-previews/preferences-controller": "9.0.1-preview-14be4d0",
  "@metamask-previews/queued-request-controller": "0.6.1-preview-14be4d0",
  "@metamask-previews/rate-limit-controller": "5.0.1-preview-14be4d0",
  "@metamask-previews/selected-network-controller": "10.0.1-preview-14be4d0",
  "@metamask-previews/signature-controller": "14.0.1-preview-14be4d0",
  "@metamask-previews/transaction-controller": "25.3.0-preview-14be4d0",
  "@metamask-previews/user-operation-controller": "6.0.2-preview-14be4d0"
}

@OGPoyraz
Copy link
Member Author

@metamaskbot publish-preview

Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "12.0.1-preview-a8ffe8e",
  "@metamask-previews/address-book-controller": "4.0.1-preview-a8ffe8e",
  "@metamask-previews/announcement-controller": "6.0.1-preview-a8ffe8e",
  "@metamask-previews/approval-controller": "6.0.1-preview-a8ffe8e",
  "@metamask-previews/assets-controllers": "27.2.0-preview-a8ffe8e",
  "@metamask-previews/base-controller": "5.0.1-preview-a8ffe8e",
  "@metamask-previews/build-utils": "2.0.1-preview-a8ffe8e",
  "@metamask-previews/composable-controller": "6.0.1-preview-a8ffe8e",
  "@metamask-previews/controller-utils": "9.0.2-preview-a8ffe8e",
  "@metamask-previews/ens-controller": "10.0.1-preview-a8ffe8e",
  "@metamask-previews/eth-json-rpc-provider": "3.0.1-preview-a8ffe8e",
  "@metamask-previews/gas-fee-controller": "14.0.1-preview-a8ffe8e",
  "@metamask-previews/json-rpc-engine": "8.0.1-preview-a8ffe8e",
  "@metamask-previews/json-rpc-middleware-stream": "7.0.1-preview-a8ffe8e",
  "@metamask-previews/keyring-controller": "14.0.1-preview-a8ffe8e",
  "@metamask-previews/logging-controller": "3.0.1-preview-a8ffe8e",
  "@metamask-previews/message-manager": "8.0.1-preview-a8ffe8e",
  "@metamask-previews/name-controller": "6.0.1-preview-a8ffe8e",
  "@metamask-previews/network-controller": "18.0.1-preview-a8ffe8e",
  "@metamask-previews/notification-controller": "5.0.1-preview-a8ffe8e",
  "@metamask-previews/permission-controller": "9.0.2-preview-a8ffe8e",
  "@metamask-previews/permission-log-controller": "2.0.1-preview-a8ffe8e",
  "@metamask-previews/phishing-controller": "9.0.1-preview-a8ffe8e",
  "@metamask-previews/polling-controller": "6.0.1-preview-a8ffe8e",
  "@metamask-previews/preferences-controller": "9.0.1-preview-a8ffe8e",
  "@metamask-previews/queued-request-controller": "0.6.1-preview-a8ffe8e",
  "@metamask-previews/rate-limit-controller": "5.0.1-preview-a8ffe8e",
  "@metamask-previews/selected-network-controller": "10.0.1-preview-a8ffe8e",
  "@metamask-previews/signature-controller": "14.0.1-preview-a8ffe8e",
  "@metamask-previews/transaction-controller": "25.3.0-preview-a8ffe8e",
  "@metamask-previews/user-operation-controller": "6.0.2-preview-a8ffe8e"
}

@OGPoyraz OGPoyraz merged commit 850461d into main Mar 27, 2024
139 checks passed
@OGPoyraz OGPoyraz deleted the 2254-use-infura-endpoints-in-gas-fee-controller branch March 27, 2024 13:02
OGPoyraz added a commit to MetaMask/metamask-extension that referenced this pull request Apr 23, 2024
## **Description**

This PR introduces an updated `GasFeeController` that transitions to the
new Infura gas API.

Preview `GasFeeController` PR:
MetaMask/core#4068

**Important Note**: With the introduction of these changes, developers
must complete two critical steps within their Infura project:

1. Activate the Infura gas API in the Expansion APIs section.

![infura all-endpoints
](https://github.com/MetaMask/metamask-extension/assets/7644512/ec976245-cab5-4b8f-b25d-b5a75f5b381b)

Access this section via
`https://app.infura.io/key/<INFURA_PROJECT_ID>/all-endpoints`. Please
replace `<INFURA_PROJECT_ID>` with the project ID found in your
`.metamaskrc` file.

2. Ensure that the `REQUIRE API KEY SECRET FOR ALL REQUESTS` option is
disabled.

![infura
settings](https://github.com/MetaMask/metamask-extension/assets/7644512/de0a3e1a-767b-468c-b0d5-fc7f393e4841)

Access this section via
`https://app.infura.io/key/<INFURA_PROJECT_ID>/settings`. Again,
`<INFURA_PROJECT_ID>` with the project ID found in your `.metamaskrc`
file.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23717?quickstart=1)

## **Related issues**

Fixes: MetaMask/MetaMask-planning#2254

## **Manual testing steps**

Although there are no functional changes, the update to the gas API URL
warrants manual testing of gas-related components to ensure they remain
operational.

## **Screenshots/Recordings**

N/A

### **Before**

N/A

### **After**

N/A

## **Pre-merge author checklist**

- [X] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [X] I've completed the PR template to the best of my ability
- [X] I’ve included tests if applicable
- [X] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [X] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

---------

Co-authored-by: MetaMask Bot <[email protected]>
dbrans added a commit that referenced this pull request Jun 10, 2024
This reverts commit 850461d.

merge conflicts:
- determineGasFeeCalculations.ts
- GasFeeController.ts
- GasFeeController.test.ts
dbrans added a commit that referenced this pull request Jun 11, 2024
This reverts commit 850461d.

merge conflicts:
- determineGasFeeCalculations.ts
- GasFeeController.ts
- GasFeeController.test.ts
dbrans added a commit that referenced this pull request Jun 26, 2024
This reverts commit 850461d.

merge conflicts:
- determineGasFeeCalculations.ts
- GasFeeController.ts
- GasFeeController.test.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-confirmations-system DEPRECATED: please use "team-confirmations" label instead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants