Skip to content

Commit

Permalink
Remove infuraKeySecret from constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
OGPoyraz committed Mar 26, 2024
1 parent 831fa3a commit 14be4d0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
4 changes: 0 additions & 4 deletions packages/gas-fee-controller/src/GasFeeController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,13 @@ describe('GasFeeController', () => {
* @param options.interval - The polling interval.
* @param options.state - The initial GasFeeController state
* @param options.infuraAPIKey - The Infura API key.
* @param options.infuraAPIKeySecret - The Infura API key secret.
*/
async function setupGasFeeController({
getIsEIP1559Compatible = jest.fn().mockResolvedValue(true),
getCurrentNetworkLegacyGasAPICompatibility = jest
.fn()
.mockReturnValue(false),
infuraAPIKey = 'INFURA_API_KEY',
infuraAPIKeySecret = 'INFURA_API_KEY_SECRET',
clientId,
getChainId,
networkControllerState = {},
Expand All @@ -251,7 +249,6 @@ describe('GasFeeController', () => {
state?: GasFeeState;
interval?: number;
infuraAPIKey?: string;
infuraAPIKeySecret?: string;
} = {}) {
const controllerMessenger = getControllerMessenger();
networkController = await setupNetworkController({
Expand All @@ -270,7 +267,6 @@ describe('GasFeeController', () => {
clientId,
interval,
infuraAPIKey,
infuraAPIKeySecret,
});
}

Expand Down
8 changes: 1 addition & 7 deletions packages/gas-fee-controller/src/GasFeeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ export class GasFeeController extends StaticIntervalPollingController<
* @param options.clientId - The client ID used to identify to the gas estimation API who is
* asking for estimates.
* @param options.infuraAPIKey - The Infura API key used for infura API requests.
* @param options.infuraAPIKeySecret - The Infura API key secret used for infura API requests.
*/
constructor({
interval = 15000,
Expand All @@ -319,7 +318,6 @@ export class GasFeeController extends StaticIntervalPollingController<
onNetworkDidChange,
clientId,
infuraAPIKey,
infuraAPIKeySecret,
}: {
interval?: number;
messenger: GasFeeMessenger;
Expand All @@ -332,7 +330,6 @@ export class GasFeeController extends StaticIntervalPollingController<
onNetworkDidChange?: (listener: (state: NetworkState) => void) => void;
clientId?: string;
infuraAPIKey: string;
infuraAPIKeySecret: string;
}) {
super({
name,
Expand All @@ -353,10 +350,7 @@ export class GasFeeController extends StaticIntervalPollingController<
this.EIP1559APIEndpoint = `${GAS_API_BASE_URL}/networks/<chain_id>/suggestedGasFees`;
this.legacyAPIEndpoint = `${GAS_API_BASE_URL}/networks/<chain_id>/gasPrices`;
this.clientId = clientId;
this.infuraAuthToken = buildInfuraAuthToken(
infuraAPIKey,
infuraAPIKeySecret,
);
this.infuraAuthToken = buildInfuraAuthToken(infuraAPIKey);

this.ethQuery = new EthQuery(this.#getProvider());

Expand Down
11 changes: 3 additions & 8 deletions packages/gas-fee-controller/src/gas-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,11 @@ export function calculateTimeEstimate(
* Build an infura auth token from the given API key and secret.
*
* @param infuraAPIKey - The Infura API key.
* @param infuraAPIKeySecret - The Infura API key secret.
* @returns The base64 encoded auth token.
*/
export function buildInfuraAuthToken(
infuraAPIKey: string,
infuraAPIKeySecret: string,
) {
return Buffer.from(`${infuraAPIKey}:${infuraAPIKeySecret}`).toString(
'base64',
);
export function buildInfuraAuthToken(infuraAPIKey: string) {
// We intentionally leave the password empty, as Infura does not require one
return Buffer.from(`${infuraAPIKey}:`).toString('base64');
}

/**
Expand Down

0 comments on commit 14be4d0

Please sign in to comment.