Skip to content

Commit

Permalink
fix issue where ethQuery is not instantiated correctly when GasFeeCon…
Browse files Browse the repository at this point in the history
…troller is constructed (#936)

* fix issue where ethQuery is not instantiated correctly when GasFeeController is constructed
  • Loading branch information
adonesky1 authored Oct 13, 2022
1 parent 4c70024 commit aaa85c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/gas/GasFeeController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ describe('GasFeeController', () => {
legacyAPIEndpoint = 'http://legacy.endpoint/<chain_id>',
EIP1559APIEndpoint = 'http://eip-1559.endpoint/<chain_id>',
clientId,
getChainId,
}: {
getChainId?: jest.Mock<`0x${string}` | `${number}` | number>;
getIsEIP1559Compatible?: jest.Mock<Promise<boolean>>;
Expand All @@ -211,6 +212,8 @@ describe('GasFeeController', () => {
setupNetworkController(controllerMessenger);
const messenger = getRestrictedMessenger(controllerMessenger);
gasFeeController = new GasFeeController({
getProvider: jest.fn(),
getChainId,
messenger,
getCurrentNetworkLegacyGasAPICompatibility,
getCurrentNetworkEIP1559Compatibility: getIsEIP1559Compatible, // change this for networkController.state.properties.isEIP1559Compatible ???
Expand Down
6 changes: 4 additions & 2 deletions src/gas/GasFeeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export class GasFeeController extends BaseController<
getCurrentNetworkLegacyGasAPICompatibility: () => boolean;
getCurrentAccountEIP1559Compatibility?: () => boolean;
getChainId?: () => `0x${string}` | `${number}` | number;
getProvider?: () => NetworkController['provider'];
getProvider: () => NetworkController['provider'];
onNetworkStateChange?: (listener: (state: NetworkState) => void) => void;
legacyAPIEndpoint?: string;
EIP1559APIEndpoint?: string;
Expand All @@ -329,7 +329,9 @@ export class GasFeeController extends BaseController<
this.EIP1559APIEndpoint = EIP1559APIEndpoint;
this.legacyAPIEndpoint = legacyAPIEndpoint;
this.clientId = clientId;
if (onNetworkStateChange && getChainId && getProvider) {
if (onNetworkStateChange && getChainId) {
const initialProvider = getProvider();
this.ethQuery = new EthQuery(initialProvider);
this.currentChainId = getChainId();
onNetworkStateChange(async () => {
const newProvider = getProvider();
Expand Down

0 comments on commit aaa85c0

Please sign in to comment.