Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace NetworksChainId constant with ChainId #1354

Merged
merged 2 commits into from
May 9, 2023

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented May 9, 2023

Description

The constant NetworksChainId was ambiguous in whether it referred to network or chain Ids, and it didn't match our enum naming conventions. It was also undocumented, and unclear in which networks it was intended to contain.

It has been replaced with a ChainId constant with documentation and a clear scope (built-in networks). A BuiltInNetworks enum has been added as well to make that more clear.

Changes

@metamask/controller-utils

  • BREAKING: Replace the NetworksChainId constant with ChainId
  • Added: Add constants BuiltInNetwork and ChainId

References

Relates to #1209

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 Gudahtt force-pushed the replace-network-chain-ids branch 2 times, most recently from d4daa70 to 7c32737 Compare May 9, 2023 18:34
@Gudahtt Gudahtt marked this pull request as ready for review May 9, 2023 18:37
@Gudahtt Gudahtt requested a review from a team as a code owner May 9, 2023 18:37
@Gudahtt Gudahtt force-pushed the replace-network-chain-ids branch 3 times, most recently from c5f2464 to 23e4122 Compare May 9, 2023 19:16
controller.setProviderType(NetworkType.rpc),
).rejects.toThrow(
'rpcUrl must be provided for custom RPC endpoints',
'chainId must be provided for custom RPC endpoints',
Copy link
Member Author

Choose a reason for hiding this comment

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

This changed because NetworksChainId had an empty string for the RPC network type, causing it to pass chain ID validation but fail rpcUrl validation. Now it fails chain ID validation instead because that entry wasn't brought along to the ChainId constant.

@Gudahtt Gudahtt force-pushed the replace-network-chain-ids branch from 23e4122 to f1e9d69 Compare May 9, 2023 19:47
The constant `NetworksChainId` was ambiguous in whether it referred to
network or chain Ids, and it didn't match our enum naming conventions.
It was also undocumented, and unclear in which networks it was intended
to contain.

It has been replaced with a `ChainId` constant with documentation and a
clear scope (built-in networks). A `BuiltInNetworks` enum has been
added as well to make that more clear.

Relates to #1209
@Gudahtt Gudahtt force-pushed the replace-network-chain-ids branch from f1e9d69 to 397220a Compare May 9, 2023 19:55
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

One suggestion but looks good to me otherwise.

packages/controller-utils/src/types.ts Outdated Show resolved Hide resolved
mcmire
mcmire previously approved these changes May 9, 2023
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

One suggestion but looks good to me otherwise.

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

LGTM!

@Gudahtt Gudahtt merged commit f53e5d8 into main May 9, 2023
@Gudahtt Gudahtt deleted the replace-network-chain-ids branch May 9, 2023 23:18
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
* Replace `NetworksChainId` constant with `ChainId`

The constant `NetworksChainId` was ambiguous in whether it referred to
network or chain Ids, and it didn't match our enum naming conventions.
It was also undocumented, and unclear in which networks it was intended
to contain.

It has been replaced with a `ChainId` constant with documentation and a
clear scope (built-in networks). A `BuiltInNetworks` enum has been
added as well to make that more clear.

Relates to #1209

* Rename BuiltInNetwork to BuiltInNetworkName
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
* Replace `NetworksChainId` constant with `ChainId`

The constant `NetworksChainId` was ambiguous in whether it referred to
network or chain Ids, and it didn't match our enum naming conventions.
It was also undocumented, and unclear in which networks it was intended
to contain.

It has been replaced with a `ChainId` constant with documentation and a
clear scope (built-in networks). A `BuiltInNetworks` enum has been
added as well to make that more clear.

Relates to #1209

* Rename BuiltInNetwork to BuiltInNetworkName
Sign up for free to 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.

2 participants