Skip to content

Replace network state with networkId and networkStatus - #1196

Merged
Gudahtt merged 4 commits into
mainfrom
replace-network-with-network-status
Apr 18, 2023
Merged

Replace network state with networkId and networkStatus#1196
Gudahtt merged 4 commits into
mainfrom
replace-network-with-network-status

Conversation

@Gudahtt

@GudahttGudahtt commented Apr 17, 2023

Copy link
Copy Markdown
Member

Description

The network controller network state used to be set to loading if the network was loading or uninitialized, or to the network ID if the network had finished loading. Effectively it was tracking both the network ID for the current selected network, and the network status.

This state property has been split in two; now we track the network ID of the current selected network separately from the network status. The network status has been expanded to include more states as well.

Changes

  • BREAKING: The network state has been replaced by networkId and networkStatus
    • If you were using network to access the network ID, use networkId now instead. It will be set to null rather than loading if the network is not currently available.
    • If you were using network to see if the network was currently available, use networkStatus instead. It will be set to NetworkStatus.Available if the network is available.
    • When the network is unavailable, we now have two different states to represent that: "Unknown" and "Unavailable". Unavailable means that we know the network is not currently available, whereas unknown is used for unknown errors and for cases where we don't yet know the network status (e.g. before initialization, or while the network is loading).

References

Relates to #1020

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation for new or updated code as appropriate (note: this will usually be JSDoc)
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@Gudahtt
Gudahttforce-pushed the replace-network-with-network-status branch 5 times, most recently from 087e0f5 to 03739b1CompareApril 17, 2023 22:27
The network controller `network` state used to be set to `loading` if
the network was loading or uninitialized, or to the network ID if the
network had finished loading. Effectively it was tracking both the
network ID for the current selected network, and the network status.
This state property has been split in two; now we track the network ID
of the current selected network separately from the network status. The
network status has been expanded to include more states as well.
Closes#1020
@Gudahtt
Gudahttforce-pushed the replace-network-with-network-status branch from 03739b1 to fb98499CompareApril 17, 2023 22:28
@Gudahtt
Gudahtt marked this pull request as ready for review April 17, 2023 22:35
@Gudahtt
Gudahtt requested a review from a team as a code ownerApril 17, 2023 22:35
Comment threadpackages/network-controller/src/constants.ts Outdated
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
@GudahttGudahtt mentioned this pull request Apr 18, 2023
3 tasks

@mcmiremcmire left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Makes sense! Just had a single suggestion.

Comment threadpackages/transaction-controller/src/TransactionController.test.ts Outdated

@mcmiremcmire left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great!

@Gudahtt
Gudahtt merged commit d73498e into mainApr 18, 2023
@Gudahtt
Gudahtt deleted the replace-network-with-network-status branch April 18, 2023 19:23
@legobeatlegobeat mentioned this pull request Apr 25, 2023
Gudahtt added a commit that referenced this pull request May 10, 2023
The network change handler for the ENS controller has been broken since
the PR #1170 due to a conflict with #1196, which was merged around the
same time. It referenced the `network` property of the network state
that we have removed.
The change handler has been updated to use `networkId` instead.
Additionally, the `NetworkState` type has been imported so that we're
less likely to make this mistake again.
Gudahtt added a commit that referenced this pull request May 10, 2023
The network change handler for the ENS controller has been broken since
the PR #1170 due to a conflict with #1196, which was merged around the
same time. It referenced the `network` property of the network state
that we have removed.
The change handler has been updated to use `networkId` instead.
Additionally, the `NetworkState` type has been imported so that we're
less likely to make this mistake again.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Gudahtt@mcmire@legobeat