json output formatting fix for Claim

This commit is contained in:
Lex Berezhny 2019-03-22 03:38:54 -04:00
parent a3c3143868
commit df649341cd
2 changed files with 5 additions and 9 deletions

View file

@ -25,7 +25,10 @@ class JSONResponseEncoder(JSONEncoder):
if isinstance(obj, Output): if isinstance(obj, Output):
return self.encode_output(obj) return self.encode_output(obj)
if isinstance(obj, Claim): if isinstance(obj, Claim):
return obj.to_dict() claim_dict = obj.to_dict()
if obj.is_stream:
claim_dict['stream']['hash'] = obj.stream.hash
return claim_dict
if isinstance(obj, datetime): if isinstance(obj, datetime):
return obj.strftime("%Y%m%dT%H:%M:%S") return obj.strftime("%Y%m%dT%H:%M:%S")
if isinstance(obj, Decimal): if isinstance(obj, Decimal):
@ -71,9 +74,7 @@ class JSONResponseEncoder(JSONEncoder):
if txo.script.is_claim_name or txo.script.is_update_claim: if txo.script.is_claim_name or txo.script.is_update_claim:
claim = txo.claim claim = txo.claim
output['value'] = claim.to_dict() output['value'] = claim
if claim.is_stream:
output['value']['stream']['hash'] = claim.stream.hash
if claim.is_signed: if claim.is_signed:
output['valid_signature'] = None output['valid_signature'] = None
if txo.channel is not None: if txo.channel is not None:

View file

@ -1,13 +1,8 @@
from unittest import mock from unittest import mock
from lbrynet.schema.claim import ClaimDict
from torba.orchstr8.node import WalletNode, SPVNode from torba.orchstr8.node import WalletNode, SPVNode
from torba.testcase import AsyncioTestCase from torba.testcase import AsyncioTestCase
import lbrynet.schema
lbrynet.schema.BLOCKCHAIN_NAME = 'lbrycrd_regtest'
from lbrynet.conf import Config from lbrynet.conf import Config
from lbrynet.wallet import LbryWalletManager, RegTestLedger from lbrynet.wallet import LbryWalletManager, RegTestLedger
from lbrynet.extras.daemon.Daemon import Daemon from lbrynet.extras.daemon.Daemon import Daemon