Skip to content

Commit aaa85c0

Browse files
authored
fix issue where ethQuery is not instantiated correctly when GasFeeController is constructed (#936)
* fix issue where ethQuery is not instantiated correctly when GasFeeController is constructed
1 parent 4c70024 commit aaa85c0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/gas/GasFeeController.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ describe('GasFeeController', () => {
199199
legacyAPIEndpoint = 'http://legacy.endpoint/<chain_id>',
200200
EIP1559APIEndpoint = 'http://eip-1559.endpoint/<chain_id>',
201201
clientId,
202+
getChainId,
202203
}: {
203204
getChainId?: jest.Mock<`0x${string}` | `${number}` | number>;
204205
getIsEIP1559Compatible?: jest.Mock<Promise<boolean>>;
@@ -211,6 +212,8 @@ describe('GasFeeController', () => {
211212
setupNetworkController(controllerMessenger);
212213
const messenger = getRestrictedMessenger(controllerMessenger);
213214
gasFeeController = new GasFeeController({
215+
getProvider: jest.fn(),
216+
getChainId,
214217
messenger,
215218
getCurrentNetworkLegacyGasAPICompatibility,
216219
getCurrentNetworkEIP1559Compatibility: getIsEIP1559Compatible, // change this for networkController.state.properties.isEIP1559Compatible ???

src/gas/GasFeeController.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ export class GasFeeController extends BaseController<
304304
getCurrentNetworkLegacyGasAPICompatibility: () => boolean;
305305
getCurrentAccountEIP1559Compatibility?: () => boolean;
306306
getChainId?: () => `0x${string}` | `${number}` | number;
307-
getProvider?: () => NetworkController['provider'];
307+
getProvider: () => NetworkController['provider'];
308308
onNetworkStateChange?: (listener: (state: NetworkState) => void) => void;
309309
legacyAPIEndpoint?: string;
310310
EIP1559APIEndpoint?: string;
@@ -329,7 +329,9 @@ export class GasFeeController extends BaseController<
329329
this.EIP1559APIEndpoint = EIP1559APIEndpoint;
330330
this.legacyAPIEndpoint = legacyAPIEndpoint;
331331
this.clientId = clientId;
332-
if (onNetworkStateChange && getChainId && getProvider) {
332+
if (onNetworkStateChange && getChainId) {
333+
const initialProvider = getProvider();
334+
this.ethQuery = new EthQuery(initialProvider);
333335
this.currentChainId = getChainId();
334336
onNetworkStateChange(async () => {
335337
const newProvider = getProvider();

0 commit comments

Comments
 (0)