From 7e31a6a6f7537d4d0d587733df4f6b2a25417058 Mon Sep 17 00:00:00 2001 From: pixelsoup42 Date: Tue, 12 Sep 2023 11:37:31 +0200 Subject: [PATCH] fix duplicates --- .../cardano_account_pandas_dumper.py | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/cardano_account_pandas_dumper/cardano_account_pandas_dumper.py b/src/cardano_account_pandas_dumper/cardano_account_pandas_dumper.py index 399c7a3..c892538 100644 --- a/src/cardano_account_pandas_dumper/cardano_account_pandas_dumper.py +++ b/src/cardano_account_pandas_dumper/cardano_account_pandas_dumper.py @@ -66,32 +66,33 @@ def _transaction_data( self, api: BlockFrostApi, ) -> pd.Series: - result_list = [] + transaction_set = set() for addr in self.own_addresses: for outer_tx in api.address_transactions( addr, to_block=self.to_block, gather_pages=True, ): - transaction = api.transaction(outer_tx.tx_hash) - transaction.utxos = api.transaction_utxos(outer_tx.tx_hash) - transaction.utxos.nonref_inputs = [ - i for i in transaction.utxos.inputs if not i.reference - ] - transaction.metadata = api.transaction_metadata(outer_tx.tx_hash) - transaction.redeemers = ( - api.transaction_redeemers(outer_tx.tx_hash) - if transaction.redeemer_count - else [] - ) - transaction.withdrawals = ( - api.transaction_withdrawals(outer_tx.tx_hash) - if transaction.withdrawal_count - else [] - ) - transaction.reward_amount = None + transaction_set.add(outer_tx.tx_hash) + result_list = [] + for tx_hash in transaction_set: + transaction = api.transaction(tx_hash) + transaction.utxos = api.transaction_utxos(tx_hash) + transaction.utxos.nonref_inputs = [ + i for i in transaction.utxos.inputs if not i.reference + ] + transaction.metadata = api.transaction_metadata(tx_hash) + transaction.redeemers = ( + api.transaction_redeemers(tx_hash) if transaction.redeemer_count else [] + ) + transaction.withdrawals = ( + api.transaction_withdrawals(tx_hash) + if transaction.withdrawal_count + else [] + ) + transaction.reward_amount = None - result_list.append(transaction) + result_list.append(transaction) return pd.Series( name="Transactions", data=result_list, index=[t.hash for t in result_list] ).sort_index() @@ -447,6 +448,5 @@ def make_transaction_frame(self) -> pd.DataFrame: ] ) frame = frame.join(balance) - # frame.drop_duplicates(inplace=True) frame.sort_values(by=frame.columns[0], inplace=True) return frame