Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/network-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Bump `@metamask/eth-json-rpc-middleware` from `^22.0.0` to `^22.0.1` ([#7330](https://github.com/MetaMask/core/pull/7330))

### Fixed

- Ensure `get1559CompatibilityWithNetworkClientId` updates network metadata with EIP-1559 compatibility data missing ([#7532](https://github.com/MetaMask/core/pull/7532))

## [27.0.0]

### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/network-controller/src/NetworkController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2132,7 +2132,7 @@ export class NetworkController extends BaseController<
networkClientId: NetworkClientId,
): Promise<boolean> {
let metadata = this.state.networksMetadata[networkClientId];
if (metadata === undefined) {
if (metadata?.EIPS[1559] === undefined) {
await this.lookupNetwork(networkClientId);
metadata = this.state.networksMetadata[networkClientId];
}
Expand Down
44 changes: 43 additions & 1 deletion packages/network-controller/tests/NetworkController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3590,7 +3590,7 @@ describe('NetworkController', () => {
},
);
});
it('calls provider of the networkClientId and returns true', async () => {
it('updates network metadata if undefined', async () => {
await withController(
{
infuraProjectId: 'some-infura-project-id',
Expand Down Expand Up @@ -3624,6 +3624,48 @@ describe('NetworkController', () => {
},
);
});
it('updates network metadata if EIP-1559 compatibility is missing', async () => {
await withController(
{
infuraProjectId: 'some-infura-project-id',
state: {
networksMetadata: {
'linea-mainnet': {
EIPS: {},
status: NetworkStatus.Unknown,
},
},
},
},
async ({ controller }) => {
await setFakeProvider(controller, {
stubs: [
{
request: {
method: 'eth_getBlockByNumber',
params: ['latest', false],
},
response: {
result: POST_1559_BLOCK,
},
},
{
request: {
method: 'eth_getBlockByNumber',
params: ['latest', false],
},
response: {
result: POST_1559_BLOCK,
},
},
],
});
const isEIP1559Compatible =
await controller.getEIP1559Compatibility('linea-mainnet');
expect(isEIP1559Compatible).toBe(true);
},
);
});
});

describe('if a provider has been set but networksMetadata[selectedNetworkClientId].EIPS in state already has a "1559" property', () => {
Expand Down
Loading