Skip to content

Commit

Permalink
Fixed error in getting cashtoken ft/nft records in recording of walle…
Browse files Browse the repository at this point in the history
…t history
  • Loading branch information
joemarct committed Jan 19, 2024
1 parent 986823e commit 51c53b0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
12 changes: 10 additions & 2 deletions main/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1356,8 +1356,16 @@ def parse_wallet_history(self, txid, wallet_handle, tx_fee=None, senders=[], rec
_txns = txns.exclude(token__name='bch')
if _txns.exists():
txns = _txns
cashtoken_ft = txns.last().cashtoken_ft
cashtoken_nft = txns.last().cashtoken_nft
ft_tx = txns.filter(cashtoken_ft__isnull=False).last()
if ft_tx:
cashtoken_ft = ft_tx.cashtoken_ft
if not cashtoken_ft:
nft_tx = txns.filter(
cashtoken_nft__isnull=False,
cashtoken_nft__category=cashtoken_ft.category
).last()
if nft_tx:
cashtoken_nft = nft_tx.cashtoken_nft
else:
# Get the cashtoken record if transaction does not have this info
ct_recipient = None
Expand Down
2 changes: 1 addition & 1 deletion smartbch/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def save_token_icons_task():
address_image_map = contract_utils.fetch_icons_from_marketcap() or {}
results = []
for token_contract in token_contracts:
url = f"https://www.smartscan.cash/assets/images/tokens/{token_contract.address}.png"
url = f"https://www.smartscout.cash/assets/images/tokens/{token_contract.address}.png"
src = "smartscan"
if token_contract.address.lower() in address_image_map and address_image_map[token_contract.address.lower()]:
url = address_image_map[token_contract.address.lower()]
Expand Down
10 changes: 6 additions & 4 deletions smartbch/utils/contract/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ def fetch_icons_from_marketcap():
address_image_url_map: Map<Address, URL>
address is in lowercase to prevent mismatch due to case sensitivity
"""
marketcap_token_list_json_url = "https://raw.githubusercontent.com/MarketCap-Cash/SmartBCH-Token-List/main/tokens.json"
response = requests.get(marketcap_token_list_json_url)
if not response.ok:
try:
marketcap_token_list_json_url = "https://raw.githubusercontent.com/MarketCap-Cash/SmartBCH-Token-List/main/tokens.json"
response = requests.get(marketcap_token_list_json_url)
if not response.ok:
return None
except:
return None

data = {}
try:
data = response.json()
Expand Down
4 changes: 2 additions & 2 deletions smartbch/utils/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ def send_transaction_transfer_notification_to_subscriber(
\n Token: {tx_transfer_obj.token_contract.name}
\n Token Address: {tx_transfer_obj.token_contract.address}
\n Amount: {tx_transfer_obj.amount}
\nhttps://www.smartscan.cash/transaction/{tx_transfer_obj.transaction.txid}
\nhttps://www.smartscout.cash/transaction/{tx_transfer_obj.transaction.txid}
"""
else:
message=f"""<b>WatchTower Notification</b> ℹ️
\n Address: {subscription.address.address}
\n Amount: {tx_transfer_obj.amount} BCH
\nhttps://www.smartscan.cash/transaction/{tx_transfer_obj.transaction.txid}
\nhttps://www.smartscout.cash/transaction/{tx_transfer_obj.transaction.txid}
"""

send_telegram_message(message, recipient.telegram_id)
Expand Down

0 comments on commit 51c53b0

Please sign in to comment.