-
-
Notifications
You must be signed in to change notification settings - Fork 266
feat: add slip44 identfiers for added chains #7609
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
Open
salimtb
wants to merge
2
commits into
main
Choose a base branch
from
feat/add-slip44-identfiers-for-added-chains
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+960
−238
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
589e726 to
f075c1f
Compare
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
packages/network-enablement-controller/src/NetworkEnablementController.ts
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation
Current State
The
NetworkEnablementControllertracks which networks are enabled/disabled but lacks information about the native asset identifier for each chain. This information is needed to properly identify native assets across different blockchain networks using a standardized format.Extension UI PR: MetaMask/metamask-extension#39234
Solution
This PR adds a new state property
nativeAssetIdentifiersto theNetworkEnablementControllerthat maps CAIP-2 chain IDs to CAIP-19-like native asset identifiers.For example:
eip155:1→eip155:1/slip44:60(Ethereum uses ETH, SLIP-44 coin type 60)eip155:56→eip155:56/slip44:714(BSC uses BNB, SLIP-44 coin type 714)solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp→solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501Implementation Details
New
Slip44Service: A service that wraps the@metamask/slip44package to look up SLIP-44 coin types by symbol (e.g.,ETH→60,BTC→0).State Updates: The
nativeAssetIdentifiersstate is automatically updated when:NetworkController:networkAdded)NetworkController:networkRemoved)NetworkController:stateChange)Default State: Popular networks are pre-populated with their correct native asset identifiers based on their native currency symbols.
Graceful Handling: If a symbol has no SLIP-44 mapping, the entry is removed from the state rather than storing an invalid identifier.
Dependency Addition
Added
@metamask/slip44package to dynamically look up SLIP-44 coin types instead of hardcoding them, ensuring accuracy and maintainability.References
Checklist
Note
Introduces standardized native asset IDs and automated maintenance in
NetworkEnablementController.nativeAssetIdentifiersstate mapping CAIP-2 chain IDs to CAIP-19-like identifiers (e.g.,eip155:1/slip44:60) and includes it in metadata (persist/debug/ui)Slip44Service(using@metamask/slip44) to resolve SLIP-44 coin types by symbol; exported via package indexNetworkController:stateChangeto update identifiers whennativeCurrencychanges; update onnetworkAdded/networkRemoved; remove mapping when symbol is unknowninitNativeAssetIdentifiers(networks)helper and populates identifiers duringinit()for EVM configs@metamask/slip44dependency and CHANGELOG entryWritten by Cursor Bugbot for commit 057a1a5. This will update automatically on new commits. Configure here.