Skip to content

Conversation

@mcmire
Copy link
Contributor

@mcmire mcmire commented May 22, 2024

Explanation

The providerConfig state property is being removed from NetworkController. Currently this property is used in NftDetectionController to get the currently selected chain, but selectedNetworkClientId can be used instead. This commit makes that transition so that we can fully drop providerConfig.

References

Progresses #4185.

Changelog

(Updates to changelog in PR.)

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

@mcmire mcmire requested a review from a team May 22, 2024 20:12
@mcmire mcmire force-pushed the remove-provider-config-from-nft-detection-controller branch from 81c0ef0 to b0facae Compare May 22, 2024 20:18
});
});

it('should respond to chain ID changing when using legacy polling', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a missing test.

async ({ controller, controllerEvents }) => {
const selectedAddress = '0x1';
triggerPreferencesStateChange({
controllerEvents.preferencesStateChange({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that there are a lot of changes in this PR that are unrelated to the change from providerConfig to selectedNetworkClientId. I took this opportunity to align the tests in this file to use our latest convention for mocking events couched as callbacks.

preferencesStateChangeListeners.push(listener);
controllerEvents.preferencesStateChange = listener;
},
onNetworkStateChange: (listener) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously we were just passing jest.fn() as the value for this callback, but now we are capturing the listener so that we can call it in tests, effectively firing the event.

},
],
});
console.log(nock.activeMocks());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure why we were doing this; this was just adding to the noise when running these tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess someone forgot to remove it while debugging

The `providerConfig` state property is being removed from
NetworkController. Currently this property is used in
NftDetectionController to get the currently selected chain, but
`selectedNetworkClientId` can be used instead. This commit makes that
transition so that we can fully drop `providerConfig`.
@mcmire mcmire force-pushed the remove-provider-config-from-nft-detection-controller branch from b0facae to 23a21ec Compare May 22, 2024 20:21
Copy link
Contributor

@cryptodev-2s cryptodev-2s left a comment

Choose a reason for hiding this comment

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

LGTM!

@mcmire mcmire merged commit 43c3d30 into main May 23, 2024
@mcmire mcmire deleted the remove-provider-config-from-nft-detection-controller branch May 23, 2024 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants