Repository: rotki/rotki

Issue:
Managed price not taken into account for manually added NFT assets
## Problem Definition

<!-- Provide a description of what is the current problem and why you are raising this issue.
If it's a bug please describe what was the unexpected thing that occured and what was the
expected behaviour. -->

I manually added an nft type asset in Rotki. Then as this asset has no price info, I added a managed price for the asset value in $.

I added a new externally held item for this nft using this asset in manual balances and set its amount to 1 but the value is still $0.

When I set the asset of this item to any non manually added asset as USD and set an amount, the value is correctly calculated.

**Expected result:** nft idem value should be `asset value x item amount`, not $0.

## Logs

<!-- Before being able to provide logs you need to enable debug logging on rotki, which is off by default.
You can enable debug logging by going to the login screen of the application, and in the lower right corner 
(or upper if you have a smaller screen) of the application you will find a cog icon. To enable debug logging
press the cog icon and select the `debug` entry. Try the flow that created the problem once again.
For more information please check: https://rotki.readthedocs.io/en/latest/contribute.html#bug-reporting
The debug information is stored to the `rotkehlchen.log` file. Please attach it to the
issue as it may help us find the source of the issue faster. You can find the logs location by going
to the Help menu on the top and then choosing "Logs directory" -->


### System Description

App Version: 1.21.2
Frontend Version: 1.21.2
Platform: darwin x64 11.6.0
Electron: 14.0.0




Discussion:
Hey Nicolas.

> I manually added an nft type asset in Rotki.

How did you do that? There is no way to manually add custom assets such as NFTs in rotki
![image](https://user-images.githubusercontent.com/4677568/139139344-5b987b05-2ef3-49bb-9f5f-e1b8400649d8.png)

Ha! Nice. This is interesting.

This is a misconfiguration after the addition of NFTs in rotki. Should not have been there. This would not work. This is why you are seeing the problem you described.

We hope to be able to allow for custom assets of any type (such as stocks, real estate e.t.c.) with custom price throught this issue: https://github.com/rotki/rotki/issues/2021. Which would allow you to also do what you want.

But let me keep your issue also open since until 2021 is done there should be no option to enter custom nft there.

Will have to go in and check the logic in there in case there is an easy way to achieve this maybe.

Resolving patch:
diff --git a/rotkehlchen/api/rest.py b/rotkehlchen/api/rest.py
--- a/rotkehlchen/api/rest.py
+++ b/rotkehlchen/api/rest.py
@@ -56,7 +56,7 @@
     FREE_LEDGER_ACTIONS_LIMIT,
     FREE_TRADES_LIMIT,
 )
-from rotkehlchen.constants.misc import ZERO
+from rotkehlchen.constants.misc import ASSET_TYPES_EXCLUDED_FOR_USERS, ZERO
 from rotkehlchen.constants.resolver import ethaddress_to_identifier
 from rotkehlchen.db.cache_handler import DBAccountingReports
 from rotkehlchen.db.ethtx import DBEthTx
@@ -1333,7 +1333,7 @@ def query_owned_assets(self) -> Response:
 
     @staticmethod
     def get_asset_types() -> Response:
-        types = [str(x) for x in AssetType]
+        types = [str(x) for x in AssetType if x not in ASSET_TYPES_EXCLUDED_FOR_USERS]
         return api_response(_wrap_in_ok_result(types), status_code=HTTPStatus.OK)
 
     @require_loggedin_user()
diff --git a/rotkehlchen/constants/misc.py b/rotkehlchen/constants/misc.py
--- a/rotkehlchen/constants/misc.py
+++ b/rotkehlchen/constants/misc.py
@@ -1,3 +1,4 @@
+from rotkehlchen.assets.typing import AssetType
 from rotkehlchen.fval import FVal
 from rotkehlchen.typing import EventType
 
@@ -24,3 +25,5 @@
 # KRAKEN_BASE_URL = 'http://localhost:5001/kraken'
 # KRAKEN_API_VERSION = 'mock'
 # BINANCE_BASE_URL = 'http://localhost:5001/binance/api/'
+
+ASSET_TYPES_EXCLUDED_FOR_USERS = {AssetType.NFT}


Test patch:
diff --git a/rotkehlchen/tests/api/test_custom_assets.py b/rotkehlchen/tests/api/test_custom_assets.py
--- a/rotkehlchen/tests/api/test_custom_assets.py
+++ b/rotkehlchen/tests/api/test_custom_assets.py
@@ -9,6 +9,7 @@
 from rotkehlchen.assets.asset import Asset
 from rotkehlchen.assets.typing import AssetType
 from rotkehlchen.balances.manual import ManuallyTrackedBalance
+from rotkehlchen.constants.misc import ASSET_TYPES_EXCLUDED_FOR_USERS
 from rotkehlchen.constants.resolver import strethaddress_to_identifier
 from rotkehlchen.fval import FVal
 from rotkehlchen.tests.utils.api import (
@@ -527,7 +528,7 @@ def test_query_asset_types(rotkehlchen_api_server):
         ),
     )
     result = assert_proper_response_with_result(response)
-    assert result == [str(x) for x in AssetType]
+    assert result == [str(x) for x in AssetType if x not in ASSET_TYPES_EXCLUDED_FOR_USERS]
     assert all(isinstance(AssetType.deserialize(x), AssetType) for x in result)