Skip to content

Commit ef647ea

Browse files
committed
update get_transactions_related
1 parent 8974c24 commit ef647ea

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tronapi/trx.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,14 @@ def get_transactions_related(self, address, direction='all', limit=30, offset=0)
239239
raise InvalidTronError('Invalid direction provided: Expected "to", "from" or "all"')
240240

241241
if direction == 'all':
242-
from_direction = {'from': self.get_transactions_related(address, 'from', limit, offset)}
243-
to_direction = {'to': self.get_transactions_related(address, 'to', limit, offset)}
242+
_from = self.get_transactions_related(address, 'from', limit, offset)
243+
_to = self.get_transactions_related(address, 'to', limit, offset)
244244

245-
callback = from_direction
246-
callback.update(to_direction)
245+
filter_from = [{**i, 'direction': 'from'} for i in _from]
246+
filter_to = [{**i, 'direction': 'to'} for i in _to]
247+
248+
callback = filter_from
249+
callback.extend(filter_to)
247250
return callback
248251

249252
if address is None:
@@ -267,7 +270,8 @@ def get_transactions_related(self, address, direction='all', limit=30, offset=0)
267270
'offset': offset
268271
})
269272

270-
# response.update({'direction': direction})
273+
if 'transaction' in response:
274+
return response['transaction']
271275
return response
272276

273277
def get_transactions_to_address(self, address=None, limit=30, offset=0):

0 commit comments

Comments
 (0)