Skip to content

Commit

Permalink
group withdrawals
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelsoup42 committed Nov 13, 2023
1 parent a175fea commit 661ff80
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/cardano_account_pandas_dumper/cardano_account_pandas_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,13 @@ def _format_message(self, tx_obj: blockfrost.utils.Namespace) -> str:
)
for k, redeemer_script in redeemer_scripts.items():
result.extend([k, str(redeemer_script)])
if not result and all(
if all(
[
utxo.address in self.data.own_addresses
for utxo in tx_obj.utxos.nonref_inputs + tx_obj.utxos.outputs
]
):
result = ["(internal)"]
result.extend(["(internal)"])
return " ".join(result)

def _format_script(self, script: str) -> str:
Expand Down Expand Up @@ -430,29 +430,33 @@ def _transaction_balance(
raw_values: bool,
) -> Any:
result: MutableMapping[Tuple, np.longlong] = defaultdict(lambda: np.longlong(0))
result[(self.ADA_ASSET, self.OTHER_LABEL, " fees")] += np.longlong(
result[(self.ADA_ASSET, self.OTHER_LABEL, " fees")] += np.longlong(
transaction.fees
)
result[(self.ADA_ASSET, self.OWN_LABEL, " deposit")] += np.longlong(
result[(self.ADA_ASSET, self.OWN_LABEL, " deposit")] += np.longlong(
transaction.deposit
)
if transaction.reward_amount:
result[(self.ADA_ASSET, self.OTHER_LABEL, " rewards")] -= np.longlong(
transaction.reward_amount
)
result[
(
self.ADA_ASSET,
self.OTHER_LABEL,
f" {self._truncate(transaction.reward_address)}-rewards",
)
] -= np.longlong(transaction.reward_amount)
result[
(
self.ADA_ASSET,
self.OWN_LABEL,
f" withdrawals-{self._truncate(transaction.reward_address)}",
f" {self._truncate(transaction.reward_address)}-withdrawals",
)
] += np.longlong(transaction.reward_amount)
for _w in transaction.withdrawals:
result[
(
self.ADA_ASSET,
self.OWN_LABEL,
f" withdrawals-{self._truncate(_w.address)}",
f" {self._truncate(_w.address)}-withdrawals",
)
] -= np.longlong(_w.amount)
for utxo in transaction.utxos.nonref_inputs:
Expand Down

0 comments on commit 661ff80

Please sign in to comment.