json output formatting fix for Claim
This commit is contained in:
parent
a3c3143868
commit
df649341cd
2 changed files with 5 additions and 9 deletions
|
@ -25,7 +25,10 @@ class JSONResponseEncoder(JSONEncoder):
|
|||
if isinstance(obj, Output):
|
||||
return self.encode_output(obj)
|
||||
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):
|
||||
return obj.strftime("%Y%m%dT%H:%M:%S")
|
||||
if isinstance(obj, Decimal):
|
||||
|
@ -71,9 +74,7 @@ class JSONResponseEncoder(JSONEncoder):
|
|||
|
||||
if txo.script.is_claim_name or txo.script.is_update_claim:
|
||||
claim = txo.claim
|
||||
output['value'] = claim.to_dict()
|
||||
if claim.is_stream:
|
||||
output['value']['stream']['hash'] = claim.stream.hash
|
||||
output['value'] = claim
|
||||
if claim.is_signed:
|
||||
output['valid_signature'] = None
|
||||
if txo.channel is not None:
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
from unittest import mock
|
||||
|
||||
from lbrynet.schema.claim import ClaimDict
|
||||
|
||||
from torba.orchstr8.node import WalletNode, SPVNode
|
||||
from torba.testcase import AsyncioTestCase
|
||||
|
||||
import lbrynet.schema
|
||||
lbrynet.schema.BLOCKCHAIN_NAME = 'lbrycrd_regtest'
|
||||
|
||||
from lbrynet.conf import Config
|
||||
from lbrynet.wallet import LbryWalletManager, RegTestLedger
|
||||
from lbrynet.extras.daemon.Daemon import Daemon
|
||||
|
|
Loading…
Reference in a new issue