-
-
Notifications
You must be signed in to change notification settings - Fork 267
fix: clean up slip 44 service logic #7626
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
Conversation
d039284 to
e368883
Compare
|
|
||
| return undefined; | ||
| // Default to 60 (Ethereum) for EVM networks without specific mapping | ||
| return 60; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💀
Is undefined not better here? If not, at least the behaviour is very clear here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forget what I said, I see now that it defaulted to 60 anyway in the consumer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think undefined is better here, because it pushes the ambiguity to runtime.
Defaulting to slip44:60 makes the behavior explicit and deterministic for EVM chains, which matches how wallets already derive and sign accounts. An undefined value would still require downstream logic to infer or guess the coin type, and that inference would almost certainly end up being 60 anyway.
packages/network-enablement-controller/src/NetworkEnablementController.ts
Outdated
Show resolved
Hide resolved
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
Explanation
The
Slip44Servicewas introduced in #7609 to look up SLIP-44 coin types for building native asset identifiers (CAIP-19). However, the initial API had some complexity that wasn't necessary:The
getSlip44ByChainIdmethod had an optionalsymbolparameter for fallback, but this fallback logic was confusing since EVM networks should use chain ID lookup and non-EVM networks should use symbol lookup - mixing them in one method added unnecessary complexity.The method could return
undefinedfor unknown EVM chains, but since EVM networks are all Ethereum-compatible, defaulting to 60 (Ethereum's SLIP-44 coin type) is a reasonable and safe default.The
getSlip44Entrymethod andSlip44Entrytype export weren't being used anywhere.This PR cleans up the service by:
getSlip44ByChainId→getEvmSlip44to make it explicit that it's for EVM networks onlysymbolfallback parameter (usegetSlip44BySymboldirectly for non-EVM networks)60(Ethereum) as the default for unknown EVM chain IDs instead ofundefinedgetSlip44Entrymethod andSlip44Entrytype exportNetworkEnablementControllerto no longer pass the native currency symbol to the lookup functionReferences
Checklist
Note
Streamlines SLIP-44 resolution and aligns controller usage.
getSlip44ByChainId→getEvmSlip44(EVM-only) and always default to coin type60when unmappedgetSlip44BySymbolonly for non-EVM networksgetSlip44Entryand its type/export; updateservices/index.tsand packageindex.tsexportsNetworkEnablementControllerto callSlip44Service.getEvmSlip44, stop passing native currency to add-network handler, and parse references correctlygetEvmSlip44, update expectations (e.g.,eip155:2→slip44:60), and remove unused entry testsWritten by Cursor Bugbot for commit 47cfb4e. This will update automatically on new commits. Configure here.