Skip to content

Commit 23f2ed4

Browse files
dehidehidehidehidehidehi
authored andcommitted
Hotfix: Resolved pagination issue where pagination used to end too early.
1 parent 96f1b99 commit 23f2ed4

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

open_sea_v1/responses/event.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import locale
2+
import logging
23
from dataclasses import dataclass
34

45
from open_sea_v1.helpers.ether_converter import EtherConverter, EtherUnit
56
from open_sea_v1.responses.abc import BaseResponse
67
from open_sea_v1.responses.asset import AssetResponse
78

9+
logger = logging.getLogger(__name__)
10+
811

912
@dataclass
1013
class EventResponse(BaseResponse):
@@ -14,14 +17,15 @@ def __str__(self) -> str:
1417
locale.setlocale(locale.LC_ALL, '') # big number str formater
1518

1619
name = self.asset.name[:20]
17-
transaction_date = f"{self.transaction['timestamp'][:10]} {self.transaction['timestamp'][11:-3]}"
20+
transaction_date = f"{self.transaction['timestamp'][:10]} {self.transaction['timestamp'][11:-3]}" if self.transaction else ''
21+
1822
usd_price = round(self.usd_price / int(self.quantity), 2)
1923
usd_price = f"{usd_price:,.2f}"
2024
usd_price = f"{usd_price} USD"
2125
eth_price = self.eth_price / int(self.quantity)
2226
eth_price = f"{eth_price:.4f} ETH" # trailing zeros
2327

24-
str_representation =" ".join([name, transaction_date, usd_price, eth_price])
28+
str_representation = " ".join([name, transaction_date, usd_price, eth_price])
2529
return str_representation
2630

2731
def __post_init__(self):
@@ -47,12 +51,18 @@ def __post_init__(self):
4751
self.is_private = self._json.get('is_private')
4852

4953
@property
50-
def eth_price(self):
54+
def eth_price(self) -> float:
55+
if not self.total_price:
56+
logger.debug(f'Event {self.id} for asset {self.asset.name} ({self.asset.id}) has no ETH price. Returning 0.')
57+
return 0.0
5158
eth_price = EtherConverter(quantity=self.total_price, unit=EtherUnit.WEI).ether
5259
return eth_price
5360

5461
@property
5562
def usd_price(self):
63+
if not self.payment_token:
64+
logger.debug(f'Event {self.id} for asset {self.asset.name} ({self.asset.id}) has no payment token. Returning 0.')
65+
return 0.0
5666
eth_to_usd_price = float(self.payment_token['usd_price']) # 'eth_price' key also available
5767
usd_price = round(self.eth_price * eth_to_usd_price, 2)
5868
return usd_price
@@ -76,4 +86,3 @@ def transaction(self) -> dict:
7686
@property
7787
def winner_account(self) -> dict:
7888
return self._json['winner_account']
79-

open_sea_v1/responses/order.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class OrderResponse(BaseResponse):
1414
_json: dict
1515

1616
def __str__(self):
17-
return f"order_id={self.id} {str(self.asset)}"
17+
return f"order_id={self.id}"
1818

1919
def __post_init__(self):
2020
self._set_common_attrs()

0 commit comments

Comments
 (0)