classic-frontend icon indicating copy to clipboard operation
classic-frontend copied to clipboard

Fix loading custom tokens with 0 decimals.

Open DeltaBalances opened this issue 5 years ago • 0 comments

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:

  • Adding a 0 decimal token in the UI with 'other' works.
  • There are 0 decimal tokens listed (e.g ATR-ETH 0x93713bf12ba1bb55edf94298a302a8fc9d118086)

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.

  • A listed token: 0x93713bf12ba1bb55edf94298a302a8fc9d118086: switches to ATR-ETH, as expected.
  • Unknown 0 decimal token:
    0x0000000000004946c0e9f43f4dee607b0ef1fa1c: loads as expected.
  • Unknown 6 decimals token ( >0 test): 0x9ba00d6856a4edf4665bca2c2309936572473b7e: loads as expected.
  • Non-erc20 contract: 0xbf320b8336b131e0270295c15478d91741f9fc11: resets to DAI-ETH
  • Regular wallet address: 0xf6e914d07d12636759868a61e52973d17ed7111b: resets to DAI-ETH

DeltaBalances avatar Jul 17 '20 09:07 DeltaBalances