From 34a421fa267c5543d1f9cf4c7f7372e5715416fe Mon Sep 17 00:00:00 2001 From: khirvy019 Date: Tue, 28 Feb 2023 10:48:51 +0800 Subject: [PATCH] fix error when updating wallet nft in post save tx, fix some simple nft owners not getting updated --- main/tasks.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/main/tasks.py b/main/tasks.py index aa3900a4..992677df 100644 --- a/main/tasks.py +++ b/main/tasks.py @@ -947,6 +947,11 @@ def parse_wallet_history(self, txid, wallet_handle, tx_fee=None, senders=[], rec except Exception as exception: LOGGER.exception(exception) + # for older token records + if txn.token and txn.token.tokenid and (txn.token.token_type is None or txn.token.mint_amount is None): + get_token_meta_data(txn.token.tokenid, async_image_download=True) + txn.token.refresh_from_db() + if txn.token and txn.token.is_nft: if record_type == 'incoming': wallet_nft_token, created = WalletNftToken.objects.get_or_create( @@ -1065,12 +1070,12 @@ def transaction_post_save_task(self, address, transaction_id, blockheight_id=Non if txn_check.exists(): txn_obj = txn_check.last() if txn_obj.token.is_nft: - wallet_nft_token = WalletNftToken.objects.get( - acquisition_transaction=txn_obj - ) - wallet_nft_token.date_dispensed = timezone.now() - wallet_nft_token.dispensation_transaction = transaction - wallet_nft_token.save() + wallet_nft_tokens = WalletNftToken.objects.filter(acquisition_transaction=txn_obj) + if wallet_nft_tokens.exists(): + wallet_nft_tokens.update( + date_dispensed = timezone.now(), + dispensation_transaction = transaction, + ) # Parse SLP tx outputs if slp_tx['valid']: