Uh oh!
There was an error while loading. Please reload this page.
Make TokenRatesController findChainSlug method accommodate hex formatted chainIds - #584
Make TokenRatesController findChainSlug method accommodate hex formatted chainIds#584adonesky1 wants to merge 2 commits into
Conversation
2032637 to
2c471feCompare49c08da to
5ae4eb1Compare5ae4eb1 to
025758aCompareadonesky1
commented
Sep 13, 2021
@danjm@Gudahtt I think this change may run the risk of a misidentified chain if say, a chain from the extension's network controller passed as the chainID in hex format that didn't start with '0x' and was a valid number that could be found in coingecko's platform list. All the instances I've seen coming from extension's network controller where this confusion could occur ( e.g. '0x38' = 56) are prefixed with '0x' but just want to raise this to your attention for thoughts. |
Gudahtt
commented
Sep 14, 2021
We should be guaranteeing that the chain ID in the network controller is always a hex-prefixed string. What motivated this change? Did you find an example of the network chain ID being a decimal string? |
wachunei
commented
Sep 14, 2021
FYI: When we created Swaps, Token Rates and Smart Transactions controllers are currently not handling the chain id and expecting base 10 numeric string. |
adonesky1
commented
Sep 14, 2021
@Gudahtt, yea so the reason is, as @wachunei alludes to, the controllers based NetworkController is actually using base 10 numeric strings for chainId, while the extensions NetworkController uses base 16 numeric strings. |
Gudahtt
commented
Sep 14, 2021
Huh, OK. That is a pretty major discrepancy. In the meantime we can accept one type or the other, and ensure the caller converts the chain ID accordingly. Accepting both would further entrench this ambiguity and could lead to parsing bugs. |
adonesky1
commented
Sep 14, 2021
@Gudahtt ok yeah that makes sense. |
adonesky1
commented
Sep 16, 2021
OBE - Extension modifies chainID to dec format before passing into TokenRatesController OnNetworkChange instead of this change. |
* 24.1.0 * update changelog --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Michele Esposito <michele@esposito.codes>
The findChainSlug method on the TokensRateController should accept and correctly search for chain slugs when passed either a hex or decimal formatted chainId.