This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
Fix loading custom tokens with 0 decimals. #198
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.
Issue
Adding a custom address in the ForkDelta url allows you to load a custom token.
However loading a token with 0 decimals, will reload the page to the default DAI-ETH pair.
0 decimal tokens should work:
The old EtherDelta website used to load these tokens just fine.
Fix
Checking the code, there is a
result > 0
check for loading decimals.That was probably added because an invalid token without a
decimals
property returns "0x", which gets parsed as a 0 decimal token. Thus the UI would load for any random address in the url.The check is now
result >= 0
. And a 'decimals' calls that returns "0x" will return an error instead of a number.Testing
Loading some example addresses in the url to test normal usage.
0x93713bf12ba1bb55edf94298a302a8fc9d118086
: switches to ATR-ETH, as expected.0x0000000000004946c0e9f43f4dee607b0ef1fa1c
: loads as expected.0x9ba00d6856a4edf4665bca2c2309936572473b7e
: loads as expected.0xbf320b8336b131e0270295c15478d91741f9fc11
: resets to DAI-ETH0xf6e914d07d12636759868a61e52973d17ed7111b
: resets to DAI-ETH