Repository: rotki/rotki

Issue:
TradeType is not JSON serializable
## Problem Definition

As the title says. I faced this error when i rebased on latest master.
```
26/02/2019 20:40:54 CET -- ERROR:rotkehlchen.server:Greenlet for task 5 dies with exception: Object of type TradeType is not JSON serializable.
Exception Name: <class 'TypeError'>
Exception Info: Object of type TradeType is not JSON serializable
Traceback:
   File "src/gevent/greenlet.py", line 716, in gevent._greenlet.Greenlet.run
  File "/home/rakan/Code/Python/rotkehlchen/rotkehlchen/server.py", line 115, in _query_async
    result = getattr(self, command)(**kwargs)
  File "/home/rakan/Code/Python/rotkehlchen/rotkehlchen/server.py", line 230, in process_trade_history
    result, error_or_empty = self.rotkehlchen.process_history(start_ts, end_ts)
  File "/home/rakan/Code/Python/rotkehlchen/rotkehlchen/rotkehlchen.py", line 482, in process_history
    end_at_least_ts=end_ts,
  File "/home/rakan/Code/Python/rotkehlchen/rotkehlchen/history.py", line 925, in get_history
    return self.create_history(start_ts, end_ts, end_at_least_ts)
  File "/home/rakan/Code/Python/rotkehlchen/rotkehlchen/history.py", line 764, in create_history
    write_tupledata_history_in_file(history, historyfile_path, start_ts, end_ts)
  File "/home/rakan/Code/Python/rotkehlchen/rotkehlchen/history.py", line 128, in write_tupledata_history_in_file
    write_history_data_in_file(out_history, filepath, start_ts, end_ts)
  File "/home/rakan/Code/Python/rotkehlchen/rotkehlchen/history.py", line 123, in write_history_data_in_file
    outfile.write(rlk_jsondumps(history_dict))
  File "/home/rakan/Code/Python/rotkehlchen/rotkehlchen/utils.py", line 316, in rlk_jsondumps
    return json.dumps(data, cls=RKLEncoder)
  File "/home/rakan/.pyenv/versions/3.7.0/lib/python3.7/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/home/rakan/.pyenv/versions/3.7.0/lib/python3.7/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/home/rakan/.pyenv/versions/3.7.0/lib/python3.7/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/home/rakan/Code/Python/rotkehlchen/rotkehlchen/utils.py", line 296, in default
    return json.JSONEncoder.default(self, obj)
  File "/home/rakan/.pyenv/versions/3.7.0/lib/python3.7/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
```



Discussion:

Resolving patch:
diff --git a/rotkehlchen/utils.py b/rotkehlchen/utils.py
--- a/rotkehlchen/utils.py
+++ b/rotkehlchen/utils.py
@@ -12,7 +12,7 @@
 
 import requests
 from rlp.sedes import big_endian_int
-
+from rotkehlchen.order_formatting import TradeType
 from rotkehlchen.constants import ALL_REMOTES_TIMEOUT, ZERO
 from rotkehlchen.errors import RecoverableRequestError, RemoteError
 from rotkehlchen.fval import FVal
@@ -272,7 +272,6 @@ def rkl_decode_value(
             return FVal(val)
         except ValueError:
             pass
-
     assert not isinstance(val, float)
     return val
 
@@ -290,6 +289,8 @@ class RKLEncoder(json.JSONEncoder):
     def default(self, obj):
         if isinstance(obj, FVal):
             return str(obj)
+        if isinstance(obj, TradeType):
+            return str(obj)
         if isinstance(obj, float):
             raise ValueError("Trying to json encode a float.")
 


Test patch: